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 "classes-list.h"
|
|
|
|
#include "css-editor.h"
|
|
|
|
#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-07-06 16:18:09 +00:00
|
|
|
#include "style-prop-list.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-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"
|
|
|
|
#include "gtkwindow.h"
|
2014-07-12 03:45:18 +00:00
|
|
|
#include "gtkwindowgroup.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
|
|
|
|
|
|
|
static void
|
2014-10-11 02:34:32 +00:00
|
|
|
on_object_activated (GtkInspectorObjectTree *wt,
|
|
|
|
GObject *selected,
|
|
|
|
const gchar *name,
|
|
|
|
GtkInspectorWindow *iw)
|
2014-05-05 03:47:11 +00:00
|
|
|
{
|
2014-05-31 03:21:13 +00:00
|
|
|
const gchar *tab;
|
2014-05-03 01:48:33 +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))
|
|
|
|
return;
|
|
|
|
|
|
|
|
gtk_inspector_prop_list_set_object (GTK_INSPECTOR_PROP_LIST (iw->child_prop_list), selected);
|
2014-07-06 16:18:09 +00:00
|
|
|
gtk_inspector_style_prop_list_set_object (GTK_INSPECTOR_STYLE_PROP_LIST (iw->style_prop_list), selected);
|
2014-05-10 16:26:22 +00:00
|
|
|
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);
|
2014-05-10 16:26:22 +00:00
|
|
|
gtk_inspector_classes_list_set_object (GTK_INSPECTOR_CLASSES_LIST (iw->classes_list), selected);
|
|
|
|
gtk_inspector_css_editor_set_object (GTK_INSPECTOR_CSS_EDITOR (iw->widget_css_editor), 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-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-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-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
|
|
|
|
close_details (GtkWidget *button, GtkInspectorWindow *iw)
|
|
|
|
{
|
|
|
|
gtk_stack_set_visible_child_name (GTK_STACK (iw->object_stack), "object-tree");
|
|
|
|
}
|
|
|
|
|
2014-10-11 04:23:21 +00:00
|
|
|
static void
|
|
|
|
visible_child_name_changed (GObject *obj, GParamSpec *pspec, GtkInspectorWindow *iw)
|
|
|
|
{
|
|
|
|
const gchar *child;
|
|
|
|
gboolean objects_visible;
|
|
|
|
gboolean object_details_visible;
|
|
|
|
|
|
|
|
child = gtk_stack_get_visible_child_name (GTK_STACK (iw->top_stack));
|
|
|
|
objects_visible = g_strcmp0 (child, "objects") == 0;
|
|
|
|
child = gtk_stack_get_visible_child_name (GTK_STACK (iw->object_stack));
|
|
|
|
object_details_visible = g_strcmp0 (child, "object-details") == 0;
|
|
|
|
|
|
|
|
gtk_widget_set_visible (iw->select_object, objects_visible);
|
2014-10-11 04:58:47 +00:00
|
|
|
gtk_widget_set_visible (iw->close_object_details, objects_visible && object_details_visible);
|
2014-10-11 04:23:21 +00:00
|
|
|
}
|
|
|
|
|
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-05-07 03:24:20 +00:00
|
|
|
gtk_widget_init_template (GTK_WIDGET (iw));
|
2014-05-03 01:48:33 +00:00
|
|
|
|
2014-05-07 03:24:20 +00:00
|
|
|
gtk_window_group_add_window (gtk_window_group_new (), GTK_WINDOW (iw));
|
2014-10-11 04:23:21 +00:00
|
|
|
|
|
|
|
g_signal_connect (iw->top_stack, "notify::visible-child-name",
|
|
|
|
G_CALLBACK (visible_child_name_changed), iw);
|
|
|
|
g_signal_connect (iw->object_stack, "notify::visible-child-name",
|
|
|
|
G_CALLBACK (visible_child_name_changed), iw);
|
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
|
|
|
|
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
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
2014-05-07 03:24:20 +00:00
|
|
|
gtk_widget_class_set_template_from_resource (widget_class, "/org/gtk/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-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);
|
2014-10-11 04:58:47 +00:00
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, close_object_details);
|
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);
|
2014-05-07 03:24:20 +00:00
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, classes_list);
|
2014-07-06 16:18:09 +00:00
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, style_prop_list);
|
2014-05-07 03:24:20 +00:00
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, widget_css_editor);
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, object_hierarchy);
|
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-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);
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, close_details);
|
2014-05-03 01:48:33 +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-05-07 03:24:20 +00:00
|
|
|
return GTK_WIDGET (g_object_new (GTK_TYPE_INSPECTOR_WINDOW, NULL));
|
2014-05-03 01:48:33 +00:00
|
|
|
}
|
|
|
|
|
2014-05-05 03:47:11 +00:00
|
|
|
// vim: set et sw=2 ts=2:
|