]> git.0d.be Git - empathy.git/commitdiff
debug-window: add Telepathy clients
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Tue, 29 Jun 2010 12:56:19 +0000 (14:56 +0200)
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Fri, 9 Jul 2010 11:38:39 +0000 (13:38 +0200)
src/empathy-debug-window.c

index 0894d94536d265407352b5f1866d855122b919c6..11d56a473e33667ab3b88a5a60c1db628afae9b4 100644 (file)
@@ -811,6 +811,54 @@ debug_window_name_owner_changed_cb (TpDBusDaemon *proxy,
     }
 }
 
+static void
+add_client (EmpathyDebugWindow *self,
+    const gchar *name)
+{
+  EmpathyDebugWindowPriv *priv = GET_PRIV (self);
+  const gchar *suffix;
+  GtkTreeIter iter;
+
+  suffix = name + strlen (TP_CLIENT_BUS_NAME_BASE);
+
+  gtk_list_store_append (priv->cms, &iter);
+  gtk_list_store_set (priv->cms, &iter,
+      COL_CM_NAME, suffix,
+      COL_CM_UNIQUE_NAME, name,
+      -1);
+
+  /* Select Empathy by default */
+  if (!tp_strdiff (suffix, "Empathy"))
+    {
+      gtk_combo_box_set_active_iter (GTK_COMBO_BOX (priv->cm_chooser), &iter);
+    }
+}
+
+static void
+list_names_cb (TpDBusDaemon *bus_daemon,
+    const gchar * const *names,
+    const GError *error,
+    gpointer user_data,
+    GObject *weak_object)
+{
+  EmpathyDebugWindow *self = EMPATHY_DEBUG_WINDOW (weak_object);
+  guint i;
+
+  if (error != NULL)
+    {
+      DEBUG ("Failed to list names: %s", error->message);
+      return;
+    }
+
+  for (i = 0; names[i] != NULL; i++)
+    {
+      if (g_str_has_prefix (names[i], TP_CLIENT_BUS_NAME_BASE))
+        {
+          add_client (self, names[i]);
+        }
+    }
+}
+
 static void
 debug_window_fill_cm_chooser (EmpathyDebugWindow *debug_window)
 {
@@ -838,6 +886,12 @@ debug_window_fill_cm_chooser (EmpathyDebugWindow *debug_window)
       COL_CM_UNIQUE_NAME, "org.freedesktop.Telepathy.MissionControl5",
       -1);
 
+  gtk_combo_box_set_active (GTK_COMBO_BOX (priv->cm_chooser), 0);
+
+  /* add clients */
+  tp_dbus_daemon_list_names (priv->dbus, 2000,
+      list_names_cb, NULL, NULL, G_OBJECT (debug_window));
+
   priv->name_owner_changed_signal =
       tp_cli_dbus_daemon_connect_to_name_owner_changed (priv->dbus,
       debug_window_name_owner_changed_cb, debug_window, NULL, NULL, NULL);