diff options
author | Felipe Borges <felipeborges@gnome.org> | 2016-11-27 17:22:40 +0100 |
---|---|---|
committer | Felipe Borges <felipeborges@gnome.org> | 2016-11-29 15:50:50 +0100 |
commit | 6f514280947f2d433d5fd4e8c56cf3deeeb165a3 (patch) | |
tree | d9700808e67a9ee2b2fbda3e9c18c5ec2343452c | |
parent | b995e16c9853680e1b4f89695401ef430228235d (diff) | |
download | gnome-control-center-6f514280947f2d433d5fd4e8c56cf3deeeb165a3.tar.gz |
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
-rw-r--r-- | panels/region/cc-region-panel.c | 51 | ||||
-rw-r--r-- | 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 <act/act.h> -#include <libgd/gd-notification.h> - #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 @@ <!-- interface-requires gtk+ 3.0 --> <object class="GtkOverlay" id="overlay"> <property name="visible">True</property> + <child type="overlay"> + <object class="GtkRevealer" id="notification"> + <property name="visible">True</property> + <property name="halign">GTK_ALIGN_CENTER</property> + <property name="valign">GTK_ALIGN_START</property> + <child> + <object class="GtkBox"> + <property name="visible">True</property> + <property name="spacing">6</property> + <style> + <class name="app-notification"/> + </style> + <child> + <object class="GtkLabel"> + <property name="visible">True</property> + <property name="wrap">True</property> + <property name="max_width_chars">30</property> + <property name="label" translatable="yes">Your session needs to be restarted for changes to take effect</property> + </object> + </child> + <child> + <object class="GtkButton" id="restart-button"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="valign">GTK_ALIGN_CENTER</property> + <property name="label" translatable="yes">Restart Now</property> + </object> + </child> + <child> + <object class="GtkButton" id="dismiss-button"> + <property name="visible">True</property> + <property name="valign">GTK_ALIGN_CENTER</property> + <style> + <class name="flat"/> + </style> + <child> + <object class="GtkImage"> + <property name="visible">True</property> + <property name="icon_name">window-close-symbolic</property> + </object> + </child> + </object> + </child> + </object> + </child> + </object> + </child> <child> <object class="GtkBox" id="vbox_region"> <property name="visible">True</property> |