diff options
author | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2010-03-12 18:18:58 +0100 |
---|---|---|
committer | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2010-03-15 10:18:01 +0100 |
commit | e1e6e92bae0eac67637b06eca8860a88d29bd8b7 (patch) | |
tree | d3427e9452138377a41d7767a81f96f72c5fbe6e /libempathy-gtk/empathy-contact-selector-dialog.c | |
parent | 9f839398aa851f66bcd426f5a1754c7becb8c990 (diff) | |
download | empathy-e1e6e92bae0eac67637b06eca8860a88d29bd8b7.tar.gz |
contact-selector-dialog: Add a property to filter contacts by account
This is useful when the account chooser is not displayed to filter contacts
from one specific account.
Diffstat (limited to 'libempathy-gtk/empathy-contact-selector-dialog.c')
-rw-r--r-- | libempathy-gtk/empathy-contact-selector-dialog.c | 68 |
1 files changed, 65 insertions, 3 deletions
diff --git a/libempathy-gtk/empathy-contact-selector-dialog.c b/libempathy-gtk/empathy-contact-selector-dialog.c index 3c59061ae..3428b0513 100644 --- a/libempathy-gtk/empathy-contact-selector-dialog.c +++ b/libempathy-gtk/empathy-contact-selector-dialog.c @@ -55,6 +55,7 @@ struct _EmpathyContactSelectorDialogPriv { GtkWidget *account_chooser; GtkWidget *entry_id; EmpathyContactManager *contact_manager; + TpAccount *filter_account; gboolean show_account_chooser; }; @@ -65,7 +66,8 @@ struct _EmpathyContactSelectorDialogPriv { enum { PROP_0, - PROP_SHOW_ACCOUNT_CHOOSER + PROP_SHOW_ACCOUNT_CHOOSER, + PROP_FILTER_ACCOUNT }; enum { @@ -103,8 +105,22 @@ contact_selector_dialog_account_changed_cb (GtkWidget *widget, } else { - members = empathy_contact_list_get_members ( - EMPATHY_CONTACT_LIST (priv->contact_manager)); + if (priv->filter_account != NULL) + { + EmpathyTpContactList *contact_list; + + connection = tp_account_get_connection (priv->filter_account); + contact_list = empathy_contact_manager_get_list ( + priv->contact_manager, connection); + + members = empathy_contact_list_get_members ( + EMPATHY_CONTACT_LIST (contact_list)); + } + else + { + members = empathy_contact_list_get_members ( + EMPATHY_CONTACT_LIST (priv->contact_manager)); + } } /* Add members to the completion */ @@ -361,6 +377,11 @@ empathy_contact_selector_dialog_get_property (GObject *self, empathy_contact_selector_dialog_get_show_account_chooser (dialog)); break; + case PROP_FILTER_ACCOUNT: + g_value_set_object (value, + empathy_contact_selector_dialog_get_filter_account (dialog)); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (self, prop_id, pspec); break; @@ -382,6 +403,11 @@ empathy_contact_selector_dialog_set_property (GObject *self, g_value_get_boolean (value)); break; + case PROP_FILTER_ACCOUNT: + empathy_contact_selector_dialog_set_filter_account (dialog, + g_value_get_object (value)); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (self, prop_id, pspec); break; @@ -445,6 +471,14 @@ empathy_contact_selector_dialog_class_init ( "Whether or not this dialog should show an account chooser", TRUE, G_PARAM_READWRITE)); + + g_object_class_install_property (object_class, PROP_FILTER_ACCOUNT, + g_param_spec_object ("filter-account", + "Account to filter contacts", + "if 'show-account-chooser' is unset, only the contacts from this " + "account are displayed", + TP_TYPE_ACCOUNT, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); } const gchar * @@ -502,3 +536,31 @@ empathy_contact_selector_dialog_get_show_account_chooser ( priv = GET_PRIV (self); return priv->show_account_chooser; } + +void +empathy_contact_selector_dialog_set_filter_account ( + EmpathyContactSelectorDialog *self, + TpAccount *account) +{ + EmpathyContactSelectorDialogPriv *priv; + + g_return_if_fail (EMPATHY_IS_CONTACT_SELECTOR_DIALOG (self)); + + priv = GET_PRIV (self); + priv->filter_account = g_object_ref (account); + + g_object_notify (G_OBJECT (self), "filter-account"); +} + +TpAccount * +empathy_contact_selector_dialog_get_filter_account ( + EmpathyContactSelectorDialog *self) +{ + EmpathyContactSelectorDialogPriv *priv; + + g_return_val_if_fail (EMPATHY_IS_CONTACT_SELECTOR_DIALOG (self), FALSE); + + priv = GET_PRIV (self); + return priv->filter_account; + +} |