From 6f514280947f2d433d5fd4e8c56cf3deeeb165a3 Mon Sep 17 00:00:00 2001 From: Felipe Borges Date: Sun, 27 Nov 2016 17:22:40 +0100 Subject: [PATCH] region: Use GtkRevealer instead of GdNotification GtkRevealer combined with the "app-notification" class is enough to represent the notification concept nowadays. https://bugzilla.gnome.org/show_bug.cgi?id=775183 --- panels/region/cc-region-panel.c | 51 ++++++++++++--------------------- panels/region/region.ui | 47 ++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 32 deletions(-) diff --git a/panels/region/cc-region-panel.c b/panels/region/cc-region-panel.c index 2e054c29c..bef68ab74 100644 --- a/panels/region/cc-region-panel.c +++ b/panels/region/cc-region-panel.c @@ -47,8 +47,6 @@ #include -#include - #define GNOME_DESKTOP_INPUT_SOURCES_DIR "org.gnome.desktop.input-sources" #define KEY_INPUT_SOURCES "sources" @@ -209,7 +207,7 @@ restart_now (CcRegionPanel *self) { CcRegionPanelPrivate *priv = self->priv; - gd_notification_dismiss (GD_NOTIFICATION (self->priv->notification)); + gtk_revealer_set_reveal_child (GTK_REVEALER (self->priv->notification), FALSE); g_dbus_proxy_call (priv->session, "Logout", @@ -223,42 +221,14 @@ show_restart_notification (CcRegionPanel *self, const gchar *locale) { CcRegionPanelPrivate *priv = self->priv; - GtkWidget *box; - GtkWidget *label; - GtkWidget *button; gchar *current_locale = NULL; - if (priv->notification) - return; - if (locale) { current_locale = g_strdup (setlocale (LC_MESSAGES, NULL)); setlocale (LC_MESSAGES, locale); } - priv->notification = gd_notification_new (); - g_object_add_weak_pointer (G_OBJECT (priv->notification), - (gpointer *)&priv->notification); - box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); - gtk_widget_set_margin_start (box, 6); - gtk_widget_set_margin_end (box, 6); - gtk_widget_set_margin_top (box, 6); - gtk_widget_set_margin_bottom (box, 6); - label = gtk_label_new (_("Your session needs to be restarted for changes to take effect")); - gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); - gtk_label_set_max_width_chars (GTK_LABEL (label), 30); - g_object_set (G_OBJECT (label), "xalign", 0, NULL); - button = gtk_button_new_with_label (_("Restart Now")); - gtk_widget_set_valign (button, GTK_ALIGN_CENTER); - g_signal_connect_swapped (button, "clicked", - G_CALLBACK (restart_now), self); - gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 0); - gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 0); - gtk_widget_show_all (box); - - gtk_container_add (GTK_CONTAINER (priv->notification), box); - gtk_overlay_add_overlay (GTK_OVERLAY (self->priv->overlay), priv->notification); - gtk_widget_show (priv->notification); + gtk_revealer_set_reveal_child (GTK_REVEALER (priv->notification), TRUE); if (locale) { setlocale (LC_MESSAGES, current_locale); @@ -266,6 +236,14 @@ show_restart_notification (CcRegionPanel *self, } } +static void +dismiss_notification (CcRegionPanel *self) +{ + CcRegionPanelPrivate *priv = self->priv; + + gtk_revealer_set_reveal_child (GTK_REVEALER (priv->notification), FALSE); +} + typedef struct { CcRegionPanel *self; int category; @@ -1818,6 +1796,7 @@ static void cc_region_panel_init (CcRegionPanel *self) { CcRegionPanelPrivate *priv; + GtkWidget *button; GError *error = NULL; priv = self->priv = REGION_PANEL_PRIVATE (self); @@ -1848,6 +1827,14 @@ cc_region_panel_init (CcRegionPanel *self) session_proxy_ready, self); + priv->notification = GTK_WIDGET (gtk_builder_get_object (priv->builder, "notification")); + + button = GTK_WIDGET (gtk_builder_get_object (priv->builder, "restart-button")); + g_signal_connect_swapped (button, "clicked", G_CALLBACK (restart_now), self); + + button = GTK_WIDGET (gtk_builder_get_object (priv->builder, "dismiss-button")); + g_signal_connect_swapped (button, "clicked", G_CALLBACK (dismiss_notification), self); + setup_login_button (self); setup_language_section (self); setup_input_section (self); diff --git a/panels/region/region.ui b/panels/region/region.ui index 07c0d4d7d..b818eb763 100644 --- a/panels/region/region.ui +++ b/panels/region/region.ui @@ -3,6 +3,53 @@ True + + + True + GTK_ALIGN_CENTER + GTK_ALIGN_START + + + True + 6 + + + + True + True + 30 + Your session needs to be restarted for changes to take effect + + + + + True + True + GTK_ALIGN_CENTER + Restart Now + + + + + True + GTK_ALIGN_CENTER + + + + True + window-close-symbolic + + + + + + + + True