From: Danielle Madeley Date: Fri, 18 Dec 2009 05:34:38 +0000 (+1100) Subject: [EmpathyContactSelectorDialog] make the Account Chooser optional X-Git-Url: https://git.0d.be/?p=empathy.git;a=commitdiff_plain;h=270d39eae11b2723a086e10e5dd9c358d1e90ade [EmpathyContactSelectorDialog] make the Account Chooser optional --- diff --git a/libempathy-gtk/empathy-contact-selector-dialog.c b/libempathy-gtk/empathy-contact-selector-dialog.c index 291184e1..8f1ec149 100644 --- a/libempathy-gtk/empathy-contact-selector-dialog.c +++ b/libempathy-gtk/empathy-contact-selector-dialog.c @@ -17,6 +17,7 @@ * * Authors: Xavier Claessens * Authors: Guillaume Desmottes + * Authors: Danielle Madeley */ #include @@ -49,15 +50,23 @@ typedef struct _EmpathyContactSelectorDialogPriv \ EmpathyContactSelectorDialogPriv; struct _EmpathyContactSelectorDialogPriv { + GtkWidget *account_chooser_label; GtkWidget *account_chooser; GtkWidget *entry_id; EmpathyContactManager *contact_manager; + + gboolean show_account_chooser; }; #define GET_PRIV(o) \ (G_TYPE_INSTANCE_GET_PRIVATE ((o), EMPATHY_TYPE_CONTACT_SELECTOR_DIALOG, \ EmpathyContactSelectorDialogPriv)) +enum { + PROP_0, + PROP_SHOW_ACCOUNT_CHOOSER +}; + enum { COMPLETION_COL_TEXT, COMPLETION_COL_ID, @@ -71,12 +80,9 @@ contact_selector_dialog_account_changed_cb (GtkWidget *widget, EmpathyContactSelectorDialogPriv *priv = GET_PRIV (dialog); EmpathyAccountChooser *chooser; TpConnection *connection; - EmpathyTpContactList *contact_list; GList *members; GtkListStore *store; GtkEntryCompletion *completion; - GtkTreeIter iter; - gchar *tmpstr; /* Remove completions */ completion = gtk_entry_get_completion (GTK_ENTRY (priv->entry_id)); @@ -89,15 +95,27 @@ contact_selector_dialog_account_changed_cb (GtkWidget *widget, if (!connection) return; - contact_list = empathy_contact_manager_get_list (priv->contact_manager, - connection); - members = empathy_contact_list_get_members ( - EMPATHY_CONTACT_LIST (contact_list)); + if (priv->show_account_chooser) + { + EmpathyTpContactList *contact_list; + + 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 */ while (members) { EmpathyContact *contact = members->data; + GtkTreeIter iter; + gchar *tmpstr; DEBUG ("Adding contact ID %s, Name %s", empathy_contact_get_id (contact), @@ -262,6 +280,7 @@ empathy_contact_selector_dialog_init (EmpathyContactSelectorDialog *dialog) "libempathy-gtk"); gui = empathy_builder_get_file (filename, "table_contact", &dialog->table_contact, + "account_chooser_label", &priv->account_chooser_label, "entry_id", &priv->entry_id, NULL); g_free (filename); @@ -326,6 +345,48 @@ empathy_contact_selector_dialog_init (EmpathyContactSelectorDialog *dialog) dialog); } +static void +empathy_contact_selector_dialog_get_property (GObject *self, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + EmpathyContactSelectorDialog *dialog = EMPATHY_CONTACT_SELECTOR_DIALOG (self); + + switch (prop_id) + { + case PROP_SHOW_ACCOUNT_CHOOSER: + g_value_set_boolean (value, + empathy_contact_selector_dialog_get_show_account_chooser (dialog)); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (self, prop_id, pspec); + break; + } +} + +static void +empathy_contact_selector_dialog_set_property (GObject *self, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + EmpathyContactSelectorDialog *dialog = EMPATHY_CONTACT_SELECTOR_DIALOG (self); + + switch (prop_id) + { + case PROP_SHOW_ACCOUNT_CHOOSER: + empathy_contact_selector_dialog_set_show_account_chooser (dialog, + g_value_get_boolean (value)); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (self, prop_id, pspec); + break; + } +} + static void empathy_contact_selector_dialog_dispose (GObject *object) { @@ -350,4 +411,44 @@ empathy_contact_selector_dialog_class_init ( g_type_class_add_private (class, sizeof (EmpathyContactSelectorDialogPriv)); object_class->dispose = empathy_contact_selector_dialog_dispose; + object_class->get_property = empathy_contact_selector_dialog_get_property; + object_class->set_property = empathy_contact_selector_dialog_set_property; + + g_object_class_install_property (object_class, PROP_SHOW_ACCOUNT_CHOOSER, + g_param_spec_boolean ("show-account-chooser", + "Show Account Chooser", + "Whether or not this dialog should show an account chooser", + TRUE, + G_PARAM_READWRITE)); +} + +void +empathy_contact_selector_dialog_set_show_account_chooser ( + EmpathyContactSelectorDialog *self, + gboolean show_account_chooser) +{ + EmpathyContactSelectorDialogPriv *priv; + + g_return_if_fail (EMPATHY_IS_CONTACT_SELECTOR_DIALOG (self)); + + priv = GET_PRIV (self); + priv->show_account_chooser = show_account_chooser; + + gtk_widget_set_visible (priv->account_chooser_label, show_account_chooser); + gtk_widget_set_visible (priv->account_chooser, show_account_chooser); + contact_selector_dialog_account_changed_cb (priv->account_chooser, self); + + g_object_notify (G_OBJECT (self), "show-account-chooser"); +} + +gboolean +empathy_contact_selector_dialog_get_show_account_chooser ( + EmpathyContactSelectorDialog *self) +{ + EmpathyContactSelectorDialogPriv *priv; + + g_return_val_if_fail (EMPATHY_IS_CONTACT_SELECTOR_DIALOG (self), FALSE); + + priv = GET_PRIV (self); + return priv->show_account_chooser; } diff --git a/libempathy-gtk/empathy-contact-selector-dialog.h b/libempathy-gtk/empathy-contact-selector-dialog.h index 5fd6c213..e317cd7a 100644 --- a/libempathy-gtk/empathy-contact-selector-dialog.h +++ b/libempathy-gtk/empathy-contact-selector-dialog.h @@ -17,6 +17,7 @@ * * Authors: Xavier Claessens * Authors: Guillaume Desmottes + * Authors: Danielle Madeley */ #ifndef __EMPATHY_CONTACT_SELECTOR_DIALOG_H__ @@ -54,6 +55,11 @@ struct _EmpathyContactSelectorDialog { }; GType empathy_contact_selector_dialog_get_type (void); +void empathy_contact_selector_dialog_set_show_account_chooser ( + EmpathyContactSelectorDialog *self, + gboolean show_account_chooser); +gboolean empathy_contact_selector_dialog_get_show_account_chooser ( + EmpathyContactSelectorDialog *self); /* TYPE MACROS */ #define EMPATHY_TYPE_CONTACT_SELECTOR_DIALOG \ diff --git a/libempathy-gtk/empathy-contact-selector-dialog.ui b/libempathy-gtk/empathy-contact-selector-dialog.ui index 009028ec..6bf68c62 100644 --- a/libempathy-gtk/empathy-contact-selector-dialog.ui +++ b/libempathy-gtk/empathy-contact-selector-dialog.ui @@ -9,7 +9,7 @@ 6 6 - + True 0 Account: