[empathy: 7/16] Add a menu item to choose whether to show account balances in the roster



commit 4786fdc5f4424c88c7fcaad5357f42a27c4e24ad
Author: Danielle Madeley <danielle madeley collabora co uk>
Date:   Fri Apr 15 16:39:40 2011 +1000

    Add a menu item to choose whether to show account balances in the roster

 data/org.gnome.Empathy.gschema.xml.in |    5 +++++
 src/empathy-main-window.c             |   30 +++++++++++++++++++++++++-----
 src/empathy-main-window.ui            |    8 ++++++++
 3 files changed, 38 insertions(+), 5 deletions(-)
---
diff --git a/data/org.gnome.Empathy.gschema.xml.in b/data/org.gnome.Empathy.gschema.xml.in
index 1c833ff..5f4e7fd 100644
--- a/data/org.gnome.Empathy.gschema.xml.in
+++ b/data/org.gnome.Empathy.gschema.xml.in
@@ -49,6 +49,11 @@
       <_summary>Show protocols</_summary>
       <_description>Whether to show protocols for contacts in the contact list.</_description>
     </key>
+    <key name="show-balance-in-roster" type="b">
+      <default>false</default>
+      <_summary>Show Balance in roster</_summary>
+      <_description>Whether to show account balances for in the contact roster.</_description>
+    </key>
     <key name="compact-contact-list" type="b">
       <default>false</default>
       <_summary>Compact contact list</_summary>
diff --git a/src/empathy-main-window.c b/src/empathy-main-window.c
index c02fccb..0952284 100644
--- a/src/empathy-main-window.c
+++ b/src/empathy-main-window.c
@@ -146,6 +146,7 @@ struct _EmpathyMainWindowPriv {
 	GtkWidget              *edit_context_separator;
 
 	GtkActionGroup         *balance_action_group;
+	GtkAction              *view_balance_show_in_roster;
 	GtkWidget              *balance_vbox;
 
 	guint                   size_timeout_id;
@@ -957,9 +958,6 @@ main_window_setup_balance_create_widget (EmpathyMainWindow *window,
 	EmpathyMainWindowPriv *priv = GET_PRIV (window);
 	GtkWidget *hbox, *image, *label, *button;
 
-	if (action == NULL)
-		return NULL;
-
 	hbox = gtk_hbox_new (FALSE, 6);
 
 	image = gtk_image_new ();
@@ -1000,6 +998,7 @@ main_window_setup_balance_conn_ready (GObject      *conn,
 				      gpointer      user_data)
 {
 	EmpathyMainWindow *window = user_data;
+	EmpathyMainWindowPriv *priv = GET_PRIV (window);
 	TpAccount *account = g_object_get_data (conn, "account");
 	GtkAction *action;
 	GtkWidget *widget;
@@ -1023,6 +1022,11 @@ main_window_setup_balance_conn_ready (GObject      *conn,
 	/* create the action */
 	action = main_window_setup_balance_create_action (window, account);
 
+	if (action == NULL)
+		return;
+
+	gtk_action_set_visible (priv->view_balance_show_in_roster, TRUE);
+
 	/* create the display widget */
 	widget = main_window_setup_balance_create_widget (window, action);
 
@@ -1079,6 +1083,7 @@ main_window_connection_changed_cb (TpAccount  *account,
 		if (priv->balance_action_group != NULL) {
 			GtkAction *action;
 			char *name;
+			GList *a;
 
 			name = main_window_account_to_action_name (account);
 
@@ -1101,6 +1106,15 @@ main_window_connection_changed_cb (TpAccount  *account,
 			}
 
 			g_free (name);
+
+			a = gtk_action_group_list_actions (
+				priv->balance_action_group);
+
+			gtk_action_set_visible (
+				priv->view_balance_show_in_roster,
+				g_list_length (a) > 0);
+
+			g_list_free (a);
 		}
 	}
 
@@ -2092,6 +2106,7 @@ empathy_main_window_init (EmpathyMainWindow *window)
 				       "notebook", &priv->notebook,
 				       "no_entry_label", &priv->no_entry_label,
 				       "roster_scrolledwindow", &sw,
+				       "view_balance_show_in_roster", &priv->view_balance_show_in_roster,
 				       NULL);
 	g_free (filename);
 
@@ -2252,8 +2267,13 @@ empathy_main_window_init (EmpathyMainWindow *window)
 	/* Set window size. */
 	empathy_geometry_bind (GTK_WINDOW (window), GEOMETRY_NAME);
 
-	/* FIXME: bind balance_vbox to action */
-	gtk_widget_show (priv->balance_vbox);
+	/* bind view_balance_show_in_roster */
+	g_settings_bind (priv->gsettings_ui, "show-balance-in-roster",
+		priv->view_balance_show_in_roster, "active",
+		G_SETTINGS_BIND_DEFAULT);
+	g_object_bind_property (priv->view_balance_show_in_roster, "active",
+		priv->balance_vbox, "visible",
+		G_BINDING_SYNC_CREATE);
 
 	/* Enable event handling */
 	priv->call_observer = empathy_call_observer_dup_singleton ();
diff --git a/src/empathy-main-window.ui b/src/empathy-main-window.ui
index 7852de1..278d139 100644
--- a/src/empathy-main-window.ui
+++ b/src/empathy-main-window.ui
@@ -70,6 +70,13 @@
           </object>
         </child>
         <child>
+          <object class="GtkToggleAction" id="view_balance_show_in_roster">
+            <property name="name">view_balance_show_in_roster</property>
+            <property name="label" translatable="yes">Show Account _Balances in Roster</property>
+            <property name="visible">False</property>
+          </object>
+        </child>
+        <child>
           <object class="GtkAction" id="view_show_map">
             <property name="name">view_show_map</property>
             <property name="label" translatable="yes">Contacts on a _Map</property>
@@ -265,6 +272,7 @@
           <menuitem action="view_show_offline"/>
           <menuitem action="view_show_protocols"/>
           <separator/>
+          <menuitem action="view_balance_show_in_roster"/>
           <placeholder name="view_balance_placeholder"/>
           <separator/>
           <menuitem action="view_sort_by_name"/>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]