From b48b73acec505bf1fb839a021c953ba18581e905 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Tue, 15 Jul 2025 13:33:22 -0700 Subject: [PATCH] MainWindow: add icons for map source buttons --- data/icons/48/explore.svg | 146 ++++++++++++++++++++++++++++++++++++++ data/icons/48/transit.svg | 140 ++++++++++++++++++++++++++++++++++++ data/maps.gresource.xml | 2 + src/MainWindow.vala | 56 +++++++++++++-- 4 files changed, 338 insertions(+), 6 deletions(-) create mode 100644 data/icons/48/explore.svg create mode 100644 data/icons/48/transit.svg diff --git a/data/icons/48/explore.svg b/data/icons/48/explore.svg new file mode 100644 index 0000000..b541cdb --- /dev/null +++ b/data/icons/48/explore.svg @@ -0,0 +1,146 @@ + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + diff --git a/data/icons/48/transit.svg b/data/icons/48/transit.svg new file mode 100644 index 0000000..b9de544 --- /dev/null +++ b/data/icons/48/transit.svg @@ -0,0 +1,140 @@ + +image/svg+xml diff --git a/data/maps.gresource.xml b/data/maps.gresource.xml index 59816f6..05f323d 100644 --- a/data/maps.gresource.xml +++ b/data/maps.gresource.xml @@ -6,5 +6,7 @@ icons/pointer.svg + icons/48/explore.svg + icons/48/transit.svg diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 310b28b..89cc966 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -94,18 +94,61 @@ public class Maps.MainWindow : Adw.ApplicationWindow { search_entry.set_key_capture_widget (search_res_popover); + var explore_source_button = new Gtk.ToggleButton () { + action_name = "win.map-source", + action_target = Define.MapSource.MAPNIK, + child = new Gtk.Image.from_icon_name ("map-tile-explore") { + pixel_size = 48 + } + }; + explore_source_button.add_css_class ("image-button"); + + var explore_source_label = new Gtk.Label (_("Explore")) { + mnemonic_widget = explore_source_button + }; + explore_source_label.add_css_class (Granite.STYLE_CLASS_SMALL_LABEL); + + var explore_source_box = new Gtk.Box (VERTICAL, 0); + explore_source_box.append (explore_source_button); + explore_source_box.append (explore_source_label); + + var transit_source_button = new Gtk.ToggleButton () { + action_name = "win.map-source", + action_target = Define.MapSource.TRANSPORT, + group = explore_source_button, + child = new Gtk.Image.from_icon_name ("map-tile-transit") { + pixel_size = 48 + } + }; + transit_source_button.add_css_class ("image-button"); + + var transit_source_label = new Gtk.Label (_("Transit")) { + mnemonic_widget = transit_source_button + }; + transit_source_label.add_css_class (Granite.STYLE_CLASS_SMALL_LABEL); + + var transit_source_box = new Gtk.Box (VERTICAL, 0); + transit_source_box.append (transit_source_button); + transit_source_box.append (transit_source_label); + + var source_box = new Gtk.Box (HORIZONTAL, 12) { + halign = CENTER, + homogeneous = true + }; + source_box.append (explore_source_box); + source_box.append (transit_source_box); + + var map_source_item = new MenuItem (null, null); + map_source_item.set_attribute_value ("custom", "source"); + var style_submenu = new Menu (); style_submenu.append (_("System"), "app.color-scheme('%s')".printf (Define.ColorScheme.DEFAULT)); style_submenu.append (_("Light"), "app.color-scheme('%s')".printf (Define.ColorScheme.FORCE_LIGHT)); style_submenu.append (_("Dark"), "app.color-scheme('%s')".printf (Define.ColorScheme.FORCE_DARK)); - var map_source_submenu = new Menu (); - map_source_submenu.append (_("Mapnik"), "win.map-source('%s')".printf (Define.MapSource.MAPNIK)); - map_source_submenu.append (_("Transport"), "win.map-source('%s')".printf (Define.MapSource.TRANSPORT)); - var main_menu = new Menu (); - main_menu.append_submenu (_("Style"), style_submenu); - main_menu.append_submenu (_("Map Source"), map_source_submenu); + main_menu.append_item (map_source_item); + main_menu.append_section (_("Style"), style_submenu); var menu_button = new Gtk.MenuButton () { icon_name = "open-menu-symbolic", @@ -114,6 +157,7 @@ public class Maps.MainWindow : Adw.ApplicationWindow { tooltip_text = _("Main Menu"), valign = CENTER }; + ((Gtk.PopoverMenu) menu_button.popover).add_child (source_box, "source"); var headerbar = new Adw.HeaderBar () { title_widget = search_clamp