]> git.0d.be Git - empathy.git/commitdiff
[EmpathyContactSelectorDialog] make the Account Chooser optional
authorDanielle Madeley <danielle.madeley@collabora.co.uk>
Fri, 18 Dec 2009 05:34:38 +0000 (16:34 +1100)
committerDanielle Madeley <danielle.madeley@collabora.co.uk>
Fri, 18 Dec 2009 23:48:55 +0000 (10:48 +1100)
libempathy-gtk/empathy-contact-selector-dialog.c
libempathy-gtk/empathy-contact-selector-dialog.h
libempathy-gtk/empathy-contact-selector-dialog.ui

index 291184e108f0c00f9f3918f97b99fd6546972a89..8f1ec149f22b50dbf769141359a23e27334d2d18 100644 (file)
@@ -17,6 +17,7 @@
  *
  * Authors: Xavier Claessens <xclaesse@gmail.com>
  * Authors: Guillaume Desmottes <guillaume.desmottes@collabora.co.uk>
+ * Authors: Danielle Madeley <danielle.madeley@collabora.co.uk>
  */
 
 #include <config.h>
@@ -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;
 }
index 5fd6c2139ca5baf104e76082f0f34e1adf3fcef7..e317cd7a457e0919b18a5baafc1d0042639f4f45 100644 (file)
@@ -17,6 +17,7 @@
  *
  * Authors: Xavier Claessens <xclaesse@gmail.com>
  * Authors: Guillaume Desmottes <guillaume.desmottes@collabora.co.uk>
+ * Authors: Danielle Madeley <danielle.madeley@collabora.co.uk>
  */
 
 #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 \
index 009028ec1d58b7516818169c6c831ded13225710..6bf68c62e4cbc3c57934e9c6faa9d0b8601bf83f 100644 (file)
@@ -9,7 +9,7 @@
     <property name="column_spacing">6</property>
     <property name="row_spacing">6</property>
     <child>
-      <object class="GtkLabel" id="label1">
+      <object class="GtkLabel" id="account_chooser_label">
         <property name="visible">True</property>
         <property name="xalign">0</property>
         <property name="label" translatable="yes">Account:</property>