[gnome-control-center] region: Offer logout option after changing language
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] region: Offer logout option after changing language
- Date: Fri, 23 Nov 2012 17:52:51 +0000 (UTC)
commit fca58d0e59e820c068968266a346d18e0a9a6c6d
Author: Adel Gadllah <adel gadllah gmail com>
Date: Mon Sep 3 12:23:02 2012 +0200
region: Offer logout option after changing language
https://bugzilla.gnome.org/show_bug.cgi?id=647373
panels/region/gnome-region-panel-lang.c | 54 ++++++++++++++++++-
panels/region/gnome-region-panel.ui | 86 +++++++++++++++++++------------
2 files changed, 104 insertions(+), 36 deletions(-)
---
diff --git a/panels/region/gnome-region-panel-lang.c b/panels/region/gnome-region-panel-lang.c
index a944eca..7e92f04 100644
--- a/panels/region/gnome-region-panel-lang.c
+++ b/panels/region/gnome-region-panel-lang.c
@@ -36,6 +36,46 @@
static GDBusProxy *proxy = NULL;
static void
+logout_requested (GtkButton *button,
+ gpointer user_data)
+{
+ GError *error;
+ GDBusProxy *sm_proxy;
+ GVariant *res;
+
+ error = NULL;
+ sm_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
+ G_DBUS_PROXY_FLAGS_NONE,
+ NULL,
+ "org.gnome.SessionManager",
+ "/org/gnome/SessionManager",
+ "org.gnome.SessionManager",
+ NULL,
+ &error);
+
+ if (sm_proxy == NULL) {
+ g_warning ("Failed to contact gnome session service: %s", error->message);
+ g_error_free (error);
+ return;
+ }
+
+ res = g_dbus_proxy_call_sync (sm_proxy,
+ "Logout",
+ g_variant_new ("(u)", 0),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ &error);
+ if (res == NULL) {
+ g_warning ("Logout failed: %s", error->message);
+ g_error_free (error);
+ } else
+ g_variant_unref (res);
+
+ g_object_unref (sm_proxy);
+}
+
+static void
selection_changed (GtkTreeSelection *selection,
GtkBuilder *builder)
{
@@ -46,6 +86,7 @@ selection_changed (GtkTreeSelection *selection,
GVariant *variant;
GError *error = NULL;
char *object_path;
+ GtkWidget *widget;
if (gtk_tree_selection_get_selected (selection, &model, &iter) == FALSE) {
g_warning ("No selected languages, this shouldn't happen");
@@ -114,7 +155,10 @@ selection_changed (GtkTreeSelection *selection,
formats_update_language (builder, locale);
system_update_language (builder, locale);
- /* And done */
+ /* And done, ask for logout */
+ //FIXME we should only do that if it wasn't the original language we started the session with
+ widget = (GtkWidget *)gtk_builder_get_object (builder, "logout_button");
+ gtk_widget_show (widget);
bail:
if (variant != NULL)
@@ -202,13 +246,17 @@ setup_language (GtkBuilder *builder)
widget = (GtkWidget *)gtk_builder_get_object (builder, "language-toolbar");
context = gtk_widget_get_style_context (widget);
gtk_style_context_set_junction_sides (context, GTK_JUNCTION_TOP);
-
+
treeview = GTK_WIDGET (gtk_builder_get_object (builder, "display_language_treeview"));
/* Connect buttons */
widget = (GtkWidget *)gtk_builder_get_object (builder, "language_add");
g_signal_connect (widget, "clicked",
- G_CALLBACK (add_language), treeview);
+ G_CALLBACK (add_language), treeview);
+
+ widget = (GtkWidget *)gtk_builder_get_object (builder, "logout_button");
+ g_signal_connect (widget, "clicked",
+ G_CALLBACK (logout_requested), NULL);
/* Setup accounts service */
proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
diff --git a/panels/region/gnome-region-panel.ui b/panels/region/gnome-region-panel.ui
index 1c69ad7..9cb576f 100644
--- a/panels/region/gnome-region-panel.ui
+++ b/panels/region/gnome-region-panel.ui
@@ -112,11 +112,35 @@
<property name="border_width">12</property>
<property name="spacing">12</property>
<child>
- <object class="GtkLabel" id="label4">
+ <object class="GtkBox" id="box1">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">Select a display language (change will be applied next time you log in)</property>
+ <child>
+ <object class="GtkLabel" id="label4">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Select a display language</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="logout_button">
+ <property name="label" translatable="yes">Log out for changes to take effect</property>
+ <property name="visible">False</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="expand">False</property>
@@ -153,30 +177,19 @@
</packing>
</child>
<child>
- <object class="GtkToolbar" id="language-toolbar">
- <property name="visible">True</property>
+ <object class="GtkVBox" id="vbox3">
<property name="can_focus">False</property>
- <property name="toolbar_style">icons</property>
- <property name="show_arrow">False</property>
- <property name="icon_size">1</property>
- <style>
- <class name="inline-toolbar"/>
- </style>
- <style>
- <class name="inline-toolbar"/>
- </style>
<child>
- <object class="GtkToolButton" id="language_add">
- <property name="use_action_appearance">False</property>
+ <object class="GtkLabel" id="label23">
<property name="visible">True</property>
- <property name="label" translatable="yes">Add Language</property>
<property name="can_focus">False</property>
+ <property name="label" translatable="yes">Add Language</property>
<property name="use_underline">True</property>
- <property name="icon_name">list-add-symbolic</property>
</object>
<packing>
- <property name="expand">False</property>
- <property name="homogeneous">True</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
</packing>
</child>
</object>
@@ -187,33 +200,40 @@
</packing>
</child>
<child>
- <object class="GtkVBox" id="vbox3">
+ <object class="GtkToolbar" id="language-toolbar">
+ <property name="visible">True</property>
<property name="can_focus">False</property>
+ <property name="toolbar_style">icons</property>
+ <property name="show_arrow">False</property>
+ <property name="icon_size">1</property>
+ <style>
+ <class name="inline-toolbar"/>
+ </style>
<child>
- <object class="GtkLabel" id="label23">
+ <object class="GtkToolButton" id="language_add">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="use_underline">True</property>
<property name="label" translatable="yes">Add Language</property>
+ <property name="use_underline">True</property>
+ <property name="icon_name">list-add-symbolic</property>
</object>
<packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">0</property>
+ <property name="expand">False</property>
+ <property name="homogeneous">True</property>
</packing>
</child>
<child>
- <object class="GtkLinkButton" id="linkbutton1">
- <property name="label" translatable="yes">Install languages...</property>
+ <object class="GtkToolButton" id="language_remove">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="has_tooltip">True</property>
+ <property name="sensitive">False</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Remove Language</property>
+ <property name="use_underline">True</property>
+ <property name="icon_name">list-remove-symbolic</property>
</object>
<packing>
<property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
+ <property name="homogeneous">True</property>
</packing>
</child>
</object>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]