[empathy] DebugWindow: add function to change the service to show



commit e58bcfb19122660374ec83f9e06cbc92f97908f4
Author: Emilio Pozuelo Monfort <emilio pozuelo collabora co uk>
Date:   Wed Aug 3 12:15:28 2011 +0100

    DebugWindow: add function to change the service to show
    
    https://bugzilla.gnome.org/show_bug.cgi?id=655884

 src/empathy-debug-window.c |   60 ++++++++++++++++++++++++++++++++++++++++++++
 src/empathy-debug-window.h |    3 ++
 2 files changed, 63 insertions(+), 0 deletions(-)
---
diff --git a/src/empathy-debug-window.c b/src/empathy-debug-window.c
index 3ce4176..294c6af 100644
--- a/src/empathy-debug-window.c
+++ b/src/empathy-debug-window.c
@@ -115,6 +115,9 @@ typedef struct
   /* Service (CM, Client) chooser store */
   GtkListStore *service_store;
 
+  /* Debug to show upon creation */
+  gchar *select_name;
+
   /* Misc. */
   gboolean dispose_run;
   TpAccountManager *am;
@@ -697,6 +700,13 @@ debug_window_get_name_owner_cb (TpDBusDaemon *proxy,
           COL_UNIQUE_NAME, out,
           -1);
 
+      if (priv->select_name != NULL &&
+          !tp_strdiff (name, priv->select_name))
+        {
+          gtk_combo_box_set_active_iter (GTK_COMBO_BOX (priv->chooser), &iter);
+          tp_clear_pointer (&priv->select_name, g_free);
+        }
+
       g_free (name);
     }
 
@@ -1369,6 +1379,37 @@ tree_view_search_equal_func_cb (GtkTreeModel *model,
 }
 
 static void
+empathy_debug_window_select_name (EmpathyDebugWindow *self,
+    const gchar *name)
+{
+  EmpathyDebugWindowPriv *priv = GET_PRIV (self);
+  GtkTreeModel *model = GTK_TREE_MODEL (priv->service_store);
+  GtkTreeIter iter;
+  gchar *iter_name;
+  gboolean valid, found = FALSE;
+
+  for (valid = gtk_tree_model_get_iter_first (model, &iter);
+       valid;
+       valid = gtk_tree_model_iter_next (model, &iter))
+    {
+      gtk_tree_model_get (model, &iter,
+          COL_NAME, &iter_name,
+          -1);
+
+      if (!tp_strdiff (name, iter_name))
+        found = TRUE;
+
+      g_free (iter_name);
+
+      if (found)
+        break;
+    }
+
+  if (found)
+    gtk_combo_box_set_active_iter (GTK_COMBO_BOX (priv->chooser), &iter);
+}
+
+static void
 am_prepared_cb (GObject *am,
     GAsyncResult *res,
     gpointer user_data)
@@ -1670,6 +1711,8 @@ debug_window_finalize (GObject *object)
   char *key;
   GList *values;
 
+  g_free (priv->select_name);
+
   g_hash_table_iter_init (&iter, priv->cache);
 
   while (g_hash_table_iter_next (&iter, (gpointer *) &key,
@@ -1747,3 +1790,20 @@ empathy_debug_window_new (GtkWindow *parent)
   return GTK_WIDGET (g_object_new (EMPATHY_TYPE_DEBUG_WINDOW,
       "transient-for", parent, NULL));
 }
+
+void
+empathy_debug_window_show (EmpathyDebugWindow *self,
+    const gchar *name)
+{
+  EmpathyDebugWindowPriv *priv = GET_PRIV (self);
+
+  if (priv->service_store != NULL)
+    {
+      empathy_debug_window_select_name (self, name);
+    }
+  else
+    {
+      g_free (priv->select_name);
+      priv->select_name = g_strdup (name);
+    }
+}
diff --git a/src/empathy-debug-window.h b/src/empathy-debug-window.h
index 22eec3f..9815c85 100644
--- a/src/empathy-debug-window.h
+++ b/src/empathy-debug-window.h
@@ -58,6 +58,9 @@ GType empathy_debug_window_get_type (void) G_GNUC_CONST;
 
 GtkWidget * empathy_debug_window_new (GtkWindow *parent);
 
+void empathy_debug_window_show (EmpathyDebugWindow *self,
+  const gchar *name);
+
 G_END_DECLS
 
 #endif /* __EMPATHY_DEBUG_WINDOW_H__ */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]