Skip to content

Commit

Permalink
Handle own titlebuttons (#100)
Browse files Browse the repository at this point in the history
  • Loading branch information
danirabbit authored Mar 21, 2024
1 parent dd1b093 commit 468dea7
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 26 deletions.
2 changes: 2 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ config_file = configure_file(
configuration: config_data
)

adw_dep = dependency('libadwaita-1', version: '>=1.4')

subdir('data')
subdir('src')
subdir('po')
9 changes: 3 additions & 6 deletions src/Widgets/AppEntry.vala
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class Widgets.AppEntry : Gtk.ListBoxRow {

construct {
var image = new Gtk.Image.from_gicon (app.app_info.get_icon ()) {
pixel_size = 32
icon_size = LARGE
};

var title_label = new Gtk.Label (app.app_info.get_display_name ()) {
Expand All @@ -46,12 +46,9 @@ public class Widgets.AppEntry : Gtk.ListBoxRow {
xalign = 0,
valign = Gtk.Align.START
};
description_label.add_css_class (Granite.STYLE_CLASS_SMALL_LABEL);

var grid = new Gtk.Grid () {
margin_start = 6,
margin_end = 6,
margin_top = 6,
margin_bottom = 6,
column_spacing = 6
};
grid.attach (image, 0, 0, 1, 2);
Expand Down Expand Up @@ -84,6 +81,6 @@ public class Widgets.AppEntry : Gtk.ListBoxRow {
items += _("Disabled");
}

return "<span font_size=\"small\">%s</span>".printf (Markup.escape_text (string.joinv (", ", items)));
return string.joinv (", ", items);
}
}
3 changes: 2 additions & 1 deletion src/Widgets/AppSettingsView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,9 @@ public class Widgets.AppSettingsView : Switchboard.SettingsPage {
box.append (sound_option);
box.append (remember_option);

child = box;
add_css_class ("notifications");
child = box;
show_end_title_buttons = true;

update_selected_app ();

Expand Down
3 changes: 1 addition & 2 deletions src/Widgets/MainView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ public class Widgets.MainView : Gtk.Widget {
end_child = app_settings_view,
resize_start_child = false,
shrink_start_child = false,
shrink_end_child = false,
position = 240
shrink_end_child = false
};
main_widget.set_parent (this);
}
Expand Down
60 changes: 43 additions & 17 deletions src/Widgets/Sidebar.vala
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ public class Widgets.Sidebar : Gtk.Box {

private Gtk.SearchEntry search_entry;

class construct {
set_css_name ("settingssidebar");
}

construct {
search_entry = new Gtk.SearchEntry () {
placeholder_text = _("Search Apps"),
Expand All @@ -32,9 +36,20 @@ public class Widgets.Sidebar : Gtk.Box {
hexpand = true
};

var search_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
search_box.add_css_class (Granite.STYLE_CLASS_VIEW);
search_box.append (search_entry);
var search_revealer = new Gtk.Revealer () {
child = search_entry
};

var search_toggle = new Gtk.ToggleButton () {
icon_name = "edit-find-symbolic",
tooltip_text = _("Search Apps")
};

var headerbar = new Adw.HeaderBar () {
show_end_title_buttons = false,
show_title = false
};
headerbar.pack_end (search_toggle);

var app_list = new Gtk.ListBox () {
hexpand = true,
Expand All @@ -45,37 +60,48 @@ public class Widgets.Sidebar : Gtk.Box {
app_list.set_sort_func (sort_func);

var scrolled_window = new Gtk.ScrolledWindow () {
child = app_list
child = app_list,
hscrollbar_policy = NEVER
};

var do_not_disturb_label = new Gtk.Label (_("Do Not Disturb")) {
margin_start = 3
};
do_not_disturb_label.add_css_class (Granite.STYLE_CLASS_H4_LABEL);
var do_not_disturb_label = new Gtk.Label (_("Do Not Disturb"));

var do_not_disturb_switch = new Gtk.Switch () {
margin_start = 6,
margin_top = 6,
margin_bottom = 6,
margin_end = 3
valign = CENTER
};

var footer = new Gtk.ActionBar ();
footer.add_css_class (Granite.STYLE_CLASS_FLAT);
footer.pack_start (do_not_disturb_label);
footer.pack_end (do_not_disturb_switch);

orientation = Gtk.Orientation.VERTICAL;
append (search_box);
append (scrolled_window);
append (footer);
var toolbarview = new Adw.ToolbarView () {
content = scrolled_window,
top_bar_style = FLAT,
bottom_bar_style = RAISED
};
toolbarview.add_top_bar (headerbar);
toolbarview.add_top_bar (search_revealer);
toolbarview.add_bottom_bar (footer);

append (toolbarview);
add_css_class (Granite.STYLE_CLASS_SIDEBAR);

app_list.row_selected.connect (show_row);

search_entry.search_changed.connect (() => {
app_list.invalidate_filter ();
});

search_toggle.bind_property ("active", search_revealer, "reveal-child");

search_revealer.notify["child-revealed"].connect (() => {
if (search_revealer.child_revealed) {
search_entry.grab_focus ();
} else {
search_entry.text = "";
}
});

NotificationsPlug.notify_settings.bind (
"do-not-disturb",
do_not_disturb_switch,
Expand Down
1 change: 1 addition & 0 deletions src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ shared_module(
config_file,
plug_resources,
dependencies: [
adw_dep,
dependency('glib-2.0'),
dependency('gio-2.0'),
dependency('gobject-2.0'),
Expand Down

0 comments on commit 468dea7

Please sign in to comment.