Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions po/POTFILES
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
src/Application.vala
src/MainWindow.vala
src/SearchResultItem.vala
35 changes: 4 additions & 31 deletions src/MainWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public class Maps.MainWindow : Adw.ApplicationWindow {
};
private int current_busy_reason = 0;
private uint search_begin_timeout = 0;
private string unknown_text = _("Unknown");
private ListStore location_store;
private Cancellable? search_cancellable = null;

Expand Down Expand Up @@ -77,6 +76,7 @@ public class Maps.MainWindow : Adw.ApplicationWindow {
search_res_list = new Gtk.ListBox () {
selection_mode = Gtk.SelectionMode.BROWSE
};
search_res_list.add_css_class (Granite.STYLE_CLASS_RICH_LIST);
search_res_list.bind_model (location_store, construct_search_res);
search_res_list.set_placeholder (search_placeholder);

Expand Down Expand Up @@ -288,39 +288,12 @@ public class Maps.MainWindow : Adw.ApplicationWindow {
private Gtk.Widget construct_search_res (Object item) {
unowned var place = item as Geocode.Place;

var icon = new Gtk.Image.from_gicon (place.icon);

var place_name_label = new Gtk.Label (place.name) {
halign = Gtk.Align.START
};
place_name_label.add_css_class ("title-4");

string street = place.street ?? unknown_text;
string postal_code = place.postal_code ?? unknown_text;
string town = place.town ?? unknown_text;

string info_text = "%s, %s, %s".printf (street, postal_code, town);

var info_label = new Gtk.Label (info_text) {
halign = Gtk.Align.START
};
info_label.add_css_class ("dim-label");

var label_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 6);
label_box.append (place_name_label);
label_box.append (info_label);

var box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 6) {
margin_top = 6,
margin_bottom = 6,
margin_start = 6,
margin_end = 6
var result_item = new Maps.SearchResultItem () {
place = place
};
box.append (icon);
box.append (label_box);

var row = new PlaceListBoxRow (place) {
child = box
child = result_item
};

return row;
Expand Down
59 changes: 59 additions & 0 deletions src/SearchResultItem.vala
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* SPDX-License-Identifier: GPL-3.0-or-later
* SPDX-FileCopyrightText: 2025 elementary, Inc. (https://elementary.io)
* 2018-2025 Ryo Nakano <ryonakaknock3@gmail.com>
* 2014-2015 Atlas Developers
*/

public class Maps.SearchResultItem : Granite.Bin {
private Geocode.Place? _place = null;
public Geocode.Place place {
get {
return _place;
}

set {
_place = value;

var street = place.street ?? unknown_text;
var postal_code = place.postal_code ?? unknown_text;
var town = place.town ?? unknown_text;

image.gicon = place.icon;
name_label.label = place.name;
info_label.label = "%s, %s, %s".printf (street, postal_code, town);
}
}

private string unknown_text = _("Unknown");

private Gtk.Image image;
private Gtk.Label name_label;
private Gtk.Label info_label;

construct {
image = new Gtk.Image () {
icon_size = LARGE
};

name_label = new Gtk.Label (null) {
halign = START
};

info_label = new Gtk.Label (null) {
halign = START
};
info_label.add_css_class (Granite.STYLE_CLASS_SMALL_LABEL);
info_label.add_css_class (Granite.STYLE_CLASS_DIM_LABEL);

var label_box = new Gtk.Box (VERTICAL, 0);
label_box.append (name_label);
label_box.append (info_label);

var box = new Gtk.Box (HORIZONTAL, 6);
box.append (image);
box.append (label_box);

child = box;
}
}
5 changes: 3 additions & 2 deletions src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ dependencies = [
dependency('gio-2.0'),
# Version limitation for GLib.ApplicationFlags.DEFAULT_FLAGS
dependency('glib-2.0', version: '>= 2.74'),
# Version limitation for automatic load of Application.css in Granite.init()
dependency('granite-7', version: '>= 7.3.0'),
# Version limitation for Granite.Bin
dependency('granite-7', version: '>= 7.6.0'),
dependency('gtk4'),
dependency('libadwaita-1'),
dependency('libgeoclue-2.0'),
Expand All @@ -27,6 +27,7 @@ sources = files(
'Define.vala',
'MainWindow.vala',
'MapWidget.vala',
'SearchResultItem.vala',
'Util.vala',
)

Expand Down