Merge branch 'inspector-display' into 'master'

Inspector display

See merge request GNOME/gtk!1234
This commit is contained in:
Matthias Clasen 2019-12-07 23:20:51 +00:00
commit 7b14c65b41
19 changed files with 379 additions and 244 deletions

View File

@ -75,7 +75,6 @@
#include "a11y/gtkwindowaccessibleprivate.h"
#include "a11y/gtkcontaineraccessibleprivate.h"
#include "inspector/init.h"
#include "inspector/window.h"
#include "gdk/gdktextureprivate.h"
@ -574,7 +573,6 @@ static GtkWindowRegion get_active_region_type (GtkWindow *window,
gint x,
gint y);
static void gtk_window_update_debugging (void);
G_DEFINE_TYPE_WITH_CODE (GtkWindow, gtk_window, GTK_TYPE_BIN,
G_ADD_PRIVATE (GtkWindow)
@ -1828,7 +1826,6 @@ gtk_window_init (GtkWindow *window)
g_object_ref_sink (window);
priv->has_user_ref_count = TRUE;
gtk_window_update_debugging ();
#ifdef GDK_WINDOWING_X11
g_signal_connect (gtk_settings_get_for_display (priv->display),
@ -4651,7 +4648,6 @@ gtk_window_destroy (GtkWidget *widget)
else
g_object_unref (item);
}
gtk_window_update_debugging ();
if (priv->transient_parent)
gtk_window_set_transient_for (window, NULL);
@ -8969,11 +8965,12 @@ _gtk_window_raise_popover (GtkWindow *window,
}
}
static GtkWidget *inspector_window = NULL;
static guint gtk_window_update_debugging_id;
static void set_warn_again (gboolean warn);
static void gtk_window_set_debugging (GdkDisplay *display,
gboolean enable,
gboolean toggle,
gboolean select,
gboolean warn);
static void
warn_response (GtkDialog *dialog,
@ -8981,67 +8978,49 @@ warn_response (GtkDialog *dialog,
{
GtkWidget *check;
gboolean remember;
GtkWidget *inspector_window;
GdkDisplay *display;
inspector_window = GTK_WIDGET (gtk_window_get_transient_for (GTK_WINDOW (dialog)));
display = gtk_inspector_window_get_inspected_display (GTK_INSPECTOR_WINDOW (inspector_window));
check = g_object_get_data (G_OBJECT (dialog), "check");
remember = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check));
gtk_widget_destroy (GTK_WIDGET (dialog));
g_object_set_data (G_OBJECT (inspector_window), "warning_dialog", NULL);
if (response == GTK_RESPONSE_NO)
{
GtkWidget *window;
if (gtk_window_update_debugging_id)
{
g_source_remove (gtk_window_update_debugging_id);
gtk_window_update_debugging_id = 0;
}
/* Steal reference into temp variable, so not to mess up with
* inspector_window during gtk_widget_destroy().
*/
window = inspector_window;
inspector_window = NULL;
gtk_widget_destroy (window);
}
gtk_window_set_debugging (display, FALSE, FALSE, FALSE, FALSE);
else
{
set_warn_again (!remember);
}
}
static gboolean
update_debugging (gpointer data)
{
gtk_window_update_debugging_id = 0;
return G_SOURCE_REMOVE;
set_warn_again (!remember);
}
static void
gtk_window_update_debugging (void)
{
if (inspector_window &&
gtk_window_update_debugging_id == 0)
{
gtk_window_update_debugging_id = g_idle_add (update_debugging, NULL);
g_source_set_name_by_id (gtk_window_update_debugging_id, "[gtk] gtk_window_update_debugging");
}
}
static void
gtk_window_set_debugging (gboolean enable,
gboolean select,
gboolean warn)
gtk_window_set_debugging (GdkDisplay *display,
gboolean enable,
gboolean toggle,
gboolean select,
gboolean warn)
{
GtkWidget *dialog = NULL;
GtkWidget *area;
GtkWidget *check;
GtkWidget *inspector_window;
gboolean was_debugging;
if (inspector_window == NULL)
was_debugging = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (display), "-gtk-debugging-enabled"));
if (toggle)
enable = !was_debugging;
g_object_set_data (G_OBJECT (display), "-gtk-debugging-enabled", GINT_TO_POINTER (enable));
if (enable)
{
gtk_inspector_init ();
inspector_window = gtk_inspector_window_new ();
gtk_window_set_hide_on_close (GTK_WINDOW (inspector_window), TRUE);
inspector_window = gtk_inspector_window_get (display);
gtk_window_present (GTK_WINDOW (inspector_window));
if (warn)
{
@ -9063,26 +9042,19 @@ gtk_window_set_debugging (gboolean enable,
g_object_set_data (G_OBJECT (dialog), "check", check);
gtk_dialog_add_button (GTK_DIALOG (dialog), _("_Cancel"), GTK_RESPONSE_NO);
gtk_dialog_add_button (GTK_DIALOG (dialog), _("_OK"), GTK_RESPONSE_YES);
g_signal_connect (dialog, "response", G_CALLBACK (warn_response), NULL);
g_signal_connect (dialog, "response", G_CALLBACK (warn_response), inspector_window);
g_object_set_data (G_OBJECT (inspector_window), "warning_dialog", dialog);
gtk_widget_show (dialog);
}
}
dialog = g_object_get_data (G_OBJECT (inspector_window), "warning_dialog");
if (enable)
{
gtk_window_present (GTK_WINDOW (inspector_window));
if (dialog)
gtk_widget_show (dialog);
if (select)
gtk_inspector_window_select_widget_under_pointer (GTK_INSPECTOR_WINDOW (inspector_window));
}
else
else if (was_debugging)
{
if (dialog)
gtk_widget_hide (dialog);
inspector_window = gtk_inspector_window_get (display);
gtk_widget_hide (inspector_window);
}
}
@ -9098,7 +9070,9 @@ gtk_window_set_debugging (gboolean enable,
void
gtk_window_set_interactive_debugging (gboolean enable)
{
gtk_window_set_debugging (enable, FALSE, FALSE);
GdkDisplay *display = gdk_display_get_default ();
gtk_window_set_debugging (display, enable, FALSE, FALSE, FALSE);
}
static gboolean
@ -9150,21 +9124,13 @@ static gboolean
gtk_window_enable_debugging (GtkWindow *window,
gboolean toggle)
{
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
gboolean warn;
if (!inspector_keybinding_enabled (&warn))
return FALSE;
if (toggle)
{
if (GTK_IS_WIDGET (inspector_window) &&
gtk_widget_is_visible (inspector_window))
gtk_window_set_debugging (FALSE, FALSE, FALSE);
else
gtk_window_set_debugging (TRUE, FALSE, warn);
}
else
gtk_window_set_debugging (TRUE, TRUE, warn);
gtk_window_set_debugging (priv->display, TRUE, toggle, !toggle, warn);
return TRUE;
}

View File

@ -23,6 +23,7 @@
#include "config.h"
#include <glib/gi18n-lib.h>
#include "window.h"
#include "css-editor.h"
#include "gtkcssprovider.h"
@ -42,6 +43,7 @@ struct _GtkInspectorCssEditorPrivate
{
GtkWidget *view;
GtkTextBuffer *text;
GdkDisplay *display;
GtkCssProvider *provider;
GtkToggleButton *disable_button;
guint timeout;
@ -157,11 +159,14 @@ static void
disable_toggled (GtkToggleButton *button,
GtkInspectorCssEditor *ce)
{
if (!ce->priv->display)
return;
if (gtk_toggle_button_get_active (button))
gtk_style_context_remove_provider_for_display (gdk_display_get_default (),
gtk_style_context_remove_provider_for_display (ce->priv->display,
GTK_STYLE_PROVIDER (ce->priv->provider));
else
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
gtk_style_context_add_provider_for_display (ce->priv->display,
GTK_STYLE_PROVIDER (ce->priv->provider),
GTK_STYLE_PROVIDER_PRIORITY_USER);
}
@ -326,22 +331,35 @@ static void
create_provider (GtkInspectorCssEditor *ce)
{
ce->priv->provider = gtk_css_provider_new ();
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
GTK_STYLE_PROVIDER (ce->priv->provider),
GTK_STYLE_PROVIDER_PRIORITY_USER);
g_signal_connect (ce->priv->provider, "parsing-error",
G_CALLBACK (show_parsing_error), ce);
}
static void
destroy_provider (GtkInspectorCssEditor *ce)
{
gtk_style_context_remove_provider_for_display (gdk_display_get_default (),
GTK_STYLE_PROVIDER (ce->priv->provider));
g_signal_handlers_disconnect_by_func (ce->priv->provider, show_parsing_error, ce);
g_clear_object (&ce->priv->provider);
}
static void
add_provider (GtkInspectorCssEditor *ce,
GdkDisplay *display)
{
gtk_style_context_add_provider_for_display (display,
GTK_STYLE_PROVIDER (ce->priv->provider),
GTK_STYLE_PROVIDER_PRIORITY_USER);
}
static void
remove_provider (GtkInspectorCssEditor *ce,
GdkDisplay *display)
{
gtk_style_context_remove_provider_for_display (display,
GTK_STYLE_PROVIDER (ce->priv->provider));
}
static void
gtk_inspector_css_editor_init (GtkInspectorCssEditor *ce)
{
@ -355,7 +373,6 @@ constructed (GObject *object)
GtkInspectorCssEditor *ce = GTK_INSPECTOR_CSS_EDITOR (object);
create_provider (ce);
set_initial_text (ce);
}
static void
@ -366,6 +383,8 @@ finalize (GObject *object)
if (ce->priv->timeout != 0)
g_source_remove (ce->priv->timeout);
if (ce->priv->display)
remove_provider (ce, ce->priv->display);
destroy_provider (ce);
g_list_free_full (ce->priv->errors, css_error_free);
@ -392,4 +411,13 @@ gtk_inspector_css_editor_class_init (GtkInspectorCssEditorClass *klass)
gtk_widget_class_bind_template_callback (widget_class, query_tooltip_cb);
}
void
gtk_inspector_css_editor_set_display (GtkInspectorCssEditor *ce,
GdkDisplay *display)
{
ce->priv->display = display;
add_provider (ce, display);
set_initial_text (ce);
}
// vim: set et sw=2 ts=2:

View File

@ -49,8 +49,8 @@ typedef struct _GtkInspectorCssEditorClass
G_BEGIN_DECLS
GType gtk_inspector_css_editor_get_type (void);
void gtk_inspector_css_editor_set_object (GtkInspectorCssEditor *ce,
GObject *object);
void gtk_inspector_css_editor_set_display (GtkInspectorCssEditor *ce,
GdkDisplay *display);
G_END_DECLS

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

@ -19,6 +19,7 @@
#include <glib/gi18n-lib.h>
#include "general.h"
#include "window.h"
#include "gtkdebug.h"
#include "gtklabel.h"
@ -89,6 +90,8 @@ struct _GtkInspectorGeneralPrivate
GtkWidget *display_composited;
GtkSizeGroup *labels;
GtkAdjustment *focus_adjustment;
GdkDisplay *display;
};
G_DEFINE_TYPE_WITH_PRIVATE (GtkInspectorGeneral, gtk_inspector_general, GTK_TYPE_WIDGET)
@ -97,41 +100,38 @@ static void
init_version (GtkInspectorGeneral *gen)
{
const char *backend;
GdkDisplay *display;
GdkSurface *surface;
GskRenderer *gsk_renderer;
const char *renderer;
display = gdk_display_get_default ();
#ifdef GDK_WINDOWING_X11
if (GDK_IS_X11_DISPLAY (display))
if (GDK_IS_X11_DISPLAY (gen->priv->display))
backend = "X11";
else
#endif
#ifdef GDK_WINDOWING_WAYLAND
if (GDK_IS_WAYLAND_DISPLAY (display))
if (GDK_IS_WAYLAND_DISPLAY (gen->priv->display))
backend = "Wayland";
else
#endif
#ifdef GDK_WINDOWING_BROADWAY
if (GDK_IS_BROADWAY_DISPLAY (display))
if (GDK_IS_BROADWAY_DISPLAY (gen->priv->display))
backend = "Broadway";
else
#endif
#ifdef GDK_WINDOWING_WIN32
if (GDK_IS_WIN32_DISPLAY (display))
if (GDK_IS_WIN32_DISPLAY (gen->priv->display))
backend = "Windows";
else
#endif
#ifdef GDK_WINDOWING_QUARTZ
if (GDK_IS_QUARTZ_DISPLAY (display))
if (GDK_IS_QUARTZ_DISPLAY (gen->priv->display))
backend = "Quartz";
else
#endif
backend = "Unknown";
surface = gdk_surface_new_toplevel (display, 10, 10);
surface = gdk_surface_new_toplevel (gen->priv->display, 10, 10);
gsk_renderer = gsk_renderer_new_for_surface (surface);
if (strcmp (G_OBJECT_TYPE_NAME (gsk_renderer), "GskVulkanRenderer") == 0)
renderer = "Vulkan";
@ -289,10 +289,9 @@ static void
init_gl (GtkInspectorGeneral *gen)
{
#ifdef GDK_WINDOWING_X11
if (GDK_IS_X11_DISPLAY (gdk_display_get_default ()))
if (GDK_IS_X11_DISPLAY (gen->priv->display))
{
GdkDisplay *display = gdk_display_get_default ();
Display *dpy = GDK_DISPLAY_XDISPLAY (display);
Display *dpy = GDK_DISPLAY_XDISPLAY (gen->priv->display);
int error_base, event_base;
gchar *version;
if (!glXQueryExtension (dpy, &error_base, &event_base))
@ -315,14 +314,13 @@ init_gl (GtkInspectorGeneral *gen)
else
#endif
#ifdef GDK_WINDOWING_WAYLAND
if (GDK_IS_WAYLAND_DISPLAY (gdk_display_get_default ()))
if (GDK_IS_WAYLAND_DISPLAY (gen->priv->display))
{
GdkDisplay *display = gdk_display_get_default ();
EGLDisplay dpy;
EGLint major, minor;
gchar *version;
dpy = wayland_get_display (gdk_wayland_display_get_wl_display (display));
dpy = wayland_get_display (gdk_wayland_display_get_wl_display (gen->priv->display));
if (!eglInitialize (dpy, &major, &minor))
return;
@ -389,9 +387,8 @@ init_vulkan (GtkInspectorGeneral *gen)
#ifdef GDK_RENDERING_VULKAN
GdkSurface *surface;
GdkVulkanContext *context;
GdkDisplay *display = gdk_display_get_default ();
surface = gdk_surface_new_toplevel (display, 10, 10);
surface = gdk_surface_new_toplevel (gen->priv->display, 10, 10);
context = gdk_surface_create_vulkan_context (surface, NULL);
gdk_surface_destroy (surface);
@ -426,11 +423,11 @@ init_vulkan (GtkInspectorGeneral *gen)
add_check_row (gen, GTK_LIST_BOX (gen->priv->vulkan_box), VK_KHR_SURFACE_EXTENSION_NAME, TRUE, 0);
#ifdef GDK_WINDOWING_X11
if (GDK_IS_X11_DISPLAY (gdk_display_get_default ()))
if (GDK_IS_X11_DISPLAY (gen->priv->display))
add_check_row (gen, GTK_LIST_BOX (gen->priv->vulkan_box), "VK_KHR_xlib_surface", TRUE, 0);
#endif
#ifdef GDK_WINDOWING_WAYLAND
if (GDK_IS_WAYLAND_DISPLAY (gdk_display_get_default ()))
if (GDK_IS_WAYLAND_DISPLAY (gen->priv->display))
add_check_row (gen, GTK_LIST_BOX (gen->priv->vulkan_box), "VK_KHR_wayland_surface", TRUE, 0);
#endif
add_check_row (gen, GTK_LIST_BOX (gen->priv->vulkan_box), VK_EXT_DEBUG_REPORT_EXTENSION_NAME,
@ -615,15 +612,11 @@ populate_display_monitor_cb (GdkDisplay *display,
static void
init_display (GtkInspectorGeneral *gen)
{
GdkDisplay *display;
g_signal_connect (gen->priv->display, "notify", G_CALLBACK (populate_display_notify_cb), gen);
g_signal_connect (gen->priv->display, "monitor-added", G_CALLBACK (populate_display_monitor_cb), gen);
g_signal_connect (gen->priv->display, "monitor-removed", G_CALLBACK (populate_display_monitor_cb), gen);
display = gdk_display_get_default ();
g_signal_connect (display, "notify", G_CALLBACK (populate_display_notify_cb), gen);
g_signal_connect (display, "monitor-added", G_CALLBACK (populate_display_monitor_cb), gen);
g_signal_connect (display, "monitor-removed", G_CALLBACK (populate_display_monitor_cb), gen);
populate_display (display, gen);
populate_display (gen->priv->display, gen);
}
static void
@ -779,7 +772,6 @@ add_seat (GtkInspectorGeneral *gen,
static void
populate_seats (GtkInspectorGeneral *gen)
{
GdkDisplay *display = gdk_display_get_default ();
GList *list, *l;
int i;
@ -788,7 +780,7 @@ populate_seats (GtkInspectorGeneral *gen)
gtk_widget_destroy (GTK_WIDGET (l->data));
g_list_free (list);
list = gdk_display_list_seats (display);
list = gdk_display_list_seats (gen->priv->display);
for (l = list, i = 0; l; l = l->next, i++)
add_seat (gen, GDK_SEAT (l->data), i);
@ -799,10 +791,8 @@ populate_seats (GtkInspectorGeneral *gen)
static void
init_device (GtkInspectorGeneral *gen)
{
GdkDisplay *display = gdk_display_get_default ();
g_signal_connect_swapped (display, "seat-added", G_CALLBACK (populate_seats), gen);
g_signal_connect_swapped (display, "seat-removed", G_CALLBACK (populate_seats), gen);
g_signal_connect_swapped (gen->priv->display, "seat-added", G_CALLBACK (populate_seats), gen);
g_signal_connect_swapped (gen->priv->display, "seat-removed", G_CALLBACK (populate_seats), gen);
populate_seats (gen);
}
@ -812,13 +802,6 @@ gtk_inspector_general_init (GtkInspectorGeneral *gen)
{
gen->priv = gtk_inspector_general_get_instance_private (gen);
gtk_widget_init_template (GTK_WIDGET (gen));
init_version (gen);
init_env (gen);
init_display (gen);
init_pango (gen);
init_gl (gen);
init_vulkan (gen);
init_device (gen);
}
static gboolean
@ -967,4 +950,19 @@ gtk_inspector_general_class_init (GtkInspectorGeneralClass *klass)
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorGeneral, device_box);
}
void
gtk_inspector_general_set_display (GtkInspectorGeneral *gen,
GdkDisplay *display)
{
gen->priv->display = display;
init_version (gen);
init_env (gen);
init_display (gen);
init_pango (gen);
init_gl (gen);
init_vulkan (gen);
init_device (gen);
}
// vim: set et sw=2 ts=2:

View File

@ -45,6 +45,8 @@ typedef struct _GtkInspectorGeneralClass
G_BEGIN_DECLS
GType gtk_inspector_general_get_type (void);
void gtk_inspector_general_set_display (GtkInspectorGeneral *general,
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

@ -256,7 +256,7 @@ gtk_inspector_window_select_widget_under_pointer (GtkInspectorWindow *iw)
GdkDevice *device;
GtkWidget *widget;
display = gdk_display_get_default ();
display = gtk_inspector_window_get_inspected_display (iw);
device = gdk_seat_get_pointer (gdk_display_get_default_seat (display));
widget = find_widget_at_pointer (device);

View File

@ -24,6 +24,7 @@
#include <glib/gi18n-lib.h>
#include "logs.h"
#include "window.h"
#include "gtktextview.h"
#include "gtkmessagedialog.h"
@ -33,6 +34,7 @@
#include "gtktooltip.h"
#include "gtktextiter.h"
#include "gtkprivate.h"
#include "gtkroot.h"
#include "gtkdebug.h"
#include "gdkinternals.h"
#include "gtknative.h"
@ -72,6 +74,8 @@ struct _GtkInspectorLogsPrivate
GtkWidget *printing;
GtkWidget *tree;
GtkWidget *text;
GdkDisplay *display;
};
G_DEFINE_TYPE_WITH_PRIVATE (GtkInspectorLogs, gtk_inspector_logs, GTK_TYPE_BOX)
@ -107,12 +111,9 @@ flag_toggled (GtkWidget *button,
GtkInspectorLogs *logs)
{
guint flags;
GdkDisplay *display;
GList *toplevels, *l;
display = gdk_display_get_default ();
flags = gdk_display_get_debug_flags (display);
flags = gdk_display_get_debug_flags (logs->priv->display);
update_flag (logs->priv->events, &flags, GDK_DEBUG_EVENTS);
update_flag (logs->priv->misc, &flags, GDK_DEBUG_MISC);
update_flag (logs->priv->dnd, &flags, GDK_DEBUG_DND);
@ -124,7 +125,7 @@ flag_toggled (GtkWidget *button,
update_flag (logs->priv->vulkan, &flags, GDK_DEBUG_VULKAN);
update_flag (logs->priv->selection, &flags, GDK_DEBUG_SELECTION);
update_flag (logs->priv->clipboard, &flags, GDK_DEBUG_CLIPBOARD);
gdk_display_set_debug_flags (display, flags);
gdk_display_set_debug_flags (logs->priv->display, flags);
flags = gsk_get_debug_flags ();
update_flag (logs->priv->renderer, &flags, GSK_DEBUG_RENDERER);
@ -141,20 +142,17 @@ flag_toggled (GtkWidget *button,
for (l = toplevels; l; l = l->next)
{
GtkWidget *toplevel = l->data;
GskRenderer *renderer;
if ((GtkRoot *)toplevel == gtk_widget_get_root (button)) /* skip the inspector */
continue;
renderer = gtk_native_get_renderer (GTK_NATIVE (toplevel));
if (!renderer)
continue;
gsk_renderer_set_debug_flags (renderer, flags);
if (gtk_root_get_display (GTK_ROOT (toplevel)) == logs->priv->display)
{
GskRenderer *renderer = gtk_native_get_renderer (GTK_NATIVE (toplevel));
if (renderer)
gsk_renderer_set_debug_flags (renderer, flags);
}
}
g_list_free (toplevels);
flags = gtk_get_display_debug_flags (display);
flags = gtk_get_display_debug_flags (logs->priv->display);
update_flag (logs->priv->actions, &flags, GTK_DEBUG_ACTIONS);
update_flag (logs->priv->builder, &flags, GTK_DEBUG_BUILDER);
update_flag (logs->priv->sizes, &flags, GTK_DEBUG_SIZE_REQUEST);
@ -164,7 +162,7 @@ flag_toggled (GtkWidget *button,
update_flag (logs->priv->printing, &flags, GTK_DEBUG_PRINTING);
update_flag (logs->priv->tree, &flags, GTK_DEBUG_TREE);
update_flag (logs->priv->text, &flags, GTK_DEBUG_TEXT);
gtk_set_display_debug_flags (display, flags);
gtk_set_display_debug_flags (logs->priv->display, flags);
}
static void
@ -208,4 +206,11 @@ gtk_inspector_logs_class_init (GtkInspectorLogsClass *klass)
gtk_widget_class_bind_template_callback (widget_class, flag_toggled);
}
void
gtk_inspector_logs_set_display (GtkInspectorLogs *logs,
GdkDisplay *display)
{
logs->priv->display = display;
}
// vim: set et sw=2 ts=2:

View File

@ -49,6 +49,9 @@ typedef struct _GtkInspectorLogsClass
G_BEGIN_DECLS
GType gtk_inspector_logs_get_type (void);
void gtk_inspector_logs_set_display (GtkInspectorLogs *logs,
GdkDisplay *display);
G_END_DECLS

View File

@ -29,6 +29,7 @@
#include "object-tree.h"
#include "prop-list.h"
#include "window.h"
#include "gtkbuildable.h"
#include "gtkbutton.h"
@ -58,16 +59,6 @@
#include "gtksearchentry.h"
#include "gtkeventcontrollerkey.h"
enum
{
OBJECT,
OBJECT_TYPE,
OBJECT_NAME,
OBJECT_LABEL,
OBJECT_CLASSES,
SENSITIVE
};
enum
{
@ -76,7 +67,6 @@ enum
LAST_SIGNAL
};
struct _GtkInspectorObjectTreePrivate
{
GtkListBox *list;
@ -820,6 +810,9 @@ destroy_controller (GtkEventController *controller)
gtk_widget_remove_controller (gtk_event_controller_get_widget (controller), controller);
}
static gboolean toplevel_filter_func (gpointer item,
gpointer data);
static void
map (GtkWidget *widget)
{
@ -1126,7 +1119,7 @@ toplevel_filter_func (gpointer item,
}
static GListModel *
create_root_model (void)
create_root_model (GdkDisplay *display)
{
GtkFilterListModel *filter;
GtkFlattenListModel *flatten;
@ -1139,15 +1132,14 @@ create_root_model (void)
item = g_application_get_default ();
if (item)
g_list_store_append (special, item);
g_list_store_append (special, gtk_settings_get_default ());
g_list_store_append (special, gtk_settings_get_for_display (display));
g_list_store_append (list, special);
g_object_unref (special);
filter = gtk_filter_list_model_new_for_type (G_TYPE_OBJECT);
gtk_filter_list_model_set_filter_func (filter,
toplevel_filter_func,
g_object_ref (gdk_display_get_default ()),
g_object_unref);
display, NULL);
gtk_filter_list_model_set_model (filter, gtk_window_get_toplevels ());
g_list_store_append (list, filter);
g_object_unref (filter);
@ -1160,28 +1152,11 @@ create_root_model (void)
static void
gtk_inspector_object_tree_init (GtkInspectorObjectTree *wt)
{
GListModel *root_model;
wt->priv = gtk_inspector_object_tree_get_instance_private (wt);
gtk_widget_init_template (GTK_WIDGET (wt));
gtk_search_bar_connect_entry (GTK_SEARCH_BAR (wt->priv->search_bar),
GTK_EDITABLE (wt->priv->search_entry));
root_model = create_root_model ();
wt->priv->tree_model = gtk_tree_list_model_new (FALSE,
root_model,
FALSE,
create_model_for_object,
NULL,
NULL);
g_object_unref (root_model);
gtk_list_box_bind_model (wt->priv->list,
G_LIST_MODEL (wt->priv->tree_model),
gtk_inspector_object_tree_create_list_widget,
wt,
NULL);
}
static void
@ -1305,3 +1280,24 @@ gtk_inspector_object_tree_select_object (GtkInspectorObjectTree *wt,
g_object_unref (row_item);
}
void
gtk_inspector_object_tree_set_display (GtkInspectorObjectTree *wt,
GdkDisplay *display)
{
GListModel *root_model;
root_model = create_root_model (display);
wt->priv->tree_model = gtk_tree_list_model_new (FALSE,
root_model,
FALSE,
create_model_for_object,
NULL,
NULL);
g_object_unref (root_model);
gtk_list_box_bind_model (wt->priv->list,
G_LIST_MODEL (wt->priv->tree_model),
gtk_inspector_object_tree_create_list_widget,
wt,
NULL);
}

View File

@ -67,6 +67,9 @@ void gtk_inspector_object_tree_activate_object (GtkInspectorObjectTree
GObject *gtk_inspector_object_tree_get_selected (GtkInspectorObjectTree *wt);
void gtk_inspector_object_tree_set_display (GtkInspectorObjectTree *wt,
GdkDisplay *display);
G_END_DECLS

View File

@ -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:

View File

@ -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

View File

@ -27,6 +27,7 @@
#include <stdlib.h>
#include "init.h"
#include "window.h"
#include "prop-list.h"
#include "controllers.h"
@ -40,6 +41,9 @@
#include "misc-info.h"
#include "magnifier.h"
#include "recorder.h"
#include "visual.h"
#include "general.h"
#include "logs.h"
#include "gdk-private.h"
#include "gskrendererprivate.h"
@ -58,6 +62,13 @@
#include "gtkstylecontext.h"
enum {
PROP_INSPECTED_DISPLAY = 1,
NUM_PROPERTIES
};
static GParamSpec *properties[NUM_PROPERTIES];
G_DEFINE_TYPE (GtkInspectorWindow, gtk_inspector_window, GTK_TYPE_WINDOW)
static gboolean
@ -197,6 +208,8 @@ gtk_inspector_window_init (GtkInspectorWindow *iw)
iw,
NULL);
gtk_window_set_hide_on_close (GTK_WINDOW (iw), TRUE);
gtk_window_group_add_window (gtk_window_group_new (), GTK_WINDOW (iw));
extension_point = g_io_extension_point_lookup ("gtk-inspector-page");
@ -254,13 +267,22 @@ gtk_inspector_window_constructed (GObject *object)
G_OBJECT_CLASS (gtk_inspector_window_parent_class)->constructed (object);
g_object_set_data (G_OBJECT (gdk_display_get_default ()), "-gtk-inspector", iw);
g_object_set_data (G_OBJECT (iw->inspected_display), "-gtk-inspector", iw);
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);
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
gtk_inspector_window_dispose (GObject *object)
{
g_object_set_data (G_OBJECT (gdk_display_get_default ()), "-gtk-inspector", NULL);
GtkInspectorWindow *iw = GTK_INSPECTOR_WINDOW (object);
g_object_set_data (G_OBJECT (iw->inspected_display), "-gtk-inspector", NULL);
G_OBJECT_CLASS (gtk_inspector_window_parent_class)->dispose (object);
}
@ -308,6 +330,46 @@ gtk_inspector_window_realize (GtkWidget *widget)
g_object_unref (provider);
}
static void
gtk_inspector_window_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
GtkInspectorWindow *iw = GTK_INSPECTOR_WINDOW (object);
switch (prop_id)
{
case PROP_INSPECTED_DISPLAY:
iw->inspected_display = g_value_get_object (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gtk_inspector_window_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
GtkInspectorWindow *iw = GTK_INSPECTOR_WINDOW (object);
switch (prop_id)
{
case PROP_INSPECTED_DISPLAY:
g_value_set_object (value, iw->inspected_display);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gtk_inspector_window_class_init (GtkInspectorWindowClass *klass)
{
@ -316,8 +378,16 @@ gtk_inspector_window_class_init (GtkInspectorWindowClass *klass)
object_class->constructed = gtk_inspector_window_constructed;
object_class->dispose = gtk_inspector_window_dispose;
object_class->set_property = gtk_inspector_window_set_property;
object_class->get_property = gtk_inspector_window_get_property;
widget_class->realize = gtk_inspector_window_realize;
properties[PROP_INSPECTED_DISPLAY] =
g_param_spec_object ("inspected-display", "Inspected display", "Inspected display",
GDK_TYPE_DISPLAY,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (object_class, NUM_PROPERTIES, properties);
g_signal_new (g_intern_static_string ("event"),
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST,
@ -354,6 +424,10 @@ gtk_inspector_window_class_init (GtkInspectorWindowClass *klass)
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, controllers);
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_child (widget_class, GtkInspectorWindow, general);
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, logs);
gtk_widget_class_bind_template_callback (widget_class, gtk_inspector_on_inspect);
gtk_widget_class_bind_template_callback (widget_class, on_object_activated);
@ -415,12 +489,32 @@ get_inspector_display (void)
return display;
}
GtkWidget *
gtk_inspector_window_new (void)
static GtkInspectorWindow *
gtk_inspector_window_new (GdkDisplay *display)
{
return GTK_WIDGET (g_object_new (GTK_TYPE_INSPECTOR_WINDOW,
"display", get_inspector_display (),
NULL));
GtkInspectorWindow *iw;
iw = g_object_new (GTK_TYPE_INSPECTOR_WINDOW,
"display", get_inspector_display (),
"inspected-display", display,
NULL);
return iw;
}
GtkWidget *
gtk_inspector_window_get (GdkDisplay *display)
{
GtkWidget *iw;
gtk_inspector_init ();
iw = GTK_WIDGET (g_object_get_data (G_OBJECT (display), "-gtk-inspector"));
if (!iw)
iw = GTK_WIDGET (gtk_inspector_window_new (display));
return iw;
}
void
@ -528,4 +622,11 @@ gtk_inspector_handle_event (GdkEvent *event)
return handled;
}
GdkDisplay *
gtk_inspector_window_get_inspected_display (GtkInspectorWindow *iw)
{
return iw->inspected_display;
}
// vim: set et sw=2 ts=2:

View File

@ -71,6 +71,10 @@ typedef struct
GtkWidget *controllers;
GtkWidget *magnifier;
GtkWidget *sidebar_revealer;
GtkWidget *css_editor;
GtkWidget *visual;
GtkWidget *general;
GtkWidget *logs;
GtkWidget *selected_widget;
@ -84,6 +88,8 @@ typedef struct
GList *overlays;
GdkDisplay *inspected_display;
} GtkInspectorWindow;
typedef struct
@ -95,7 +101,7 @@ typedef struct
G_BEGIN_DECLS
GType gtk_inspector_window_get_type (void);
GtkWidget *gtk_inspector_window_new (void);
GtkWidget *gtk_inspector_window_get (GdkDisplay *display);
void gtk_inspector_flash_widget (GtkInspectorWindow *iw,
GtkWidget *widget);
@ -109,6 +115,7 @@ void gtk_inspector_window_remove_overlay
GtkInspectorOverlay *overlay);
void gtk_inspector_window_select_widget_under_pointer (GtkInspectorWindow *iw);
GdkDisplay * gtk_inspector_window_get_inspected_display (GtkInspectorWindow *iw);
gboolean gtk_inspector_is_recording (GtkWidget *widget);
GskRenderNode * gtk_inspector_prepare_render (GtkWidget *widget,

View File

@ -464,7 +464,7 @@
<property name="name">general</property>
<property name="title" translatable="yes">Information</property>
<property name="child">
<object class="GtkInspectorGeneral"/>
<object class="GtkInspectorGeneral" id="general"/>
</property>
</object>
</child>
@ -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>
@ -504,7 +504,7 @@
<property name="name">logs</property>
<property name="title" translatable="yes">Logging</property>
<property name="child">
<object class="GtkInspectorLogs"/>
<object class="GtkInspectorLogs" id="logs"/>
</property>
</object>
</child>
@ -519,7 +519,7 @@
<property name="name">css</property>
<property name="title" translatable="yes">CSS</property>
<property name="child">
<object class="GtkInspectorCssEditor"/>
<object class="GtkInspectorCssEditor" id="css_editor"/>
</property>
</object>
</child>

View File

@ -33,6 +33,13 @@ main (int argc, char *argv[])
gtk_init ();
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
if (g_getenv ("CUSTOM_DISPLAY"))
{
GdkDisplay *display = gdk_display_open (NULL);
gtk_window_set_display (GTK_WINDOW (window), display);
}
gtk_window_set_title (GTK_WINDOW (window), "hello world");
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);