2014-05-11 01:19:21 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2014 Red Hat, Inc.
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2014-07-10 14:33:27 +00:00
|
|
|
#include "config.h"
|
|
|
|
#include <glib/gi18n-lib.h>
|
2014-07-12 03:14:04 +00:00
|
|
|
|
2014-05-11 01:19:21 +00:00
|
|
|
#include "visual.h"
|
|
|
|
|
2018-04-05 10:58:46 +00:00
|
|
|
#include "fpsoverlay.h"
|
2018-04-04 11:22:28 +00:00
|
|
|
#include "updatesoverlay.h"
|
2018-07-08 09:26:12 +00:00
|
|
|
#include "layoutoverlay.h"
|
2019-12-27 17:16:14 +00:00
|
|
|
#include "focusoverlay.h"
|
2019-05-13 17:36:46 +00:00
|
|
|
#include "baselineoverlay.h"
|
2018-04-04 11:22:28 +00:00
|
|
|
#include "window.h"
|
|
|
|
|
2014-07-12 05:43:03 +00:00
|
|
|
#include "gtkadjustment.h"
|
|
|
|
#include "gtkbox.h"
|
2019-12-14 05:50:26 +00:00
|
|
|
#include "gtkdropdown.h"
|
2016-10-26 03:29:07 +00:00
|
|
|
#include "gtkcssproviderprivate.h"
|
2014-07-12 03:14:04 +00:00
|
|
|
#include "gtkdebug.h"
|
2014-05-16 10:02:00 +00:00
|
|
|
#include "gtkprivate.h"
|
2014-07-12 03:14:04 +00:00
|
|
|
#include "gtksettings.h"
|
|
|
|
#include "gtkswitch.h"
|
2016-03-25 12:42:31 +00:00
|
|
|
#include "gtkscale.h"
|
2014-07-12 03:14:04 +00:00
|
|
|
#include "gtkwindow.h"
|
2019-04-06 17:39:00 +00:00
|
|
|
#include "gtklistbox.h"
|
2019-10-31 02:31:27 +00:00
|
|
|
#include "gskdebugprivate.h"
|
|
|
|
#include "gskrendererprivate.h"
|
|
|
|
#include "gtknative.h"
|
2020-03-22 14:41:21 +00:00
|
|
|
#include "gtkbinlayout.h"
|
2019-12-14 05:50:26 +00:00
|
|
|
#include "gtkeditable.h"
|
|
|
|
#include "gtkentry.h"
|
2020-07-26 13:34:08 +00:00
|
|
|
#include "gtkstringlist.h"
|
2014-05-16 10:02:00 +00:00
|
|
|
|
2014-07-12 05:43:03 +00:00
|
|
|
#ifdef GDK_WINDOWING_X11
|
|
|
|
#include "x11/gdkx.h"
|
|
|
|
#endif
|
2016-11-24 00:16:16 +00:00
|
|
|
#ifdef GDK_WINDOWING_WAYLAND
|
|
|
|
#include "wayland/gdkwayland.h"
|
|
|
|
#endif
|
2014-07-12 05:43:03 +00:00
|
|
|
|
2014-11-07 14:27:56 +00:00
|
|
|
#include "gdk/gdk-private.h"
|
2014-11-07 12:11:38 +00:00
|
|
|
|
2016-03-14 10:38:55 +00:00
|
|
|
#define EPSILON 1e-10
|
|
|
|
|
2020-07-18 04:17:42 +00:00
|
|
|
struct _GtkInspectorVisual
|
2014-05-11 01:19:21 +00:00
|
|
|
{
|
2020-07-18 04:17:42 +00:00
|
|
|
GtkWidget widget;
|
|
|
|
|
2019-05-28 22:34:47 +00:00
|
|
|
GtkWidget *swin;
|
|
|
|
GtkWidget *box;
|
2014-07-12 05:43:03 +00:00
|
|
|
GtkWidget *visual_box;
|
|
|
|
GtkWidget *theme_combo;
|
|
|
|
GtkWidget *dark_switch;
|
|
|
|
GtkWidget *icon_combo;
|
2014-12-13 04:14:34 +00:00
|
|
|
GtkWidget *cursor_combo;
|
|
|
|
GtkWidget *cursor_size_spin;
|
2014-05-11 01:19:21 +00:00
|
|
|
GtkWidget *direction_combo;
|
2014-07-19 23:15:58 +00:00
|
|
|
GtkWidget *font_button;
|
2014-07-12 05:43:03 +00:00
|
|
|
GtkWidget *hidpi_spin;
|
2014-08-04 22:03:37 +00:00
|
|
|
GtkWidget *animation_switch;
|
2016-04-09 15:46:12 +00:00
|
|
|
GtkWidget *font_scale_entry;
|
|
|
|
GtkAdjustment *font_scale_adjustment;
|
2014-07-12 05:43:03 +00:00
|
|
|
GtkAdjustment *scale_adjustment;
|
2016-03-14 10:38:55 +00:00
|
|
|
GtkAdjustment *slowdown_adjustment;
|
|
|
|
GtkWidget *slowdown_entry;
|
2014-12-13 04:14:34 +00:00
|
|
|
GtkAdjustment *cursor_size_adjustment;
|
2014-07-12 05:43:03 +00:00
|
|
|
|
|
|
|
GtkWidget *debug_box;
|
2019-04-12 02:06:16 +00:00
|
|
|
GtkWidget *fps_switch;
|
|
|
|
GtkWidget *updates_switch;
|
2019-10-31 02:31:27 +00:00
|
|
|
GtkWidget *fallback_switch;
|
2019-04-12 02:06:16 +00:00
|
|
|
GtkWidget *baselines_switch;
|
|
|
|
GtkWidget *layout_switch;
|
2019-12-27 17:16:14 +00:00
|
|
|
GtkWidget *focus_switch;
|
2014-05-11 01:19:21 +00:00
|
|
|
|
2019-04-06 17:39:00 +00:00
|
|
|
GtkWidget *misc_box;
|
|
|
|
GtkWidget *touchscreen_switch;
|
2014-11-07 04:29:49 +00:00
|
|
|
GtkWidget *software_gl_switch;
|
|
|
|
|
2018-04-05 10:58:46 +00:00
|
|
|
GtkInspectorOverlay *fps_overlay;
|
2018-04-04 11:22:28 +00:00
|
|
|
GtkInspectorOverlay *updates_overlay;
|
2018-07-08 09:26:12 +00:00
|
|
|
GtkInspectorOverlay *layout_overlay;
|
2019-12-27 17:16:14 +00:00
|
|
|
GtkInspectorOverlay *focus_overlay;
|
2019-05-13 17:36:46 +00:00
|
|
|
GtkInspectorOverlay *baseline_overlay;
|
2019-12-07 17:07:12 +00:00
|
|
|
|
|
|
|
GdkDisplay *display;
|
2014-05-15 02:53:32 +00:00
|
|
|
};
|
2014-05-11 01:19:21 +00:00
|
|
|
|
2020-07-18 04:17:42 +00:00
|
|
|
typedef struct _GtkInspectorVisualClass
|
|
|
|
{
|
|
|
|
GtkWidgetClass parent_class;
|
|
|
|
} GtkInspectorVisualClass;
|
|
|
|
|
|
|
|
G_DEFINE_TYPE (GtkInspectorVisual, gtk_inspector_visual, GTK_TYPE_WIDGET)
|
2014-05-11 01:19:21 +00:00
|
|
|
|
|
|
|
static void
|
2019-05-22 00:43:04 +00:00
|
|
|
fix_direction_recurse (GtkWidget *widget,
|
|
|
|
GtkTextDirection dir)
|
2014-05-11 01:19:21 +00:00
|
|
|
{
|
2016-11-15 15:49:41 +00:00
|
|
|
GtkWidget *child;
|
2014-05-11 01:19:21 +00:00
|
|
|
|
|
|
|
g_object_ref (widget);
|
|
|
|
|
|
|
|
gtk_widget_set_direction (widget, dir);
|
2016-11-15 15:49:41 +00:00
|
|
|
for (child = gtk_widget_get_first_child (widget);
|
|
|
|
child != NULL;
|
|
|
|
child = gtk_widget_get_next_sibling (child))
|
|
|
|
{
|
2019-05-22 00:43:04 +00:00
|
|
|
fix_direction_recurse (child, dir);
|
2016-11-15 15:49:41 +00:00
|
|
|
}
|
2014-05-11 01:19:21 +00:00
|
|
|
|
|
|
|
g_object_unref (widget);
|
|
|
|
}
|
|
|
|
|
|
|
|
static GtkTextDirection initial_direction;
|
|
|
|
|
|
|
|
static void
|
|
|
|
fix_direction (GtkWidget *iw)
|
|
|
|
{
|
2019-05-22 00:43:04 +00:00
|
|
|
fix_direction_recurse (iw, initial_direction);
|
2014-05-11 01:19:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2019-12-14 05:50:26 +00:00
|
|
|
direction_changed (GtkDropDown *combo)
|
2014-05-11 01:19:21 +00:00
|
|
|
{
|
|
|
|
GtkWidget *iw;
|
2019-12-14 05:50:26 +00:00
|
|
|
guint selected;
|
2014-05-11 01:19:21 +00:00
|
|
|
|
2019-05-20 04:47:50 +00:00
|
|
|
iw = GTK_WIDGET (gtk_widget_get_root (GTK_WIDGET (combo)));
|
2019-05-22 00:43:04 +00:00
|
|
|
if (iw)
|
|
|
|
fix_direction (iw);
|
2014-05-11 01:19:21 +00:00
|
|
|
|
2019-12-14 05:50:26 +00:00
|
|
|
selected = gtk_drop_down_get_selected (combo);
|
|
|
|
|
|
|
|
if (selected == 0)
|
2014-05-11 01:19:21 +00:00
|
|
|
gtk_widget_set_default_direction (GTK_TEXT_DIR_LTR);
|
|
|
|
else
|
|
|
|
gtk_widget_set_default_direction (GTK_TEXT_DIR_RTL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
init_direction (GtkInspectorVisual *vis)
|
|
|
|
{
|
|
|
|
initial_direction = gtk_widget_get_default_direction ();
|
|
|
|
if (initial_direction == GTK_TEXT_DIR_LTR)
|
2020-07-18 04:17:42 +00:00
|
|
|
gtk_drop_down_set_selected (GTK_DROP_DOWN (vis->direction_combo), 0);
|
2014-05-11 01:19:21 +00:00
|
|
|
else
|
2020-07-18 04:17:42 +00:00
|
|
|
gtk_drop_down_set_selected (GTK_DROP_DOWN (vis->direction_combo), 1);
|
2014-05-11 01:19:21 +00:00
|
|
|
}
|
|
|
|
|
2014-05-15 20:11:14 +00:00
|
|
|
static void
|
|
|
|
redraw_everything (void)
|
|
|
|
{
|
|
|
|
GList *toplevels;
|
|
|
|
toplevels = gtk_window_list_toplevels ();
|
|
|
|
g_list_foreach (toplevels, (GFunc) gtk_widget_queue_draw, NULL);
|
|
|
|
g_list_free (toplevels);
|
|
|
|
}
|
|
|
|
|
2016-11-24 00:16:16 +00:00
|
|
|
static double
|
|
|
|
get_font_scale (GtkInspectorVisual *vis)
|
|
|
|
{
|
|
|
|
#ifdef GDK_WINDOWING_X11
|
2020-07-18 04:17:42 +00:00
|
|
|
if (GDK_IS_X11_DISPLAY (vis->display))
|
2016-11-24 00:16:16 +00:00
|
|
|
{
|
|
|
|
int dpi_int;
|
|
|
|
|
2020-07-18 04:17:42 +00:00
|
|
|
g_object_get (gtk_settings_get_for_display (vis->display),
|
2016-11-24 00:16:16 +00:00
|
|
|
"gtk-xft-dpi", &dpi_int,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
return dpi_int / (96.0 * 1024.0);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#ifdef GDK_WINDOWING_WAYLAND
|
2020-07-18 04:17:42 +00:00
|
|
|
if (GDK_IS_WAYLAND_DISPLAY (vis->display))
|
2016-11-24 00:16:16 +00:00
|
|
|
{
|
|
|
|
int dpi_int;
|
|
|
|
|
2020-07-18 04:17:42 +00:00
|
|
|
g_object_get (gtk_settings_get_for_display (vis->display),
|
2016-11-24 00:16:16 +00:00
|
|
|
"gtk-xft-dpi", &dpi_int,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
return dpi_int / (96.0 * 1024.0);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return 1.0;
|
|
|
|
}
|
|
|
|
|
2016-03-25 12:42:31 +00:00
|
|
|
static void
|
2016-04-09 15:46:12 +00:00
|
|
|
update_font_scale (GtkInspectorVisual *vis,
|
2020-07-24 20:32:16 +00:00
|
|
|
double factor,
|
2016-04-09 15:46:12 +00:00
|
|
|
gboolean update_adjustment,
|
|
|
|
gboolean update_entry)
|
|
|
|
{
|
2020-07-18 04:17:42 +00:00
|
|
|
g_object_set (gtk_settings_get_for_display (vis->display),
|
2020-07-24 13:54:49 +00:00
|
|
|
"gtk-xft-dpi", (int)(factor * 96 * 1024),
|
2016-11-24 00:16:16 +00:00
|
|
|
NULL);
|
2016-04-09 15:46:12 +00:00
|
|
|
|
|
|
|
if (update_adjustment)
|
2020-07-18 04:17:42 +00:00
|
|
|
gtk_adjustment_set_value (vis->font_scale_adjustment, factor);
|
2016-04-09 15:46:12 +00:00
|
|
|
|
|
|
|
if (update_entry)
|
|
|
|
{
|
2020-07-24 18:40:36 +00:00
|
|
|
char *str = g_strdup_printf ("%0.2f", factor);
|
2016-04-09 15:46:12 +00:00
|
|
|
|
2020-07-18 04:17:42 +00:00
|
|
|
gtk_editable_set_text (GTK_EDITABLE (vis->font_scale_entry), str);
|
2016-04-09 15:46:12 +00:00
|
|
|
g_free (str);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
font_scale_adjustment_changed (GtkAdjustment *adjustment,
|
|
|
|
GtkInspectorVisual *vis)
|
2016-03-25 12:42:31 +00:00
|
|
|
{
|
2020-07-24 20:32:16 +00:00
|
|
|
double factor;
|
2016-03-25 12:42:31 +00:00
|
|
|
|
|
|
|
factor = gtk_adjustment_get_value (adjustment);
|
2016-04-09 15:46:12 +00:00
|
|
|
update_font_scale (vis, factor, FALSE, TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
font_scale_entry_activated (GtkEntry *entry,
|
|
|
|
GtkInspectorVisual *vis)
|
|
|
|
{
|
2020-07-24 20:32:16 +00:00
|
|
|
double factor;
|
2020-07-24 18:40:36 +00:00
|
|
|
char *err = NULL;
|
2016-04-09 15:46:12 +00:00
|
|
|
|
2019-02-28 19:31:36 +00:00
|
|
|
factor = g_strtod (gtk_editable_get_text (GTK_EDITABLE (entry)), &err);
|
2016-04-09 15:46:12 +00:00
|
|
|
if (err != NULL)
|
|
|
|
update_font_scale (vis, factor, TRUE, FALSE);
|
2016-03-25 12:42:31 +00:00
|
|
|
}
|
|
|
|
|
2018-04-05 10:58:46 +00:00
|
|
|
static void
|
|
|
|
fps_activate (GtkSwitch *sw,
|
|
|
|
GParamSpec *pspec,
|
|
|
|
GtkInspectorVisual *vis)
|
|
|
|
{
|
|
|
|
GtkInspectorWindow *iw;
|
|
|
|
gboolean fps;
|
|
|
|
|
|
|
|
fps = gtk_switch_get_active (sw);
|
2019-05-20 04:47:50 +00:00
|
|
|
iw = GTK_INSPECTOR_WINDOW (gtk_widget_get_root (GTK_WIDGET (vis)));
|
2018-04-05 10:58:46 +00:00
|
|
|
if (iw == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (fps)
|
|
|
|
{
|
2020-07-18 04:17:42 +00:00
|
|
|
if (vis->fps_overlay == NULL)
|
2018-04-05 10:58:46 +00:00
|
|
|
{
|
2020-07-18 04:17:42 +00:00
|
|
|
vis->fps_overlay = gtk_fps_overlay_new ();
|
|
|
|
gtk_inspector_window_add_overlay (iw, vis->fps_overlay);
|
|
|
|
g_object_unref (vis->fps_overlay);
|
2018-04-05 10:58:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-07-18 04:17:42 +00:00
|
|
|
if (vis->fps_overlay != NULL)
|
2018-04-05 10:58:46 +00:00
|
|
|
{
|
2020-07-18 04:17:42 +00:00
|
|
|
gtk_inspector_window_remove_overlay (iw, vis->fps_overlay);
|
|
|
|
vis->fps_overlay = NULL;
|
2018-04-05 10:58:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
redraw_everything ();
|
|
|
|
}
|
|
|
|
|
2018-04-04 11:22:28 +00:00
|
|
|
static void
|
|
|
|
updates_activate (GtkSwitch *sw,
|
|
|
|
GParamSpec *pspec,
|
|
|
|
GtkInspectorVisual *vis)
|
|
|
|
{
|
|
|
|
GtkInspectorWindow *iw;
|
|
|
|
gboolean updates;
|
|
|
|
|
|
|
|
updates = gtk_switch_get_active (sw);
|
2019-05-20 04:47:50 +00:00
|
|
|
iw = GTK_INSPECTOR_WINDOW (gtk_widget_get_root (GTK_WIDGET (vis)));
|
2018-04-04 11:22:28 +00:00
|
|
|
if (iw == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (updates)
|
|
|
|
{
|
2020-07-18 04:17:42 +00:00
|
|
|
if (vis->updates_overlay == NULL)
|
2018-04-04 11:22:28 +00:00
|
|
|
{
|
2020-07-18 04:17:42 +00:00
|
|
|
vis->updates_overlay = gtk_updates_overlay_new ();
|
|
|
|
gtk_inspector_window_add_overlay (iw, vis->updates_overlay);
|
|
|
|
g_object_unref (vis->updates_overlay);
|
2018-04-04 11:22:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-07-18 04:17:42 +00:00
|
|
|
if (vis->updates_overlay != NULL)
|
2018-04-04 11:22:28 +00:00
|
|
|
{
|
2020-07-18 04:17:42 +00:00
|
|
|
gtk_inspector_window_remove_overlay (iw, vis->updates_overlay);
|
|
|
|
vis->updates_overlay = NULL;
|
2018-04-04 11:22:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
redraw_everything ();
|
|
|
|
}
|
|
|
|
|
2019-10-31 02:31:27 +00:00
|
|
|
static void
|
|
|
|
fallback_activate (GtkSwitch *sw,
|
|
|
|
GParamSpec *pspec,
|
|
|
|
GtkInspectorVisual *vis)
|
|
|
|
{
|
|
|
|
GtkInspectorWindow *iw;
|
|
|
|
gboolean fallback;
|
|
|
|
guint flags;
|
|
|
|
GList *toplevels, *l;
|
|
|
|
|
|
|
|
fallback = gtk_switch_get_active (sw);
|
|
|
|
iw = GTK_INSPECTOR_WINDOW (gtk_widget_get_root (GTK_WIDGET (vis)));
|
|
|
|
if (iw == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
flags = gsk_get_debug_flags ();
|
|
|
|
if (fallback)
|
|
|
|
flags = flags | GSK_DEBUG_FALLBACK;
|
|
|
|
else
|
|
|
|
flags = flags & ~GSK_DEBUG_FALLBACK;
|
|
|
|
gsk_set_debug_flags (flags);
|
|
|
|
|
|
|
|
toplevels = gtk_window_list_toplevels ();
|
|
|
|
for (l = toplevels; l; l = l->next)
|
|
|
|
{
|
|
|
|
GtkWidget *toplevel = l->data;
|
|
|
|
GskRenderer *renderer;
|
|
|
|
|
|
|
|
if ((GtkRoot *)toplevel == gtk_widget_get_root (GTK_WIDGET (sw))) /* skip the inspector */
|
|
|
|
continue;
|
|
|
|
|
|
|
|
renderer = gtk_native_get_renderer (GTK_NATIVE (toplevel));
|
|
|
|
if (!renderer)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
gsk_renderer_set_debug_flags (renderer, flags);
|
|
|
|
}
|
|
|
|
g_list_free (toplevels);
|
|
|
|
|
|
|
|
redraw_everything ();
|
|
|
|
}
|
|
|
|
|
2014-05-11 01:19:21 +00:00
|
|
|
static void
|
2019-05-13 17:36:46 +00:00
|
|
|
baselines_activate (GtkSwitch *sw,
|
|
|
|
GParamSpec *pspec,
|
|
|
|
GtkInspectorVisual *vis)
|
2014-05-11 01:19:21 +00:00
|
|
|
{
|
2019-05-13 17:36:46 +00:00
|
|
|
GtkInspectorWindow *iw;
|
|
|
|
gboolean baselines;
|
2014-05-11 01:19:21 +00:00
|
|
|
|
2019-05-13 17:36:46 +00:00
|
|
|
baselines = gtk_switch_get_active (sw);
|
|
|
|
iw = GTK_INSPECTOR_WINDOW (gtk_widget_get_root (GTK_WIDGET (vis)));
|
|
|
|
if (iw == NULL)
|
|
|
|
return;
|
2014-05-11 01:19:21 +00:00
|
|
|
|
2019-05-13 17:36:46 +00:00
|
|
|
if (baselines)
|
|
|
|
{
|
2020-07-18 04:17:42 +00:00
|
|
|
if (vis->baseline_overlay == NULL)
|
2019-05-13 17:36:46 +00:00
|
|
|
{
|
2020-07-18 04:17:42 +00:00
|
|
|
vis->baseline_overlay = gtk_baseline_overlay_new ();
|
|
|
|
gtk_inspector_window_add_overlay (iw, vis->baseline_overlay);
|
|
|
|
g_object_unref (vis->baseline_overlay);
|
2019-05-13 17:36:46 +00:00
|
|
|
}
|
|
|
|
}
|
2014-05-11 01:19:21 +00:00
|
|
|
else
|
2019-05-13 17:36:46 +00:00
|
|
|
{
|
2020-07-18 04:17:42 +00:00
|
|
|
if (vis->baseline_overlay != NULL)
|
2019-05-13 17:36:46 +00:00
|
|
|
{
|
2020-07-18 04:17:42 +00:00
|
|
|
gtk_inspector_window_remove_overlay (iw, vis->baseline_overlay);
|
|
|
|
vis->baseline_overlay = NULL;
|
2019-05-13 17:36:46 +00:00
|
|
|
}
|
|
|
|
}
|
2014-05-11 01:19:21 +00:00
|
|
|
|
2014-05-15 20:11:14 +00:00
|
|
|
redraw_everything ();
|
2014-05-11 01:19:21 +00:00
|
|
|
}
|
|
|
|
|
2016-03-11 05:17:37 +00:00
|
|
|
static void
|
2018-07-08 09:26:12 +00:00
|
|
|
layout_activate (GtkSwitch *sw,
|
|
|
|
GParamSpec *pspec,
|
|
|
|
GtkInspectorVisual *vis)
|
2016-03-11 05:17:37 +00:00
|
|
|
{
|
2018-07-08 09:26:12 +00:00
|
|
|
GtkInspectorWindow *iw;
|
|
|
|
gboolean draw_layout;
|
2016-03-11 05:17:37 +00:00
|
|
|
|
2018-07-08 09:26:12 +00:00
|
|
|
draw_layout = gtk_switch_get_active (sw);
|
2019-05-20 04:47:50 +00:00
|
|
|
iw = GTK_INSPECTOR_WINDOW (gtk_widget_get_root (GTK_WIDGET (vis)));
|
2018-07-08 09:26:12 +00:00
|
|
|
if (iw == NULL)
|
|
|
|
return;
|
2016-03-11 05:17:37 +00:00
|
|
|
|
2018-07-08 09:26:12 +00:00
|
|
|
if (draw_layout)
|
|
|
|
{
|
2020-07-18 04:17:42 +00:00
|
|
|
if (vis->layout_overlay == NULL)
|
2018-07-08 09:26:12 +00:00
|
|
|
{
|
2020-07-18 04:17:42 +00:00
|
|
|
vis->layout_overlay = gtk_layout_overlay_new ();
|
|
|
|
gtk_inspector_window_add_overlay (iw, vis->layout_overlay);
|
|
|
|
g_object_unref (vis->layout_overlay);
|
2018-07-08 09:26:12 +00:00
|
|
|
}
|
|
|
|
}
|
2016-03-11 05:17:37 +00:00
|
|
|
else
|
2018-07-08 09:26:12 +00:00
|
|
|
{
|
2020-07-18 04:17:42 +00:00
|
|
|
if (vis->layout_overlay != NULL)
|
2018-07-08 09:26:12 +00:00
|
|
|
{
|
2020-07-18 04:17:42 +00:00
|
|
|
gtk_inspector_window_remove_overlay (iw, vis->layout_overlay);
|
|
|
|
vis->layout_overlay = NULL;
|
2018-07-08 09:26:12 +00:00
|
|
|
}
|
|
|
|
}
|
2016-03-11 05:17:37 +00:00
|
|
|
|
|
|
|
redraw_everything ();
|
|
|
|
}
|
|
|
|
|
2019-12-27 17:16:14 +00:00
|
|
|
static void
|
|
|
|
focus_activate (GtkSwitch *sw,
|
|
|
|
GParamSpec *pspec,
|
|
|
|
GtkInspectorVisual *vis)
|
|
|
|
{
|
|
|
|
GtkInspectorWindow *iw;
|
|
|
|
gboolean focus;
|
|
|
|
|
|
|
|
focus = gtk_switch_get_active (sw);
|
|
|
|
iw = GTK_INSPECTOR_WINDOW (gtk_widget_get_root (GTK_WIDGET (vis)));
|
|
|
|
if (iw == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (focus)
|
|
|
|
{
|
2020-07-18 04:17:42 +00:00
|
|
|
if (vis->focus_overlay == NULL)
|
2019-12-27 17:16:14 +00:00
|
|
|
{
|
2020-07-18 04:17:42 +00:00
|
|
|
vis->focus_overlay = gtk_focus_overlay_new ();
|
|
|
|
gtk_inspector_window_add_overlay (iw, vis->focus_overlay);
|
|
|
|
g_object_unref (vis->focus_overlay);
|
2019-12-27 17:16:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-07-18 04:17:42 +00:00
|
|
|
if (vis->focus_overlay != NULL)
|
2019-12-27 17:16:14 +00:00
|
|
|
{
|
2020-07-18 04:17:42 +00:00
|
|
|
gtk_inspector_window_remove_overlay (iw, vis->focus_overlay);
|
|
|
|
vis->focus_overlay = NULL;
|
2019-12-27 17:16:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
redraw_everything ();
|
|
|
|
}
|
|
|
|
|
2014-05-11 01:19:21 +00:00
|
|
|
static void
|
2020-07-24 18:40:36 +00:00
|
|
|
fill_gtk (const char *path,
|
2014-05-15 02:53:32 +00:00
|
|
|
GHashTable *t)
|
|
|
|
{
|
2020-07-24 18:40:36 +00:00
|
|
|
const char *dir_entry;
|
2014-05-15 02:53:32 +00:00
|
|
|
GDir *dir = g_dir_open (path, 0, NULL);
|
|
|
|
|
|
|
|
if (!dir)
|
|
|
|
return;
|
|
|
|
|
|
|
|
while ((dir_entry = g_dir_read_name (dir)))
|
|
|
|
{
|
2020-07-24 18:40:36 +00:00
|
|
|
char *filename = g_build_filename (path, dir_entry, "gtk-4.0", "gtk.css", NULL);
|
2014-05-15 02:53:32 +00:00
|
|
|
|
|
|
|
if (g_file_test (filename, G_FILE_TEST_IS_REGULAR) &&
|
|
|
|
!g_hash_table_contains (t, dir_entry))
|
|
|
|
g_hash_table_add (t, g_strdup (dir_entry));
|
|
|
|
|
|
|
|
g_free (filename);
|
|
|
|
}
|
2016-01-24 07:01:36 +00:00
|
|
|
|
|
|
|
g_dir_close (dir);
|
2014-05-15 02:53:32 +00:00
|
|
|
}
|
|
|
|
|
2020-07-24 18:40:36 +00:00
|
|
|
static char *
|
|
|
|
get_data_path (const char *subdir)
|
2014-05-16 10:02:00 +00:00
|
|
|
{
|
2020-07-24 18:40:36 +00:00
|
|
|
char *base_datadir, *full_datadir;
|
2014-05-16 10:02:00 +00:00
|
|
|
#if defined (GDK_WINDOWING_WIN32) || defined (GDK_WINDOWING_QUARTZ)
|
2014-11-07 19:17:41 +00:00
|
|
|
base_datadir = g_strdup (_gtk_get_datadir ());
|
2014-05-16 10:02:00 +00:00
|
|
|
#else
|
|
|
|
base_datadir = g_strdup (GTK_DATADIR);
|
|
|
|
#endif
|
|
|
|
full_datadir = g_build_filename (base_datadir, subdir, NULL);
|
|
|
|
g_free (base_datadir);
|
|
|
|
return full_datadir;
|
|
|
|
}
|
|
|
|
|
2019-12-14 05:50:26 +00:00
|
|
|
static gboolean
|
|
|
|
theme_to_pos (GBinding *binding,
|
|
|
|
const GValue *from,
|
|
|
|
GValue *to,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
2020-07-26 13:34:08 +00:00
|
|
|
GtkStringList *names = user_data;
|
2019-12-14 05:50:26 +00:00
|
|
|
const char *theme = g_value_get_string (from);
|
2020-07-26 13:34:08 +00:00
|
|
|
guint i, n;
|
2019-12-14 05:50:26 +00:00
|
|
|
|
2020-07-26 13:34:08 +00:00
|
|
|
for (i = 0, n = g_list_model_get_n_items (G_LIST_MODEL (names)); i < n; i++)
|
2019-12-14 05:50:26 +00:00
|
|
|
{
|
2020-07-26 13:34:08 +00:00
|
|
|
const char *name = gtk_string_list_get_string (names, i);
|
2020-08-08 22:05:21 +00:00
|
|
|
if (g_strcmp0 (name, theme) == 0)
|
2019-12-14 05:50:26 +00:00
|
|
|
{
|
|
|
|
g_value_set_uint (to, i);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
pos_to_theme (GBinding *binding,
|
|
|
|
const GValue *from,
|
|
|
|
GValue *to,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
2020-07-26 13:34:08 +00:00
|
|
|
GtkStringList *names = user_data;
|
2019-12-14 05:50:26 +00:00
|
|
|
int pos = g_value_get_uint (from);
|
2020-07-26 13:34:08 +00:00
|
|
|
g_value_set_string (to, gtk_string_list_get_string (names, pos));
|
2019-12-14 05:50:26 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2014-05-15 02:53:32 +00:00
|
|
|
static void
|
|
|
|
init_theme (GtkInspectorVisual *vis)
|
|
|
|
{
|
|
|
|
GHashTable *t;
|
|
|
|
GHashTableIter iter;
|
2020-07-24 18:40:36 +00:00
|
|
|
char *theme, *path;
|
|
|
|
char **builtin_themes;
|
2016-01-08 00:49:17 +00:00
|
|
|
GList *list, *l;
|
2020-07-26 13:34:08 +00:00
|
|
|
GtkStringList *names;
|
2016-02-04 12:34:34 +00:00
|
|
|
guint i;
|
2020-07-24 18:40:36 +00:00
|
|
|
const char * const *dirs;
|
2014-05-15 02:53:32 +00:00
|
|
|
|
|
|
|
t = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
|
2014-10-30 16:50:09 +00:00
|
|
|
/* Builtin themes */
|
2016-02-04 12:34:34 +00:00
|
|
|
builtin_themes = g_resources_enumerate_children ("/org/gtk/libgtk/theme", 0, NULL);
|
|
|
|
for (i = 0; builtin_themes[i] != NULL; i++)
|
|
|
|
{
|
|
|
|
if (g_str_has_suffix (builtin_themes[i], "/"))
|
|
|
|
g_hash_table_add (t, g_strndup (builtin_themes[i], strlen (builtin_themes[i]) - 1));
|
|
|
|
}
|
|
|
|
g_strfreev (builtin_themes);
|
2014-05-16 10:02:00 +00:00
|
|
|
|
2016-03-17 04:57:45 +00:00
|
|
|
path = _gtk_get_theme_dir ();
|
2014-11-07 19:17:41 +00:00
|
|
|
fill_gtk (path, t);
|
|
|
|
g_free (path);
|
2014-05-15 02:53:32 +00:00
|
|
|
|
|
|
|
path = g_build_filename (g_get_user_data_dir (), "themes", NULL);
|
|
|
|
fill_gtk (path, t);
|
|
|
|
g_free (path);
|
|
|
|
|
2014-11-07 19:17:41 +00:00
|
|
|
path = g_build_filename (g_get_home_dir (), ".themes", NULL);
|
2014-10-21 18:30:07 +00:00
|
|
|
fill_gtk (path, t);
|
|
|
|
g_free (path);
|
|
|
|
|
2016-03-22 12:20:20 +00:00
|
|
|
dirs = g_get_system_data_dirs ();
|
|
|
|
for (i = 0; dirs[i]; i++)
|
|
|
|
{
|
|
|
|
path = g_build_filename (dirs[i], "themes", NULL);
|
|
|
|
fill_gtk (path, t);
|
|
|
|
g_free (path);
|
|
|
|
}
|
|
|
|
|
2016-01-08 00:49:17 +00:00
|
|
|
list = NULL;
|
2014-05-15 02:53:32 +00:00
|
|
|
g_hash_table_iter_init (&iter, t);
|
|
|
|
while (g_hash_table_iter_next (&iter, (gpointer *)&theme, NULL))
|
2016-01-08 00:49:17 +00:00
|
|
|
list = g_list_insert_sorted (list, theme, (GCompareFunc)strcmp);
|
|
|
|
|
2020-07-26 13:34:08 +00:00
|
|
|
names = gtk_string_list_new (NULL);
|
2019-12-14 05:50:26 +00:00
|
|
|
for (l = list, i = 0; l; l = l->next, i++)
|
2020-07-26 13:34:08 +00:00
|
|
|
gtk_string_list_append (names, (const char *)l->data);
|
2016-01-08 00:49:17 +00:00
|
|
|
|
|
|
|
g_list_free (list);
|
2014-05-15 02:53:32 +00:00
|
|
|
g_hash_table_destroy (t);
|
|
|
|
|
2020-07-26 13:34:08 +00:00
|
|
|
gtk_drop_down_set_model (GTK_DROP_DOWN (vis->theme_combo), G_LIST_MODEL (names));
|
2019-12-14 05:50:26 +00:00
|
|
|
|
2020-07-18 04:17:42 +00:00
|
|
|
g_object_bind_property_full (gtk_settings_get_for_display (vis->display), "gtk-theme-name",
|
|
|
|
vis->theme_combo, "selected",
|
2019-12-14 05:50:26 +00:00
|
|
|
G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE,
|
2020-07-26 13:34:08 +00:00
|
|
|
theme_to_pos, pos_to_theme, names, (GDestroyNotify)g_object_unref);
|
2014-07-10 14:33:27 +00:00
|
|
|
|
|
|
|
if (g_getenv ("GTK_THEME") != NULL)
|
|
|
|
{
|
2019-04-06 17:39:00 +00:00
|
|
|
GtkWidget *row;
|
|
|
|
|
2014-07-10 14:33:27 +00:00
|
|
|
/* theme is hardcoded, nothing we can do */
|
2020-07-18 04:17:42 +00:00
|
|
|
gtk_widget_set_sensitive (vis->theme_combo, FALSE);
|
|
|
|
row = gtk_widget_get_ancestor (vis->theme_combo, GTK_TYPE_LIST_BOX_ROW);
|
2019-04-06 17:39:00 +00:00
|
|
|
gtk_widget_set_tooltip_text (row, _("Theme is hardcoded by GTK_THEME"));
|
2014-07-10 14:33:27 +00:00
|
|
|
}
|
2014-05-15 02:53:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
init_dark (GtkInspectorVisual *vis)
|
|
|
|
{
|
2020-07-18 04:17:42 +00:00
|
|
|
g_object_bind_property (gtk_settings_get_for_display (vis->display),
|
2019-12-07 17:07:12 +00:00
|
|
|
"gtk-application-prefer-dark-theme",
|
2020-07-18 04:17:42 +00:00
|
|
|
vis->dark_switch, "active",
|
2014-09-14 12:36:41 +00:00
|
|
|
G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
|
2014-07-10 14:33:27 +00:00
|
|
|
|
|
|
|
if (g_getenv ("GTK_THEME") != NULL)
|
|
|
|
{
|
2019-04-06 17:39:00 +00:00
|
|
|
GtkWidget *row;
|
|
|
|
|
2014-07-10 14:33:27 +00:00
|
|
|
/* theme is hardcoded, nothing we can do */
|
2020-07-18 04:17:42 +00:00
|
|
|
gtk_widget_set_sensitive (vis->dark_switch, FALSE);
|
|
|
|
row = gtk_widget_get_ancestor (vis->theme_combo, GTK_TYPE_LIST_BOX_ROW);
|
2019-04-06 17:39:00 +00:00
|
|
|
gtk_widget_set_tooltip_text (row, _("Theme is hardcoded by GTK_THEME"));
|
2014-07-10 14:33:27 +00:00
|
|
|
}
|
2014-05-15 02:53:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2020-07-24 18:40:36 +00:00
|
|
|
fill_icons (const char *path,
|
2014-05-15 02:53:32 +00:00
|
|
|
GHashTable *t)
|
|
|
|
{
|
2020-07-24 18:40:36 +00:00
|
|
|
const char *dir_entry;
|
2014-05-15 02:53:32 +00:00
|
|
|
GDir *dir;
|
|
|
|
|
|
|
|
dir = g_dir_open (path, 0, NULL);
|
|
|
|
if (!dir)
|
|
|
|
return;
|
|
|
|
|
|
|
|
while ((dir_entry = g_dir_read_name (dir)))
|
|
|
|
{
|
2020-07-24 18:40:36 +00:00
|
|
|
char *filename = g_build_filename (path, dir_entry, "index.theme", NULL);
|
2014-05-15 02:53:32 +00:00
|
|
|
|
|
|
|
if (g_file_test (filename, G_FILE_TEST_IS_REGULAR) &&
|
|
|
|
g_strcmp0 (dir_entry, "hicolor") != 0 &&
|
|
|
|
!g_hash_table_contains (t, dir_entry))
|
|
|
|
g_hash_table_add (t, g_strdup (dir_entry));
|
|
|
|
|
|
|
|
g_free (filename);
|
|
|
|
}
|
2016-01-24 07:01:36 +00:00
|
|
|
|
|
|
|
g_dir_close (dir);
|
2014-05-15 02:53:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
init_icons (GtkInspectorVisual *vis)
|
|
|
|
{
|
|
|
|
GHashTable *t;
|
|
|
|
GHashTableIter iter;
|
2020-07-24 18:40:36 +00:00
|
|
|
char *theme, *path;
|
2016-01-08 00:49:17 +00:00
|
|
|
GList *list, *l;
|
2019-12-14 05:50:26 +00:00
|
|
|
int i;
|
2020-07-26 13:34:08 +00:00
|
|
|
GtkStringList *names;
|
2014-05-15 02:53:32 +00:00
|
|
|
|
|
|
|
t = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
|
|
|
|
|
2015-01-09 20:28:53 +00:00
|
|
|
path = get_data_path ("icons");
|
|
|
|
fill_icons (path, t);
|
|
|
|
g_free (path);
|
2014-05-16 10:02:00 +00:00
|
|
|
|
2014-05-15 02:53:32 +00:00
|
|
|
path = g_build_filename (g_get_user_data_dir (), "icons", NULL);
|
|
|
|
fill_icons (path, t);
|
|
|
|
g_free (path);
|
|
|
|
|
2016-01-08 00:49:17 +00:00
|
|
|
list = NULL;
|
2014-05-15 02:53:32 +00:00
|
|
|
g_hash_table_iter_init (&iter, t);
|
|
|
|
while (g_hash_table_iter_next (&iter, (gpointer *)&theme, NULL))
|
2016-01-08 00:49:17 +00:00
|
|
|
list = g_list_insert_sorted (list, theme, (GCompareFunc)strcmp);
|
|
|
|
|
2020-07-26 13:34:08 +00:00
|
|
|
names = gtk_string_list_new (NULL);
|
2019-12-14 05:50:26 +00:00
|
|
|
for (l = list, i = 0; l; l = l->next, i++)
|
2020-07-26 13:34:08 +00:00
|
|
|
gtk_string_list_append (names, (const char *)l->data);
|
2016-01-08 00:49:17 +00:00
|
|
|
|
2014-05-15 02:53:32 +00:00
|
|
|
g_hash_table_destroy (t);
|
2016-01-08 00:49:17 +00:00
|
|
|
g_list_free (list);
|
2014-05-15 02:53:32 +00:00
|
|
|
|
2020-07-26 13:34:08 +00:00
|
|
|
gtk_drop_down_set_model (GTK_DROP_DOWN (vis->icon_combo), G_LIST_MODEL (names));
|
2019-12-14 05:50:26 +00:00
|
|
|
|
2020-07-18 04:17:42 +00:00
|
|
|
g_object_bind_property_full (gtk_settings_get_for_display (vis->display), "gtk-icon-theme-name",
|
|
|
|
vis->icon_combo, "selected",
|
2019-12-14 05:50:26 +00:00
|
|
|
G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE,
|
2020-07-26 13:34:08 +00:00
|
|
|
theme_to_pos, pos_to_theme, names, (GDestroyNotify)g_object_unref);
|
2014-05-15 02:53:32 +00:00
|
|
|
}
|
|
|
|
|
2014-12-13 04:14:34 +00:00
|
|
|
static void
|
2020-07-24 18:40:36 +00:00
|
|
|
fill_cursors (const char *path,
|
2014-12-13 04:14:34 +00:00
|
|
|
GHashTable *t)
|
|
|
|
{
|
2020-07-24 18:40:36 +00:00
|
|
|
const char *dir_entry;
|
2014-12-13 04:14:34 +00:00
|
|
|
GDir *dir;
|
|
|
|
|
|
|
|
dir = g_dir_open (path, 0, NULL);
|
|
|
|
if (!dir)
|
|
|
|
return;
|
|
|
|
|
|
|
|
while ((dir_entry = g_dir_read_name (dir)))
|
|
|
|
{
|
2020-07-24 18:40:36 +00:00
|
|
|
char *filename = g_build_filename (path, dir_entry, "cursors", NULL);
|
2014-12-13 04:14:34 +00:00
|
|
|
|
|
|
|
if (g_file_test (filename, G_FILE_TEST_IS_DIR) &&
|
|
|
|
!g_hash_table_contains (t, dir_entry))
|
|
|
|
g_hash_table_add (t, g_strdup (dir_entry));
|
|
|
|
|
|
|
|
g_free (filename);
|
|
|
|
}
|
2016-01-24 07:01:36 +00:00
|
|
|
|
|
|
|
g_dir_close (dir);
|
2014-12-13 04:14:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
init_cursors (GtkInspectorVisual *vis)
|
|
|
|
{
|
|
|
|
GHashTable *t;
|
|
|
|
GHashTableIter iter;
|
2020-07-24 18:40:36 +00:00
|
|
|
char *theme, *path;
|
2016-01-08 00:49:17 +00:00
|
|
|
GList *list, *l;
|
2020-07-26 13:34:08 +00:00
|
|
|
GtkStringList *names;
|
2019-12-14 05:50:26 +00:00
|
|
|
int i;
|
2014-12-13 04:14:34 +00:00
|
|
|
|
|
|
|
t = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
|
|
|
|
|
2015-01-09 20:28:53 +00:00
|
|
|
path = get_data_path ("icons");
|
|
|
|
fill_cursors (path, t);
|
|
|
|
g_free (path);
|
2014-12-13 04:14:34 +00:00
|
|
|
|
|
|
|
path = g_build_filename (g_get_user_data_dir (), "icons", NULL);
|
|
|
|
fill_cursors (path, t);
|
|
|
|
g_free (path);
|
|
|
|
|
2016-01-08 00:49:17 +00:00
|
|
|
list = NULL;
|
2014-12-13 04:14:34 +00:00
|
|
|
g_hash_table_iter_init (&iter, t);
|
|
|
|
while (g_hash_table_iter_next (&iter, (gpointer *)&theme, NULL))
|
2016-01-08 00:49:17 +00:00
|
|
|
list = g_list_insert_sorted (list, theme, (GCompareFunc)strcmp);
|
|
|
|
|
2020-07-26 13:34:08 +00:00
|
|
|
names = gtk_string_list_new (NULL);
|
2019-12-14 05:50:26 +00:00
|
|
|
for (l = list, i = 0; l; l = l->next, i++)
|
2020-07-26 13:34:08 +00:00
|
|
|
gtk_string_list_append (names, (const char *)l->data);
|
2016-01-08 00:49:17 +00:00
|
|
|
|
2014-12-13 04:14:34 +00:00
|
|
|
g_hash_table_destroy (t);
|
2016-01-08 00:49:17 +00:00
|
|
|
g_list_free (list);
|
2014-12-13 04:14:34 +00:00
|
|
|
|
2020-07-26 13:34:08 +00:00
|
|
|
gtk_drop_down_set_model (GTK_DROP_DOWN (vis->cursor_combo), G_LIST_MODEL (names));
|
2019-12-14 05:50:26 +00:00
|
|
|
|
2020-07-18 04:17:42 +00:00
|
|
|
g_object_bind_property_full (gtk_settings_get_for_display (vis->display), "gtk-cursor-theme-name",
|
|
|
|
vis->cursor_combo, "selected",
|
2019-12-14 05:50:26 +00:00
|
|
|
G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE,
|
2020-07-26 13:34:08 +00:00
|
|
|
theme_to_pos, pos_to_theme, names, (GDestroyNotify)g_object_unref);
|
2014-12-13 04:14:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
cursor_size_changed (GtkAdjustment *adjustment, GtkInspectorVisual *vis)
|
|
|
|
{
|
2020-07-24 13:54:49 +00:00
|
|
|
int size;
|
2014-12-13 04:14:34 +00:00
|
|
|
|
|
|
|
size = gtk_adjustment_get_value (adjustment);
|
2020-07-18 04:17:42 +00:00
|
|
|
g_object_set (gtk_settings_get_for_display (vis->display), "gtk-cursor-theme-size", size, NULL);
|
2014-12-13 04:14:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
init_cursor_size (GtkInspectorVisual *vis)
|
|
|
|
{
|
2020-07-24 13:54:49 +00:00
|
|
|
int size;
|
2014-12-13 04:14:34 +00:00
|
|
|
|
2020-07-18 04:17:42 +00:00
|
|
|
g_object_get (gtk_settings_get_for_display (vis->display), "gtk-cursor-theme-size", &size, NULL);
|
2014-12-13 04:14:34 +00:00
|
|
|
if (size == 0)
|
2018-01-17 04:21:32 +00:00
|
|
|
size = 32;
|
2014-12-13 04:14:34 +00:00
|
|
|
|
2020-07-24 20:32:16 +00:00
|
|
|
gtk_adjustment_set_value (vis->scale_adjustment, (double)size);
|
2020-07-18 04:17:42 +00:00
|
|
|
g_signal_connect (vis->cursor_size_adjustment, "value-changed",
|
2014-12-13 04:14:34 +00:00
|
|
|
G_CALLBACK (cursor_size_changed), vis);
|
|
|
|
}
|
|
|
|
|
2014-07-19 23:15:58 +00:00
|
|
|
static void
|
|
|
|
init_font (GtkInspectorVisual *vis)
|
|
|
|
{
|
2020-07-18 04:17:42 +00:00
|
|
|
g_object_bind_property (gtk_settings_get_for_display (vis->display),
|
2019-12-07 17:07:12 +00:00
|
|
|
"gtk-font-name",
|
2020-07-18 04:17:42 +00:00
|
|
|
vis->font_button, "font",
|
2014-07-19 23:15:58 +00:00
|
|
|
G_BINDING_BIDIRECTIONAL|G_BINDING_SYNC_CREATE);
|
|
|
|
}
|
|
|
|
|
2016-03-25 12:42:31 +00:00
|
|
|
static void
|
|
|
|
init_font_scale (GtkInspectorVisual *vis)
|
|
|
|
{
|
2016-11-24 00:16:16 +00:00
|
|
|
double scale;
|
|
|
|
|
|
|
|
scale = get_font_scale (vis);
|
|
|
|
update_font_scale (vis, scale, TRUE, TRUE);
|
2020-07-18 04:17:42 +00:00
|
|
|
g_signal_connect (vis->font_scale_adjustment, "value-changed",
|
2016-04-09 15:46:12 +00:00
|
|
|
G_CALLBACK (font_scale_adjustment_changed), vis);
|
2020-07-18 04:17:42 +00:00
|
|
|
g_signal_connect (vis->font_scale_entry, "activate",
|
2016-04-09 15:46:12 +00:00
|
|
|
G_CALLBACK (font_scale_entry_activated), vis);
|
2016-03-25 12:42:31 +00:00
|
|
|
}
|
|
|
|
|
2014-10-25 19:23:16 +00:00
|
|
|
#if defined (GDK_WINDOWING_X11)
|
2014-07-12 05:43:03 +00:00
|
|
|
static void
|
|
|
|
scale_changed (GtkAdjustment *adjustment, GtkInspectorVisual *vis)
|
|
|
|
{
|
2020-07-24 13:54:49 +00:00
|
|
|
int scale;
|
2014-07-12 05:43:03 +00:00
|
|
|
|
|
|
|
scale = gtk_adjustment_get_value (adjustment);
|
2020-07-18 04:17:42 +00:00
|
|
|
gdk_x11_display_set_surface_scale (vis->display, scale);
|
2014-07-12 05:43:03 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static void
|
|
|
|
init_scale (GtkInspectorVisual *vis)
|
|
|
|
{
|
2014-10-25 19:23:16 +00:00
|
|
|
#if defined (GDK_WINDOWING_X11)
|
2020-07-18 04:17:42 +00:00
|
|
|
if (GDK_IS_X11_DISPLAY (vis->display))
|
2014-07-12 05:43:03 +00:00
|
|
|
{
|
2020-07-24 20:32:16 +00:00
|
|
|
double scale;
|
2014-07-12 05:43:03 +00:00
|
|
|
|
2020-07-18 04:17:42 +00:00
|
|
|
scale = gdk_monitor_get_scale_factor (gdk_x11_display_get_primary_monitor (vis->display));
|
|
|
|
gtk_adjustment_set_value (vis->scale_adjustment, scale);
|
|
|
|
g_signal_connect (vis->scale_adjustment, "value-changed",
|
2014-07-12 05:43:03 +00:00
|
|
|
G_CALLBACK (scale_changed), vis);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
2019-04-06 17:39:00 +00:00
|
|
|
GtkWidget *row;
|
|
|
|
|
2020-07-18 04:17:42 +00:00
|
|
|
gtk_adjustment_set_value (vis->scale_adjustment, 1);
|
|
|
|
gtk_widget_set_sensitive (vis->hidpi_spin, FALSE);
|
|
|
|
row = gtk_widget_get_ancestor (vis->hidpi_spin, GTK_TYPE_LIST_BOX_ROW);
|
2019-04-06 17:39:00 +00:00
|
|
|
gtk_widget_set_tooltip_text (row, _("Backend does not support window scaling"));
|
2014-07-12 05:43:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-04 22:03:37 +00:00
|
|
|
static void
|
|
|
|
init_animation (GtkInspectorVisual *vis)
|
|
|
|
{
|
2020-07-18 04:17:42 +00:00
|
|
|
g_object_bind_property (gtk_settings_get_for_display (vis->display), "gtk-enable-animations",
|
|
|
|
vis->animation_switch, "active",
|
2014-08-04 22:03:37 +00:00
|
|
|
G_BINDING_BIDIRECTIONAL|G_BINDING_SYNC_CREATE);
|
|
|
|
}
|
|
|
|
|
2016-03-14 10:38:55 +00:00
|
|
|
static void
|
|
|
|
update_slowdown (GtkInspectorVisual *vis,
|
2020-07-24 20:32:16 +00:00
|
|
|
double slowdown,
|
2016-03-14 10:38:55 +00:00
|
|
|
gboolean update_adjustment,
|
|
|
|
gboolean update_entry)
|
|
|
|
{
|
|
|
|
_gtk_set_slowdown (slowdown);
|
|
|
|
|
|
|
|
if (update_adjustment)
|
2020-07-18 04:17:42 +00:00
|
|
|
gtk_adjustment_set_value (vis->slowdown_adjustment,
|
2016-03-14 10:38:55 +00:00
|
|
|
log2 (slowdown));
|
|
|
|
|
|
|
|
if (update_entry)
|
|
|
|
{
|
2020-07-24 18:40:36 +00:00
|
|
|
char *str = g_strdup_printf ("%0.*f", 2, slowdown);
|
2016-03-14 10:38:55 +00:00
|
|
|
|
2020-07-18 04:17:42 +00:00
|
|
|
gtk_editable_set_text (GTK_EDITABLE (vis->slowdown_entry), str);
|
2016-03-14 10:38:55 +00:00
|
|
|
g_free (str);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
slowdown_adjustment_changed (GtkAdjustment *adjustment,
|
|
|
|
GtkInspectorVisual *vis)
|
|
|
|
{
|
2020-07-24 20:32:16 +00:00
|
|
|
double value = gtk_adjustment_get_value (adjustment);
|
|
|
|
double previous = CLAMP (log2 (_gtk_get_slowdown ()),
|
2016-03-14 10:38:55 +00:00
|
|
|
gtk_adjustment_get_lower (adjustment),
|
|
|
|
gtk_adjustment_get_upper (adjustment));
|
|
|
|
|
|
|
|
if (fabs (value - previous) > EPSILON)
|
|
|
|
update_slowdown (vis, exp2 (value), FALSE, TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
slowdown_entry_activated (GtkEntry *entry,
|
|
|
|
GtkInspectorVisual *vis)
|
|
|
|
{
|
2020-07-24 20:32:16 +00:00
|
|
|
double slowdown;
|
2020-07-24 18:40:36 +00:00
|
|
|
char *err = NULL;
|
2016-03-14 10:38:55 +00:00
|
|
|
|
2019-02-28 19:31:36 +00:00
|
|
|
slowdown = g_strtod (gtk_editable_get_text (GTK_EDITABLE (entry)), &err);
|
2016-03-14 10:38:55 +00:00
|
|
|
if (err != NULL)
|
|
|
|
update_slowdown (vis, slowdown, TRUE, FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
init_slowdown (GtkInspectorVisual *vis)
|
|
|
|
{
|
|
|
|
update_slowdown (vis, _gtk_get_slowdown (), TRUE, TRUE);
|
2020-07-18 04:17:42 +00:00
|
|
|
g_signal_connect (vis->slowdown_adjustment, "value-changed",
|
2016-03-14 10:38:55 +00:00
|
|
|
G_CALLBACK (slowdown_adjustment_changed), vis);
|
2020-07-18 04:17:42 +00:00
|
|
|
g_signal_connect (vis->slowdown_entry, "activate",
|
2016-03-14 10:38:55 +00:00
|
|
|
G_CALLBACK (slowdown_entry_activated), vis);
|
|
|
|
}
|
|
|
|
|
2014-07-12 05:43:03 +00:00
|
|
|
static void
|
|
|
|
update_touchscreen (GtkSwitch *sw)
|
|
|
|
{
|
|
|
|
GtkDebugFlag flags;
|
|
|
|
|
|
|
|
flags = gtk_get_debug_flags ();
|
|
|
|
|
|
|
|
if (gtk_switch_get_active (sw))
|
|
|
|
flags |= GTK_DEBUG_TOUCHSCREEN;
|
|
|
|
else
|
|
|
|
flags &= ~GTK_DEBUG_TOUCHSCREEN;
|
|
|
|
|
|
|
|
gtk_set_debug_flags (flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
init_touchscreen (GtkInspectorVisual *vis)
|
|
|
|
{
|
2020-07-18 04:17:42 +00:00
|
|
|
gtk_switch_set_active (GTK_SWITCH (vis->touchscreen_switch), (gtk_get_debug_flags () & GTK_DEBUG_TOUCHSCREEN) != 0);
|
|
|
|
g_signal_connect (vis->touchscreen_switch, "notify::active",
|
2014-07-12 05:43:03 +00:00
|
|
|
G_CALLBACK (update_touchscreen), NULL);
|
|
|
|
|
|
|
|
if (g_getenv ("GTK_TEST_TOUCHSCREEN") != 0)
|
|
|
|
{
|
2019-04-06 17:39:00 +00:00
|
|
|
GtkWidget *row;
|
|
|
|
|
2014-07-12 05:43:03 +00:00
|
|
|
/* hardcoded, nothing we can do */
|
2020-07-18 04:17:42 +00:00
|
|
|
gtk_switch_set_active (GTK_SWITCH (vis->touchscreen_switch), TRUE);
|
|
|
|
gtk_widget_set_sensitive (vis->touchscreen_switch, FALSE);
|
|
|
|
row = gtk_widget_get_ancestor (vis->touchscreen_switch, GTK_TYPE_LIST_BOX_ROW);
|
2019-04-06 17:39:00 +00:00
|
|
|
gtk_widget_set_tooltip_text (row, _("Setting is hardcoded by GTK_TEST_TOUCHSCREEN"));
|
2014-07-12 05:43:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
keynav_failed (GtkWidget *widget, GtkDirectionType direction, GtkInspectorVisual *vis)
|
|
|
|
{
|
|
|
|
GtkWidget *next;
|
|
|
|
|
|
|
|
if (direction == GTK_DIR_DOWN &&
|
2020-07-18 04:17:42 +00:00
|
|
|
widget == vis->visual_box)
|
|
|
|
next = vis->debug_box;
|
2014-11-07 04:29:49 +00:00
|
|
|
else if (direction == GTK_DIR_DOWN &&
|
2020-07-18 04:17:42 +00:00
|
|
|
widget == vis->debug_box)
|
|
|
|
next = vis->misc_box;
|
2014-07-12 05:43:03 +00:00
|
|
|
else if (direction == GTK_DIR_UP &&
|
2020-07-18 04:17:42 +00:00
|
|
|
widget == vis->debug_box)
|
|
|
|
next = vis->visual_box;
|
2014-11-07 04:29:49 +00:00
|
|
|
else if (direction == GTK_DIR_UP &&
|
2020-07-18 04:17:42 +00:00
|
|
|
widget == vis->misc_box)
|
|
|
|
next = vis->debug_box;
|
2015-01-09 20:28:53 +00:00
|
|
|
else
|
2014-07-12 05:43:03 +00:00
|
|
|
next = NULL;
|
|
|
|
|
|
|
|
if (next)
|
|
|
|
{
|
|
|
|
gtk_widget_child_focus (next, direction);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-04-12 02:06:16 +00:00
|
|
|
static void
|
|
|
|
row_activated (GtkListBox *box,
|
|
|
|
GtkListBoxRow *row,
|
|
|
|
GtkInspectorVisual *vis)
|
|
|
|
{
|
2020-07-18 04:17:42 +00:00
|
|
|
if (gtk_widget_is_ancestor (vis->dark_switch, GTK_WIDGET (row)))
|
2019-04-12 02:06:16 +00:00
|
|
|
{
|
2020-07-18 04:17:42 +00:00
|
|
|
GtkSwitch *sw = GTK_SWITCH (vis->dark_switch);
|
2019-04-12 02:06:16 +00:00
|
|
|
gtk_switch_set_active (sw, !gtk_switch_get_active (sw));
|
|
|
|
}
|
2020-07-18 04:17:42 +00:00
|
|
|
else if (gtk_widget_is_ancestor (vis->animation_switch, GTK_WIDGET (row)))
|
2019-04-12 02:06:16 +00:00
|
|
|
{
|
2020-07-18 04:17:42 +00:00
|
|
|
GtkSwitch *sw = GTK_SWITCH (vis->animation_switch);
|
2019-04-12 02:06:16 +00:00
|
|
|
gtk_switch_set_active (sw, !gtk_switch_get_active (sw));
|
|
|
|
}
|
2020-07-18 04:17:42 +00:00
|
|
|
else if (gtk_widget_is_ancestor (vis->fps_switch, GTK_WIDGET (row)))
|
2019-04-12 02:06:16 +00:00
|
|
|
{
|
2020-07-18 04:17:42 +00:00
|
|
|
GtkSwitch *sw = GTK_SWITCH (vis->fps_switch);
|
2019-04-12 02:06:16 +00:00
|
|
|
gtk_switch_set_active (sw, !gtk_switch_get_active (sw));
|
|
|
|
}
|
2020-07-18 04:17:42 +00:00
|
|
|
else if (gtk_widget_is_ancestor (vis->updates_switch, GTK_WIDGET (row)))
|
2019-04-12 02:06:16 +00:00
|
|
|
{
|
2020-07-18 04:17:42 +00:00
|
|
|
GtkSwitch *sw = GTK_SWITCH (vis->updates_switch);
|
2019-04-12 02:06:16 +00:00
|
|
|
gtk_switch_set_active (sw, !gtk_switch_get_active (sw));
|
|
|
|
}
|
2020-07-18 04:17:42 +00:00
|
|
|
else if (gtk_widget_is_ancestor (vis->fallback_switch, GTK_WIDGET (row)))
|
2019-10-31 02:31:27 +00:00
|
|
|
{
|
2020-07-18 04:17:42 +00:00
|
|
|
GtkSwitch *sw = GTK_SWITCH (vis->fallback_switch);
|
2019-10-31 02:31:27 +00:00
|
|
|
gtk_switch_set_active (sw, !gtk_switch_get_active (sw));
|
|
|
|
}
|
2020-07-18 04:17:42 +00:00
|
|
|
else if (gtk_widget_is_ancestor (vis->baselines_switch, GTK_WIDGET (row)))
|
2019-04-12 02:06:16 +00:00
|
|
|
{
|
2020-07-18 04:17:42 +00:00
|
|
|
GtkSwitch *sw = GTK_SWITCH (vis->baselines_switch);
|
2019-04-12 02:06:16 +00:00
|
|
|
gtk_switch_set_active (sw, !gtk_switch_get_active (sw));
|
|
|
|
}
|
2020-07-18 04:17:42 +00:00
|
|
|
else if (gtk_widget_is_ancestor (vis->layout_switch, GTK_WIDGET (row)))
|
2019-04-12 02:06:16 +00:00
|
|
|
{
|
2020-07-18 04:17:42 +00:00
|
|
|
GtkSwitch *sw = GTK_SWITCH (vis->layout_switch);
|
2019-04-12 02:06:16 +00:00
|
|
|
gtk_switch_set_active (sw, !gtk_switch_get_active (sw));
|
|
|
|
}
|
2020-07-18 04:17:42 +00:00
|
|
|
else if (gtk_widget_is_ancestor (vis->focus_switch, GTK_WIDGET (row)))
|
2019-12-27 17:16:14 +00:00
|
|
|
{
|
2020-07-18 04:17:42 +00:00
|
|
|
GtkSwitch *sw = GTK_SWITCH (vis->focus_switch);
|
2019-12-27 17:16:14 +00:00
|
|
|
gtk_switch_set_active (sw, !gtk_switch_get_active (sw));
|
|
|
|
}
|
2020-07-18 04:17:42 +00:00
|
|
|
else if (gtk_widget_is_ancestor (vis->touchscreen_switch, GTK_WIDGET (row)))
|
2019-04-12 02:06:16 +00:00
|
|
|
{
|
2020-07-18 04:17:42 +00:00
|
|
|
GtkSwitch *sw = GTK_SWITCH (vis->touchscreen_switch);
|
2019-04-12 02:06:16 +00:00
|
|
|
gtk_switch_set_active (sw, !gtk_switch_get_active (sw));
|
|
|
|
}
|
2020-07-18 04:17:42 +00:00
|
|
|
else if (gtk_widget_is_ancestor (vis->software_gl_switch, GTK_WIDGET (row)))
|
2019-04-12 02:06:16 +00:00
|
|
|
{
|
2020-07-18 04:17:42 +00:00
|
|
|
GtkSwitch *sw = GTK_SWITCH (vis->software_gl_switch);
|
2019-04-12 02:06:16 +00:00
|
|
|
gtk_switch_set_active (sw, !gtk_switch_get_active (sw));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-07 04:29:49 +00:00
|
|
|
static void
|
|
|
|
init_gl (GtkInspectorVisual *vis)
|
|
|
|
{
|
2020-07-18 04:17:42 +00:00
|
|
|
GdkDebugFlags flags = gdk_display_get_debug_flags (vis->display);
|
2014-11-07 04:29:49 +00:00
|
|
|
|
2020-07-18 04:17:42 +00:00
|
|
|
gtk_switch_set_active (GTK_SWITCH (vis->software_gl_switch), flags & GDK_DEBUG_GL_SOFTWARE);
|
2014-11-07 04:29:49 +00:00
|
|
|
|
2018-01-11 13:53:57 +00:00
|
|
|
if (flags & GDK_DEBUG_GL_DISABLE)
|
2014-11-07 04:29:49 +00:00
|
|
|
{
|
2019-04-06 17:39:00 +00:00
|
|
|
GtkWidget *row;
|
|
|
|
|
2020-07-18 04:17:42 +00:00
|
|
|
gtk_widget_set_sensitive (vis->software_gl_switch, FALSE);
|
|
|
|
row = gtk_widget_get_ancestor (vis->software_gl_switch, GTK_TYPE_LIST_BOX_ROW);
|
2019-04-06 17:39:00 +00:00
|
|
|
gtk_widget_set_tooltip_text (row, _("GL rendering is disabled"));
|
2014-11-07 04:29:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-01-11 13:53:57 +00:00
|
|
|
update_gl_flag (GtkSwitch *sw,
|
2019-12-07 17:07:12 +00:00
|
|
|
GdkDebugFlags flag,
|
|
|
|
GtkInspectorVisual *vis)
|
2014-11-07 04:29:49 +00:00
|
|
|
{
|
2020-07-18 04:17:42 +00:00
|
|
|
GdkDebugFlags flags = gdk_display_get_debug_flags (vis->display);
|
2014-11-07 04:29:49 +00:00
|
|
|
|
|
|
|
if (gtk_switch_get_active (sw))
|
|
|
|
flags |= flag;
|
|
|
|
else
|
|
|
|
flags &= ~flag;
|
|
|
|
|
2020-07-18 04:17:42 +00:00
|
|
|
gdk_display_set_debug_flags (vis->display, flags);
|
2014-11-07 04:29:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2019-12-07 17:07:12 +00:00
|
|
|
software_gl_activate (GtkSwitch *sw,
|
2020-02-28 19:42:19 +00:00
|
|
|
GParamSpec *pspec,
|
2019-12-07 17:07:12 +00:00
|
|
|
GtkInspectorVisual *vis)
|
2014-11-07 04:29:49 +00:00
|
|
|
{
|
2019-12-07 17:07:12 +00:00
|
|
|
update_gl_flag (sw, GDK_DEBUG_GL_SOFTWARE, vis);
|
2014-11-07 04:29:49 +00:00
|
|
|
}
|
|
|
|
|
2014-05-15 02:53:32 +00:00
|
|
|
static void
|
|
|
|
gtk_inspector_visual_init (GtkInspectorVisual *vis)
|
|
|
|
{
|
|
|
|
gtk_widget_init_template (GTK_WIDGET (vis));
|
2014-07-12 05:43:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_inspector_visual_constructed (GObject *object)
|
|
|
|
{
|
|
|
|
GtkInspectorVisual *vis = GTK_INSPECTOR_VISUAL (object);
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (gtk_inspector_visual_parent_class)->constructed (object);
|
|
|
|
|
2020-07-18 04:17:42 +00:00
|
|
|
g_signal_connect (vis->visual_box, "keynav-failed", G_CALLBACK (keynav_failed), vis);
|
|
|
|
g_signal_connect (vis->debug_box, "keynav-failed", G_CALLBACK (keynav_failed), vis);
|
|
|
|
g_signal_connect (vis->misc_box, "keynav-failed", G_CALLBACK (keynav_failed), vis);
|
|
|
|
g_signal_connect (vis->visual_box, "row-activated", G_CALLBACK (row_activated), vis);
|
|
|
|
g_signal_connect (vis->debug_box, "row-activated", G_CALLBACK (row_activated), vis);
|
|
|
|
g_signal_connect (vis->misc_box, "row-activated", G_CALLBACK (row_activated), vis);
|
2014-05-11 01:19:21 +00:00
|
|
|
}
|
|
|
|
|
2020-03-22 14:41:21 +00:00
|
|
|
static void
|
|
|
|
gtk_inspector_visual_dispose (GObject *object)
|
2019-04-06 15:46:14 +00:00
|
|
|
{
|
|
|
|
GtkInspectorVisual *vis = GTK_INSPECTOR_VISUAL (object);
|
2019-05-20 04:47:50 +00:00
|
|
|
GtkInspectorWindow *iw = GTK_INSPECTOR_WINDOW (gtk_widget_get_root (GTK_WIDGET (vis)));
|
2019-04-06 15:46:14 +00:00
|
|
|
|
2020-07-18 04:17:42 +00:00
|
|
|
g_clear_pointer (&vis->swin, gtk_widget_unparent);
|
2019-04-06 15:46:14 +00:00
|
|
|
|
2020-07-18 04:17:42 +00:00
|
|
|
if (vis->layout_overlay)
|
|
|
|
{
|
|
|
|
gtk_inspector_window_remove_overlay (iw, vis->layout_overlay);
|
|
|
|
vis->layout_overlay = NULL;
|
|
|
|
}
|
|
|
|
if (vis->updates_overlay)
|
|
|
|
{
|
|
|
|
gtk_inspector_window_remove_overlay (iw, vis->updates_overlay);
|
|
|
|
vis->updates_overlay = NULL;
|
|
|
|
}
|
|
|
|
if (vis->fps_overlay)
|
|
|
|
{
|
|
|
|
gtk_inspector_window_remove_overlay (iw, vis->fps_overlay);
|
|
|
|
vis->fps_overlay = NULL;
|
|
|
|
}
|
|
|
|
if (vis->focus_overlay)
|
|
|
|
{
|
|
|
|
gtk_inspector_window_remove_overlay (iw, vis->focus_overlay);
|
|
|
|
vis->focus_overlay = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (gtk_inspector_visual_parent_class)->dispose (object);
|
2019-04-06 15:46:14 +00:00
|
|
|
}
|
|
|
|
|
2014-05-11 01:19:21 +00:00
|
|
|
static void
|
|
|
|
gtk_inspector_visual_class_init (GtkInspectorVisualClass *klass)
|
|
|
|
{
|
|
|
|
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
2014-07-12 05:43:03 +00:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
|
|
|
object_class->constructed = gtk_inspector_visual_constructed;
|
2020-03-22 14:41:21 +00:00
|
|
|
object_class->dispose = gtk_inspector_visual_dispose;
|
2014-05-11 01:19:21 +00:00
|
|
|
|
2014-11-30 20:59:53 +00:00
|
|
|
gtk_widget_class_set_template_from_resource (widget_class, "/org/gtk/libgtk/inspector/visual.ui");
|
2020-07-18 04:17:42 +00:00
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkInspectorVisual, swin);
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkInspectorVisual, box);
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkInspectorVisual, direction_combo);
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkInspectorVisual, theme_combo);
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkInspectorVisual, dark_switch);
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkInspectorVisual, cursor_combo);
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkInspectorVisual, cursor_size_spin);
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkInspectorVisual, cursor_size_adjustment);
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkInspectorVisual, icon_combo);
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkInspectorVisual, hidpi_spin);
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkInspectorVisual, scale_adjustment);
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkInspectorVisual, animation_switch);
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkInspectorVisual, slowdown_adjustment);
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkInspectorVisual, slowdown_entry);
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkInspectorVisual, touchscreen_switch);
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkInspectorVisual, visual_box);
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkInspectorVisual, debug_box);
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkInspectorVisual, font_button);
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkInspectorVisual, misc_box);
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkInspectorVisual, software_gl_switch);
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkInspectorVisual, font_scale_entry);
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkInspectorVisual, font_scale_adjustment);
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkInspectorVisual, fps_switch);
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkInspectorVisual, updates_switch);
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkInspectorVisual, fallback_switch);
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkInspectorVisual, baselines_switch);
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkInspectorVisual, layout_switch);
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkInspectorVisual, focus_switch);
|
2014-05-15 02:53:32 +00:00
|
|
|
|
2018-04-05 10:58:46 +00:00
|
|
|
gtk_widget_class_bind_template_callback (widget_class, fps_activate);
|
2018-04-04 11:22:28 +00:00
|
|
|
gtk_widget_class_bind_template_callback (widget_class, updates_activate);
|
2019-10-31 02:31:27 +00:00
|
|
|
gtk_widget_class_bind_template_callback (widget_class, fallback_activate);
|
2014-05-11 01:19:21 +00:00
|
|
|
gtk_widget_class_bind_template_callback (widget_class, direction_changed);
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, baselines_activate);
|
2016-03-11 05:17:37 +00:00
|
|
|
gtk_widget_class_bind_template_callback (widget_class, layout_activate);
|
2019-12-27 17:16:14 +00:00
|
|
|
gtk_widget_class_bind_template_callback (widget_class, focus_activate);
|
2014-11-07 04:29:49 +00:00
|
|
|
gtk_widget_class_bind_template_callback (widget_class, software_gl_activate);
|
2020-03-22 14:41:21 +00:00
|
|
|
|
|
|
|
gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BIN_LAYOUT);
|
2014-05-11 01:19:21 +00:00
|
|
|
}
|
|
|
|
|
2019-12-07 17:07:12 +00:00
|
|
|
void
|
|
|
|
gtk_inspector_visual_set_display (GtkInspectorVisual *vis,
|
|
|
|
GdkDisplay *display)
|
|
|
|
{
|
2020-07-18 04:17:42 +00:00
|
|
|
vis->display = display;
|
2019-12-07 17:07:12 +00:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2014-05-11 01:19:21 +00:00
|
|
|
// vim: set et sw=2 ts=2:
|