Commit 6f514280 authored by Felipe Borges's avatar Felipe Borges
Browse files

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
parent b995e16c
......@@ -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);
......
......@@ -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>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment