diff --git a/panels/notifications/cc-notifications-panel.c b/panels/notifications/cc-notifications-panel.c
index e46f0f8a2..83a2fdbee 100644
--- a/panels/notifications/cc-notifications-panel.c
+++ b/panels/notifications/cc-notifications-panel.c
@@ -35,21 +35,28 @@
#define APP_PREFIX "/org/gnome/desktop/notifications/application/"
struct _CcNotificationsPanel {
- CcPanel parent_instance;
+ CcPanel parent_instance;
- GSettings *master_settings;
- GtkBuilder *builder;
+ GtkListBox *app_listbox;
+ GtkSwitch *lock_screen_switch;
+ GtkScrolledWindow *main_scrolled_window;
+ GtkBox *main_box;
+ GtkListBox *options_listbox;
+ GtkSwitch *popups_switch;
+ GtkSizeGroup *sizegroup1;
- GCancellable *apps_load_cancellable;
+ GSettings *master_settings;
- GHashTable *known_applications;
+ GCancellable *apps_load_cancellable;
- GtkAdjustment *focus_adjustment;
+ GHashTable *known_applications;
- GList *sections;
- GList *sections_reverse;
+ GtkAdjustment *focus_adjustment;
- GDBusProxy *perm_store;
+ GList *sections;
+ GList *sections_reverse;
+
+ GDBusProxy *perm_store;
};
struct _CcNotificationsPanelClass {
@@ -67,7 +74,7 @@ typedef struct {
} Application;
static void build_app_store (CcNotificationsPanel *panel);
-static void select_app (GtkListBox *box, GtkListBoxRow *row, CcNotificationsPanel *panel);
+static void select_app (CcNotificationsPanel *panel, GtkListBoxRow *row);
static int sort_apps (gconstpointer one, gconstpointer two, gpointer user_data);
CC_PANEL_REGISTER (CcNotificationsPanel, cc_notifications_panel);
@@ -77,7 +84,6 @@ cc_notifications_panel_dispose (GObject *object)
{
CcNotificationsPanel *panel = CC_NOTIFICATIONS_PANEL (object);
- g_clear_object (&panel->builder);
g_clear_object (&panel->master_settings);
g_clear_pointer (&panel->known_applications, g_hash_table_unref);
g_clear_pointer (&panel->sections, g_list_free);
@@ -100,9 +106,9 @@ cc_notifications_panel_finalize (GObject *object)
}
static gboolean
-keynav_failed (GtkWidget *widget,
+keynav_failed (CcNotificationsPanel *panel,
GtkDirectionType direction,
- CcNotificationsPanel *panel)
+ GtkWidget *widget)
{
gdouble value, lower, upper, page;
GList *item, *sections;
@@ -164,79 +170,41 @@ on_perm_store_ready (GObject *source_object,
static void
cc_notifications_panel_init (CcNotificationsPanel *panel)
{
- GtkWidget *w;
- GtkWidget *label;
- g_autoptr(GError) error = NULL;
-
g_resources_register (cc_notifications_get_resource ());
+
+ gtk_widget_init_template (GTK_WIDGET (panel));
+
panel->known_applications = g_hash_table_new_full (g_str_hash, g_str_equal,
NULL, g_free);
- panel->builder = gtk_builder_new ();
- if (gtk_builder_add_from_resource (panel->builder,
- "/org/gnome/control-center/notifications/notifications.ui",
- &error) == 0)
- {
- g_error ("Error loading UI file: %s", error->message);
- return;
- }
-
panel->master_settings = g_settings_new (MASTER_SCHEMA);
g_settings_bind (panel->master_settings, "show-banners",
- gtk_builder_get_object (panel->builder, "ccnotify-switch-banners"),
+ panel->popups_switch,
"active", G_SETTINGS_BIND_DEFAULT);
g_settings_bind (panel->master_settings, "show-in-lock-screen",
- gtk_builder_get_object (panel->builder, "ccnotify-switch-lock-screen"),
+ panel->lock_screen_switch,
"active", G_SETTINGS_BIND_DEFAULT);
- w = GTK_WIDGET (gtk_builder_get_object (panel->builder,
- "ccnotify-main-scrolled-window"));
- panel->focus_adjustment = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (w));
+ panel->focus_adjustment = gtk_scrolled_window_get_vadjustment (panel->main_scrolled_window);
- w = GTK_WIDGET (gtk_builder_get_object (panel->builder,
- "ccnotify-main-box"));
- gtk_container_set_focus_vadjustment (GTK_CONTAINER (w), panel->focus_adjustment);
+ gtk_container_set_focus_vadjustment (GTK_CONTAINER (panel->main_box), panel->focus_adjustment);
- w = GTK_WIDGET (gtk_builder_get_object (panel->builder,
- "ccnotify-switch-listbox"));
- panel->sections = g_list_append (panel->sections, w);
- panel->sections_reverse = g_list_prepend (panel->sections_reverse, w);
- g_signal_connect_object (w, "keynav-failed", G_CALLBACK (keynav_failed), panel, 0);
- gtk_list_box_set_header_func (GTK_LIST_BOX (w),
+ panel->sections = g_list_append (panel->sections, panel->options_listbox);
+ panel->sections_reverse = g_list_prepend (panel->sections_reverse, panel->options_listbox);
+ gtk_list_box_set_header_func (panel->options_listbox,
cc_list_box_update_header_func,
NULL, NULL);
- label = GTK_WIDGET (gtk_builder_get_object (panel->builder,
- "label1"));
- w = GTK_WIDGET (gtk_builder_get_object (panel->builder,
- "ccnotify-app-listbox"));
- atk_object_add_relationship (ATK_OBJECT (gtk_widget_get_accessible (label)),
- ATK_RELATION_LABEL_FOR,
- ATK_OBJECT (gtk_widget_get_accessible (w)));
- atk_object_add_relationship (ATK_OBJECT (gtk_widget_get_accessible (w)),
- ATK_RELATION_LABELLED_BY,
- ATK_OBJECT (gtk_widget_get_accessible (label)));
-
- panel->sections = g_list_append (panel->sections, w);
- panel->sections_reverse = g_list_prepend (panel->sections_reverse, w);
- g_signal_connect_object (w, "keynav-failed", G_CALLBACK (keynav_failed), panel, 0);
- gtk_list_box_set_sort_func (GTK_LIST_BOX (w), (GtkListBoxSortFunc)sort_apps, NULL, NULL);
- gtk_list_box_set_header_func (GTK_LIST_BOX (w),
+ 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);
+ gtk_list_box_set_header_func (panel->app_listbox,
cc_list_box_update_header_func,
NULL, NULL);
- g_signal_connect_object (GTK_LIST_BOX (w), "row-activated",
- G_CALLBACK (select_app), panel, 0);
-
build_app_store (panel);
- w = GTK_WIDGET (gtk_builder_get_object (panel->builder,
- "ccnotify-main-scrolled-window"));
- gtk_container_add (GTK_CONTAINER (panel), w);
-
- gtk_widget_show (w);
-
g_dbus_proxy_new_for_bus (G_BUS_TYPE_SESSION,
G_DBUS_PROXY_FLAGS_NONE,
NULL,
@@ -257,8 +225,9 @@ cc_notifications_panel_get_help_uri (CcPanel *panel)
static void
cc_notifications_panel_class_init (CcNotificationsPanelClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- CcPanelClass *panel_class = CC_PANEL_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+ CcPanelClass *panel_class = CC_PANEL_CLASS (klass);
panel_class->get_help_uri = cc_notifications_panel_get_help_uri;
@@ -267,6 +236,19 @@ cc_notifications_panel_class_init (CcNotificationsPanelClass *klass)
* gets finalized */
object_class->dispose = cc_notifications_panel_dispose;
object_class->finalize = cc_notifications_panel_finalize;
+
+ 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, lock_screen_switch);
+ 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, popups_switch);
+ 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);
}
static inline GQuark
@@ -306,7 +288,7 @@ static void
add_application (CcNotificationsPanel *panel,
Application *app)
{
- GtkWidget *box, *w, *row, *list_box;
+ GtkWidget *box, *w, *row;
g_autoptr(GIcon) icon = NULL;
const gchar *app_name;
int size;
@@ -330,17 +312,14 @@ add_application (CcNotificationsPanel *panel,
g_object_set_qdata_full (G_OBJECT (row), application_quark (),
app, (GDestroyNotify) application_free);
- list_box = GTK_WIDGET (gtk_builder_get_object (panel->builder,
- "ccnotify-app-listbox"));
-
- gtk_container_add (GTK_CONTAINER (list_box), row);
+ gtk_container_add (GTK_CONTAINER (panel->app_listbox), row);
gtk_container_add (GTK_CONTAINER (row), box);
w = gtk_image_new_from_gicon (icon, GTK_ICON_SIZE_DIALOG);
gtk_widget_show (w);
gtk_icon_size_lookup (GTK_ICON_SIZE_DND, &size, NULL);
gtk_image_set_pixel_size (GTK_IMAGE (w), size);
- gtk_size_group_add_widget (GTK_SIZE_GROUP (gtk_builder_get_object (panel->builder, "sizegroup1")), w);
+ gtk_size_group_add_widget (panel->sizegroup1, w);
gtk_container_add (GTK_CONTAINER (box), w);
w = gtk_label_new (app_name);
@@ -527,9 +506,8 @@ load_apps_async (CcNotificationsPanel *panel)
}
static void
-children_changed (GSettings *settings,
- const char *key,
- CcNotificationsPanel *panel)
+children_changed (CcNotificationsPanel *panel,
+ const char *key)
{
int i;
g_auto (GStrv) new_app_ids = NULL;
@@ -545,19 +523,18 @@ static void
build_app_store (CcNotificationsPanel *panel)
{
/* Build application entries for known applications */
- children_changed (panel->master_settings, NULL, panel);
+ children_changed (panel, NULL);
g_signal_connect_object (panel->master_settings,
"changed::application-children",
- G_CALLBACK (children_changed), panel, 0);
+ G_CALLBACK (children_changed), panel, G_CONNECT_SWAPPED);
/* Scan applications that statically declare to show notifications */
load_apps_async (panel);
}
static void
-select_app (GtkListBox *list_box,
- GtkListBoxRow *row,
- CcNotificationsPanel *panel)
+select_app (CcNotificationsPanel *panel,
+ GtkListBoxRow *row)
{
Application *app;
g_autofree gchar *app_id = NULL;
diff --git a/panels/notifications/cc-notifications-panel.ui b/panels/notifications/cc-notifications-panel.ui
new file mode 100644
index 000000000..7527001d8
--- /dev/null
+++ b/panels/notifications/cc-notifications-panel.ui
@@ -0,0 +1,242 @@
+
+
+
+
+ True
+
+
+
+
+
+ both
+
+
diff --git a/panels/notifications/meson.build b/panels/notifications/meson.build
index 03930955a..bbec5dfea 100644
--- a/panels/notifications/meson.build
+++ b/panels/notifications/meson.build
@@ -24,7 +24,7 @@ sources = files(
resource_data = files(
'cc-app-notifications-dialog.ui',
- 'notifications.ui'
+ 'cc-notifications-panel.ui'
)
sources += gnome.compile_resources(
diff --git a/panels/notifications/notifications.gresource.xml b/panels/notifications/notifications.gresource.xml
index 0098c9c0b..8f1d5dbb8 100644
--- a/panels/notifications/notifications.gresource.xml
+++ b/panels/notifications/notifications.gresource.xml
@@ -1,7 +1,7 @@
- notifications.ui
cc-app-notifications-dialog.ui
+ cc-notifications-panel.ui
diff --git a/panels/notifications/notifications.ui b/panels/notifications/notifications.ui
deleted file mode 100644
index 8e9f00138..000000000
--- a/panels/notifications/notifications.ui
+++ /dev/null
@@ -1,228 +0,0 @@
-
-
-
-
- 400
- True
- True
- never
- none
-
-
- True
- False
-
-
- True
- False
-
-
-
-
- True
- False
- True
-
-
-
-
-
- True
- False
- True
-
-
- end
-
-
-
-
-
-
- True
- False
- 32
- vertical
- True
-
-
- True
- False
- 32
- True
- 0
- in
-
-
- True
- False
- True
- none
- False
-
-
- True
- True
- False
- False
-
-
- True
- False
- center
-
-
- 32
- True
- False
- start
- 12
- 8
- 8
- True
- 0
- Notification _Popups
- True
- ccnotify-switch-banners
-
-
- False
- True
- 0
-
-
-
-
- True
- True
- end
- center
- 12
-
-
- False
- True
- 1
-
-
-
-
-
-
-
-
- True
- True
- False
- False
-
-
- True
- False
- center
-
-
- 32
- True
- False
- start
- 12
- 8
- 8
- True
- 0
- _Lock Screen Notifications
- True
- ccnotify-switch-lock-screen
-
-
- False
- True
- 0
-
-
-
-
- True
- True
- end
- center
- 12
-
-
- False
- True
- 1
-
-
-
-
-
-
-
-
-
-
-
-
-
- False
- True
- 0
-
-
-
-
- True
- False
- 0
- 12
- Applications
-
-
-
-
-
- False
- True
- 1
-
-
-
-
- True
- False
- True
- True
- 0
- in
-
-
- True
- False
- True
- True
- none
-
-
-
-
-
-
-
- False
- True
- 2
-
-
-
-
-
-
-
-
-
-
- both
-
-
diff --git a/po/POTFILES.in b/po/POTFILES.in
index bfea59b4c..1a0d2fc26 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -123,8 +123,8 @@ panels/network/wireless-security/ws-wpa-psk.c
panels/network/wireless-security/ws-wpa-psk.ui
panels/notifications/cc-app-notifications-dialog.ui
panels/notifications/cc-notifications-panel.c
+panels/notifications/cc-notifications-panel.ui
panels/notifications/gnome-notifications-panel.desktop.in.in
-panels/notifications/notifications.ui
panels/online-accounts/cc-online-accounts-panel.c
panels/online-accounts/gnome-online-accounts-panel.desktop.in.in
panels/online-accounts/online-accounts.ui