diff options
author | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2012-12-26 19:06:38 +0800 |
---|---|---|
committer | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2012-12-26 19:48:32 +0800 |
commit | b3ab97d23625f6febd97d9c4459e2939bcbbd7ff (patch) | |
tree | ef9b87b2d72e703ef78ee723eb4ef67c0082cae1 | |
parent | 7e28ffdb6b89919f840f8e81a53b5cc06f724899 (diff) | |
download | gsoc2013-empathy-b3ab97d23625f6febd97d9c4459e2939bcbbd7ff.tar gsoc2013-empathy-b3ab97d23625f6febd97d9c4459e2939bcbbd7ff.tar.gz gsoc2013-empathy-b3ab97d23625f6febd97d9c4459e2939bcbbd7ff.tar.bz2 gsoc2013-empathy-b3ab97d23625f6febd97d9c4459e2939bcbbd7ff.tar.lz gsoc2013-empathy-b3ab97d23625f6febd97d9c4459e2939bcbbd7ff.tar.xz gsoc2013-empathy-b3ab97d23625f6febd97d9c4459e2939bcbbd7ff.tar.zst gsoc2013-empathy-b3ab97d23625f6febd97d9c4459e2939bcbbd7ff.zip |
roster-window: prevent adding contact if not supported by CM
https://bugzilla.gnome.org/show_bug.cgi?id=690733
-rw-r--r-- | src/empathy-roster-window.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/empathy-roster-window.c b/src/empathy-roster-window.c index b87741b35..d2f6d542d 100644 --- a/src/empathy-roster-window.c +++ b/src/empathy-roster-window.c @@ -420,6 +420,31 @@ typedef enum PAGE_MESSAGE_FLAG_ADD_CONTACT = 1 << 5, } PageMessageFlags; +static gboolean +can_add_contact (EmpathyRosterWindow *self) +{ + GList *accounts, *l; + gboolean result = FALSE; + + accounts = tp_account_manager_dup_valid_accounts ( + self->priv->account_manager); + for (l = accounts; l != NULL && !result; l = g_list_next (l)) + { + TpAccount *account = TP_ACCOUNT (l->data); + TpConnection *conn; + + conn = tp_account_get_connection (account); + if (conn == NULL) + continue; + + if (tp_connection_get_can_change_contact_list (conn)) + result = TRUE; + } + + g_list_free_full (accounts, g_object_unref); + return result; +} + static void display_page_message (EmpathyRosterWindow *self, const gchar *msg, @@ -453,6 +478,10 @@ display_page_message (EmpathyRosterWindow *self, gtk_widget_set_visible (self->priv->button_add_contact, (flags & PAGE_MESSAGE_FLAG_ADD_CONTACT) != 0); + if ((flags & PAGE_MESSAGE_FLAG_ADD_CONTACT) != 0) + gtk_widget_set_sensitive (self->priv->button_add_contact, + can_add_contact (self)); + gtk_notebook_set_current_page (GTK_NOTEBOOK (self->priv->notebook), PAGE_MESSAGE); } @@ -738,6 +767,7 @@ roster_window_update_status (EmpathyRosterWindow *self) { gboolean connected, connecting; GList *l; + GAction *action; connected = empathy_account_manager_get_accounts_connected (&connecting); @@ -756,6 +786,10 @@ roster_window_update_status (EmpathyRosterWindow *self) /* Update widgets sensibility */ for (l = self->priv->actions_connected; l; l = l->next) g_simple_action_set_enabled (l->data, connected); + + action = g_action_map_lookup_action (G_ACTION_MAP (self), "chat_add_contact"); + if (!can_add_contact (self)) + g_simple_action_set_enabled (G_SIMPLE_ACTION (action), FALSE); } static void |