2014-05-03 01:48:33 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2008-2009 Christian Hammond
|
|
|
|
* Copyright (c) 2008-2009 David Trowbridge
|
|
|
|
* Copyright (c) 2013 Intel Corporation
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included
|
|
|
|
* in all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
* THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
2014-05-07 04:13:00 +00:00
|
|
|
#include "config.h"
|
|
|
|
#include <glib/gi18n-lib.h>
|
2014-07-12 03:14:04 +00:00
|
|
|
|
2014-05-03 01:48:33 +00:00
|
|
|
#include <stdlib.h>
|
2014-07-12 03:14:04 +00:00
|
|
|
|
2014-05-05 03:47:11 +00:00
|
|
|
#include "window.h"
|
2014-05-03 01:48:33 +00:00
|
|
|
#include "prop-list.h"
|
|
|
|
#include "css-editor.h"
|
2015-03-02 23:02:25 +00:00
|
|
|
#include "css-node-tree.h"
|
2014-05-03 01:48:33 +00:00
|
|
|
#include "object-hierarchy.h"
|
2014-10-11 01:40:53 +00:00
|
|
|
#include "object-tree.h"
|
2014-10-12 02:04:57 +00:00
|
|
|
#include "selector.h"
|
2014-05-21 01:44:48 +00:00
|
|
|
#include "size-groups.h"
|
2014-05-10 04:50:21 +00:00
|
|
|
#include "data-list.h"
|
2014-05-08 05:04:16 +00:00
|
|
|
#include "signals-list.h"
|
2014-05-14 00:36:02 +00:00
|
|
|
#include "actions.h"
|
2014-06-05 12:31:06 +00:00
|
|
|
#include "menu.h"
|
2014-07-19 06:47:36 +00:00
|
|
|
#include "misc-info.h"
|
2014-06-05 12:31:06 +00:00
|
|
|
#include "gestures.h"
|
2014-12-21 00:24:08 +00:00
|
|
|
#include "magnifier.h"
|
2016-10-30 05:11:38 +00:00
|
|
|
#include "recorder.h"
|
2014-05-14 00:36:02 +00:00
|
|
|
|
2014-10-11 02:34:32 +00:00
|
|
|
#include "gtklabel.h"
|
|
|
|
#include "gtkbutton.h"
|
|
|
|
#include "gtkstack.h"
|
|
|
|
#include "gtktreeviewcolumn.h"
|
2014-12-01 14:37:05 +00:00
|
|
|
#include "gtkmodulesprivate.h"
|
2018-01-14 21:07:12 +00:00
|
|
|
#include "gtkwindowprivate.h"
|
2014-07-12 03:45:18 +00:00
|
|
|
#include "gtkwindowgroup.h"
|
2018-01-12 00:48:27 +00:00
|
|
|
#include "gtkprivate.h"
|
|
|
|
#include "gdk-private.h"
|
2018-01-14 21:07:12 +00:00
|
|
|
#include "gskrendererprivate.h"
|
2014-05-03 01:48:33 +00:00
|
|
|
|
2014-05-07 03:24:20 +00:00
|
|
|
G_DEFINE_TYPE (GtkInspectorWindow, gtk_inspector_window, GTK_TYPE_WINDOW)
|
2014-05-05 03:47:11 +00:00
|
|
|
|
2014-10-25 01:14:16 +00:00
|
|
|
static gboolean
|
|
|
|
set_selected_object (GtkInspectorWindow *iw,
|
|
|
|
GObject *selected)
|
2014-05-05 03:47:11 +00:00
|
|
|
{
|
2014-12-01 14:37:05 +00:00
|
|
|
GList *l;
|
2016-03-07 01:41:28 +00:00
|
|
|
const char *title;
|
2014-12-01 14:37:05 +00:00
|
|
|
|
2014-05-10 16:26:22 +00:00
|
|
|
if (!gtk_inspector_prop_list_set_object (GTK_INSPECTOR_PROP_LIST (iw->prop_list), selected))
|
2014-10-25 01:14:16 +00:00
|
|
|
return FALSE;
|
2014-05-10 16:26:22 +00:00
|
|
|
|
2016-03-07 01:41:28 +00:00
|
|
|
title = (const char *)g_object_get_data (selected, "gtk-inspector-object-title");
|
|
|
|
gtk_label_set_label (GTK_LABEL (iw->object_title), title);
|
|
|
|
|
2014-05-10 16:26:22 +00:00
|
|
|
gtk_inspector_prop_list_set_object (GTK_INSPECTOR_PROP_LIST (iw->child_prop_list), selected);
|
|
|
|
gtk_inspector_signals_list_set_object (GTK_INSPECTOR_SIGNALS_LIST (iw->signals_list), selected);
|
|
|
|
gtk_inspector_object_hierarchy_set_object (GTK_INSPECTOR_OBJECT_HIERARCHY (iw->object_hierarchy), selected);
|
2014-10-12 02:04:57 +00:00
|
|
|
gtk_inspector_selector_set_object (GTK_INSPECTOR_SELECTOR (iw->selector), selected);
|
2014-07-19 06:47:36 +00:00
|
|
|
gtk_inspector_misc_info_set_object (GTK_INSPECTOR_MISC_INFO (iw->misc_info), selected);
|
2015-03-02 23:02:25 +00:00
|
|
|
gtk_inspector_css_node_tree_set_object (GTK_INSPECTOR_CSS_NODE_TREE (iw->widget_css_node_tree), selected);
|
2014-05-21 01:44:48 +00:00
|
|
|
gtk_inspector_size_groups_set_object (GTK_INSPECTOR_SIZE_GROUPS (iw->size_groups), selected);
|
2014-05-10 16:26:22 +00:00
|
|
|
gtk_inspector_data_list_set_object (GTK_INSPECTOR_DATA_LIST (iw->data_list), selected);
|
2014-05-14 00:36:02 +00:00
|
|
|
gtk_inspector_actions_set_object (GTK_INSPECTOR_ACTIONS (iw->actions), selected);
|
2014-06-05 12:31:06 +00:00
|
|
|
gtk_inspector_menu_set_object (GTK_INSPECTOR_MENU (iw->menu), selected);
|
2014-05-16 23:44:43 +00:00
|
|
|
gtk_inspector_gestures_set_object (GTK_INSPECTOR_GESTURES (iw->gestures), selected);
|
2014-12-21 00:24:08 +00:00
|
|
|
gtk_inspector_magnifier_set_object (GTK_INSPECTOR_MAGNIFIER (iw->magnifier), selected);
|
2014-05-16 23:44:43 +00:00
|
|
|
|
2014-12-01 14:37:05 +00:00
|
|
|
for (l = iw->extra_pages; l != NULL; l = l->next)
|
|
|
|
g_object_set (l->data, "object", selected, NULL);
|
|
|
|
|
2014-10-25 01:14:16 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
on_object_activated (GtkInspectorObjectTree *wt,
|
|
|
|
GObject *selected,
|
|
|
|
const gchar *name,
|
|
|
|
GtkInspectorWindow *iw)
|
|
|
|
{
|
|
|
|
const gchar *tab;
|
|
|
|
|
|
|
|
if (!set_selected_object (iw, selected))
|
|
|
|
return;
|
|
|
|
|
2014-06-04 23:28:24 +00:00
|
|
|
tab = g_object_get_data (G_OBJECT (wt), "next-tab");
|
2014-10-11 02:34:32 +00:00
|
|
|
if (tab)
|
|
|
|
gtk_stack_set_visible_child_name (GTK_STACK (iw->object_details), tab);
|
|
|
|
|
|
|
|
gtk_stack_set_visible_child_name (GTK_STACK (iw->object_stack), "object-details");
|
2014-10-25 01:14:16 +00:00
|
|
|
gtk_stack_set_visible_child_name (GTK_STACK (iw->object_buttons), "details");
|
2014-10-11 02:34:32 +00:00
|
|
|
}
|
2014-05-31 03:21:13 +00:00
|
|
|
|
2014-10-11 02:34:32 +00:00
|
|
|
static void
|
|
|
|
on_object_selected (GtkInspectorObjectTree *wt,
|
|
|
|
GObject *selected,
|
|
|
|
GtkInspectorWindow *iw)
|
|
|
|
{
|
2014-10-25 01:52:23 +00:00
|
|
|
gtk_widget_set_sensitive (iw->object_details_button, selected != NULL);
|
2014-05-10 16:26:22 +00:00
|
|
|
if (GTK_IS_WIDGET (selected))
|
|
|
|
gtk_inspector_flash_widget (iw, GTK_WIDGET (selected));
|
2014-05-03 01:48:33 +00:00
|
|
|
}
|
|
|
|
|
2014-10-11 02:34:32 +00:00
|
|
|
static void
|
2014-10-25 01:14:16 +00:00
|
|
|
close_object_details (GtkWidget *button, GtkInspectorWindow *iw)
|
2014-10-11 02:34:32 +00:00
|
|
|
{
|
|
|
|
gtk_stack_set_visible_child_name (GTK_STACK (iw->object_stack), "object-tree");
|
2014-10-25 01:14:16 +00:00
|
|
|
gtk_stack_set_visible_child_name (GTK_STACK (iw->object_buttons), "list");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
open_object_details (GtkWidget *button, GtkInspectorWindow *iw)
|
|
|
|
{
|
|
|
|
GObject *selected;
|
|
|
|
|
|
|
|
selected = gtk_inspector_object_tree_get_selected (GTK_INSPECTOR_OBJECT_TREE (iw->object_tree));
|
|
|
|
|
|
|
|
if (!set_selected_object (iw, selected))
|
|
|
|
return;
|
|
|
|
|
|
|
|
gtk_stack_set_visible_child_name (GTK_STACK (iw->object_stack), "object-details");
|
|
|
|
gtk_stack_set_visible_child_name (GTK_STACK (iw->object_buttons), "details");
|
2014-10-11 02:34:32 +00:00
|
|
|
}
|
|
|
|
|
2016-03-07 01:41:28 +00:00
|
|
|
static gboolean
|
|
|
|
translate_visible_child_name (GBinding *binding,
|
|
|
|
const GValue *from,
|
|
|
|
GValue *to,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
GtkInspectorWindow *iw = user_data;
|
|
|
|
const char *name;
|
|
|
|
|
|
|
|
name = g_value_get_string (from);
|
|
|
|
|
|
|
|
if (gtk_stack_get_child_by_name (GTK_STACK (iw->object_start_stack), name))
|
|
|
|
g_value_set_string (to, name);
|
|
|
|
else
|
|
|
|
g_value_set_string (to, "empty");
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2014-05-05 03:47:11 +00:00
|
|
|
static void
|
2014-05-07 03:24:20 +00:00
|
|
|
gtk_inspector_window_init (GtkInspectorWindow *iw)
|
2014-05-03 01:48:33 +00:00
|
|
|
{
|
2014-12-01 14:37:05 +00:00
|
|
|
GIOExtensionPoint *extension_point;
|
|
|
|
GList *l, *extensions;
|
|
|
|
|
2014-05-07 03:24:20 +00:00
|
|
|
gtk_widget_init_template (GTK_WIDGET (iw));
|
2014-05-03 01:48:33 +00:00
|
|
|
|
2016-03-07 01:41:28 +00:00
|
|
|
g_object_bind_property_full (iw->object_details, "visible-child-name",
|
|
|
|
iw->object_start_stack, "visible-child-name",
|
|
|
|
G_BINDING_SYNC_CREATE,
|
|
|
|
translate_visible_child_name,
|
|
|
|
NULL,
|
|
|
|
iw,
|
|
|
|
NULL);
|
|
|
|
|
2014-05-07 03:24:20 +00:00
|
|
|
gtk_window_group_add_window (gtk_window_group_new (), GTK_WINDOW (iw));
|
2014-12-01 14:37:05 +00:00
|
|
|
|
|
|
|
extension_point = g_io_extension_point_lookup ("gtk-inspector-page");
|
|
|
|
extensions = g_io_extension_point_get_extensions (extension_point);
|
|
|
|
|
|
|
|
for (l = extensions; l != NULL; l = l->next)
|
|
|
|
{
|
|
|
|
GIOExtension *extension = l->data;
|
|
|
|
GType type;
|
|
|
|
GtkWidget *widget;
|
2014-12-09 23:22:12 +00:00
|
|
|
const char *name;
|
2014-12-01 14:37:05 +00:00
|
|
|
char *title;
|
2014-12-09 23:22:12 +00:00
|
|
|
GtkWidget *button;
|
|
|
|
gboolean use_picker;
|
2014-12-01 14:37:05 +00:00
|
|
|
|
|
|
|
type = g_io_extension_get_type (extension);
|
|
|
|
|
|
|
|
widget = g_object_new (type, NULL);
|
|
|
|
|
|
|
|
iw->extra_pages = g_list_prepend (iw->extra_pages, widget);
|
|
|
|
|
2014-12-09 23:22:12 +00:00
|
|
|
name = g_io_extension_get_name (extension);
|
2014-12-01 14:37:05 +00:00
|
|
|
g_object_get (widget, "title", &title, NULL);
|
2014-12-09 23:22:12 +00:00
|
|
|
|
|
|
|
if (g_object_class_find_property (G_OBJECT_GET_CLASS (widget), "use-picker"))
|
|
|
|
g_object_get (widget, "use-picker", &use_picker, NULL);
|
|
|
|
else
|
|
|
|
use_picker = FALSE;
|
|
|
|
|
|
|
|
if (use_picker)
|
|
|
|
{
|
2017-01-20 07:02:48 +00:00
|
|
|
button = gtk_button_new_from_icon_name ("find-location-symbolic");
|
2015-10-23 20:13:30 +00:00
|
|
|
gtk_widget_set_focus_on_click (button, FALSE);
|
2014-12-09 23:22:12 +00:00
|
|
|
gtk_widget_set_halign (button, GTK_ALIGN_START);
|
|
|
|
gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
|
|
|
|
g_signal_connect (button, "clicked",
|
|
|
|
G_CALLBACK (gtk_inspector_on_inspect), iw);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
button = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
|
|
|
|
|
|
|
gtk_stack_add_titled (GTK_STACK (iw->top_stack), widget, name, title);
|
|
|
|
gtk_stack_add_named (GTK_STACK (iw->button_stack), button, name);
|
2014-12-01 14:37:05 +00:00
|
|
|
gtk_widget_show (widget);
|
2014-12-09 23:22:12 +00:00
|
|
|
gtk_widget_show (button);
|
|
|
|
|
|
|
|
g_free (title);
|
2014-12-01 14:37:05 +00:00
|
|
|
}
|
2014-05-03 01:48:33 +00:00
|
|
|
}
|
|
|
|
|
2014-05-07 10:34:23 +00:00
|
|
|
static void
|
|
|
|
gtk_inspector_window_constructed (GObject *object)
|
|
|
|
{
|
2014-09-26 13:49:47 +00:00
|
|
|
GtkInspectorWindow *iw = GTK_INSPECTOR_WINDOW (object);
|
2014-06-27 22:43:59 +00:00
|
|
|
|
|
|
|
G_OBJECT_CLASS (gtk_inspector_window_parent_class)->constructed (object);
|
2014-09-26 13:49:47 +00:00
|
|
|
|
2016-10-30 05:11:38 +00:00
|
|
|
g_object_set_data (G_OBJECT (gdk_display_get_default ()), "-gtk-inspector", iw);
|
|
|
|
|
2014-10-11 01:40:53 +00:00
|
|
|
gtk_inspector_object_tree_scan (GTK_INSPECTOR_OBJECT_TREE (iw->object_tree), NULL);
|
2014-05-07 10:34:23 +00:00
|
|
|
}
|
|
|
|
|
2016-03-07 01:41:28 +00:00
|
|
|
static void
|
|
|
|
object_details_changed (GtkWidget *combo,
|
|
|
|
GParamSpec *pspec,
|
|
|
|
GtkInspectorWindow *iw)
|
|
|
|
{
|
|
|
|
gtk_stack_set_visible_child_name (GTK_STACK (iw->object_center_stack), "title");
|
|
|
|
}
|
|
|
|
|
2018-01-14 21:07:12 +00:00
|
|
|
static void
|
|
|
|
gtk_inspector_window_realize (GtkWidget *widget)
|
|
|
|
{
|
|
|
|
GskRenderer *renderer;
|
|
|
|
|
|
|
|
GTK_WIDGET_CLASS (gtk_inspector_window_parent_class)->realize (widget);
|
|
|
|
|
|
|
|
renderer = gtk_window_get_renderer (GTK_WINDOW (widget));
|
|
|
|
gsk_renderer_set_debug_flags (renderer, 0);
|
|
|
|
}
|
|
|
|
|
2014-05-03 01:48:33 +00:00
|
|
|
static void
|
2014-05-07 03:24:20 +00:00
|
|
|
gtk_inspector_window_class_init (GtkInspectorWindowClass *klass)
|
2014-05-03 01:48:33 +00:00
|
|
|
{
|
2014-05-07 10:34:23 +00:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
2014-05-05 03:47:11 +00:00
|
|
|
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
|
|
|
|
2014-05-07 10:34:23 +00:00
|
|
|
object_class->constructed = gtk_inspector_window_constructed;
|
2018-01-14 21:07:12 +00:00
|
|
|
widget_class->realize = gtk_inspector_window_realize;
|
2014-05-07 10:34:23 +00:00
|
|
|
|
2014-11-30 20:59:53 +00:00
|
|
|
gtk_widget_class_set_template_from_resource (widget_class, "/org/gtk/libgtk/inspector/window.ui");
|
2014-05-05 03:47:11 +00:00
|
|
|
|
2014-10-10 20:06:37 +00:00
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, top_stack);
|
2014-12-01 14:37:05 +00:00
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, button_stack);
|
2014-10-11 02:34:32 +00:00
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, object_stack);
|
2014-10-11 01:40:53 +00:00
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, object_tree);
|
2014-10-11 02:34:32 +00:00
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, object_details);
|
2016-03-07 01:41:28 +00:00
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, object_start_stack);
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, object_center_stack);
|
2014-10-25 01:14:16 +00:00
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, object_buttons);
|
2014-10-25 01:52:23 +00:00
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, object_details_button);
|
2014-10-11 04:23:21 +00:00
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, select_object);
|
2014-05-07 03:24:20 +00:00
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, prop_list);
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, child_prop_list);
|
2014-05-08 05:04:16 +00:00
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, signals_list);
|
2015-03-02 23:02:25 +00:00
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, widget_css_node_tree);
|
2016-10-29 19:11:23 +00:00
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, widget_recorder);
|
2014-05-07 03:24:20 +00:00
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, object_hierarchy);
|
2016-03-07 01:41:28 +00:00
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, object_title);
|
2014-10-12 02:04:57 +00:00
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, selector);
|
2014-05-21 01:44:48 +00:00
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, size_groups);
|
2014-05-10 04:50:21 +00:00
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, data_list);
|
2014-05-14 00:36:02 +00:00
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, actions);
|
2014-06-05 12:31:06 +00:00
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, menu);
|
2014-07-19 06:47:36 +00:00
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, misc_info);
|
2014-05-16 23:44:43 +00:00
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, gestures);
|
2014-12-21 00:24:08 +00:00
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, magnifier);
|
2014-05-05 03:47:11 +00:00
|
|
|
|
2014-09-06 00:52:03 +00:00
|
|
|
gtk_widget_class_bind_template_callback (widget_class, gtk_inspector_on_inspect);
|
2014-10-11 02:34:32 +00:00
|
|
|
gtk_widget_class_bind_template_callback (widget_class, on_object_activated);
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, on_object_selected);
|
2014-10-25 01:14:16 +00:00
|
|
|
gtk_widget_class_bind_template_callback (widget_class, open_object_details);
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, close_object_details);
|
2016-03-07 01:41:28 +00:00
|
|
|
gtk_widget_class_bind_template_callback (widget_class, object_details_changed);
|
2014-05-03 01:48:33 +00:00
|
|
|
}
|
|
|
|
|
2017-10-31 17:36:36 +00:00
|
|
|
static GdkDisplay *
|
|
|
|
get_inspector_display (void)
|
2014-10-24 19:55:31 +00:00
|
|
|
{
|
|
|
|
static GdkDisplay *display = NULL;
|
|
|
|
|
|
|
|
if (display == NULL)
|
|
|
|
{
|
|
|
|
const gchar *name;
|
|
|
|
|
|
|
|
name = g_getenv ("GTK_INSPECTOR_DISPLAY");
|
|
|
|
display = gdk_display_open (name);
|
|
|
|
|
|
|
|
if (display)
|
|
|
|
g_debug ("Using display %s for GtkInspector", name);
|
|
|
|
else
|
|
|
|
g_message ("Failed to open display %s", name);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!display)
|
|
|
|
{
|
|
|
|
display = gdk_display_open (NULL);
|
|
|
|
if (display)
|
|
|
|
g_debug ("Using default display for GtkInspector");
|
|
|
|
else
|
|
|
|
g_message ("Failed to separate connection to default display");
|
|
|
|
}
|
|
|
|
|
2017-03-17 15:12:45 +00:00
|
|
|
|
|
|
|
if (display)
|
|
|
|
{
|
|
|
|
const gchar *name;
|
|
|
|
|
|
|
|
name = g_getenv ("GTK_INSPECTOR_RENDERER");
|
|
|
|
|
|
|
|
g_object_set_data_full (G_OBJECT (display), "gsk-renderer",
|
|
|
|
g_strdup (name), g_free);
|
2018-01-12 00:48:27 +00:00
|
|
|
|
|
|
|
gdk_display_set_debug_flags (display, 0);
|
|
|
|
gtk_set_display_debug_flags (display, 0);
|
2017-03-17 15:12:45 +00:00
|
|
|
}
|
|
|
|
|
2014-10-24 19:55:31 +00:00
|
|
|
if (!display)
|
|
|
|
display = gdk_display_get_default ();
|
|
|
|
|
2017-10-31 17:36:36 +00:00
|
|
|
return display;
|
2014-10-24 19:55:31 +00:00
|
|
|
}
|
|
|
|
|
2014-05-05 03:47:11 +00:00
|
|
|
GtkWidget *
|
2014-05-07 03:24:20 +00:00
|
|
|
gtk_inspector_window_new (void)
|
2014-05-03 01:48:33 +00:00
|
|
|
{
|
2014-10-24 19:55:31 +00:00
|
|
|
return GTK_WIDGET (g_object_new (GTK_TYPE_INSPECTOR_WINDOW,
|
2017-10-31 17:36:36 +00:00
|
|
|
"display", get_inspector_display (),
|
2014-10-24 19:55:31 +00:00
|
|
|
NULL));
|
2014-05-03 01:48:33 +00:00
|
|
|
}
|
|
|
|
|
2018-04-04 10:38:09 +00:00
|
|
|
void
|
|
|
|
gtk_inspector_window_add_overlay (GtkInspectorWindow *iw,
|
|
|
|
GtkInspectorOverlay *overlay)
|
|
|
|
{
|
|
|
|
iw->overlays = g_list_prepend (iw->overlays, g_object_ref (overlay));
|
|
|
|
|
|
|
|
gtk_inspector_overlay_queue_draw (overlay);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gtk_inspector_window_remove_overlay (GtkInspectorWindow *iw,
|
|
|
|
GtkInspectorOverlay *overlay)
|
|
|
|
{
|
|
|
|
GList *item;
|
|
|
|
|
|
|
|
item = g_list_find (iw->overlays, overlay);
|
|
|
|
if (item == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
gtk_inspector_overlay_queue_draw (overlay);
|
|
|
|
|
|
|
|
iw->overlays = g_list_delete_link (iw->overlays, item);
|
|
|
|
}
|
|
|
|
|
2015-07-24 01:27:37 +00:00
|
|
|
void
|
|
|
|
gtk_inspector_window_rescan (GtkWidget *widget)
|
|
|
|
{
|
|
|
|
GtkInspectorWindow *iw = GTK_INSPECTOR_WINDOW (widget);
|
|
|
|
|
|
|
|
gtk_inspector_object_tree_scan (GTK_INSPECTOR_OBJECT_TREE (iw->object_tree), NULL);
|
|
|
|
}
|
|
|
|
|
2016-10-30 05:11:38 +00:00
|
|
|
static GtkInspectorWindow *
|
|
|
|
gtk_inspector_window_get_for_display (GdkDisplay *display)
|
|
|
|
{
|
|
|
|
return g_object_get_data (G_OBJECT (display), "-gtk-inspector");
|
|
|
|
}
|
|
|
|
|
2018-04-03 19:09:35 +00:00
|
|
|
GskRenderNode *
|
|
|
|
gtk_inspector_prepare_render (GtkWidget *widget,
|
|
|
|
GskRenderer *renderer,
|
|
|
|
GdkSurface *surface,
|
|
|
|
const cairo_region_t *region,
|
|
|
|
GskRenderNode *node)
|
2016-10-30 05:11:38 +00:00
|
|
|
{
|
|
|
|
GtkInspectorWindow *iw;
|
|
|
|
|
|
|
|
iw = gtk_inspector_window_get_for_display (gtk_widget_get_display (widget));
|
|
|
|
if (iw == NULL)
|
2018-04-03 19:09:35 +00:00
|
|
|
return node;
|
2016-10-30 05:11:38 +00:00
|
|
|
|
|
|
|
/* sanity check for single-display GDK backends */
|
|
|
|
if (GTK_WIDGET (iw) == widget)
|
2018-04-03 19:09:35 +00:00
|
|
|
return node;
|
2016-10-30 05:11:38 +00:00
|
|
|
|
|
|
|
gtk_inspector_recorder_record_render (GTK_INSPECTOR_RECORDER (iw->widget_recorder),
|
|
|
|
widget,
|
2016-11-20 02:52:56 +00:00
|
|
|
renderer,
|
2018-03-21 10:49:14 +00:00
|
|
|
surface,
|
2016-10-30 05:11:38 +00:00
|
|
|
region,
|
|
|
|
node);
|
2018-04-03 19:09:35 +00:00
|
|
|
|
2018-04-04 10:38:09 +00:00
|
|
|
if (iw->overlays)
|
|
|
|
{
|
|
|
|
GtkSnapshot *snapshot;
|
|
|
|
GList *l;
|
|
|
|
|
2018-04-24 01:17:23 +00:00
|
|
|
snapshot = gtk_snapshot_new ();
|
2018-04-04 10:38:09 +00:00
|
|
|
gtk_snapshot_append_node (snapshot, node);
|
|
|
|
|
|
|
|
for (l = iw->overlays; l; l = l->next)
|
|
|
|
{
|
2018-04-04 11:22:28 +00:00
|
|
|
gtk_inspector_overlay_snapshot (l->data, snapshot, node, widget);
|
2018-04-04 10:38:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
gsk_render_node_unref (node);
|
|
|
|
node = gtk_snapshot_free_to_node (snapshot);
|
|
|
|
}
|
|
|
|
|
2018-04-03 19:09:35 +00:00
|
|
|
return node;
|
2016-10-30 05:11:38 +00:00
|
|
|
}
|
|
|
|
|
2017-01-11 09:08:58 +00:00
|
|
|
gboolean
|
|
|
|
gtk_inspector_is_recording (GtkWidget *widget)
|
|
|
|
{
|
|
|
|
GtkInspectorWindow *iw;
|
|
|
|
|
|
|
|
iw = gtk_inspector_window_get_for_display (gtk_widget_get_display (widget));
|
|
|
|
if (iw == NULL)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
/* sanity check for single-display GDK backends */
|
|
|
|
if (GTK_WIDGET (iw) == widget)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return gtk_inspector_recorder_is_recording (GTK_INSPECTOR_RECORDER (iw->widget_recorder));
|
|
|
|
}
|
|
|
|
|
2014-05-05 03:47:11 +00:00
|
|
|
// vim: set et sw=2 ts=2:
|