]> git.0d.be Git - empathy.git/commitdiff
Add a menu item to choose whether to show account balances in the roster
authorDanielle Madeley <danielle.madeley@collabora.co.uk>
Fri, 15 Apr 2011 06:39:40 +0000 (16:39 +1000)
committerDanielle Madeley <danielle.madeley@collabora.co.uk>
Thu, 5 May 2011 07:12:27 +0000 (17:12 +1000)
data/org.gnome.Empathy.gschema.xml.in
src/empathy-main-window.c
src/empathy-main-window.ui

index 1c833ffcb5f63e93323120d78f21b233cc79ce85..5f4e7fdecd0124593d696b5bd2a8df32b9884b88 100644 (file)
       <_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>
index c02fccb022ae26b76287383397c20ff37eeba7ec..0952284e63f73fd0a3e05dbfbf0cdaec8a71b891 100644 (file)
@@ -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 ();
index 7852de15153ee3a2d4d3a434b01c3cc82cb64a8b..278d1392a686f7b24bcf7048dd32d6ddf1f56d34 100644 (file)
             <property name="label" translatable="yes">Show P_rotocols</property>
           </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>
           <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"/>