diff options
author | Danielle Madeley <danielle.madeley@collabora.co.uk> | 2011-05-26 14:38:22 +0800 |
---|---|---|
committer | Danielle Madeley <danielle.madeley@collabora.co.uk> | 2011-05-26 14:45:55 +0800 |
commit | cddd93283537e99037176b7c01c3ac36bfcb6bf0 (patch) | |
tree | c05f545ea4e1226c8d8ca57ee4be22f1ff0cb3c6 /src | |
parent | 465d2ffaf8c2cd31ae1efc7fdcc85b3d5cb0773c (diff) | |
download | gsoc2013-empathy-cddd93283537e99037176b7c01c3ac36bfcb6bf0.tar gsoc2013-empathy-cddd93283537e99037176b7c01c3ac36bfcb6bf0.tar.gz gsoc2013-empathy-cddd93283537e99037176b7c01c3ac36bfcb6bf0.tar.bz2 gsoc2013-empathy-cddd93283537e99037176b7c01c3ac36bfcb6bf0.tar.lz gsoc2013-empathy-cddd93283537e99037176b7c01c3ac36bfcb6bf0.tar.xz gsoc2013-empathy-cddd93283537e99037176b7c01c3ac36bfcb6bf0.tar.zst gsoc2013-empathy-cddd93283537e99037176b7c01c3ac36bfcb6bf0.zip |
Remove the balance action when an account is removed
Diffstat (limited to 'src')
-rw-r--r-- | src/empathy-main-window.c | 86 |
1 files changed, 48 insertions, 38 deletions
diff --git a/src/empathy-main-window.c b/src/empathy-main-window.c index 3f1be88be..1878431bc 100644 --- a/src/empathy-main-window.c +++ b/src/empathy-main-window.c @@ -1076,6 +1076,50 @@ main_window_setup_balance (EmpathyMainWindow *window, } static void +main_window_remove_balance_action (EmpathyMainWindow *window, + TpAccount *account) +{ + EmpathyMainWindowPriv *priv = GET_PRIV (window); + GtkAction *action; + char *name; + GList *a; + + if (priv->balance_action_group == NULL) + return; + + name = main_window_account_to_action_name (account); + + action = gtk_action_group_get_action ( + priv->balance_action_group, name); + + if (action != NULL) { + guint merge_id; + + DEBUG ("Removing action"); + + merge_id = GPOINTER_TO_UINT (g_object_get_data ( + G_OBJECT (action), + "merge-id")); + + gtk_ui_manager_remove_ui (priv->ui_manager, + merge_id); + gtk_action_group_remove_action ( + priv->balance_action_group, action); + } + + 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); +} + +static void main_window_connection_changed_cb (TpAccount *account, guint old_status, guint current, @@ -1084,8 +1128,6 @@ main_window_connection_changed_cb (TpAccount *account, GHashTable *details, EmpathyMainWindow *window) { - EmpathyMainWindowPriv *priv = GET_PRIV (window); - main_window_update_status (window); if (current == TP_CONNECTION_STATUS_DISCONNECTED && @@ -1098,42 +1140,7 @@ main_window_connection_changed_cb (TpAccount *account, EMPATHY_SOUND_ACCOUNT_DISCONNECTED); /* remove balance action if required */ - if (priv->balance_action_group != NULL) { - GtkAction *action; - char *name; - GList *a; - - name = main_window_account_to_action_name (account); - - action = gtk_action_group_get_action ( - priv->balance_action_group, name); - - if (action != NULL) { - guint merge_id; - - DEBUG ("Removing action"); - - merge_id = GPOINTER_TO_UINT (g_object_get_data ( - G_OBJECT (action), - "merge-id")); - - gtk_ui_manager_remove_ui (priv->ui_manager, - merge_id); - gtk_action_group_remove_action ( - priv->balance_action_group, action); - } - - 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); - } + main_window_remove_balance_action (window, account); } if (current == TP_CONNECTION_STATUS_CONNECTED) { @@ -1919,6 +1926,9 @@ main_window_account_removed_cb (TpAccountManager *manager, /* remove errors if any */ main_window_remove_error (window, account); + + /* remove the balance action if required */ + main_window_remove_balance_action (window, account); } static void |