From e1c1c46e34366bab45f7a1d57aed8f42d11e424c Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Tue, 7 May 2019 22:04:41 +0000 Subject: [PATCH] inspector: Style the property list Make the property list look more like a list. --- gtk/gen-gtk-gresources-xml.py | 1 + gtk/inspector/inspector.css | 35 +++++++++++++++++++++++++++++++++++ gtk/inspector/prop-list.c | 13 +++++++------ gtk/inspector/prop-list.ui | 19 ++++++++++++++++--- gtk/inspector/window.c | 11 +++++++++++ 5 files changed, 70 insertions(+), 9 deletions(-) create mode 100644 gtk/inspector/inspector.css diff --git a/gtk/gen-gtk-gresources-xml.py b/gtk/gen-gtk-gresources-xml.py index cd42ce6169..846b27dd0b 100644 --- a/gtk/gen-gtk-gresources-xml.py +++ b/gtk/gen-gtk-gresources-xml.py @@ -70,6 +70,7 @@ for f in get_files('inspector', '.ui'): xml += ''' inspector/logo.png + inspector/inspector.css emoji/emoji.data ''' diff --git a/gtk/inspector/inspector.css b/gtk/inspector/inspector.css new file mode 100644 index 0000000000..70b777d5e7 --- /dev/null +++ b/gtk/inspector/inspector.css @@ -0,0 +1,35 @@ +/* some style for the inspector */ + +.header { + background: lightgray; + border: 1px solid gray; +} + +.header>* { + padding: 2px; + font-weight: bold; +} + +.header sort_indicator { + min-width: 16px; +} + +.header>*:not(:last-child) { + border-right: 1px solid gray; +} + +.list .cell { + font-size: smaller; + padding: 0 2px; + min-height: 24px; +} + +.list .cell entry, +.list .cell spinbutton, +.list .cell button, +.list .cell combobox + { + min-height: 24px; + min-width: 0; + padding: 0 4px; +} diff --git a/gtk/inspector/prop-list.c b/gtk/inspector/prop-list.c index fc1996f95d..70543d1eb9 100644 --- a/gtk/inspector/prop-list.c +++ b/gtk/inspector/prop-list.c @@ -43,6 +43,7 @@ #include "gtksizegroup.h" #include "gtkroot.h" #include "gtkgesturemultipress.h" +#include "gtkstylecontext.h" enum { @@ -105,17 +106,13 @@ apply_sort (GtkInspectorPropList *pl, if (column == COLUMN_NAME) { - gtk_widget_hide (pl->priv->origin_sort_indicator); - gtk_widget_show (pl->priv->name_sort_indicator); - + gtk_image_clear (GTK_IMAGE (pl->priv->origin_sort_indicator)); gtk_image_set_from_icon_name (GTK_IMAGE (pl->priv->name_sort_indicator), icon_name); } else { - gtk_widget_show (pl->priv->origin_sort_indicator); - gtk_widget_hide (pl->priv->name_sort_indicator); - + gtk_image_clear (GTK_IMAGE (pl->priv->name_sort_indicator)); gtk_image_set_from_icon_name (GTK_IMAGE (pl->priv->origin_sort_indicator), icon_name); } @@ -540,24 +537,28 @@ gtk_inspector_prop_list_create_row (GtkInspectorPropList *pl, gtk_container_add (GTK_CONTAINER (row), box); label = gtk_label_new (prop->name); + gtk_style_context_add_class (gtk_widget_get_style_context (label), "cell"); gtk_widget_set_sensitive (label, writable); gtk_label_set_xalign (GTK_LABEL (label), 0); gtk_size_group_add_widget (pl->priv->names, label); gtk_container_add (GTK_CONTAINER (box), label); label = gtk_label_new (type ? type : ""); + gtk_style_context_add_class (gtk_widget_get_style_context (label), "cell"); gtk_widget_set_sensitive (label, writable); gtk_label_set_xalign (GTK_LABEL (label), 0); gtk_size_group_add_widget (pl->priv->types, label); gtk_container_add (GTK_CONTAINER (box), label); label = gtk_label_new (g_type_name (prop->owner_type)); + gtk_style_context_add_class (gtk_widget_get_style_context (label), "cell"); gtk_widget_set_sensitive (label, writable); gtk_label_set_xalign (GTK_LABEL (label), 0); gtk_size_group_add_widget (pl->priv->origins, label); gtk_container_add (GTK_CONTAINER (box), label); widget = gtk_inspector_prop_editor_new (pl->priv->object, prop->name, pl->priv->values); + gtk_style_context_add_class (gtk_widget_get_style_context (widget), "cell"); gtk_container_add (GTK_CONTAINER (box), widget); g_signal_connect (widget, "show-object", G_CALLBACK (show_object), pl); diff --git a/gtk/inspector/prop-list.ui b/gtk/inspector/prop-list.ui index a7aff1d071..290bf15bd4 100644 --- a/gtk/inspector/prop-list.ui +++ b/gtk/inspector/prop-list.ui @@ -15,6 +15,7 @@ + 0 @@ -30,6 +31,9 @@ + @@ -42,6 +46,7 @@ + 0 @@ -57,6 +62,9 @@ + @@ -65,9 +73,7 @@ Value 0 - 1 - 6 - 6 + 0 @@ -78,6 +84,9 @@ never + none @@ -87,21 +96,25 @@ + horizontal + horizontal + horizontal + horizontal diff --git a/gtk/inspector/window.c b/gtk/inspector/window.c index e7c9ee9fb1..683a95f079 100644 --- a/gtk/inspector/window.c +++ b/gtk/inspector/window.c @@ -54,6 +54,9 @@ #include "gtkwindowgroup.h" #include "gtkrevealer.h" #include "gtklayoutmanager.h" +#include "gtkcssprovider.h" +#include "gtkstylecontext.h" + G_DEFINE_TYPE (GtkInspectorWindow, gtk_inspector_window, GTK_TYPE_WINDOW) @@ -290,11 +293,19 @@ static void gtk_inspector_window_realize (GtkWidget *widget) { GskRenderer *renderer; + GtkCssProvider *provider; GTK_WIDGET_CLASS (gtk_inspector_window_parent_class)->realize (widget); renderer = gtk_root_get_renderer (GTK_ROOT (widget)); gsk_renderer_set_debug_flags (renderer, 0); + + provider = gtk_css_provider_new (); + gtk_css_provider_load_from_resource (provider, "/org/gtk/libgtk/inspector/inspector.css"); + gtk_style_context_add_provider_for_display (gtk_widget_get_display (widget), + GTK_STYLE_PROVIDER (provider), + 800); + g_object_unref (provider); } static void