[gtkparasite] Add support for clutter-gtk



commit e2021385a5827664768a4bebf46ab9ee35765f74
Author: Bastien Nocera <hadess hadess net>
Date:   Fri Sep 27 15:14:00 2013 +0200

    Add support for clutter-gtk

 configure.ac      |    2 +-
 src/parasite.h    |    2 +-
 src/prop-list.c   |    6 ++--
 src/prop-list.h   |    2 +-
 src/widget-tree.c |   84 +++++++++++++++++++++++++++++++++++++++++++++++++++--
 src/widget-tree.h |    2 +-
 src/window.c      |   12 +++++--
 7 files changed, 96 insertions(+), 14 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 235d446..852e49c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -52,7 +52,7 @@ AC_C_CONST
 AC_TYPE_SIZE_T
 AC_EXEEXT
 
-PKG_CHECK_MODULES(GTK, [gtk+-3.0 >= 3.3.16])
+PKG_CHECK_MODULES(GTK, [gtk+-3.0 >= 3.3.16 clutter-gtk-1.0])
 AC_SUBST(GTK_CFLAGS)
 AC_SUBST(GTK_LIBS)
 
diff --git a/src/parasite.h b/src/parasite.h
index 90a1899..7b29ceb 100644
--- a/src/parasite.h
+++ b/src/parasite.h
@@ -25,7 +25,7 @@
 
 
 #include <gtk/gtk.h>
-
+#include <clutter-gtk/clutter-gtk.h>
 
 #define TREE_TEXT_SCALE 0.8
 #define TREE_CHECKBOX_SIZE (gint)(0.8 * 13)
diff --git a/src/prop-list.c b/src/prop-list.c
index ab2461a..5cdf32e 100644
--- a/src/prop-list.c
+++ b/src/prop-list.c
@@ -36,7 +36,7 @@ enum
 
 struct _ParasitePropListPrivate
 {
-    GtkWidget *widget;
+    GObject *widget;
     GtkListStore *model;
     GHashTable *prop_iters;
     GList *signal_cnxs;
@@ -48,7 +48,7 @@ static void
 free_signal_cnxs (ParasitePropList *proplist)
 {
     GList *l;
-    GtkWidget *widget = proplist->priv->widget;
+    GObject *widget = proplist->priv->widget;
 
     for (l = proplist->priv->signal_cnxs; l != NULL; l = l->next)
     {
@@ -187,7 +187,7 @@ parasite_proplist_new()
 
 void
 parasite_proplist_set_widget(ParasitePropList* proplist,
-                             GtkWidget *widget)
+                             GObject *widget)
 {
     GtkTreeIter iter;
     GParamSpec **props;
diff --git a/src/prop-list.h b/src/prop-list.h
index 354761b..8eced8f 100644
--- a/src/prop-list.h
+++ b/src/prop-list.h
@@ -61,7 +61,7 @@ G_BEGIN_DECLS
 GType parasite_proplist_get_type();
 GtkWidget *parasite_proplist_new();
 void parasite_proplist_set_widget(ParasitePropList* proplist,
-                                  GtkWidget *widget);
+                                  GObject *widget);
 
 
 G_END_DECLS
diff --git a/src/widget-tree.c b/src/widget-tree.c
index 87e3e1b..2b69772 100644
--- a/src/widget-tree.c
+++ b/src/widget-tree.c
@@ -294,7 +294,7 @@ parasite_widget_tree_new()
 }
 
 
-GtkWidget *
+GObject *
 parasite_widget_tree_get_selected_widget(ParasiteWidgetTree *widget_tree)
 {
     GtkTreeIter iter;
@@ -305,7 +305,7 @@ parasite_widget_tree_get_selected_widget(ParasiteWidgetTree *widget_tree)
 
     if (gtk_tree_selection_get_selected(sel, &model, &iter))
     {
-        GtkWidget *widget;
+        GObject *widget;
 
         gtk_tree_model_get(GTK_TREE_MODEL(model), &iter,
                            WIDGET, &widget,
@@ -344,6 +344,73 @@ widget_destroyed (gpointer  tree,
     g_hash_table_remove (priv->paths, was_widget);
 }
 
+static void
+append_widget(ParasiteWidgetTree *widget_tree,
+              GtkWidget *widget,
+              GtkTreeIter *parent_iter);
+
+static void
+append_actor(ParasiteWidgetTree *widget_tree,
+             ClutterActor *actor,
+             GtkTreeIter *parent_iter)
+{
+    GtkTreeIter iter;
+    GtkTreeStore *model = widget_tree->priv->model;
+    const char *class_name = G_OBJECT_CLASS_NAME(CLUTTER_ACTOR_GET_CLASS(actor));
+    const char *name;
+    const char *row_color;
+    char *window_info;
+    char *address;
+    gboolean realized;
+    gboolean mapped;
+    gboolean visible;
+    GList *l;
+
+    name = clutter_actor_get_name(actor);
+    window_info = g_strdup("");
+
+    address = g_strdup_printf("%p", actor);
+
+    realized = CLUTTER_ACTOR_IS_REALIZED(actor);
+    mapped = CLUTTER_ACTOR_IS_MAPPED(actor);
+    visible = CLUTTER_ACTOR_IS_VISIBLE(actor);
+
+    row_color = (realized && mapped && visible) ? "black" : "grey";
+
+    gtk_tree_store_append(model, &iter, parent_iter);
+    gtk_tree_store_set(model, &iter,
+                       WIDGET, actor,
+                       WIDGET_TYPE, class_name,
+                       WIDGET_NAME, name,
+                       WIDGET_REALIZED, realized,
+                       WIDGET_MAPPED, mapped,
+                       WIDGET_VISIBLE, visible,
+                       WIDGET_WINDOW, window_info,
+                       WIDGET_ADDRESS, address,
+                       ROW_COLOR, row_color,
+                       -1);
+    g_object_weak_ref (G_OBJECT (actor), widget_destroyed, widget_tree);
+    g_object_weak_ref (G_OBJECT (widget_tree), tree_destroyed, actor);
+
+    g_free(window_info);
+    g_free(address);
+
+    if (!GTK_CLUTTER_IS_ACTOR(actor))
+    {
+        for (l = clutter_actor_get_children(actor);
+             l != NULL;
+             l = l->next)
+        {
+            append_actor(widget_tree, CLUTTER_ACTOR(l->data), &iter);
+        }
+    } else {
+        GtkWidget *widget;
+
+        widget = gtk_clutter_actor_get_widget(GTK_CLUTTER_ACTOR(actor));
+        if (widget)
+            append_widget(widget_tree, GTK_WIDGET(widget), &iter);
+    }
+}
 
 static void
 append_widget(ParasiteWidgetTree *widget_tree,
@@ -449,7 +516,7 @@ append_widget(ParasiteWidgetTree *widget_tree,
     g_free(window_info);
     g_free(address);
 
-    if (GTK_IS_CONTAINER(widget))
+    if (GTK_IS_CONTAINER(widget) && !GTK_CLUTTER_IS_EMBED(widget))
     {
         for (l = gtk_container_get_children(GTK_CONTAINER(widget));
              l != NULL;
@@ -458,6 +525,17 @@ append_widget(ParasiteWidgetTree *widget_tree,
             append_widget(widget_tree, GTK_WIDGET(l->data), &iter);
         }
     }
+    else if (GTK_CLUTTER_IS_EMBED(widget))
+    {
+        ClutterActor *stage = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (widget));
+
+        for (l = clutter_actor_get_children (stage);
+             l != NULL;
+             l = l->next)
+        {
+            append_actor(widget_tree, CLUTTER_ACTOR(l->data), &iter);
+        }
+    }
 }
 
 
diff --git a/src/widget-tree.h b/src/widget-tree.h
index 008c3a9..d40521d 100644
--- a/src/widget-tree.h
+++ b/src/widget-tree.h
@@ -56,7 +56,7 @@ G_BEGIN_DECLS
 
 GType parasite_widget_tree_get_type();
 GtkWidget *parasite_widget_tree_new();
-GtkWidget *parasite_widget_tree_get_selected_widget(ParasiteWidgetTree *widget_tree);
+GObject *parasite_widget_tree_get_selected_widget(ParasiteWidgetTree *widget_tree);
 void parasite_widget_tree_scan(ParasiteWidgetTree *widget_tree,
                                GtkWidget *window);
 void parasite_widget_tree_select_widget(ParasiteWidgetTree *widget_tree,
diff --git a/src/window.c b/src/window.c
index f47bc2a..08e4a39 100644
--- a/src/window.c
+++ b/src/window.c
@@ -32,17 +32,21 @@ static void
 on_widget_tree_selection_changed(ParasiteWidgetTree *widget_tree,
                                  ParasiteWindow *parasite)
 {
-    GtkWidget *selected = parasite_widget_tree_get_selected_widget(widget_tree);
+    GObject *selected = parasite_widget_tree_get_selected_widget(widget_tree);
+    GtkWidget *selected_widget = NULL;
 
     parasite_proplist_set_widget(PARASITE_PROPLIST(parasite->prop_list),
                                  selected);
+    if (GTK_IS_WIDGET(selected))
+        selected_widget = GTK_WIDGET(selected);
+
     parasite_style_list_set_widget (PARASITE_STYLE_LIST (parasite->style_list),
-                                    selected);
-    if (selected)
+                                    selected_widget);
+    if (selected_widget)
     {
         gchar *path;
 
-        path = gtk_widget_path_to_string (gtk_widget_get_path (selected));
+        path = gtk_widget_path_to_string (gtk_widget_get_path (GTK_WIDGET(selected)));
         gtk_entry_set_text (GTK_ENTRY (parasite->widget_path_entry), path);
         gtk_editable_set_position (GTK_EDITABLE (parasite->widget_path_entry), -1);
         g_free (path);


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