From 490ba5797b864a0f23bcfbfa186e2c75b8cca1d6 Mon Sep 17 00:00:00 2001 From: Danielle Fore Date: Tue, 23 Jan 2024 12:45:46 -0800 Subject: [PATCH] CategoryView: absorb headerbar --- src/Application.vala | 38 +------------------------------------- src/CategoryView.vala | 12 +++++++----- 2 files changed, 8 insertions(+), 42 deletions(-) diff --git a/src/Application.vala b/src/Application.vala index 873c1335..12ba645d 100644 --- a/src/Application.vala +++ b/src/Application.vala @@ -21,15 +21,10 @@ namespace Switchboard { public class SwitchboardApp : Gtk.Application { - private string all_settings_label = N_("All Settings"); - private GLib.HashTable plug_widgets; - private Gtk.Button navigation_button; private Adw.Leaflet leaflet; - private Gtk.HeaderBar headerbar; private Gtk.Window main_window; private Switchboard.CategoryView category_view; - private Gtk.Label title_label; private static bool opened_directly = false; private static string? link = null; @@ -126,22 +121,6 @@ namespace Switchboard { set_accels_for_action ("app.back", {"Left", "Back"}); set_accels_for_action ("app.quit", {"q"}); - navigation_button = new Gtk.Button.with_label (_(all_settings_label)); - navigation_button.action_name = "app.back"; - navigation_button.set_tooltip_markup ( - Granite.markup_accel_tooltip (get_accels_for_action (navigation_button.action_name)) - ); - navigation_button.get_style_context ().add_class ("back-button"); - - title_label = new Gtk.Label (""); - title_label.add_css_class (Granite.STYLE_CLASS_TITLE_LABEL); - - headerbar = new Gtk.HeaderBar () { - show_title_buttons = true, - title_widget = title_label - }; - headerbar.pack_start (navigation_button); - category_view = new Switchboard.CategoryView (plug_to_open); category_view.load_default_plugs.begin (); @@ -157,13 +136,11 @@ namespace Switchboard { child = leaflet, icon_name = application_id, title = _("System Settings"), - titlebar = headerbar + titlebar = new Gtk.Grid () { visible = false } }; add_window (main_window); main_window.present (); - navigation_button.hide (); - /* * This is very finicky. Bind size after present else set_titlebar gives us bad sizes * Set maximize after height/width else window is min size on unmaximize @@ -179,8 +156,6 @@ namespace Switchboard { settings.bind ("window-maximized", main_window, "maximized", SettingsBindFlags.SET); - main_window.bind_property ("title", title_label, "label"); - back_action.activate.connect (() => { handle_navigation_button_clicked (); }); @@ -218,8 +193,6 @@ namespace Switchboard { var visible_widget = leaflet.visible_child; if (visible_widget is Switchboard.CategoryView) { main_window.title = _("System Settings"); - - navigation_button.hide (); } else { var plug = plug_widgets[visible_widget]; if (plug != null) { @@ -228,15 +201,6 @@ namespace Switchboard { } else { critical ("Visible child is not CategoryView nor is associated with a Plug."); } - - - if (previous_child != null && previous_child is Switchboard.Plug) { - navigation_button.label = previous_child.display_name; - } else { - navigation_button.label = _(all_settings_label); - } - - navigation_button.show (); } } } diff --git a/src/CategoryView.vala b/src/CategoryView.vala index decdc391..e167e0ed 100644 --- a/src/CategoryView.vala +++ b/src/CategoryView.vala @@ -40,10 +40,6 @@ namespace Switchboard { var search_box_eventcontrollerkey = new Gtk.EventControllerKey (); search_box = new Gtk.SearchEntry () { - margin_top = 12, - margin_end = 12, - margin_bottom = 12, - margin_start = 12, placeholder_text = _("Search Settings") }; search_box.add_controller (search_box_eventcontrollerkey); @@ -99,8 +95,14 @@ namespace Switchboard { search_stack.add_child (clamp); search_stack.add_child (searchview); + var headerbar = new Gtk.HeaderBar () { + show_title_buttons = true, + title_widget = search_clamp + }; + headerbar.add_css_class (Granite.STYLE_CLASS_FLAT); + orientation = VERTICAL; - append (search_clamp); + append (headerbar); append (search_stack); if (Switchboard.PlugsManager.get_default ().has_plugs () == false) {