[gtk/listview-for-merge: 87/181] inspector: Use a GtkTreeExpander in the object tree



commit 17adfc2a52fe31badcdc4840a83e34eef6a2528c
Author: Benjamin Otte <otte redhat com>
Date:   Mon Oct 14 06:22:41 2019 +0200

    inspector: Use a GtkTreeExpander in the object tree

 gtk/inspector/object-tree.c | 37 +++++++------------------------------
 1 file changed, 7 insertions(+), 30 deletions(-)
---
diff --git a/gtk/inspector/object-tree.c b/gtk/inspector/object-tree.c
index e17f1594a5..aaa8684284 100644
--- a/gtk/inspector/object-tree.c
+++ b/gtk/inspector/object-tree.c
@@ -47,6 +47,7 @@
 #include "gtksizegroup.h"
 #include "gtktextview.h"
 #include "gtktogglebutton.h"
+#include "gtktreeexpander.h"
 #include "gtktreelistmodel.h"
 #include "gtktreeview.h"
 #include "gtktreeselection.h"
@@ -985,7 +986,6 @@ gtk_inspector_object_tree_create_list_widget (gpointer row_item,
   GtkInspectorObjectTree *wt = user_data;
   gpointer item;
   GtkWidget *row, *box, *column, *child;
-  guint depth;
 
   item = gtk_tree_list_row_get_item (row_item);
 
@@ -1002,37 +1002,14 @@ gtk_inspector_object_tree_create_list_widget (gpointer row_item,
   box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
   gtk_list_box_row_set_child (GTK_LIST_BOX_ROW (row), box);
 
-  column = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
-  gtk_size_group_add_widget (wt->priv->type_size_group, column);
-  gtk_box_append (GTK_BOX (box), column);
-
   /* expander */
-  depth = gtk_tree_list_row_get_depth (row_item);
-  if (depth > 0)
-    {
-      child = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
-      gtk_widget_set_size_request (child, 16 * depth, 0);
-      gtk_box_append (GTK_BOX (column), child);
-    }
-  if (gtk_tree_list_row_is_expandable (row_item))
-    {
-      GtkWidget *title, *arrow;
-
-      child = g_object_new (GTK_TYPE_BOX, "css-name", "expander", NULL);
-
-      title = g_object_new (GTK_TYPE_TOGGLE_BUTTON, "css-name", "title", NULL);
-      gtk_button_set_has_frame (GTK_BUTTON (title), FALSE);
-      g_object_bind_property (row_item, "expanded", title, "active", G_BINDING_BIDIRECTIONAL | 
G_BINDING_SYNC_CREATE);
-      gtk_box_append (GTK_BOX (child), title);
+  child = gtk_tree_expander_new ();
+  gtk_tree_expander_set_list_row (GTK_TREE_EXPANDER (child), row_item);
+  gtk_size_group_add_widget (wt->priv->type_size_group, child);
+  gtk_box_append (GTK_BOX (box), child);
 
-      arrow = gtk_builtin_icon_new ("expander");
-      gtk_button_set_child (GTK_BUTTON (title), arrow);
-    }
-  else
-    {
-      child = gtk_image_new (); /* empty whatever */
-    }
-  gtk_box_append (GTK_BOX (column), child);
+  column = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+  gtk_tree_expander_set_child (GTK_TREE_EXPANDER (child), column);
 
   /* 1st column: type name */
   child = gtk_label_new (G_OBJECT_TYPE_NAME (item));


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