aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy-gtk/empathy-protocol-chooser.c
diff options
context:
space:
mode:
authorCosimo Cecchi <cosimo.cecchi@collabora.co.uk>2009-07-22 20:15:01 +0800
committerCosimo Cecchi <cosimoc@gnome.org>2009-07-30 06:13:08 +0800
commit4b6db27ff05428dda571c5e60bc7229a4dd91d5f (patch)
tree7bf9d862efab167c9f48e86a8ab90ab60e7dd380 /libempathy-gtk/empathy-protocol-chooser.c
parentb50b7039d3b52f33df94e5a3526d9f43a51401ad (diff)
downloadgsoc2013-empathy-4b6db27ff05428dda571c5e60bc7229a4dd91d5f.tar
gsoc2013-empathy-4b6db27ff05428dda571c5e60bc7229a4dd91d5f.tar.gz
gsoc2013-empathy-4b6db27ff05428dda571c5e60bc7229a4dd91d5f.tar.bz2
gsoc2013-empathy-4b6db27ff05428dda571c5e60bc7229a4dd91d5f.tar.lz
gsoc2013-empathy-4b6db27ff05428dda571c5e60bc7229a4dd91d5f.tar.xz
gsoc2013-empathy-4b6db27ff05428dda571c5e60bc7229a4dd91d5f.tar.zst
gsoc2013-empathy-4b6db27ff05428dda571c5e60bc7229a4dd91d5f.zip
Synchronize EmpathyProtocolChooser and EmpathyAccountsDialog
Synchronize the two objects with the help of EmpathyConnectionManagers, so that we can get a consistent list of the CMs when using the chooser.
Diffstat (limited to 'libempathy-gtk/empathy-protocol-chooser.c')
-rw-r--r--libempathy-gtk/empathy-protocol-chooser.c77
1 files changed, 35 insertions, 42 deletions
diff --git a/libempathy-gtk/empathy-protocol-chooser.c b/libempathy-gtk/empathy-protocol-chooser.c
index ebb198455..462979843 100644
--- a/libempathy-gtk/empathy-protocol-chooser.c
+++ b/libempathy-gtk/empathy-protocol-chooser.c
@@ -29,6 +29,7 @@
#include <gtk/gtk.h>
#include <libempathy/empathy-utils.h>
+#include <libempathy/empathy-connection-managers.h>
#include "empathy-protocol-chooser.h"
#include "empathy-ui-utils.h"
@@ -59,6 +60,7 @@ typedef struct
{
GtkListStore *store;
gboolean dispose_run;
+ EmpathyConnectionManagers *cms;
} EmpathyProtocolChooserPriv;
@@ -154,27 +156,26 @@ protocol_choosers_add_cm (EmpathyProtocolChooser *chooser,
}
}
-
static void
-protocol_choosers_cms_listed (TpConnectionManager * const *cms,
- gsize n_cms,
- const GError *error,
- gpointer user_data,
- GObject *weak_object)
+protocol_chooser_add_cms_list (EmpathyProtocolChooser *protocol_chooser,
+ GList *cms)
{
- TpConnectionManager * const *iter;
+ GList *l;
- if (error !=NULL)
- {
- DEBUG ("Failed to get connection managers: %s", error->message);
- return;
- }
+ for (l = cms; l != NULL; l = l->next)
+ protocol_choosers_add_cm (protocol_chooser, l->data);
- for (iter = cms ; iter != NULL && *iter != NULL; iter++)
- protocol_choosers_add_cm (EMPATHY_PROTOCOL_CHOOSER (weak_object),
- *iter);
+ gtk_combo_box_set_active (GTK_COMBO_BOX (protocol_chooser), 0);
+}
- gtk_combo_box_set_active (GTK_COMBO_BOX (weak_object), 0);
+static void
+protocol_chooser_cms_ready_cb (EmpathyConnectionManagers *cms,
+ GParamSpec *pspec,
+ EmpathyProtocolChooser *protocol_chooser)
+{
+ if (empathy_connection_managers_is_ready (cms))
+ protocol_chooser_add_cms_list
+ (protocol_chooser, empathy_connection_managers_get_cms (cms));
}
static void
@@ -182,9 +183,7 @@ protocol_chooser_constructed (GObject *object)
{
EmpathyProtocolChooser *protocol_chooser;
EmpathyProtocolChooserPriv *priv;
-
GtkCellRenderer *renderer;
- TpDBusDaemon *dbus;
priv = GET_PRIV (object);
protocol_chooser = EMPATHY_PROTOCOL_CHOOSER (object);
@@ -212,11 +211,6 @@ protocol_chooser_constructed (GObject *object)
"text", COL_LABEL,
NULL);
- dbus = tp_dbus_daemon_dup (NULL);
- tp_list_connection_managers (dbus, protocol_choosers_cms_listed,
- NULL, NULL, object);
- g_object_unref (dbus);
-
/* Set the protocol sort function */
gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (priv->store),
COL_PROTOCOL,
@@ -226,6 +220,13 @@ protocol_chooser_constructed (GObject *object)
COL_PROTOCOL,
GTK_SORT_ASCENDING);
+ if (empathy_connection_managers_is_ready (priv->cms))
+ protocol_chooser_add_cms_list (protocol_chooser,
+ empathy_connection_managers_get_cms (priv->cms));
+ else
+ g_signal_connect (priv->cms, "notify::ready",
+ G_CALLBACK (protocol_chooser_cms_ready_cb), protocol_chooser);
+
if (G_OBJECT_CLASS (empathy_protocol_chooser_parent_class)->constructed)
G_OBJECT_CLASS (empathy_protocol_chooser_parent_class)->constructed (object);
}
@@ -238,6 +239,7 @@ empathy_protocol_chooser_init (EmpathyProtocolChooser *protocol_chooser)
EMPATHY_TYPE_PROTOCOL_CHOOSER, EmpathyProtocolChooserPriv);
priv->dispose_run = FALSE;
+ priv->cms = empathy_connection_managers_dup_singleton ();
protocol_chooser->priv = priv;
}
@@ -259,6 +261,12 @@ protocol_chooser_dispose (GObject *object)
priv->store = NULL;
}
+ if (priv->cms)
+ {
+ g_object_unref (priv->cms);
+ priv->cms = NULL;
+ }
+
(G_OBJECT_CLASS (empathy_protocol_chooser_parent_class)->dispose) (object);
}
@@ -273,6 +281,8 @@ empathy_protocol_chooser_class_init (EmpathyProtocolChooserClass *klass)
g_type_class_add_private (object_class, sizeof (EmpathyProtocolChooserPriv));
}
+/* public methods */
+
/**
* empathy_protocol_chooser_get_selected_protocol:
* @protocol_chooser: an #EmpathyProtocolChooser
@@ -308,30 +318,13 @@ TpConnectionManager *empathy_protocol_chooser_dup_selected (
}
/**
- * empathy_protocol_chooser_n_protocols:
- * @protocol_chooser: an #EmpathyProtocolChooser
- *
- * Returns the number of protocols in @protocol_chooser.
- *
- * Return value: the number of protocols in @protocol_chooser
- */
-gint
-empathy_protocol_chooser_n_protocols (EmpathyProtocolChooser *protocol_chooser)
-{
- EmpathyProtocolChooserPriv *priv = GET_PRIV (protocol_chooser);
-
- g_return_val_if_fail (EMPATHY_IS_PROTOCOL_CHOOSER (protocol_chooser), 0);
-
- return gtk_tree_model_iter_n_children (GTK_TREE_MODEL (priv->store), NULL);
-}
-
-/**
* empathy_protocol_chooser_new:
*
- * Creates a new #EmpathyProtocolChooser widget.
+ * Triggers the creation of a new #EmpathyProtocolChooser.
*
* Return value: a new #EmpathyProtocolChooser widget
*/
+
GtkWidget *
empathy_protocol_chooser_new (void)
{