aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy-gtk
diff options
context:
space:
mode:
authorDanielle Madeley <danielle.madeley@collabora.co.uk>2009-12-18 13:34:38 +0800
committerDanielle Madeley <danielle.madeley@collabora.co.uk>2009-12-19 07:48:55 +0800
commit270d39eae11b2723a086e10e5dd9c358d1e90ade (patch)
tree7d440ed230ae054cfe2cc9c155cdffaa13e6e558 /libempathy-gtk
parent51b0e60035f1125428148dee926e8085a9ba571c (diff)
downloadgsoc2013-empathy-270d39eae11b2723a086e10e5dd9c358d1e90ade.tar
gsoc2013-empathy-270d39eae11b2723a086e10e5dd9c358d1e90ade.tar.gz
gsoc2013-empathy-270d39eae11b2723a086e10e5dd9c358d1e90ade.tar.bz2
gsoc2013-empathy-270d39eae11b2723a086e10e5dd9c358d1e90ade.tar.lz
gsoc2013-empathy-270d39eae11b2723a086e10e5dd9c358d1e90ade.tar.xz
gsoc2013-empathy-270d39eae11b2723a086e10e5dd9c358d1e90ade.tar.zst
gsoc2013-empathy-270d39eae11b2723a086e10e5dd9c358d1e90ade.zip
[EmpathyContactSelectorDialog] make the Account Chooser optional
Diffstat (limited to 'libempathy-gtk')
-rw-r--r--libempathy-gtk/empathy-contact-selector-dialog.c115
-rw-r--r--libempathy-gtk/empathy-contact-selector-dialog.h6
-rw-r--r--libempathy-gtk/empathy-contact-selector-dialog.ui2
3 files changed, 115 insertions, 8 deletions
diff --git a/libempathy-gtk/empathy-contact-selector-dialog.c b/libempathy-gtk/empathy-contact-selector-dialog.c
index 291184e10..8f1ec149f 100644
--- a/libempathy-gtk/empathy-contact-selector-dialog.c
+++ b/libempathy-gtk/empathy-contact-selector-dialog.c
@@ -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,9 +50,12 @@ 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) \
@@ -59,6 +63,11 @@ struct _EmpathyContactSelectorDialogPriv {
EmpathyContactSelectorDialogPriv))
enum {
+ PROP_0,
+ PROP_SHOW_ACCOUNT_CHOOSER
+};
+
+enum {
COMPLETION_COL_TEXT,
COMPLETION_COL_ID,
COMPLETION_COL_NAME,
@@ -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);
@@ -327,6 +346,48 @@ empathy_contact_selector_dialog_init (EmpathyContactSelectorDialog *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)
{
EmpathyContactSelectorDialogPriv *priv = GET_PRIV (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 5fd6c2139..e317cd7a4 100644
--- a/libempathy-gtk/empathy-contact-selector-dialog.h
+++ b/libempathy-gtk/empathy-contact-selector-dialog.h
@@ -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 \
diff --git a/libempathy-gtk/empathy-contact-selector-dialog.ui b/libempathy-gtk/empathy-contact-selector-dialog.ui
index 009028ec1..6bf68c62e 100644
--- a/libempathy-gtk/empathy-contact-selector-dialog.ui
+++ b/libempathy-gtk/empathy-contact-selector-dialog.ui
@@ -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>