inspector: Make the css tree respect inspected display

The display is used here to force reparsing the theme
on the right settings object.
This commit is contained in:
Matthias Clasen 2019-12-07 12:42:37 -05:00
parent f0f57d156b
commit c89c652401
4 changed files with 21 additions and 16 deletions

View File

@ -24,6 +24,7 @@
#include "css-node-tree.h"
#include "prop-editor.h"
#include "window.h"
#include "gtktreemodelcssnode.h"
#include "gtktreeview.h"
@ -221,28 +222,12 @@ gtk_inspector_css_node_tree_finalize (GObject *object)
G_OBJECT_CLASS (gtk_inspector_css_node_tree_parent_class)->finalize (object);
}
static void
ensure_css_sections (void)
{
GtkSettings *settings;
gchar *theme_name;
gtk_css_provider_set_keep_css_sections ();
settings = gtk_settings_get_default ();
g_object_get (settings, "gtk-theme-name", &theme_name, NULL);
g_object_set (settings, "gtk-theme-name", theme_name, NULL);
g_free (theme_name);
}
static void
gtk_inspector_css_node_tree_class_init (GtkInspectorCssNodeTreeClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
ensure_css_sections ();
object_class->set_property = gtk_inspector_css_node_tree_set_property;
object_class->get_property = gtk_inspector_css_node_tree_get_property;
object_class->finalize = gtk_inspector_css_node_tree_finalize;
@ -531,4 +516,17 @@ gtk_inspector_css_node_tree_get_node (GtkInspectorCssNodeTree *cnt)
return priv->node;
}
void
gtk_inspector_css_node_tree_set_display (GtkInspectorCssNodeTree *cnt,
GdkDisplay *display)
{
GtkSettings *settings;
gchar *theme_name;
settings = gtk_settings_get_for_display (display);
g_object_get (settings, "gtk-theme-name", &theme_name, NULL);
g_object_set (settings, "gtk-theme-name", theme_name, NULL);
g_free (theme_name);
}
// vim: set et sw=2 ts=2:

View File

@ -55,6 +55,9 @@ void gtk_inspector_css_node_tree_set_object (GtkInspectorCss
GObject *object);
GtkCssNode * gtk_inspector_css_node_tree_get_node (GtkInspectorCssNodeTree *cnt);
void gtk_inspector_css_node_tree_set_display (GtkInspectorCssNodeTree *cnt,
GdkDisplay *display);
G_END_DECLS

View File

@ -46,6 +46,7 @@
#include "window.h"
#include "gtkmagnifierprivate.h"
#include "gtkcssproviderprivate.h"
#include "gtkmodulesprivate.h"
@ -96,6 +97,8 @@ gtk_inspector_init (void)
g_strfreev (paths);
g_io_module_scope_free (scope);
}
gtk_css_provider_set_keep_css_sections ();
}
// vim: set et sw=2 ts=2:

View File

@ -274,6 +274,7 @@ gtk_inspector_window_constructed (GObject *object)
gtk_inspector_visual_set_display (GTK_INSPECTOR_VISUAL (iw->visual), iw->inspected_display);
gtk_inspector_general_set_display (GTK_INSPECTOR_GENERAL (iw->general), iw->inspected_display);
gtk_inspector_logs_set_display (GTK_INSPECTOR_LOGS (iw->logs), iw->inspected_display);
gtk_inspector_css_node_tree_set_display (GTK_INSPECTOR_CSS_NODE_TREE (iw->widget_css_node_tree), iw->inspected_display);
}
static void