summaryrefslogtreecommitdiff
path: root/panels/user-accounts
diff options
context:
space:
mode:
authorOndrej Holy <oholy@redhat.com>2013-07-31 13:53:18 +0200
committerOndrej Holy <oholy@redhat.com>2014-08-07 13:55:37 +0200
commit0002313af8103c1a5bf981e6e49d862f460df378 (patch)
tree2987e5ad0ffd06dfa55dad8726647b5ad3a665af /panels/user-accounts
parent064cb8967512bc383e1cda4d26bb9dae1c6ed072 (diff)
downloadgnome-control-center-0002313af8103c1a5bf981e6e49d862f460df378.tar.gz
user-accounts: Add restart notification
Show restart notification when language is changed. https://bugzilla.gnome.org/show_bug.cgi?id=703392
Diffstat (limited to 'panels/user-accounts')
-rw-r--r--panels/user-accounts/Makefile.am4
-rw-r--r--panels/user-accounts/data/user-accounts-dialog.ui5
-rw-r--r--panels/user-accounts/um-user-panel.c72
3 files changed, 79 insertions, 2 deletions
diff --git a/panels/user-accounts/Makefile.am b/panels/user-accounts/Makefile.am
index 54e24626f..5ef4c3329 100644
--- a/panels/user-accounts/Makefile.am
+++ b/panels/user-accounts/Makefile.am
@@ -12,6 +12,7 @@ AM_CPPFLAGS = \
-DHAVE_LIBPWQUALITY \
-I$(srcdir)/../common/ \
-I$(srcdir)/../../shell/ \
+ -I$(top_srcdir)/libgd/ \
$(PANEL_CFLAGS) \
$(USER_ACCOUNTS_PANEL_CFLAGS)
@@ -63,7 +64,8 @@ libuser_accounts_la_LIBADD = \
$(builddir)/../common/liblanguage.la \
-lpwquality \
-lcrypt \
- -lm
+ -lm \
+ $(top_builddir)/libgd/libgd.la
if BUILD_CHEESE
libuser_accounts_la_LIBADD += $(CHEESE_LIBS)
diff --git a/panels/user-accounts/data/user-accounts-dialog.ui b/panels/user-accounts/data/user-accounts-dialog.ui
index 331c1c9ce..071922de5 100644
--- a/panels/user-accounts/data/user-accounts-dialog.ui
+++ b/panels/user-accounts/data/user-accounts-dialog.ui
@@ -33,6 +33,9 @@
<column type="gchararray"/>
</columns>
</object>
+ <object class="GtkOverlay" id="overlay">
+ <property name="visible">True</property>
+ <child>
<object class="GtkVBox" id="accounts-vbox">
<property name="visible">True</property>
<property name="orientation">vertical</property>
@@ -509,6 +512,8 @@
</object>
</child>
</object>
+ </child>
+ </object>
<object class="GtkSizeGroup" id="user-icon-sizegroup">
<property name="mode">both</property>
<widgets>
diff --git a/panels/user-accounts/um-user-panel.c b/panels/user-accounts/um-user-panel.c
index 80c933cd3..49271bd6d 100644
--- a/panels/user-accounts/um-user-panel.c
+++ b/panels/user-accounts/um-user-panel.c
@@ -26,12 +26,17 @@
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
+#include <locale.h>
#include <glib.h>
#include <glib/gi18n.h>
#include <gtk/gtk.h>
#include <polkit/polkit.h>
#include <act/act.h>
+#include <libgd/gd-notification.h>
+
+#define GNOME_DESKTOP_USE_UNSTABLE_API
+#include <libgnome-desktop/gnome-languages.h>
#ifdef HAVE_CHEESE
#include <gst/gst.h>
@@ -63,6 +68,7 @@ CC_PANEL_REGISTER (CcUserPanel, cc_user_panel)
struct _CcUserPanelPrivate {
ActUserManager *um;
GtkBuilder *builder;
+ GtkWidget *notification;
GtkWidget *main_box;
GPermission *permission;
@@ -846,6 +852,65 @@ language_response (GtkDialog *dialog,
}
static void
+restart_now (CcUserPanelPrivate *d)
+{
+ GDBusConnection *bus;
+
+ gd_notification_dismiss (GD_NOTIFICATION (d->notification));
+
+ bus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);
+ g_dbus_connection_call (bus,
+ "org.gnome.SessionManager",
+ "/org/gnome/SessionManager",
+ "org.gnome.SessionManager",
+ "Logout",
+ g_variant_new ("(u)", 0),
+ NULL, 0, G_MAXINT,
+ NULL, NULL, NULL);
+ g_object_unref (bus);
+}
+
+static void
+show_restart_notification (CcUserPanelPrivate *d, gchar *locale)
+{
+ GtkWidget *box;
+ GtkWidget *label;
+ GtkWidget *button;
+ gchar *current_locale;
+
+ if (d->notification)
+ return;
+
+ if (locale) {
+ current_locale = g_strdup (setlocale (LC_MESSAGES, NULL));
+ setlocale (LC_MESSAGES, locale);
+ }
+
+ d->notification = gd_notification_new ();
+ g_object_add_weak_pointer (G_OBJECT (d->notification), (gpointer *)&d->notification);
+ box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 24);
+ gtk_widget_set_margin_start (box, 12);
+ gtk_widget_set_margin_end (box, 12);
+ 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"));
+ button = gtk_button_new_with_label (_("Restart Now"));
+ g_signal_connect_swapped (button, "clicked", G_CALLBACK (restart_now), d);
+ 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 (d->notification), box);
+ gtk_overlay_add_overlay (GTK_OVERLAY (get_widget (d, "overlay")), d->notification);
+ gtk_widget_show (d->notification);
+
+ if (locale) {
+ setlocale (LC_MESSAGES, current_locale);
+ g_free (current_locale);
+ }
+}
+
+static void
language_changed (UmEditableCombo *combo,
CcUserPanelPrivate *d)
{
@@ -853,11 +918,13 @@ language_changed (UmEditableCombo *combo,
GtkTreeIter iter;
gchar *lang;
ActUser *user;
+ gboolean self_selected;
if (!um_editable_combo_get_active_iter (combo, &iter))
return;
user = get_selected_user (d);
+ self_selected = act_user_get_uid (user) == geteuid ();
model = um_editable_combo_get_model (combo);
@@ -865,6 +932,9 @@ language_changed (UmEditableCombo *combo,
if (lang) {
if (g_strcmp0 (lang, act_user_get_language (user)) != 0) {
act_user_set_language (user, lang);
+
+ if (self_selected)
+ show_restart_notification (d, lang);
}
g_free (lang);
goto out;
@@ -1432,7 +1502,7 @@ cc_user_panel_init (CcUserPanel *self)
button = get_widget (d, "user-icon-button");
d->photo_dialog = um_photo_dialog_new (button);
d->main_box = get_widget (d, "accounts-vbox");
- gtk_container_add (GTK_CONTAINER (self), d->main_box);
+ gtk_container_add (GTK_CONTAINER (self), get_widget (d, "overlay"));
d->history_dialog = um_history_dialog_new ();
setup_main_window (d);