[gtk/inspector-navigation] inspector: Fix property list styling



commit 4d371b2b16a62b631ba8384f8183b761bc97becb
Author: Matthias Clasen <mclasen redhat com>
Date:   Tue Jul 7 02:12:30 2020 -0400

    inspector: Fix property list styling
    
    We use dropdowns here now, so style them.
    
    Also, avoid the swoosh when switching to the
    property list, when everything shrinks.

 gtk/inspector/inspector.css |  2 ++
 gtk/inspector/prop-list.c   | 27 ++++++++++++++++++++++-----
 gtk/inspector/prop-list.ui  |  1 +
 3 files changed, 25 insertions(+), 5 deletions(-)
---
diff --git a/gtk/inspector/inspector.css b/gtk/inspector/inspector.css
index 857fb2f8ce..920a7cceea 100644
--- a/gtk/inspector/inspector.css
+++ b/gtk/inspector/inspector.css
@@ -35,6 +35,7 @@
 .list .cell entry,
 .list .cell spinbutton,
 .list .cell button,
+.list .cell dropdown
 .list .cell combobox {
   min-height: 24px;
   min-width: 0;
@@ -42,6 +43,7 @@
 
 .list .cell entry,
 .list .cell button,
+.list .cell dropdown
 .list .cell combobox {
   padding: 0 4px;
 }
diff --git a/gtk/inspector/prop-list.c b/gtk/inspector/prop-list.c
index e3f4668d29..5c5a2c5e33 100644
--- a/gtk/inspector/prop-list.c
+++ b/gtk/inspector/prop-list.c
@@ -381,12 +381,25 @@ bind_origin_cb (GtkSignalListItemFactory *factory,
   gtk_label_set_label (GTK_LABEL (label), origin);
 }
 
+static void
+setup_value_cb (GtkSignalListItemFactory *factory,
+                GtkListItem              *list_item,
+                gpointer                  data)
+{
+  GtkWidget *widget;
+
+  widget = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+  gtk_widget_add_css_class (widget, "cell");
+  gtk_list_item_set_child (list_item, widget);
+}
+
 static void
 bind_value_cb (GtkSignalListItemFactory *factory,
                GtkListItem              *list_item,
                gpointer                  data)
 {
   GObject *item;
+  GtkWidget *editor;
   GtkWidget *widget;
   GObject *object;
   const char *name;
@@ -396,10 +409,10 @@ bind_value_cb (GtkSignalListItemFactory *factory,
   object = prop_holder_get_object (PROP_HOLDER (item));
   name = prop_holder_get_name (PROP_HOLDER (item));
 
-  widget = gtk_inspector_prop_editor_new (object, name, NULL);
-  g_signal_connect (widget, "show-object", G_CALLBACK (show_object), data);
-  gtk_list_item_set_child (list_item, widget);
-  gtk_widget_add_css_class (widget, "cell");
+  editor = gtk_inspector_prop_editor_new (object, name, NULL);
+  g_signal_connect (editor, "show-object", G_CALLBACK (show_object), data);
+  widget = gtk_list_item_get_child (list_item);
+  gtk_box_append (GTK_BOX (widget), editor);
 }
 
 static void
@@ -407,7 +420,10 @@ unbind_value_cb (GtkSignalListItemFactory *factory,
                  GtkListItem              *list_item,
                  gpointer                  data)
 {
-  gtk_list_item_set_child (list_item, NULL);
+  GtkWidget *widget;
+
+  widget = gtk_list_item_get_child (list_item);
+  gtk_box_remove (GTK_BOX (widget), gtk_widget_get_first_child (widget));
 }
 
 static void
@@ -441,6 +457,7 @@ gtk_inspector_prop_list_class_init (GtkInspectorPropListClass *klass)
   gtk_widget_class_bind_template_callback (widget_class, bind_type_cb);
   gtk_widget_class_bind_template_callback (widget_class, setup_origin_cb);
   gtk_widget_class_bind_template_callback (widget_class, bind_origin_cb);
+  gtk_widget_class_bind_template_callback (widget_class, setup_value_cb);
   gtk_widget_class_bind_template_callback (widget_class, bind_value_cb);
   gtk_widget_class_bind_template_callback (widget_class, unbind_value_cb);
 }
diff --git a/gtk/inspector/prop-list.ui b/gtk/inspector/prop-list.ui
index 9c952c3f41..15ccf2e2e9 100644
--- a/gtk/inspector/prop-list.ui
+++ b/gtk/inspector/prop-list.ui
@@ -57,6 +57,7 @@
                     <property name="expand">1</property>
                     <property name="factory">
                       <object class="GtkSignalListItemFactory">
+                        <signal name="setup" handler="setup_value_cb"/>
                         <signal name="bind" handler="bind_value_cb"/>
                         <signal name="unbind" handler="unbind_value_cb"/>
                       </object>


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