Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CategoryView: absorb headerbar #279

Merged
merged 8 commits into from
Mar 21, 2024
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
4 changes: 2 additions & 2 deletions data/styles/CategoryView.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
category-view {
> scrolledwindow {
box > scrolledwindow {
overshoot.top {
background:
linear-gradient(
Expand All @@ -24,7 +24,7 @@ category-view {
}
}

clamp {
scrolledwindow clamp {
padding: rem(12px);

box.vertical {
Expand Down
35 changes: 1 addition & 34 deletions src/Application.vala
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,10 @@

namespace Switchboard {
public class SwitchboardApp : Gtk.Application {
private string all_settings_label = N_("All Settings");

private GLib.HashTable <Gtk.Widget, Switchboard.Plug> 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;
Expand Down Expand Up @@ -134,22 +129,6 @@ namespace Switchboard {

plug_widgets = new GLib.HashTable <Gtk.Widget, Switchboard.Plug> (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 ({"<Alt>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 ();
Expand All @@ -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
Expand All @@ -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 ();
});
Expand All @@ -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;
}

Expand Down
8 changes: 7 additions & 1 deletion src/CategoryView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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")) {
Expand Down Expand Up @@ -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;
Expand Down
Loading