From 004e78f70d1088c94bdd00e66c96260abe03cae9 Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Sat, 20 Oct 2007 22:07:28 +0000 Subject: To know if an account is connected, use 2007-10-21 Xavier Claessens * libempathy-gtk/empathy-account-chooser.c: * libempathy-gtk/empathy-contact-dialogs.c: * libempathy-gtk/empathy-contact-widget.c: * libempathy-gtk/empathy-contact-widget.h: * libempathy-gtk/empathy-accounts-dialog.c: To know if an account is connected, use mission_control_get_connection_status() instead of mission_control_get_connection(). Update account chooser if an account's status changes or if it get removed. Move account chooser filter func for add-contact's window from EmpathyContactWidget to EmpathyContactDialogs. svn path=/trunk/; revision=384 --- libempathy-gtk/empathy-contact-widget.c | 57 ++++++++++++--------------------- 1 file changed, 21 insertions(+), 36 deletions(-) (limited to 'libempathy-gtk/empathy-contact-widget.c') diff --git a/libempathy-gtk/empathy-contact-widget.c b/libempathy-gtk/empathy-contact-widget.c index 34a8023fe..cde5acd61 100644 --- a/libempathy-gtk/empathy-contact-widget.c +++ b/libempathy-gtk/empathy-contact-widget.c @@ -223,6 +223,27 @@ empathy_contact_widget_get_contact (GtkWidget *widget) return information->contact; } + +void +empathy_contact_widget_set_account_filter (GtkWidget *widget, + EmpathyAccountChooserFilterFunc filter, + gpointer user_data) +{ + EmpathyContactWidget *information; + EmpathyAccountChooser *chooser; + + g_return_if_fail (GTK_IS_WIDGET (widget)); + + information = g_object_get_data (G_OBJECT (widget), "EmpathyContactWidget"); + if (!information) { + return; + } + + chooser = EMPATHY_ACCOUNT_CHOOSER (information->widget_account); + if (chooser) { + empathy_account_chooser_set_filter (chooser, filter, user_data); + } +} static void contact_widget_destroy_cb (GtkWidget *widget, @@ -281,38 +302,6 @@ contact_widget_set_contact (EmpathyContactWidget *information, contact_widget_client_update (information); } -static gboolean -contact_widget_can_add_contact_to_account (McAccount *account, - gpointer user_data) -{ - MissionControl *mc; - TpConn *tp_conn; - McProfile *profile; - const gchar *protocol_name; - - mc = empathy_mission_control_new (); - tp_conn = mission_control_get_connection (mc, account, NULL); - g_object_unref (mc); - if (tp_conn == NULL) { - /* Account is disconnected */ - return FALSE; - } - g_object_unref (tp_conn); - - profile = mc_account_get_profile (account); - protocol_name = mc_profile_get_protocol_name (profile); - if (strcmp (protocol_name, "local-xmpp") == 0) { - /* We can't add accounts to a XMPP LL connection - * FIXME: We should inspect the flags of the contact list group interface - */ - g_object_unref (profile); - return FALSE; - } - - g_object_unref (profile); - return TRUE; -} - static gboolean contact_widget_id_activate_timeout (EmpathyContactWidget *self) { @@ -354,10 +343,6 @@ contact_widget_contact_setup (EmpathyContactWidget *information) /* Setup account label/chooser */ if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_ACCOUNT) { information->widget_account = empathy_account_chooser_new (); - empathy_account_chooser_set_filter ( - EMPATHY_ACCOUNT_CHOOSER (information->widget_account), - contact_widget_can_add_contact_to_account, - NULL); g_signal_connect (information->widget_account, "changed", G_CALLBACK (contact_widget_account_changed_cb), -- cgit v1.2.3