[gtk/inspector-display: 10/14] inspector: Make visual settings respect the inspected display
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/inspector-display: 10/14] inspector: Make visual settings respect the inspected display
- Date: Sat, 7 Dec 2019 20:04:39 +0000 (UTC)
commit 11193e65f137f248e21cbcff2e6460a388c0988b
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Dec 7 12:07:12 2019 -0500
inspector: Make visual settings respect the inspected display
This is not quite complete, GTK and GSK debug flags
are not per display, and slowdown and text direction
are not either.
gtk/inspector/visual.c | 92 ++++++++++++++++++++++++++++---------------------
gtk/inspector/visual.h | 3 ++
gtk/inspector/window.c | 3 ++
gtk/inspector/window.h | 1 +
gtk/inspector/window.ui | 2 +-
5 files changed, 60 insertions(+), 41 deletions(-)
---
diff --git a/gtk/inspector/visual.c b/gtk/inspector/visual.c
index d11bb94c8f..183b30cf8c 100644
--- a/gtk/inspector/visual.c
+++ b/gtk/inspector/visual.c
@@ -91,6 +91,8 @@ struct _GtkInspectorVisualPrivate
GtkInspectorOverlay *fps_overlay;
GtkInspectorOverlay *updates_overlay;
GtkInspectorOverlay *layout_overlay;
+
+ GdkDisplay *display;
};
G_DEFINE_TYPE_WITH_PRIVATE (GtkInspectorVisual, gtk_inspector_visual, GTK_TYPE_WIDGET)
@@ -165,11 +167,11 @@ static double
get_font_scale (GtkInspectorVisual *vis)
{
#ifdef GDK_WINDOWING_X11
- if (GDK_IS_X11_DISPLAY (gdk_display_get_default ()))
+ if (GDK_IS_X11_DISPLAY (vis->priv->display))
{
int dpi_int;
- g_object_get (gtk_settings_get_default (),
+ g_object_get (gtk_settings_get_for_display (vis->priv->display),
"gtk-xft-dpi", &dpi_int,
NULL);
@@ -177,11 +179,11 @@ get_font_scale (GtkInspectorVisual *vis)
}
#endif
#ifdef GDK_WINDOWING_WAYLAND
- if (GDK_IS_WAYLAND_DISPLAY (gdk_display_get_default ()))
+ if (GDK_IS_WAYLAND_DISPLAY (vis->priv->display))
{
int dpi_int;
- g_object_get (gtk_settings_get_default (),
+ g_object_get (gtk_settings_get_for_display (vis->priv->display),
"gtk-xft-dpi", &dpi_int,
NULL);
@@ -198,7 +200,7 @@ update_font_scale (GtkInspectorVisual *vis,
gboolean update_adjustment,
gboolean update_entry)
{
- g_object_set (gtk_settings_get_default (),
+ g_object_set (gtk_settings_get_for_display (vis->priv->display),
"gtk-xft-dpi", (gint)(factor * 96 * 1024),
NULL);
@@ -505,7 +507,8 @@ init_theme (GtkInspectorVisual *vis)
g_list_free (list);
g_hash_table_destroy (t);
- g_object_bind_property (gtk_settings_get_default (), "gtk-theme-name",
+ g_object_bind_property (gtk_settings_get_for_display (vis->priv->display),
+ "gtk-theme-name",
vis->priv->theme_combo, "active-id",
G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
@@ -523,7 +526,8 @@ init_theme (GtkInspectorVisual *vis)
static void
init_dark (GtkInspectorVisual *vis)
{
- g_object_bind_property (gtk_settings_get_default (), "gtk-application-prefer-dark-theme",
+ g_object_bind_property (gtk_settings_get_for_display (vis->priv->display),
+ "gtk-application-prefer-dark-theme",
vis->priv->dark_switch, "active",
G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
@@ -596,7 +600,8 @@ init_icons (GtkInspectorVisual *vis)
g_hash_table_destroy (t);
g_list_free (list);
- g_object_bind_property (gtk_settings_get_default (), "gtk-icon-theme-name",
+ g_object_bind_property (gtk_settings_get_for_display (vis->priv->display),
+ "gtk-icon-theme-name",
vis->priv->icon_combo, "active-id",
G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
}
@@ -658,7 +663,8 @@ init_cursors (GtkInspectorVisual *vis)
g_hash_table_destroy (t);
g_list_free (list);
- g_object_bind_property (gtk_settings_get_default (), "gtk-cursor-theme-name",
+ g_object_bind_property (gtk_settings_get_for_display (vis->priv->display),
+ "gtk-cursor-theme-name",
vis->priv->cursor_combo, "active-id",
G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
}
@@ -669,7 +675,7 @@ cursor_size_changed (GtkAdjustment *adjustment, GtkInspectorVisual *vis)
gint size;
size = gtk_adjustment_get_value (adjustment);
- g_object_set (gtk_settings_get_default (), "gtk-cursor-theme-size", size, NULL);
+ g_object_set (gtk_settings_get_for_display (vis->priv->display), "gtk-cursor-theme-size", size, NULL);
}
static void
@@ -677,7 +683,7 @@ init_cursor_size (GtkInspectorVisual *vis)
{
gint size;
- g_object_get (gtk_settings_get_default (), "gtk-cursor-theme-size", &size, NULL);
+ g_object_get (gtk_settings_get_for_display (vis->priv->display), "gtk-cursor-theme-size", &size, NULL);
if (size == 0)
size = 32;
@@ -689,7 +695,8 @@ init_cursor_size (GtkInspectorVisual *vis)
static void
init_font (GtkInspectorVisual *vis)
{
- g_object_bind_property (gtk_settings_get_default (), "gtk-font-name",
+ g_object_bind_property (gtk_settings_get_for_display (vis->priv->display),
+ "gtk-font-name",
vis->priv->font_button, "font",
G_BINDING_BIDIRECTIONAL|G_BINDING_SYNC_CREATE);
}
@@ -711,12 +718,10 @@ init_font_scale (GtkInspectorVisual *vis)
static void
scale_changed (GtkAdjustment *adjustment, GtkInspectorVisual *vis)
{
- GdkDisplay *display;
gint scale;
scale = gtk_adjustment_get_value (adjustment);
- display = gdk_display_get_default ();
- gdk_x11_display_set_surface_scale (display, scale);
+ gdk_x11_display_set_surface_scale (vis->priv->display, scale);
}
#endif
@@ -724,14 +729,11 @@ static void
init_scale (GtkInspectorVisual *vis)
{
#if defined (GDK_WINDOWING_X11)
- GdkDisplay *display;
-
- display = gdk_display_get_default ();
- if (GDK_IS_X11_DISPLAY (display))
+ if (GDK_IS_X11_DISPLAY (vis->priv->display))
{
gdouble scale;
- scale = gdk_monitor_get_scale_factor (gdk_display_get_primary_monitor (display));
+ scale = gdk_monitor_get_scale_factor (gdk_display_get_primary_monitor (vis->priv->display));
gtk_adjustment_set_value (vis->priv->scale_adjustment, scale);
g_signal_connect (vis->priv->scale_adjustment, "value-changed",
G_CALLBACK (scale_changed), vis);
@@ -751,7 +753,7 @@ init_scale (GtkInspectorVisual *vis)
static void
init_animation (GtkInspectorVisual *vis)
{
- g_object_bind_property (gtk_settings_get_default (), "gtk-enable-animations",
+ g_object_bind_property (gtk_settings_get_for_display (vis->priv->display), "gtk-enable-animations",
vis->priv->animation_switch, "active",
G_BINDING_BIDIRECTIONAL|G_BINDING_SYNC_CREATE);
}
@@ -952,7 +954,7 @@ row_activated (GtkListBox *box,
static void
init_gl (GtkInspectorVisual *vis)
{
- GdkDebugFlags flags = gdk_display_get_debug_flags (gdk_display_get_default ());
+ GdkDebugFlags flags = gdk_display_get_debug_flags (vis->priv->display);
gtk_switch_set_active (GTK_SWITCH (vis->priv->software_gl_switch), flags & GDK_DEBUG_GL_SOFTWARE);
@@ -968,22 +970,24 @@ init_gl (GtkInspectorVisual *vis)
static void
update_gl_flag (GtkSwitch *sw,
- GdkDebugFlags flag)
+ GdkDebugFlags flag,
+ GtkInspectorVisual *vis)
{
- GdkDebugFlags flags = gdk_display_get_debug_flags (gdk_display_get_default ());
+ GdkDebugFlags flags = gdk_display_get_debug_flags (vis->priv->display);
if (gtk_switch_get_active (sw))
flags |= flag;
else
flags &= ~flag;
- gdk_display_set_debug_flags (gdk_display_get_default (), flags);
+ gdk_display_set_debug_flags (vis->priv->display, flags);
}
static void
-software_gl_activate (GtkSwitch *sw)
+software_gl_activate (GtkSwitch *sw,
+ GtkInspectorVisual *vis)
{
- update_gl_flag (sw, GDK_DEBUG_GL_SOFTWARE);
+ update_gl_flag (sw, GDK_DEBUG_GL_SOFTWARE, vis);
}
static void
@@ -991,19 +995,6 @@ gtk_inspector_visual_init (GtkInspectorVisual *vis)
{
vis->priv = gtk_inspector_visual_get_instance_private (vis);
gtk_widget_init_template (GTK_WIDGET (vis));
- init_direction (vis);
- init_theme (vis);
- init_dark (vis);
- init_icons (vis);
- init_cursors (vis);
- init_cursor_size (vis);
- init_font (vis);
- init_font_scale (vis);
- init_scale (vis);
- init_animation (vis);
- init_slowdown (vis);
- init_touchscreen (vis);
- init_gl (vis);
}
static void
@@ -1124,4 +1115,25 @@ gtk_inspector_visual_class_init (GtkInspectorVisualClass *klass)
gtk_widget_class_bind_template_callback (widget_class, software_gl_activate);
}
+void
+gtk_inspector_visual_set_display (GtkInspectorVisual *vis,
+ GdkDisplay *display)
+{
+ vis->priv->display = display;
+
+ init_direction (vis);
+ init_theme (vis);
+ init_dark (vis);
+ init_icons (vis);
+ init_cursors (vis);
+ init_cursor_size (vis);
+ init_font (vis);
+ init_font_scale (vis);
+ init_scale (vis);
+ init_animation (vis);
+ init_slowdown (vis);
+ init_touchscreen (vis);
+ init_gl (vis);
+}
+
// vim: set et sw=2 ts=2:
diff --git a/gtk/inspector/visual.h b/gtk/inspector/visual.h
index 709862e170..321ed85e31 100644
--- a/gtk/inspector/visual.h
+++ b/gtk/inspector/visual.h
@@ -44,6 +44,9 @@ typedef struct _GtkInspectorVisualClass
G_BEGIN_DECLS
GType gtk_inspector_visual_get_type (void);
+void gtk_inspector_visual_set_display (GtkInspectorVisual *vis,
+ GdkDisplay *display);
+
G_END_DECLS
diff --git a/gtk/inspector/window.c b/gtk/inspector/window.c
index b2a8a36e53..7686323aed 100644
--- a/gtk/inspector/window.c
+++ b/gtk/inspector/window.c
@@ -41,6 +41,7 @@
#include "misc-info.h"
#include "magnifier.h"
#include "recorder.h"
+#include "visual.h"
#include "gdk-private.h"
#include "gskrendererprivate.h"
@@ -268,6 +269,7 @@ gtk_inspector_window_constructed (GObject *object)
gtk_inspector_object_tree_set_display (GTK_INSPECTOR_OBJECT_TREE (iw->object_tree), iw->inspected_display);
gtk_inspector_css_editor_set_display (GTK_INSPECTOR_CSS_EDITOR (iw->css_editor), iw->inspected_display);
+ gtk_inspector_visual_set_display (GTK_INSPECTOR_VISUAL (iw->visual), iw->inspected_display);
}
static void
@@ -418,6 +420,7 @@ gtk_inspector_window_class_init (GtkInspectorWindowClass *klass)
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, magnifier);
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, sidebar_revealer);
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, css_editor);
+ gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, visual);
gtk_widget_class_bind_template_callback (widget_class, gtk_inspector_on_inspect);
gtk_widget_class_bind_template_callback (widget_class, on_object_activated);
diff --git a/gtk/inspector/window.h b/gtk/inspector/window.h
index 5616183c0b..d5f611582c 100644
--- a/gtk/inspector/window.h
+++ b/gtk/inspector/window.h
@@ -72,6 +72,7 @@ typedef struct
GtkWidget *magnifier;
GtkWidget *sidebar_revealer;
GtkWidget *css_editor;
+ GtkWidget *visual;
GtkWidget *selected_widget;
diff --git a/gtk/inspector/window.ui b/gtk/inspector/window.ui
index 265685e987..1b689371b1 100644
--- a/gtk/inspector/window.ui
+++ b/gtk/inspector/window.ui
@@ -473,7 +473,7 @@
<property name="name">visual</property>
<property name="title" translatable="yes">Settings</property>
<property name="child">
- <object class="GtkInspectorVisual"/>
+ <object class="GtkInspectorVisual" id="visual"/>
</property>
</object>
</child>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]