[gtk+] inspector: Make GMenu content show up



commit 14d1a5cba4b24078a51a48c1cbc8e6dbd4d67085
Author: Matthias Clasen <mclasen redhat com>
Date:   Thu Jun 5 09:29:18 2014 -0400

    inspector: Make GMenu content show up
    
    My problem was that all the content is usually hidden away
    in sections, so without recursion, nothing shows up. So,
    implement the recursion then.

 gtk/inspector/menu.c  |   23 +++++++++++++++++++++++
 gtk/inspector/menu.ui |    1 -
 2 files changed, 23 insertions(+), 1 deletions(-)
---
diff --git a/gtk/inspector/menu.c b/gtk/inspector/menu.c
index d73d3f2..652e308 100644
--- a/gtk/inspector/menu.c
+++ b/gtk/inspector/menu.c
@@ -43,6 +43,10 @@ gtk_inspector_menu_init (GtkInspectorMenu *sl)
   gtk_widget_init_template (GTK_WIDGET (sl));
 }
 
+static void add_menu (GtkInspectorMenu *sl,
+                      GMenuModel       *menu,
+                      GtkTreeIter      *parent);
+
 static void
 add_item (GtkInspectorMenu *sl,
           GMenuModel       *menu,
@@ -55,6 +59,7 @@ add_item (GtkInspectorMenu *sl,
   gchar *action = NULL;
   gchar *target = NULL;
   gchar *icon = NULL;
+  GMenuModel *model;
 
   g_menu_model_get_item_attribute (menu, idx, G_MENU_ATTRIBUTE_LABEL, "s", &label);
   g_menu_model_get_item_attribute (menu, idx, G_MENU_ATTRIBUTE_ACTION, "s", &action);
@@ -74,6 +79,24 @@ add_item (GtkInspectorMenu *sl,
                       COLUMN_ICON, icon,
                       -1);
 
+  model = g_menu_model_get_item_link (menu, idx, G_MENU_LINK_SECTION);
+  if (model)
+    {
+      if (label == NULL)
+        gtk_tree_store_set (sl->priv->model, &iter,
+                            COLUMN_LABEL, _("Unnamed section"),
+                            -1);
+      add_menu (sl, model, &iter);
+      g_object_unref (model);
+    }
+
+  model = g_menu_model_get_item_link (menu, idx, G_MENU_LINK_SUBMENU);
+  if (model)
+    {
+      add_menu (sl, model, &iter);
+      g_object_unref (model);
+    }
+
   g_free (label);
   g_free (action);
   g_free (target);
diff --git a/gtk/inspector/menu.ui b/gtk/inspector/menu.ui
index b63ee92..07b5be3 100644
--- a/gtk/inspector/menu.ui
+++ b/gtk/inspector/menu.ui
@@ -22,7 +22,6 @@
           <object class= "GtkTreeView">
             <property name="visible">True</property>
             <property name="model">model</property>
-            <property name="activate-on-single-click">True</property>
             <child>
               <object class="GtkTreeViewColumn">
                 <property name="title" translatable="yes">Label</property>


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