From 9bc60e2fe78c4d9fe55030e665513eb26ff876a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Thu, 21 Mar 2024 13:57:45 -0700 Subject: [PATCH] CategoryView: absorb headerbar (#279) --- data/styles/CategoryView.scss | 4 ++-- src/Application.vala | 35 +---------------------------------- src/CategoryView.vala | 8 +++++++- 3 files changed, 10 insertions(+), 37 deletions(-) diff --git a/data/styles/CategoryView.scss b/data/styles/CategoryView.scss index 4b704ab7..37366b17 100644 --- a/data/styles/CategoryView.scss +++ b/data/styles/CategoryView.scss @@ -1,5 +1,5 @@ category-view { - > scrolledwindow { + box > scrolledwindow { overshoot.top { background: linear-gradient( @@ -24,7 +24,7 @@ category-view { } } - clamp { + scrolledwindow clamp { padding: rem(12px); box.vertical { diff --git a/src/Application.vala b/src/Application.vala index d517391d..11eac6b4 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.NavigationView navigation_view; - 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; @@ -134,22 +129,6 @@ namespace Switchboard { plug_widgets = new GLib.HashTable (null, null); - 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 ({"Left", "Back"}) - ); - 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); navigation_view = new Adw.NavigationView (); @@ -160,13 +139,11 @@ namespace Switchboard { child = navigation_view, 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 @@ -182,8 +159,6 @@ namespace Switchboard { settings.bind ("window-maximized", main_window, "maximized", SettingsBindFlags.SET); - main_window.bind_property ("title", title_label, "label"); - shutdown.connect (() => { navigation_view.visible_page.hidden (); }); @@ -193,14 +168,6 @@ namespace Switchboard { } private void update_navigation () { - if (navigation_view.visible_page is Switchboard.CategoryView) { - navigation_button.hide (); - } else { - var previous_page = navigation_view.get_previous_page (navigation_view.visible_page); - navigation_button.label = previous_page.title; - navigation_button.show (); - } - main_window.title = navigation_view.visible_page.title; } diff --git a/src/CategoryView.vala b/src/CategoryView.vala index 1fbb9c08..cf548357 100644 --- a/src/CategoryView.vala +++ b/src/CategoryView.vala @@ -35,6 +35,12 @@ public class Switchboard.CategoryView : Adw.NavigationPage { tightening_threshold = 800 }; + var headerbar = new Gtk.HeaderBar () { + show_title_buttons = true, + title_widget = search_clamp + }; + headerbar.add_css_class (Granite.STYLE_CLASS_FLAT); + var searchview = new SearchView (search_box); var alert_view = new Granite.Placeholder (_("No Settings Found")) { @@ -78,7 +84,7 @@ public class Switchboard.CategoryView : Adw.NavigationPage { }; var box = new Gtk.Box (VERTICAL, 0); - box.append (search_clamp); + box.append (headerbar); box.append (scrolled); child = box;