[gnome-control-center] cc-notifications-panel: Use AdwPreferences{Page, Group}
- From: Christopher Davis <christopherdavis src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] cc-notifications-panel: Use AdwPreferences{Page, Group}
- Date: Thu, 6 Jan 2022 00:57:53 +0000 (UTC)
commit d61b5bb0b08532e42148ea09126a25319713c092
Author: Christopher Davis <christopherdavis gnome org>
Date: Tue Jan 4 16:22:29 2022 -0800
cc-notifications-panel: Use AdwPreferences{Page,Group}
libadwaita provides nice pre-built widgets for preferences
pages and groups. We should use them where possible.
panels/notifications/cc-notifications-panel.c | 58 ---------------
panels/notifications/cc-notifications-panel.ui | 98 +++++++++-----------------
2 files changed, 35 insertions(+), 121 deletions(-)
---
diff --git a/panels/notifications/cc-notifications-panel.c b/panels/notifications/cc-notifications-panel.c
index 25e69fb9e..2e3c185c3 100644
--- a/panels/notifications/cc-notifications-panel.c
+++ b/panels/notifications/cc-notifications-panel.c
@@ -38,10 +38,7 @@ struct _CcNotificationsPanel {
CcPanel parent_instance;
GtkListBox *app_listbox;
- GtkAdjustment *focus_adjustment;
CcListRow *lock_screen_row;
- GtkScrolledWindow *main_scrolled_window;
- GtkBox *main_box;
GtkListBox *options_listbox;
CcListRow *dnd_row;
GtkSizeGroup *sizegroup1;
@@ -52,9 +49,6 @@ struct _CcNotificationsPanel {
GHashTable *known_applications;
- GList *sections;
- GList *sections_reverse;
-
GDBusProxy *perm_store;
};
@@ -85,8 +79,6 @@ cc_notifications_panel_dispose (GObject *object)
g_clear_object (&panel->master_settings);
g_clear_pointer (&panel->known_applications, g_hash_table_unref);
- g_clear_pointer (&panel->sections, g_list_free);
- g_clear_pointer (&panel->sections_reverse, g_list_free);
G_OBJECT_CLASS (cc_notifications_panel_parent_class)->dispose (object);
}
@@ -101,47 +93,6 @@ cc_notifications_panel_finalize (GObject *object)
G_OBJECT_CLASS (cc_notifications_panel_parent_class)->finalize (object);
}
-static gboolean
-keynav_failed (CcNotificationsPanel *panel,
- GtkDirectionType direction,
- GtkWidget *widget)
-{
- gdouble value, lower, upper, page;
- GList *item, *sections;
-
- /* Find the widget in the list of GtkWidgets */
- if (direction == GTK_DIR_DOWN)
- sections = panel->sections;
- else
- sections = panel->sections_reverse;
-
- item = g_list_find (sections, widget);
- g_assert (item);
- if (item->next)
- {
- gtk_widget_child_focus (GTK_WIDGET (item->next->data), direction);
- return TRUE;
- }
-
- value = gtk_adjustment_get_value (panel->focus_adjustment);
- lower = gtk_adjustment_get_lower (panel->focus_adjustment);
- upper = gtk_adjustment_get_upper (panel->focus_adjustment);
- page = gtk_adjustment_get_page_size (panel->focus_adjustment);
-
- if (direction == GTK_DIR_UP && value > lower)
- {
- gtk_adjustment_set_value (panel->focus_adjustment, lower);
- return TRUE;
- }
- else if (direction == GTK_DIR_DOWN && value < upper - page)
- {
- gtk_adjustment_set_value (panel->focus_adjustment, upper - page);
- return TRUE;
- }
-
- return FALSE;
-}
-
static void
on_perm_store_ready (GObject *source_object,
GAsyncResult *res,
@@ -182,11 +133,6 @@ cc_notifications_panel_init (CcNotificationsPanel *panel)
panel->lock_screen_row,
"active", G_SETTINGS_BIND_DEFAULT);
- panel->sections = g_list_append (panel->sections, panel->options_listbox);
- panel->sections_reverse = g_list_prepend (panel->sections_reverse, panel->options_listbox);
-
- panel->sections = g_list_append (panel->sections, panel->app_listbox);
- panel->sections_reverse = g_list_prepend (panel->sections_reverse, panel->app_listbox);
gtk_list_box_set_sort_func (panel->app_listbox, (GtkListBoxSortFunc)sort_apps, NULL, NULL);
build_app_store (panel);
@@ -228,15 +174,11 @@ cc_notifications_panel_class_init (CcNotificationsPanelClass *klass)
gtk_widget_class_set_template_from_resource (widget_class,
"/org/gnome/control-center/notifications/cc-notifications-panel.ui");
gtk_widget_class_bind_template_child (widget_class, CcNotificationsPanel, app_listbox);
- gtk_widget_class_bind_template_child (widget_class, CcNotificationsPanel, focus_adjustment);
gtk_widget_class_bind_template_child (widget_class, CcNotificationsPanel, lock_screen_row);
- gtk_widget_class_bind_template_child (widget_class, CcNotificationsPanel, main_scrolled_window);
- gtk_widget_class_bind_template_child (widget_class, CcNotificationsPanel, main_box);
gtk_widget_class_bind_template_child (widget_class, CcNotificationsPanel, options_listbox);
gtk_widget_class_bind_template_child (widget_class, CcNotificationsPanel, dnd_row);
gtk_widget_class_bind_template_child (widget_class, CcNotificationsPanel, sizegroup1);
- gtk_widget_class_bind_template_callback (widget_class, keynav_failed);
gtk_widget_class_bind_template_callback (widget_class, select_app);
}
diff --git a/panels/notifications/cc-notifications-panel.ui b/panels/notifications/cc-notifications-panel.ui
index 1aec46ae8..90c279f8f 100644
--- a/panels/notifications/cc-notifications-panel.ui
+++ b/panels/notifications/cc-notifications-panel.ui
@@ -3,72 +3,46 @@
<requires lib="gtk+" version="3.12"/>
<template class="CcNotificationsPanel" parent="CcPanel">
<child>
- <object class="GtkScrolledWindow" id="main_scrolled_window">
- <property name="hscrollbar_policy">never</property>
- <property name="vadjustment">focus_adjustment</property>
+ <object class="AdwPreferencesPage">
<child>
- <object class="GtkViewport">
+ <object class="AdwPreferencesGroup">
<child>
- <object class="AdwClamp">
- <property name="margin_top">32</property>
- <property name="margin_bottom">32</property>
- <property name="margin_start">12</property>
- <property name="margin_end">12</property>
+ <object class="GtkListBox" id="options_listbox">
+ <property name="selection_mode">none</property>
+ <style>
+ <class name="boxed-list"/>
+ </style>
<child>
- <object class="GtkBox" id="main_box">
- <property name="orientation">vertical</property>
- <property name="hexpand">True</property>
- <child>
- <object class="GtkListBox" id="options_listbox">
- <property name="hexpand">True</property>
- <property name="selection_mode">none</property>
- <property name="margin_bottom">32</property>
- <signal name="keynav-failed" handler="keynav_failed" object="CcNotificationsPanel"
swapped="yes" />
- <style>
- <class name="boxed-list"/>
- </style>
- <child>
- <object class="CcListRow" id="dnd_row">
- <property name="title" translatable="yes">_Do Not Disturb</property>
- <property name="use-underline">True</property>
- <property name="show-switch">True</property>
- </object>
- </child>
- <child>
- <object class="CcListRow" id="lock_screen_row">
- <property name="title" translatable="yes">_Lock Screen Notifications</property>
- <property name="use-underline">True</property>
- <property name="show-switch">True</property>
- </object>
- </child>
- </object>
- </child>
- <child>
- <object class="GtkLabel" id="app_list_heading_label">
- <property name="xalign">0</property>
- <property name="margin_bottom">12</property>
- <property name="label" translatable="yes" comments="List of
applications.">Applications</property>
- <attributes>
- <attribute name="weight" value="bold"/>
- </attributes>
- </object>
- </child>
- <child>
- <object class="GtkListBox" id="app_listbox">
- <property name="hexpand">True</property>
- <property name="selection_mode">none</property>
- <signal name="keynav-failed" handler="keynav_failed" object="CcNotificationsPanel"
swapped="yes" />
- <signal name="row-activated" handler="select_app" object="CcNotificationsPanel"
swapped="yes" />
- <style>
- <class name="boxed-list"/>
- </style>
- <accessibility>
- <relation name="labelled-by">app_list_heading_label</relation>
- </accessibility>
- </object>
- </child>
+ <object class="CcListRow" id="dnd_row">
+ <property name="title" translatable="yes">_Do Not Disturb</property>
+ <property name="use-underline">True</property>
+ <property name="show-switch">True</property>
</object>
</child>
+ <child>
+ <object class="CcListRow" id="lock_screen_row">
+ <property name="title" translatable="yes">_Lock Screen Notifications</property>
+ <property name="use-underline">True</property>
+ <property name="show-switch">True</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="AdwPreferencesGroup" id="app_group">
+ <property name="title" translatable="yes" comments="List of
applications.">Applications</property>
+ <child>
+ <object class="GtkListBox" id="app_listbox">
+ <property name="selection_mode">none</property>
+ <signal name="row-activated" handler="select_app" object="CcNotificationsPanel"
swapped="yes" />
+ <style>
+ <class name="boxed-list"/>
+ </style>
+ <accessibility>
+ <relation name="labelled-by">app_group</relation>
+ </accessibility>
</object>
</child>
</object>
@@ -79,6 +53,4 @@
<object class="GtkSizeGroup" id="sizegroup1">
<property name="mode">both</property>
</object>
- <object class="GtkAdjustment" id="focus_adjustment">
- </object>
</interface>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]