diff options
author | Matthias Clasen <mclasen@redhat.com> | 2014-05-14 21:23:44 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2014-05-14 21:23:44 -0400 |
commit | 59c9d24bbf0a0e6c8b4a693d5fc99edac7207843 (patch) | |
tree | 78e0c70c7e9194d43515871d9f24d53dd1b5870d /modules | |
parent | 53b37b8f719a55c9aa8048ee2e7b2e5b6b4f106f (diff) | |
download | gtk+-59c9d24bbf0a0e6c8b4a693d5fc99edac7207843.tar.gz |
inspector: stop being a module
Moving the inspector into libgtk lets use reuse internals without
having to add public API for everything or inventing awkward private
call conventions.
https://bugzilla.gnome.org/show_bug.cgi?id=730095
Diffstat (limited to 'modules')
44 files changed, 1 insertions, 6132 deletions
diff --git a/modules/Makefile.am b/modules/Makefile.am index f0649d18b7..f8e7bb8797 100644 --- a/modules/Makefile.am +++ b/modules/Makefile.am @@ -1,6 +1,6 @@ include $(top_srcdir)/Makefile.decl -SUBDIRS = input inspector +SUBDIRS = input if OS_UNIX SUBDIRS += printbackends diff --git a/modules/inspector/Makefile.am b/modules/inspector/Makefile.am deleted file mode 100644 index 07b672b359..0000000000 --- a/modules/inspector/Makefile.am +++ /dev/null @@ -1,102 +0,0 @@ -moduledir = $(libdir)/gtk-3.0/modules - -module_LTLIBRARIES = libgtkinspector.la - -resource_files = $(shell $(GLIB_COMPILE_RESOURCES) --sourcedir=$(srcdir) --generate-dependencies $(srcdir)/inspector.gresource.xml) -resources.h: inspector.gresource.xml - $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) $(srcdir)/inspector.gresource.xml \ - --target=$@ --sourcedir=$(srcdir) --c-name gtk_inspector --generate-header --manual-register -resources.c: inspector.gresource.xml $(resource_files) $(template_headers) - $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) $(srcdir)/inspector.gresource.xml \ - --target=$@ --sourcedir=$(srcdir) --c-name gtk_inspector --generate-source --manual-register - -BUILT_SOURCES = \ - resources.h \ - resources.c - -libgtkinspector_la_SOURCES = \ - resources.h \ - resources.c \ - inspect-button.c \ - module.c \ - prop-list.h \ - prop-list.c \ - property-cell-renderer.h \ - property-cell-renderer.c \ - python-hooks.h \ - python-hooks.c \ - python-shell.h \ - python-shell.c \ - widget-tree.h \ - widget-tree.c \ - window.h \ - window.c \ - button-path.h \ - button-path.c \ - classes-list.h \ - classes-list.c \ - css-editor.h \ - css-editor.c \ - object-hierarchy.h \ - object-hierarchy.c \ - themes.h \ - themes.c \ - signals-list.h \ - signals-list.c \ - data-list.h \ - data-list.c \ - visual.h \ - visual.c - -libgtkinspector_la_CPPFLAGS = \ - -I$(top_srcdir) \ - -I$(top_srcdir)/gtk \ - -I$(top_builddir)/gtk \ - -I$(top_srcdir)/gdk \ - -I$(top_builddir)/gdk \ - -DGTK_DATADIR=\"$(datadir)\" \ - -DGTK_COMPILATION \ - $(GTK_DEP_CFLAGS) \ - $(GTK_DEBUG_FLAGS) - -if PLATFORM_WIN32 -no_undefined = -no-undefined -endif - -libgtkinspector_la_LDFLAGS = -avoid-version -module $(no_undefined) - -libgtkinspector_la_LIBADD = \ - $(top_builddir)/gtk/libgtk-3.la \ - $(GTK_DEP_LIBS) - -templates = \ - button-path.ui \ - classes-list.ui \ - css-editor.ui \ - data-list.ui \ - object-hierarchy.ui \ - prop-list.ui \ - signals-list.ui \ - themes.ui \ - visual.ui \ - widget-tree.ui \ - window.ui - -template_headers = $(templates:.ui=.ui.h) - -extract_strings = $(top_builddir)/gtk/extract-strings$(BUILD_EXEEXT) - -%.ui.h: %.ui $(extract_strings) - $(AM_V_GEN) $(extract_strings) $< > $@ - -distclean-local: - if test $(srcdir) != .; then \ - rm -f $(template_headers); \ - fi - -EXTRA_DIST = \ - inspector.gresource.xml \ - $(resource_files) \ - $(templates) - --include $(top_srcdir)/git.mk diff --git a/modules/inspector/button-path.c b/modules/inspector/button-path.c deleted file mode 100644 index 6019143c52..0000000000 --- a/modules/inspector/button-path.c +++ /dev/null @@ -1,86 +0,0 @@ -/* - * 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. - */ - -#include "button-path.h" - -struct _GtkInspectorButtonPathPrivate -{ - GtkWidget *sw; - GtkWidget *button_box; -}; - -G_DEFINE_TYPE_WITH_PRIVATE (GtkInspectorButtonPath, gtk_inspector_button_path, GTK_TYPE_BOX) - -static void -gtk_inspector_button_path_init (GtkInspectorButtonPath *bp) -{ - bp->priv = gtk_inspector_button_path_get_instance_private (bp); - gtk_widget_init_template (GTK_WIDGET (bp)); -} - -static void -gtk_inspector_button_path_class_init (GtkInspectorButtonPathClass *klass) -{ - GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); - - gtk_widget_class_set_template_from_resource (widget_class, "/org/gtk/inspector/button-path.ui"); - gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorButtonPath, sw); - gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorButtonPath, button_box); -} - -GtkWidget * -gtk_inspector_button_path_new (void) -{ - return GTK_WIDGET (g_object_new (GTK_TYPE_INSPECTOR_BUTTON_PATH, NULL)); -} - -void -gtk_inspector_button_path_set_object (GtkInspectorButtonPath *bp, - GObject *object) -{ - GtkContainer *box = GTK_CONTAINER (bp->priv->button_box); - GtkWidget *b; - - gtk_container_foreach (box, (GtkCallback)gtk_widget_destroy, NULL); - - if (GTK_IS_WIDGET (object)) - { - GtkWidget *widget = GTK_WIDGET (object); - gchar *path, **words; - gint i; - - path = gtk_widget_path_to_string (gtk_widget_get_path (widget)); - words = g_strsplit (path, " ", 0); - - for (i = 0; i < g_strv_length (words); i++) - { - b = gtk_button_new_with_label (words[i]); - gtk_widget_show (b); - gtk_container_add (box, b); - } - - g_strfreev (words); - g_free (path); - } -} - -// vim: set et sw=2 ts=2: diff --git a/modules/inspector/button-path.h b/modules/inspector/button-path.h deleted file mode 100644 index 6ee59b3325..0000000000 --- a/modules/inspector/button-path.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * 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. - */ -#ifndef _GTK_INSPECTOR_BUTTON_PATH_H_ -#define _GTK_INSPECTOR_BUTTON_PATH_H_ - - -#include <gtk/gtk.h> - -#define GTK_TYPE_INSPECTOR_BUTTON_PATH (gtk_inspector_button_path_get_type()) -#define GTK_INSPECTOR_BUTTON_PATH(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GTK_TYPE_INSPECTOR_BUTTON_PATH, GtkInspectorButtonPath)) -#define GTK_INSPECTOR_BUTTON_PATH_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GTK_TYPE_INSPECTOR_BUTTON_PATH, GtkInspectorButtonPathClass)) -#define GTK_INSPECTOR_IS_BUTTON_PATH(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GTK_TYPE_INSPECTOR_BUTTON_PATH)) -#define GTK_INSPECTOR_IS_BUTTON_PATH_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GTK_TYPE_INSPECTOR_BUTTON_PATH)) -#define GTK_INSPECTOR_BUTTON_PATH_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GTK_TYPE_INSPECTOR_BUTTON_PATH, GtkInspectorButtonPathClass)) - - -typedef struct _GtkInspectorButtonPathPrivate GtkInspectorButtonPathPrivate; - -typedef struct _GtkInspectorButtonPath -{ - GtkBox parent; - GtkInspectorButtonPathPrivate *priv; -} GtkInspectorButtonPath; - -typedef struct _GtkInspectorButtonPathClass -{ - GtkBoxClass parent; -} GtkInspectorButtonPathClass; - - -G_BEGIN_DECLS - -GType gtk_inspector_button_path_get_type (void); -GtkWidget *gtk_inspector_button_path_new (void); -void gtk_inspector_button_path_set_object (GtkInspectorButtonPath *bp, - GObject *object); - -G_END_DECLS - - -#endif // _GTK_INSPECTOR_BUTTON_PATH_H_ - -// vim: set et sw=2 ts=2: diff --git a/modules/inspector/button-path.ui b/modules/inspector/button-path.ui deleted file mode 100644 index 000287364d..0000000000 --- a/modules/inspector/button-path.ui +++ /dev/null @@ -1,55 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<interface domain="gtk30"> - <template class="GtkInspectorButtonPath" parent="GtkBox"> - <property name="orientation">horizontal</property> - <child> - <object class="GtkScrolledWindow" id="sw"> - <property name="visible">True</property> - <property name="hscrollbar-policy">automatic</property> - <property name="vscrollbar-policy">never</property> - <property name="hexpand">True</property> - <child> - <object class="GtkBox"> - <property name="orientation">horizontal</property> - <property name="visible">True</property> - <property name="halign">start</property> - <child> - <object class="GtkButton" id="placeholder"> - <property name="margin">6</property> - <property name="label">X</property> - </object> - </child> - <child> - <object class="GtkBox" id="button_box"> - <property name="orientation">horizontal</property> - <property name="visible">True</property> - <property name="hexpand">True</property> - <property name="margin">6</property> - <property name="spacing">0</property> - <style> - <class name="linked"/> - </style> - <child> - <object class="GtkLabel"> - <property name="visible">True</property> - <property name="label" translatable="yes">Choose a widget through the inspector</property> - <property name="hexpand">True</property> - <property name="xalign">0.5</property> - </object> - </child> - </object> - </child> - </object> - </child> - </object> - </child> - </template> - <object class="GtkSizeGroup"> - <property name="mode">vertical</property> - <property name="ignore-hidden">False</property> - <widgets> - <widget name="placeholder"/> - <widget name="button_box"/> - </widgets> - </object> -</interface> diff --git a/modules/inspector/classes-list.c b/modules/inspector/classes-list.c deleted file mode 100644 index 069881fba7..0000000000 --- a/modules/inspector/classes-list.c +++ /dev/null @@ -1,299 +0,0 @@ -/* - * 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. - */ - -#include "config.h" -#include <glib/gi18n-lib.h> -#include "classes-list.h" - -enum -{ - COLUMN_ENABLED, - COLUMN_NAME, - COLUMN_STYLE -}; - -typedef struct -{ - gboolean enabled; - PangoStyle style; -} GtkInspectorClassesListByContext; - -struct _GtkInspectorClassesListPrivate -{ - GtkListStore *model; - GtkStyleContext *context; -}; - -G_DEFINE_TYPE_WITH_PRIVATE (GtkInspectorClassesList, gtk_inspector_classes_list, GTK_TYPE_BOX) - -static void -set_hash_context (GtkInspectorClassesList *cl, GHashTable *hash_context) -{ - g_object_set_data_full (G_OBJECT (cl->priv->context), - "gtk-inspector-hash-context", - hash_context, (GDestroyNotify)g_hash_table_unref); -} - -static GHashTable * -get_hash_context (GtkInspectorClassesList *cl) -{ - return (GHashTable *)g_object_get_data (G_OBJECT (cl->priv->context), - "gtk-inspector-hash-context"); -} - -static void -enabled_toggled (GtkCellRendererToggle *renderer, - const gchar *path, - GtkInspectorClassesList *cl) -{ - GtkTreeIter iter; - gboolean enabled; - GHashTable *context; - GtkInspectorClassesListByContext *c; - gchar *name; - - if (!gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (cl->priv->model), &iter, path)) - { - g_warning ("GtkInspector: Couldn't find the css class path for %s.", path); - return; - } - - gtk_tree_model_get (GTK_TREE_MODEL (cl->priv->model), &iter, - COLUMN_ENABLED, &enabled, - COLUMN_NAME, &name, - -1); - enabled = !enabled; - gtk_list_store_set (cl->priv->model, &iter, - COLUMN_ENABLED, enabled, - -1); - - context = get_hash_context (cl); - if (context) - { - c = g_hash_table_lookup (context, name); - if (c) - { - c->enabled = enabled; - if (enabled) - gtk_style_context_add_class (cl->priv->context, name); - else - gtk_style_context_remove_class (cl->priv->context, name); - } - else - g_warning ("GtkInspector: Couldn't find the css class %s in the class hash table.", name); - } - else - g_warning ("GtkInspector: Couldn't find the hash table for the style context for css class %s.", name); -} - -static void -add_clicked (GtkButton *button, - GtkInspectorClassesList *cl) -{ - GtkWidget *dialog, *content_area, *entry; - - dialog = gtk_dialog_new_with_buttons (_("New class"), - GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (cl))), - GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_USE_HEADER_BAR, - _("_OK"), GTK_RESPONSE_OK, - _("Cancel"), GTK_RESPONSE_CANCEL, - NULL); - gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK); - - entry = g_object_new (GTK_TYPE_ENTRY, - "visible", TRUE, - "margin", 5, - "placeholder-text", _("Class name"), - "activates-default", TRUE, - NULL); - content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog)); - gtk_container_add (GTK_CONTAINER (content_area), entry); - - if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK) - { - const gchar *name; - GHashTable *context; - - context = get_hash_context (cl); - name = gtk_entry_get_text (GTK_ENTRY (entry)); - if (*name && !g_hash_table_contains (context, name)) - { - GtkTreeIter tree_iter; - - gtk_style_context_add_class (cl->priv->context, name); - - GtkInspectorClassesListByContext *c = g_new0 (GtkInspectorClassesListByContext, 1); - c->enabled = TRUE; - c->style = PANGO_STYLE_ITALIC; - g_hash_table_insert (context, (gpointer)g_strdup (name), c); - - gtk_list_store_append (cl->priv->model, &tree_iter); - gtk_list_store_set (cl->priv->model, &tree_iter, - COLUMN_ENABLED, TRUE, - COLUMN_NAME, name, - COLUMN_STYLE, PANGO_STYLE_ITALIC, - -1); - } - } - - gtk_widget_destroy (dialog); -} - -static void -read_classes_from_style_context (GtkInspectorClassesList *cl) -{ - GList *l, *classes; - GtkInspectorClassesListByContext *c; - GtkTreeIter tree_iter; - GHashTable *hash_context; - - hash_context = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); - classes = gtk_style_context_list_classes (cl->priv->context); - - for (l = classes; l; l = l->next) - { - c = g_new0 (GtkInspectorClassesListByContext, 1); - c->enabled = TRUE; - g_hash_table_insert (hash_context, g_strdup (l->data), c); - - gtk_list_store_append (cl->priv->model, &tree_iter); - gtk_list_store_set (cl->priv->model, &tree_iter, - COLUMN_ENABLED, TRUE, - COLUMN_NAME, l->data, - COLUMN_STYLE, PANGO_STYLE_NORMAL, - -1); - } - g_list_free (classes); - set_hash_context (cl, hash_context); -} - -static void -restore_defaults_clicked (GtkButton *button, - GtkInspectorClassesList *cl) -{ - GHashTableIter hash_iter; - gchar *name; - GtkInspectorClassesListByContext *c; - GHashTable *hash_context; - - hash_context = get_hash_context (cl); - g_hash_table_iter_init (&hash_iter, hash_context); - while (g_hash_table_iter_next (&hash_iter, (gpointer *)&name, (gpointer *)&c)) - { - if (c->style == PANGO_STYLE_ITALIC) - gtk_style_context_remove_class (cl->priv->context, name); - else if (!c->enabled) - gtk_style_context_add_class (cl->priv->context, name); - } - - gtk_list_store_clear (cl->priv->model); - read_classes_from_style_context (cl); -} - -static void -gtk_inspector_classes_list_init (GtkInspectorClassesList *cl) -{ - cl->priv = gtk_inspector_classes_list_get_instance_private (cl); - gtk_widget_init_template (GTK_WIDGET (cl)); -} - -static void remove_dead_object (gpointer data, GObject *dead_object); - -static void -cleanup_context (GtkInspectorClassesList *cl) -{ - if (cl->priv->context) - g_object_weak_unref (G_OBJECT (cl->priv->context), remove_dead_object, cl); - - gtk_list_store_clear (cl->priv->model); - cl->priv->context = NULL; - gtk_widget_hide (GTK_WIDGET (cl)); -} - -static void -remove_dead_object (gpointer data, GObject *dead_object) -{ - GtkInspectorClassesList *cl = data; - - cl->priv->context = NULL; - cleanup_context (cl); -} - -void -gtk_inspector_classes_list_set_object (GtkInspectorClassesList *cl, - GObject *object) -{ - GHashTable *hash_context; - GtkTreeIter tree_iter; - GtkInspectorClassesListByContext *c; - - cleanup_context (cl); - - if (!GTK_IS_WIDGET (object)) - return; - - gtk_widget_show (GTK_WIDGET (cl)); - - cl->priv->context = gtk_widget_get_style_context (GTK_WIDGET (cl)); - - g_object_weak_ref (G_OBJECT (cl->priv->context), remove_dead_object, cl); - - hash_context = get_hash_context (cl); - if (hash_context) - { - GHashTableIter hash_iter; - gchar *name; - - g_hash_table_iter_init (&hash_iter, hash_context); - while (g_hash_table_iter_next (&hash_iter, (gpointer *)&name, (gpointer *)&c)) - { - gtk_list_store_append (cl->priv->model, &tree_iter); - gtk_list_store_set (cl->priv->model, &tree_iter, - COLUMN_ENABLED, c->enabled, - COLUMN_NAME, name, - COLUMN_STYLE, c->style, - -1); - } - } - else - read_classes_from_style_context (cl); -} - -static void -gtk_inspector_classes_list_class_init (GtkInspectorClassesListClass *klass) -{ - GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); - - gtk_widget_class_set_template_from_resource (widget_class, "/org/gtk/inspector/classes-list.ui"); - gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorClassesList, model); - gtk_widget_class_bind_template_callback (widget_class, add_clicked); - gtk_widget_class_bind_template_callback (widget_class, restore_defaults_clicked); - gtk_widget_class_bind_template_callback (widget_class, enabled_toggled); -} - -GtkWidget * -gtk_inspector_classes_list_new (void) -{ - return GTK_WIDGET (g_object_new (GTK_TYPE_INSPECTOR_CLASSES_LIST, NULL)); -} - -// vim: set et sw=2 ts=2: diff --git a/modules/inspector/classes-list.h b/modules/inspector/classes-list.h deleted file mode 100644 index 9eaf39c837..0000000000 --- a/modules/inspector/classes-list.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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. - */ - -#ifndef _GTK_INSPECTOR_CLASSES_LIST_H_ -#define _GTK_INSPECTOR_CLASSES_LIST_H_ - -#include <gtk/gtk.h> - -#define GTK_TYPE_INSPECTOR_CLASSES_LIST (gtk_inspector_classes_list_get_type()) -#define GTK_INSPECTOR_CLASSES_LIST(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GTK_TYPE_INSPECTOR_CLASSES_LIST, GtkInspectorClassesList)) -#define GTK_INSPECTOR_CLASSES_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GTK_TYPE_INSPECTOR_CLASSES_LIST, GtkInspectorClassesListClass)) -#define GTK_INSPECTOR_IS_CLASSES_LIST(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GTK_TYPE_INSPECTOR_CLASSES_LIST)) -#define GTK_INSPECTOR_IS_CLASSES_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GTK_TYPE_INSPECTOR_CLASSES_LIST)) -#define GTK_INSPECTOR_CLASSES_LIST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GTK_TYPE_INSPECTOR_CLASSES_LIST, GtkInspectorClassesListClass)) - - -typedef struct _GtkInspectorClassesListPrivate GtkInspectorClassesListPrivate; - -typedef struct _GtkInspectorClassesList -{ - GtkBox parent; - GtkInspectorClassesListPrivate *priv; -} GtkInspectorClassesList; - -typedef struct _GtkInspectorClassesListClass -{ - GtkBoxClass parent; -} GtkInspectorClassesListClass; - -G_BEGIN_DECLS - -GType gtk_inspector_classes_list_get_type (void); -GtkWidget *gtk_inspector_classes_list_new (void); -void gtk_inspector_classes_list_set_object (GtkInspectorClassesList *cl, - GObject *object); - -G_END_DECLS - -#endif // _GTK_INSPECTOR_CLASSES_LIST_H_ - -// vim: set et sw=2 ts=2: diff --git a/modules/inspector/classes-list.ui b/modules/inspector/classes-list.ui deleted file mode 100644 index 0835eefe61..0000000000 --- a/modules/inspector/classes-list.ui +++ /dev/null @@ -1,71 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<interface domain="gtk30"> - <object class="GtkListStore" id="model"> - <columns> - <column type="gboolean"/> - <column type="gchararray"/> - <column type="PangoStyle"/> - </columns> - </object> - <template class="GtkInspectorClassesList" parent="GtkBox"> - <property name="orientation">vertical</property> - <child> - <object class="GtkToolbar"> - <property name="visible">True</property> - <property name="icon-size">small-toolbar</property> - <property name="sensitive">False</property> - <child> - <object class="GtkToolButton"> - <property name="visible">True</property> - <property name="icon-name">list-add</property> - <property name="tooltip-text" translatable="yes">Add a class</property> - <signal name="clicked" handler="add_clicked"/> - </object> - </child> - <child> - <object class="GtkToolButton"> - <property name="visible">True</property> - <property name="icon-name">document-revert</property> - <property name="tooltip-text" translatable="yes">Restore defaults for this widget</property> - <signal name="clicked" handler="restore_defaults_clicked"/> - </object> - </child> - </object> - </child> - <child> - <object class="GtkScrolledWindow"> - <property name="visible">True</property> - <property name="expand">True</property> - <child> - <object class="GtkTreeView"> - <property name="visible">True</property> - <property name="model">model</property> - <child> - <object class="GtkTreeViewColumn"> - <property name="title" translatable="yes">Name</property> - <child> - <object class="GtkCellRendererToggle"> - <property name="activatable">True</property> - <signal name="toggled" handler="enabled_toggled"/> - </object> - <attributes> - <attribute name="active">0</attribute> - </attributes> - </child> - <child> - <object class="GtkCellRendererText"> - <property name="scale">0.8</property> - </object> - <attributes> - <attribute name="text">1</attribute> - <attribute name="style">2</attribute> - </attributes> - </child> - </object> - </child> - </object> - </child> - </object> - </child> - </template> -</interface> diff --git a/modules/inspector/css-editor.c b/modules/inspector/css-editor.c deleted file mode 100644 index 861ad54a54..0000000000 --- a/modules/inspector/css-editor.c +++ /dev/null @@ -1,354 +0,0 @@ -/* - * 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. - */ - -#include "config.h" -#include "css-editor.h" -#include <glib/gi18n-lib.h> - -#define GTK_INSPECTOR_CSS_EDITOR_TEXT "inspector-css-editor-text" -#define GTK_INSPECTOR_CSS_EDITOR_PROVIDER "inspector-css-editor-provider" - -enum -{ - COLUMN_ENABLED, - COLUMN_NAME, - COLUMN_USER -}; - -enum -{ - PROP_0, - PROP_GLOBAL -}; - -typedef struct -{ - gboolean enabled; - gboolean user; -} GtkInspectorCssEditorByContext; - -struct _GtkInspectorCssEditorPrivate -{ - GtkWidget *toolbar; - GtkWidget *view; - GtkTextBuffer *text; - GtkCssProvider *provider; - gboolean global; - GtkStyleContext *context; - GtkToggleToolButton *disable_button; -}; - -G_DEFINE_TYPE_WITH_PRIVATE (GtkInspectorCssEditor, gtk_inspector_css_editor, GTK_TYPE_BOX) - -static void -set_initial_text (GtkInspectorCssEditor *ce) -{ - const gchar *text = NULL; - - if (ce->priv->context) - text = g_object_get_data (G_OBJECT (ce->priv->context), GTK_INSPECTOR_CSS_EDITOR_TEXT); - if (text) - gtk_text_buffer_set_text (GTK_TEXT_BUFFER (ce->priv->text), text, -1); - else - { - gchar *initial_text; - if (ce->priv->global) - initial_text = g_strconcat ("/*\n", - _("You can type here any CSS rule recognized by GTK+."), "\n", - _("You can temporarily disable this custom CSS by clicking on the \"Pause\" button above."), "\n\n", - _("Changes are applied instantly and globally, for the whole application."), "\n", - "*/\n\n", NULL); - else - initial_text = g_strconcat ("/*\n", - _("You can type here any CSS rule recognized by GTK+."), "\n", - _("You can temporarily disable this custom CSS by clicking on the \"Pause\" button above."), "\n\n", - _("Changes are applied instantly, only for this selected widget."), "\n", - "*/\n\n", NULL); - gtk_text_buffer_set_text (GTK_TEXT_BUFFER (ce->priv->text), initial_text, -1); - g_free (initial_text); - } -} - -static void -disable_toggled (GtkToggleToolButton *button, - GtkInspectorCssEditor *ce) -{ - if (gtk_toggle_tool_button_get_active (button)) - { - if (ce->priv->global) - gtk_style_context_remove_provider_for_screen (gdk_screen_get_default (), - GTK_STYLE_PROVIDER (ce->priv->provider)); - else if (ce->priv->context) - gtk_style_context_remove_provider (ce->priv->context, - GTK_STYLE_PROVIDER (g_object_get_data (G_OBJECT (ce->priv->context), GTK_INSPECTOR_CSS_EDITOR_PROVIDER))); - } - else - { - if (ce->priv->global) - gtk_style_context_add_provider_for_screen (gdk_screen_get_default (), - GTK_STYLE_PROVIDER (ce->priv->provider), - GTK_STYLE_PROVIDER_PRIORITY_USER); - else if (ce->priv->context) - gtk_style_context_add_provider (ce->priv->context, - GTK_STYLE_PROVIDER (g_object_get_data (G_OBJECT (ce->priv->context), GTK_INSPECTOR_CSS_EDITOR_PROVIDER)), - G_MAXUINT); - } -} - -static void -apply_system_font (GtkInspectorCssEditor *ce) -{ - GSettings *s = g_settings_new ("org.gnome.desktop.interface"); - gchar *font_name = g_settings_get_string (s, "monospace-font-name"); - PangoFontDescription *font_desc = pango_font_description_from_string (font_name); - - gtk_widget_override_font (ce->priv->view, font_desc); - - pango_font_description_free (font_desc); - g_free (font_name); - g_object_unref (s); -} - -static gchar * -get_current_text (GtkTextBuffer *buffer) -{ - GtkTextIter start, end; - - gtk_text_buffer_get_start_iter (buffer, &start); - gtk_text_buffer_get_end_iter (buffer, &end); - gtk_text_buffer_remove_all_tags (buffer, &start, &end); - - return gtk_text_buffer_get_text (buffer, &start, &end, FALSE); -} - -static void -text_changed (GtkTextBuffer *buffer, - GtkInspectorCssEditor *ce) -{ - GtkCssProvider *provider; - gchar *text; - - if (ce->priv->global) - provider = ce->priv->provider; - else if (ce->priv->context) - provider = g_object_get_data (G_OBJECT (ce->priv->context), GTK_INSPECTOR_CSS_EDITOR_PROVIDER); - else - return; - - text = get_current_text (buffer); - gtk_css_provider_load_from_data (provider, text, -1, NULL); - g_free (text); - - gtk_style_context_reset_widgets (gdk_screen_get_default ()); -} - -static void -show_parsing_error (GtkCssProvider *provider, - GtkCssSection *section, - const GError *error, - GtkInspectorCssEditor *ce) -{ - GtkTextIter start, end; - const char *tag_name; - GtkTextBuffer *buffer = GTK_TEXT_BUFFER (ce->priv->text); - - gtk_text_buffer_get_iter_at_line_index (buffer, - &start, - gtk_css_section_get_start_line (section), - gtk_css_section_get_start_position (section)); - gtk_text_buffer_get_iter_at_line_index (buffer, - &end, - gtk_css_section_get_end_line (section), - gtk_css_section_get_end_position (section)); - - if (g_error_matches (error, GTK_CSS_PROVIDER_ERROR, GTK_CSS_PROVIDER_ERROR_DEPRECATED)) - tag_name = "warning"; - else - tag_name = "error"; - - gtk_text_buffer_apply_tag_by_name (buffer, tag_name, &start, &end); -} - -static void -create_provider (GtkInspectorCssEditor *ce) -{ - GtkCssProvider *provider = gtk_css_provider_new (); - - if (ce->priv->global) - { - ce->priv->provider = provider; - gtk_style_context_add_provider_for_screen (gdk_screen_get_default (), - GTK_STYLE_PROVIDER (ce->priv->provider), - GTK_STYLE_PROVIDER_PRIORITY_USER); - } - else if (ce->priv->context) - { - gtk_style_context_add_provider (ce->priv->context, - GTK_STYLE_PROVIDER (provider), - G_MAXUINT); - g_object_set_data_full (G_OBJECT (ce->priv->context), - GTK_INSPECTOR_CSS_EDITOR_PROVIDER, provider, - g_object_unref); - } - - g_signal_connect (provider, "parsing-error", - G_CALLBACK (show_parsing_error), ce); -} - -static void -gtk_inspector_css_editor_init (GtkInspectorCssEditor *ce) -{ - ce->priv = gtk_inspector_css_editor_get_instance_private (ce); - gtk_widget_init_template (GTK_WIDGET (ce)); -} - -static void -constructed (GObject *object) -{ - GtkInspectorCssEditor *ce = GTK_INSPECTOR_CSS_EDITOR (object); - - create_provider (ce); - apply_system_font (ce); - set_initial_text (ce); -} - -static void -get_property (GObject *object, - guint param_id, - GValue *value, - GParamSpec *pspec) -{ - GtkInspectorCssEditor *ce = GTK_INSPECTOR_CSS_EDITOR (object); - - switch (param_id) - { - case PROP_GLOBAL: - g_value_set_boolean (value, ce->priv->global); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, param_id, pspec); - break; - } -} - -static void -set_property (GObject *object, - guint param_id, - const GValue *value, - GParamSpec *pspec) -{ - GtkInspectorCssEditor *ce = GTK_INSPECTOR_CSS_EDITOR (object); - - switch (param_id) - { - case PROP_GLOBAL: - ce->priv->global = g_value_get_boolean (value); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, param_id, pspec); - break; - } -} - -static void -gtk_inspector_css_editor_class_init (GtkInspectorCssEditorClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); - - object_class->get_property = get_property; - object_class->set_property = set_property; - object_class->constructed = constructed; - - g_object_class_install_property (object_class, PROP_GLOBAL, - g_param_spec_boolean ("global", "Global", "Whether this editor changes the whole application or just the selected widget", - TRUE, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); - - gtk_widget_class_set_template_from_resource (widget_class, "/org/gtk/inspector/css-editor.ui"); - gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorCssEditor, toolbar); - gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorCssEditor, text); - gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorCssEditor, view); - gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorCssEditor, disable_button); - gtk_widget_class_bind_template_callback (widget_class, disable_toggled); - gtk_widget_class_bind_template_callback (widget_class, text_changed); -} - -GtkWidget * -gtk_inspector_css_editor_new (gboolean global) -{ - return GTK_WIDGET (g_object_new (GTK_TYPE_INSPECTOR_CSS_EDITOR, - "global", global, - NULL)); -} - -static void -remove_dead_object (gpointer data, GObject *dead_object) -{ - GtkInspectorCssEditor *ce = data; - - ce->priv->context = NULL; - gtk_widget_hide (GTK_WIDGET (ce)); -} - -void -gtk_inspector_css_editor_set_object (GtkInspectorCssEditor *ce, - GObject *object) -{ - gchar *text; - GtkCssProvider *provider; - - g_return_if_fail (GTK_INSPECTOR_IS_CSS_EDITOR (ce)); - g_return_if_fail (!ce->priv->global); - - if (ce->priv->context) - { - g_object_weak_unref (G_OBJECT (ce->priv->context), remove_dead_object, ce); - text = get_current_text (GTK_TEXT_BUFFER (ce->priv->text)); - g_object_set_data_full (G_OBJECT (ce->priv->context), - GTK_INSPECTOR_CSS_EDITOR_TEXT, - text, g_free); - ce->priv->context = NULL; - } - - if (!GTK_IS_WIDGET (object)) - { - gtk_widget_hide (GTK_WIDGET (ce)); - return; - } - - gtk_widget_show (GTK_WIDGET (ce)); - - ce->priv->context = gtk_widget_get_style_context (GTK_WIDGET (object)); - - provider = g_object_get_data (G_OBJECT (ce->priv->context), GTK_INSPECTOR_CSS_EDITOR_PROVIDER); - if (!provider) - create_provider (ce); - - set_initial_text (ce); - disable_toggled (ce->priv->disable_button, ce); - - g_object_weak_ref (G_OBJECT (ce->priv->context), remove_dead_object, ce); -} - -// vim: set et sw=2 ts=2: diff --git a/modules/inspector/css-editor.h b/modules/inspector/css-editor.h deleted file mode 100644 index bd8eb76004..0000000000 --- a/modules/inspector/css-editor.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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. - */ - -#ifndef _GTK_INSPECTOR_CSS_EDITOR_H_ -#define _GTK_INSPECTOR_CSS_EDITOR_H_ - -#include <gtk/gtk.h> - -#define GTK_TYPE_INSPECTOR_CSS_EDITOR (gtk_inspector_css_editor_get_type()) -#define GTK_INSPECTOR_CSS_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GTK_TYPE_INSPECTOR_CSS_EDITOR, GtkInspectorCssEditor)) -#define GTK_INSPECTOR_CSS_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GTK_TYPE_INSPECTOR_CSS_EDITOR, GtkInspectorCssEditorClass)) -#define GTK_INSPECTOR_IS_CSS_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GTK_TYPE_INSPECTOR_CSS_EDITOR)) -#define GTK_INSPECTOR_IS_CSS_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GTK_TYPE_INSPECTOR_CSS_EDITOR)) -#define GTK_INSPECTOR_CSS_EDITOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GTK_TYPE_INSPECTOR_CSS_EDITOR, GtkInspectorCssEditorClass)) - - -typedef struct _GtkInspectorCssEditorPrivate GtkInspectorCssEditorPrivate; - -typedef struct _GtkInspectorCssEditor -{ - GtkBox parent; - GtkInspectorCssEditorPrivate *priv; -} GtkInspectorCssEditor; - -typedef struct _GtkInspectorCssEditorClass -{ - GtkBoxClass parent; -} GtkInspectorCssEditorClass; - -G_BEGIN_DECLS - -GType gtk_inspector_css_editor_get_type (void); -GtkWidget *gtk_inspector_css_editor_new (gboolean global); -void gtk_inspector_css_editor_set_object (GtkInspectorCssEditor *ce, - GObject *object); - -G_END_DECLS - -#endif // _GTK_INSPECTOR_CSS_EDITOR_H_ - -// vim: set et sw=2 ts=2: diff --git a/modules/inspector/css-editor.ui b/modules/inspector/css-editor.ui deleted file mode 100644 index 7a6d921a25..0000000000 --- a/modules/inspector/css-editor.ui +++ /dev/null @@ -1,49 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<interface domain="gtk30"> - <object class="GtkTextTagTable" id="tags"> - <child type="tag"> - <object class="GtkTextTag"> - <property name="name">warning</property> - <property name="underline">single</property> - </object> - <object class="GtkTextTag"> - <property name="name">error</property> - <property name="underline">error</property> - </object> - </child> - </object> - <object class="GtkTextBuffer" id="text"> - <property name="tag-table">tags</property> - <signal name="changed" handler="text_changed"/> - </object> - <template class="GtkInspectorCssEditor" parent="GtkBox"> - <property name="orientation">vertical</property> - <child> - <object class="GtkToolbar" id="toolbar"> - <property name="visible">True</property> - <property name="icon-size">small-toolbar</property> - <child> - <object class="GtkToggleToolButton" id="disable_button"> - <property name="visible">True</property> - <property name="icon-name">media-playback-pause</property> - <property name="tooltip-text" translatable="yes">Disable this custom CSS</property> - <signal name="toggled" handler="disable_toggled"/> - </object> - </child> - </object> - </child> - <child> - <object class="GtkScrolledWindow"> - <property name="visible">True</property> - <property name="expand">True</property> - <child> - <object class="GtkTextView" id="view"> - <property name="visible">True</property> - <property name="buffer">text</property> - <property name="wrap-mode">word</property> - </object> - </child> - </object> - </child> - </template> -</interface> diff --git a/modules/inspector/data-list.c b/modules/inspector/data-list.c deleted file mode 100644 index 9ccc86da06..0000000000 --- a/modules/inspector/data-list.c +++ /dev/null @@ -1,110 +0,0 @@ -/* - * 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/>. - */ - -#include "config.h" -#include <glib/gi18n-lib.h> -#include "data-list.h" - -enum -{ - COLUMN_NUMBER, - COLUMN_TYPE -}; - -struct _GtkInspectorDataListPrivate -{ - GtkListStore *model; - GtkTreeViewColumn *number_column; - GtkCellRenderer *number_renderer; -}; - -G_DEFINE_TYPE_WITH_PRIVATE (GtkInspectorDataList, gtk_inspector_data_list, GTK_TYPE_BOX) - -static void -render_number (GtkTreeViewColumn *column, - GtkCellRenderer *renderer, - GtkTreeModel *model, - GtkTreeIter *iter, - gpointer data) -{ - gint number; - gchar text[100]; - - gtk_tree_model_get (model, iter, COLUMN_NUMBER, &number, -1); - g_snprintf (text, 100, "%d", number); - g_object_set (renderer, "text", text, NULL); -} - -static void -gtk_inspector_data_list_init (GtkInspectorDataList *sl) -{ - sl->priv = gtk_inspector_data_list_get_instance_private (sl); - gtk_widget_init_template (GTK_WIDGET (sl)); - gtk_tree_view_column_set_cell_data_func (sl->priv->number_column, - sl->priv->number_renderer, - render_number, - NULL, NULL); -} - -void -gtk_inspector_data_list_set_object (GtkInspectorDataList *sl, - GObject *object) -{ - GtkTreeIter iter; - gint i; - - gtk_list_store_clear (sl->priv->model); - - if (!GTK_IS_TREE_MODEL (object)) - { - gtk_widget_hide (GTK_WIDGET (sl)); - return; - } - - gtk_widget_show (GTK_WIDGET (sl)); - - for (i = 0; i < gtk_tree_model_get_n_columns (GTK_TREE_MODEL (object)); i++) - { - GType type; - type = gtk_tree_model_get_column_type (GTK_TREE_MODEL (object), i); - - gtk_list_store_append (sl->priv->model, &iter); - gtk_list_store_set (sl->priv->model, &iter, - COLUMN_NUMBER, i, - COLUMN_TYPE, g_type_name (type), - -1); - } -} - -static void -gtk_inspector_data_list_class_init (GtkInspectorDataListClass *klass) -{ - GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); - - gtk_widget_class_set_template_from_resource (widget_class, "/org/gtk/inspector/data-list.ui"); - gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorDataList, model); - gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorDataList, number_column); - gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorDataList, number_renderer); -} - -GtkWidget * -gtk_inspector_data_list_new (void) -{ - return GTK_WIDGET (g_object_new (GTK_TYPE_INSPECTOR_DATA_LIST, NULL)); -} - -// vim: set et sw=2 ts=2: diff --git a/modules/inspector/data-list.h b/modules/inspector/data-list.h deleted file mode 100644 index c27ab992c1..0000000000 --- a/modules/inspector/data-list.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * 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/>. - */ - -#ifndef _GTK_INSPECTOR_DATA_LIST_H_ -#define _GTK_INSPECTOR_DATA_LIST_H_ - -#include <gtk/gtk.h> - -#define GTK_TYPE_INSPECTOR_DATA_LIST (gtk_inspector_data_list_get_type()) -#define GTK_INSPECTOR_DATA_LIST(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GTK_TYPE_INSPECTOR_DATA_LIST, GtkInspectorDataList)) -#define GTK_INSPECTOR_DATA_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GTK_TYPE_INSPECTOR_DATA_LIST, GtkInspectorDataListClass)) -#define GTK_INSPECTOR_IS_DATA_LIST(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GTK_TYPE_INSPECTOR_DATA_LIST)) -#define GTK_INSPECTOR_IS_DATA_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GTK_TYPE_INSPECTOR_DATA_LIST)) -#define GTK_INSPECTOR_DATA_LIST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GTK_TYPE_INSPECTOR_DATA_LIST, GtkInspectorDataListClass)) - - -typedef struct _GtkInspectorDataListPrivate GtkInspectorDataListPrivate; - -typedef struct _GtkInspectorDataList -{ - GtkBox parent; - GtkInspectorDataListPrivate *priv; -} GtkInspectorDataList; - -typedef struct _GtkInspectorDataListClass -{ - GtkBoxClass parent; -} GtkInspectorDataListClass; - -G_BEGIN_DECLS - -GType gtk_inspector_data_list_get_type (void); -GtkWidget *gtk_inspector_data_list_new (void); -void gtk_inspector_data_list_set_object (GtkInspectorDataList *sl, - GObject *object); - -G_END_DECLS - -#endif // _GTK_INSPECTOR_DATA_LIST_H_ - -// vim: set et sw=2 ts=2: diff --git a/modules/inspector/data-list.ui b/modules/inspector/data-list.ui deleted file mode 100644 index bd2786d485..0000000000 --- a/modules/inspector/data-list.ui +++ /dev/null @@ -1,53 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<interface domain="gtk30"> - <object class="GtkListStore" id="model"> - <columns> - <column type="gint"/> - <column type="gchararray"/> - </columns> - </object> - <template class="GtkInspectorDataList" parent="GtkBox"> - <property name="orientation">vertical</property> - <child> - <object class="GtkScrolledWindow"> - <property name="visible">True</property> - <property name="expand">True</property> - <property name="hscrollbar-policy">automatic</property> - <property name="vscrollbar-policy">always</property> - <property name="shadow-type">in</property> - <child> - <object class= "GtkTreeView"> - <property name="visible">True</property> - <property name="model">model</property> - <child> - <object class="GtkTreeViewColumn" id="number_column"> - <property name="title" translatable="yes">Column</property> - <child> - <object class="GtkCellRendererText" id="number_renderer"> - <property name="scale">0.8</property> - </object> - <attributes> - <attribute name="text">0</attribute> - </attributes> - </child> - </object> - </child> - <child> - <object class="GtkTreeViewColumn"> - <property name="title" translatable="yes">Type</property> - <child> - <object class="GtkCellRendererText"> - <property name="scale">0.8</property> - </object> - <attributes> - <attribute name="text">1</attribute> - </attributes> - </child> - </object> - </child> - </object> - </child> - </object> - </child> - </template> -</interface> diff --git a/modules/inspector/inspect-button.c b/modules/inspector/inspect-button.c deleted file mode 100644 index fe438ffc5c..0000000000 --- a/modules/inspector/inspect-button.c +++ /dev/null @@ -1,362 +0,0 @@ -/* - * Copyright (c) 2008-2009 Christian Hammond - * Copyright (c) 2008-2009 David Trowbridge - * - * 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. - */ - -#include "config.h" -#include <glib/gi18n-lib.h> -#include "window.h" -#include "widget-tree.h" - -typedef struct -{ - gint x; - gint y; - gboolean found; - gboolean first; - GtkWidget *res_widget; -} FindWidgetData; - -static void -find_widget (GtkWidget *widget, - FindWidgetData *data) -{ - GtkAllocation new_allocation; - gint x_offset = 0; - gint y_offset = 0; - - gtk_widget_get_allocation (widget, &new_allocation); - - if (data->found || !gtk_widget_get_mapped (widget)) - return; - - /* Note that in the following code, we only count the - * position as being inside a WINDOW widget if it is inside - * widget->window; points that are outside of widget->window - * but within the allocation are not counted. This is consistent - * with the way we highlight drag targets. - */ - if (gtk_widget_get_has_window (widget)) - { - new_allocation.x = 0; - new_allocation.y = 0; - } - - if (gtk_widget_get_parent (widget) && !data->first) - { - GdkWindow *window = gtk_widget_get_window (widget); - while (window != gtk_widget_get_window (gtk_widget_get_parent (widget))) - { - gint tx, ty, twidth, theight; - - twidth = gdk_window_get_width (window); - theight = gdk_window_get_height (window); - - if (new_allocation.x < 0) - { - new_allocation.width += new_allocation.x; - new_allocation.x = 0; - } - if (new_allocation.y < 0) - { - new_allocation.height += new_allocation.y; - new_allocation.y = 0; - } - if (new_allocation.x + new_allocation.width > twidth) - new_allocation.width = twidth - new_allocation.x; - if (new_allocation.y + new_allocation.height > theight) - new_allocation.height = theight - new_allocation.y; - - gdk_window_get_position (window, &tx, &ty); - new_allocation.x += tx; - x_offset += tx; - new_allocation.y += ty; - y_offset += ty; - - window = gdk_window_get_parent (window); - } - } - - if ((data->x >= new_allocation.x) && (data->y >= new_allocation.y) && - (data->x < new_allocation.x + new_allocation.width) && - (data->y < new_allocation.y + new_allocation.height)) - { - /* First, check if the drag is in a valid drop site in - * one of our children - */ - if (GTK_IS_CONTAINER (widget)) - { - FindWidgetData new_data = *data; - - new_data.x -= x_offset; - new_data.y -= y_offset; - new_data.found = FALSE; - new_data.first = FALSE; - - gtk_container_forall (GTK_CONTAINER (widget), - (GtkCallback)find_widget, - &new_data); - - data->found = new_data.found; - if (data->found) - data->res_widget = new_data.res_widget; - } - - /* If not, and this widget is registered as a drop site, check to - * emit "drag_motion" to check if we are actually in - * a drop site. - */ - if (!data->found) - { - data->found = TRUE; - data->res_widget = widget; - } - } -} - -static GtkWidget * -find_widget_at_pointer (GdkDevice *device) -{ - GtkWidget *widget = NULL; - GdkWindow *pointer_window; - gint x, y; - FindWidgetData data; - - pointer_window = gdk_device_get_window_at_position (device, NULL, NULL); - - if (pointer_window) - { - gpointer widget_ptr; - - gdk_window_get_user_data (pointer_window, &widget_ptr); - widget = widget_ptr; - } - - if (widget) - { - gdk_window_get_device_position (gtk_widget_get_window (widget), - device, &x, &y, NULL); - - data.x = x; - data.y = y; - data.found = FALSE; - data.first = TRUE; - - find_widget (widget, &data); - if (data.found) - return data.res_widget; - - return widget; - } - - return NULL; -} - -static gboolean draw_flash (GtkWidget *widget, - cairo_t *cr, - GtkInspectorWindow *iw); - -static void -clear_flash (GtkInspectorWindow *iw) -{ - if (iw->flash_widget) - { - gtk_widget_queue_draw (iw->flash_widget); - g_signal_handlers_disconnect_by_func (iw->flash_widget, draw_flash, iw); - iw->flash_widget = NULL; - } -} - -static void -start_flash (GtkInspectorWindow *iw, - GtkWidget *widget) -{ - iw->flash_count = 1; - iw->flash_widget = widget; - g_signal_connect_after (widget, "draw", G_CALLBACK (draw_flash), iw); - gtk_widget_queue_draw (widget); -} - -static void -on_inspect_widget (GtkWidget *button, - GdkEvent *event, - GtkInspectorWindow *iw) -{ - GtkWidget *widget; - - clear_flash (iw); - - widget = find_widget_at_pointer (gdk_event_get_device (event)); - - if (widget == NULL) - return; - - iw->selected_widget = widget; - - gtk_inspector_widget_tree_scan (GTK_INSPECTOR_WIDGET_TREE (iw->widget_tree), - gtk_widget_get_toplevel (widget)); - - gtk_inspector_widget_tree_select_object (GTK_INSPECTOR_WIDGET_TREE (iw->widget_tree), - G_OBJECT (widget)); -} - -static void -on_highlight_widget (GtkWidget *button, - GdkEvent *event, - GtkInspectorWindow *iw) -{ - GtkWidget *widget; - - widget = find_widget_at_pointer (gdk_event_get_device (event)); - - if (widget == NULL) - { - /* This window isn't in-process. Ignore it. */ - return; - } - - if (gtk_widget_get_toplevel (widget) == GTK_WIDGET (iw)) - { - /* Don't hilight things in the inspector window */ - return; - } - - if (iw->flash_widget == widget) - { - /* Already selected */ - return; - } - - clear_flash (iw); - start_flash (iw, widget); -} - -static gboolean -property_query_event (GtkWidget *widget, - GdkEvent *event, - gpointer data) -{ - if (event->type == GDK_BUTTON_RELEASE) - { - g_signal_handlers_disconnect_by_func (widget, property_query_event, data); - gtk_grab_remove (widget); - gdk_device_ungrab (gdk_event_get_device (event), GDK_CURRENT_TIME); - on_inspect_widget (widget, event, data); - } - else if (event->type == GDK_MOTION_NOTIFY) - { - on_highlight_widget (widget, event, data); - } - - return FALSE; -} - -void -on_inspect (GtkWidget *button, - GtkInspectorWindow *iw) -{ - GdkDisplay *display; - GdkDevice *device; - GdkCursor *cursor; - - g_signal_connect (button, "event", - G_CALLBACK (property_query_event), iw); - - display = gtk_widget_get_display (button); - cursor = gdk_cursor_new_for_display (display, GDK_CROSSHAIR); - device = gdk_device_manager_get_client_pointer (gdk_display_get_device_manager (display)); - gdk_device_grab (device, - gtk_widget_get_window (GTK_WIDGET (button)), - GDK_OWNERSHIP_NONE, TRUE, - GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK, - cursor, GDK_CURRENT_TIME); - g_object_unref (cursor); - gtk_grab_add (GTK_WIDGET (button)); -} - -static gboolean -draw_flash (GtkWidget *widget, - cairo_t *cr, - GtkInspectorWindow *iw) -{ - GtkAllocation alloc; - - if (iw->flash_count % 2 == 0) - return FALSE; - - if (GTK_IS_WINDOW (widget)) - { - /* We don't want to draw the drag highlight around the - * CSD window decorations - */ - gtk_widget_get_allocation (gtk_bin_get_child (GTK_BIN (widget)), &alloc); - } - else - { - alloc.x = 0; - alloc.y = 0; - alloc.width = gtk_widget_get_allocated_width (widget); - alloc.height = gtk_widget_get_allocated_height (widget); - } - - cairo_set_source_rgba (cr, 0.0, 0.0, 1.0, 0.2); - cairo_rectangle (cr, - alloc.x + 0.5, alloc.y + 0.5, - alloc.width - 1, alloc.height - 1); - cairo_fill (cr); - - return FALSE; -} - -static gboolean -on_flash_timeout (GtkInspectorWindow *iw) -{ - gtk_widget_queue_draw (iw->flash_widget); - - iw->flash_count++; - - if (iw->flash_count == 6) - { - g_signal_handlers_disconnect_by_func (iw->flash_widget, draw_flash, iw); - iw->flash_widget = NULL; - iw->flash_cnx = 0; - - return G_SOURCE_REMOVE; - } - - return G_SOURCE_CONTINUE; -} - -void -gtk_inspector_flash_widget (GtkInspectorWindow *iw, - GtkWidget *widget) -{ - if (iw->flash_cnx != 0) - return; - - if (!gtk_widget_get_visible (widget) || !gtk_widget_get_mapped (widget)) - return; - - start_flash (iw, widget); - iw->flash_cnx = g_timeout_add (150, (GSourceFunc) on_flash_timeout, iw); -} - -/* vim: set et sw=2 ts=2: */ diff --git a/modules/inspector/inspector.gresource.xml b/modules/inspector/inspector.gresource.xml deleted file mode 100644 index fb65fad987..0000000000 --- a/modules/inspector/inspector.gresource.xml +++ /dev/null @@ -1,16 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<gresources> - <gresource prefix="/org/gtk/inspector"> - <file>button-path.ui</file> - <file>classes-list.ui</file> - <file>css-editor.ui</file> - <file>data-list.ui</file> - <file>object-hierarchy.ui</file> - <file>prop-list.ui</file> - <file>signals-list.ui</file> - <file>themes.ui</file> - <file>visual.ui</file> - <file>widget-tree.ui</file> - <file>window.ui</file> - </gresource> -</gresources> diff --git a/modules/inspector/module.c b/modules/inspector/module.c deleted file mode 100644 index 1082dedb6a..0000000000 --- a/modules/inspector/module.c +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2008-2009 Christian Hammond - * Copyright (c) 2008-2009 David Trowbridge - * - * 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. - */ -#include <glib.h> - -#include "button-path.h" -#include "classes-list.h" -#include "css-editor.h" -#include "data-list.h" -#include "object-hierarchy.h" -#include "property-cell-renderer.h" -#include "prop-list.h" -#include "python-hooks.h" -#include "python-shell.h" -#include "resources.h" -#include "signals-list.h" -#include "themes.h" -#include "visual.h" -#include "widget-tree.h" -#include "window.h" - -void -gtk_module_init (gint *argc, gchar ***argv) -{ -#ifdef ENABLE_PYTHON - gtk_inspector_python_init (); -#endif - - gtk_inspector_register_resource (); - - g_type_ensure (GTK_TYPE_INSPECTOR_BUTTON_PATH); - g_type_ensure (GTK_TYPE_INSPECTOR_CLASSES_LIST); - g_type_ensure (GTK_TYPE_INSPECTOR_CSS_EDITOR); - g_type_ensure (GTK_TYPE_INSPECTOR_DATA_LIST); - g_type_ensure (GTK_TYPE_INSPECTOR_OBJECT_HIERARCHY); - g_type_ensure (GTK_TYPE_INSPECTOR_PROPERTY_CELL_RENDERER); - g_type_ensure (GTK_TYPE_INSPECTOR_PROP_LIST); - g_type_ensure (GTK_TYPE_INSPECTOR_PYTHON_SHELL); - g_type_ensure (GTK_TYPE_INSPECTOR_SIGNALS_LIST); - g_type_ensure (GTK_TYPE_INSPECTOR_THEMES); - g_type_ensure (GTK_TYPE_INSPECTOR_VISUAL); - g_type_ensure (GTK_TYPE_INSPECTOR_WIDGET_TREE); - g_type_ensure (GTK_TYPE_INSPECTOR_WINDOW); -} - - -// vim: set et sw=2 ts=2: diff --git a/modules/inspector/object-hierarchy.c b/modules/inspector/object-hierarchy.c deleted file mode 100644 index 6576a85024..0000000000 --- a/modules/inspector/object-hierarchy.c +++ /dev/null @@ -1,119 +0,0 @@ -/* - * 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. - */ - -#include "object-hierarchy.h" - -enum -{ - COLUMN_OBJECT_NAME -}; - -struct _GtkInspectorObjectHierarchyPrivate -{ - GtkTreeStore *model; - GtkTreeView *tree; -}; - -G_DEFINE_TYPE_WITH_PRIVATE (GtkInspectorObjectHierarchy, gtk_inspector_object_hierarchy, GTK_TYPE_BOX) - -static void -gtk_inspector_object_hierarchy_init (GtkInspectorObjectHierarchy *oh) -{ - oh->priv = gtk_inspector_object_hierarchy_get_instance_private (oh); - gtk_widget_init_template (GTK_WIDGET (oh)); -} - -static void -gtk_inspector_object_hierarchy_class_init (GtkInspectorObjectHierarchyClass *klass) -{ - GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); - - gtk_widget_class_set_template_from_resource (widget_class, "/org/gtk/inspector/object-hierarchy.ui"); - gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorObjectHierarchy, model); - gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorObjectHierarchy, tree); -} - -GtkWidget * -gtk_inspector_object_hierarchy_new (void) -{ - return GTK_WIDGET (g_object_new (GTK_TYPE_INSPECTOR_OBJECT_HIERARCHY, NULL)); -} - -void -gtk_inspector_object_hierarchy_set_object (GtkInspectorObjectHierarchy *oh, - GObject *object) -{ - GType type; - const gchar *class_name; - GtkTreeIter iter, parent; - GList *list = NULL, *l; - GHashTable *interfaces; - GHashTableIter hit; - GType *ifaces; - gint i; - - gtk_tree_store_clear (oh->priv->model); - - if (object == NULL) - return; - - interfaces = g_hash_table_new (g_str_hash, g_str_equal); - type = ((GTypeInstance*)object)->g_class->g_type; - - do - { - class_name = g_type_name (type); - list = g_list_append (list, (gpointer)class_name); - ifaces = g_type_interfaces (type, NULL); - for (i = 0; ifaces[i]; i++) - g_hash_table_add (interfaces, (gchar *)g_type_name (ifaces[i])); - g_free (ifaces); - } - while ((type = g_type_parent (type))); - - g_hash_table_iter_init (&hit, interfaces); - while (g_hash_table_iter_next (&hit, (gpointer *)&class_name, NULL)) - { - gtk_tree_store_append (oh->priv->model, &iter, NULL); - gtk_tree_store_set (oh->priv->model, &iter, - COLUMN_OBJECT_NAME, class_name, - -1); - } - g_hash_table_unref (interfaces); - - list = g_list_reverse (list); - for (l = list; l; l = l->next) - { - gtk_tree_store_append (oh->priv->model, &iter, l == list ? NULL : &parent); - gtk_tree_store_set (oh->priv->model, &iter, - COLUMN_OBJECT_NAME, l->data, - -1); - parent = iter; - } - - g_list_free (list); - - gtk_tree_view_expand_all (oh->priv->tree); - gtk_tree_selection_select_iter (gtk_tree_view_get_selection (oh->priv->tree), &iter); -} - -// vim: set et sw=2 ts=2: diff --git a/modules/inspector/object-hierarchy.h b/modules/inspector/object-hierarchy.h deleted file mode 100644 index baa409384b..0000000000 --- a/modules/inspector/object-hierarchy.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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. - */ - -#ifndef _GTK_INSPECTOR_OBJECT_HIERARCHY_H_ -#define _GTK_INSPECTOR_OBJECT_HIERARCHY_H_ - -#include <gtk/gtk.h> - -#define GTK_TYPE_INSPECTOR_OBJECT_HIERARCHY (gtk_inspector_object_hierarchy_get_type()) -#define GTK_INSPECTOR_OBJECT_HIERARCHY(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GTK_TYPE_INSPECTOR_OBJECT_HIERARCHY, GtkInspectorObjectHierarchy)) -#define GTK_INSPECTOR_OBJECT_HIERARCHY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GTK_TYPE_INSPECTOR_OBJECT_HIERARCHY, GtkInspectorObjectHierarchyClass)) -#define GTK_INSPECTOR_IS_OBJECT_HIERARCHY(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GTK_TYPE_INSPECTOR_OBJECT_HIERARCHY)) -#define GTK_INSPECTOR_IS_OBJECT_HIERARCHY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GTK_TYPE_INSPECTOR_OBJECT_HIERARCHY)) -#define GTK_INSPECTOR_OBJECT_HIERARCHY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GTK_TYPE_INSPECTOR_OBJECT_HIERARCHY, GtkInspectorObjectHierarchyClass)) - - -typedef struct _GtkInspectorObjectHierarchyPrivate GtkInspectorObjectHierarchyPrivate; - -typedef struct _GtkInspectorObjectHierarchy -{ - GtkBox parent; - GtkInspectorObjectHierarchyPrivate *priv; -} GtkInspectorObjectHierarchy; - -typedef struct _GtkInspectorObjectHierarchyClass -{ - GtkBoxClass parent; -} GtkInspectorObjectHierarchyClass; - -G_BEGIN_DECLS - -GType gtk_inspector_object_hierarchy_get_type (void); -GtkWidget *gtk_inspector_object_hierarchy_new (void); -void gtk_inspector_object_hierarchy_set_object (GtkInspectorObjectHierarchy *oh, - GObject *object); - -G_END_DECLS - -#endif // _GTK_INSPECTOR_OBJECT_HIERARCHY_H_ - -// vim: set et sw=2 ts=2: diff --git a/modules/inspector/object-hierarchy.ui b/modules/inspector/object-hierarchy.ui deleted file mode 100644 index fd5dd0b91e..0000000000 --- a/modules/inspector/object-hierarchy.ui +++ /dev/null @@ -1,36 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<interface domain="gtk30"> - <object class="GtkTreeStore" id="model"> - <columns> - <column type="gchararray"/> - </columns> - </object> - <template class="GtkInspectorObjectHierarchy" parent="GtkBox"> - <property name="orientation">horizontal</property> - <child> - <object class="GtkScrolledWindow"> - <property name="visible">True</property> - <property name="expand">True</property> - <child> - <object class="GtkTreeView" id="tree"> - <property name="visible">True</property> - <property name="model">model</property> - <child> - <object class="GtkTreeViewColumn"> - <property name="title" translatable="yes">Object Hierarchy</property> - <child> - <object class="GtkCellRendererText"> - <property name="scale">0.8</property> - </object> - <attributes> - <attribute name="text">0</attribute> - </attributes> - </child> - </object> - </child> - </object> - </child> - </object> - </child> - </template> -</interface> diff --git a/modules/inspector/prop-list.c b/modules/inspector/prop-list.c deleted file mode 100644 index f9eda27084..0000000000 --- a/modules/inspector/prop-list.c +++ /dev/null @@ -1,343 +0,0 @@ -/* - * Copyright (c) 2008-2009 Christian Hammond - * Copyright (c) 2008-2009 David Trowbridge - * - * 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. - */ - -#include "prop-list.h" -#include "property-cell-renderer.h" - - -enum -{ - COLUMN_NAME, - COLUMN_VALUE, - COLUMN_DEFINED_AT, - COLUMN_OBJECT, - COLUMN_TOOLTIP, - COLUMN_WRITABLE, - COLUMN_ATTRIBUTE -}; - -enum -{ - PROP_0, - PROP_WIDGET_TREE, - PROP_CHILD_PROPERTIES -}; - -struct _GtkInspectorPropListPrivate -{ - GObject *object; - GtkListStore *model; - GHashTable *prop_iters; - gulong notify_handler_id; - GtkWidget *widget_tree; - GtkCellRenderer *value_renderer; - gboolean child_properties; - GtkTreeViewColumn *attribute_column; - GtkWidget *tree; -}; - -G_DEFINE_TYPE_WITH_PRIVATE (GtkInspectorPropList, gtk_inspector_prop_list, GTK_TYPE_BOX) - -static void -gtk_inspector_prop_list_init (GtkInspectorPropList *pl) -{ - pl->priv = gtk_inspector_prop_list_get_instance_private (pl); - gtk_widget_init_template (GTK_WIDGET (pl)); - gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (pl->priv->model), - COLUMN_NAME, - GTK_SORT_ASCENDING); - pl->priv->prop_iters = g_hash_table_new_full (g_str_hash, - g_str_equal, - NULL, - (GDestroyNotify) gtk_tree_iter_free); -} - -static void -get_property (GObject *object, - guint param_id, - GValue *value, - GParamSpec *pspec) -{ - GtkInspectorPropList *pl = GTK_INSPECTOR_PROP_LIST (object); - - switch (param_id) - { - case PROP_WIDGET_TREE: - g_value_take_object (value, pl->priv->widget_tree); - break; - - case PROP_CHILD_PROPERTIES: - g_value_set_boolean (value, pl->priv->child_properties); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec); - break; - } -} - -static void -set_property (GObject *object, - guint param_id, - const GValue *value, - GParamSpec *pspec) -{ - GtkInspectorPropList *pl = GTK_INSPECTOR_PROP_LIST (object); - - switch (param_id) - { - case PROP_WIDGET_TREE: - pl->priv->widget_tree = g_value_get_object (value); - g_object_set_data (G_OBJECT (pl->priv->value_renderer), "gtk-inspector-widget-tree", pl->priv->widget_tree); - break; - - case PROP_CHILD_PROPERTIES: - pl->priv->child_properties = g_value_get_boolean (value); - g_object_set (pl->priv->value_renderer, - "is-child-property", pl->priv->child_properties, - NULL); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec); - break; - } -} - -static void -gtk_inspector_prop_list_class_init (GtkInspectorPropListClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); - - object_class->get_property = get_property; - object_class->set_property = set_property; - - g_object_class_install_property (object_class, PROP_WIDGET_TREE, - g_param_spec_object ("widget-tree", "Widget Tree", "Widget tree", - GTK_TYPE_WIDGET, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); - g_object_class_install_property (object_class, PROP_CHILD_PROPERTIES, - g_param_spec_boolean ("child-properties", "Child properties", "Child properties", - FALSE, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); - - gtk_widget_class_set_template_from_resource (widget_class, "/org/gtk/inspector/prop-list.ui"); - gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorPropList, model); - gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorPropList, value_renderer); - gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorPropList, attribute_column); - gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorPropList, tree); -} - -static void -gtk_inspector_prop_list_update_prop (GtkInspectorPropList *pl, - GtkTreeIter *iter, - GParamSpec *prop) -{ - GValue gvalue = {0}; - gchar *value = NULL; - gchar *attribute = NULL; - - g_value_init (&gvalue, prop->value_type); - if (pl->priv->child_properties) - { - GtkWidget *parent; - - parent = gtk_widget_get_parent (GTK_WIDGET (pl->priv->object)); - gtk_container_child_get_property (GTK_CONTAINER (parent), - GTK_WIDGET (pl->priv->object), - prop->name, &gvalue); - } - else - g_object_get_property (pl->priv->object, prop->name, &gvalue); - - if (G_VALUE_HOLDS_ENUM (&gvalue)) - { - GEnumClass *enum_class = G_PARAM_SPEC_ENUM (prop)->enum_class; - GEnumValue *enum_value = g_enum_get_value (enum_class, g_value_get_enum (&gvalue)); - - value = g_strdup (enum_value->value_name); - } - else - { - value = g_strdup_value_contents (&gvalue); - } - - if (GTK_IS_CELL_RENDERER (pl->priv->object)) - { - gpointer *area; - gint column = -1; - - area = g_object_get_data (pl->priv->object, "gtk-inspector-cell-area"); - if (area) - column = gtk_cell_area_attribute_get_column (GTK_CELL_AREA (area), - GTK_CELL_RENDERER (pl->priv->object), - prop->name); - - if (column != -1) - attribute = g_strdup_printf ("%d", column); - } - - gtk_list_store_set (pl->priv->model, iter, - COLUMN_NAME, prop->name, - COLUMN_VALUE, value ? value : "", - COLUMN_DEFINED_AT, g_type_name (prop->owner_type), - COLUMN_OBJECT, pl->priv->object, - COLUMN_TOOLTIP, g_param_spec_get_blurb (prop), - COLUMN_WRITABLE, (prop->flags & G_PARAM_WRITABLE) != 0, - COLUMN_ATTRIBUTE, attribute ? attribute : "", - -1); - - g_free (value); - g_free (attribute); - g_value_unset (&gvalue); -} - -static void -gtk_inspector_prop_list_prop_changed_cb (GObject *pspec, - GParamSpec *prop, - GtkInspectorPropList *pl) -{ - GtkTreeIter *iter = g_hash_table_lookup (pl->priv->prop_iters, prop->name); - - if (iter != NULL) - gtk_inspector_prop_list_update_prop (pl, iter, prop); -} - -GtkWidget * -gtk_inspector_prop_list_new (GtkWidget *widget_tree, - gboolean child_properties) -{ - g_type_ensure (GTK_TYPE_INSPECTOR_PROPERTY_CELL_RENDERER); - - return g_object_new (GTK_TYPE_INSPECTOR_PROP_LIST, - "widget-tree", widget_tree, - "child-properties", child_properties, - NULL); -} - -static void remove_dead_object (gpointer data, GObject *dead_object); - -static void -cleanup_object (GtkInspectorPropList *pl) -{ - if (pl->priv->object) - g_object_weak_unref (pl->priv->object, remove_dead_object, pl); - - if (pl->priv->object && pl->priv->notify_handler_id != 0) - { - g_signal_handler_disconnect (pl->priv->object, pl->priv->notify_handler_id); - pl->priv->notify_handler_id = 0; - } - - pl->priv->object = NULL; - - g_hash_table_remove_all (pl->priv->prop_iters); - gtk_list_store_clear (pl->priv->model); -} - -static void -remove_dead_object (gpointer data, GObject *dead_object) -{ - GtkInspectorPropList *pl = data; - - pl->priv->notify_handler_id = 0; - pl->priv->object = NULL; - cleanup_object (pl); -} - -gboolean -gtk_inspector_prop_list_set_object (GtkInspectorPropList *pl, - GObject *object) -{ - GtkTreeIter iter; - GParamSpec **props; - guint num_properties; - guint i; - - if (pl->priv->object == object) - return FALSE; - - cleanup_object (pl); - - pl->priv->object = object; - - if (!object) - { - gtk_widget_hide (GTK_WIDGET (pl)); - return TRUE; - } - - g_object_weak_ref (object, remove_dead_object, pl); - - if (pl->priv->child_properties) - { - GtkWidget *parent; - - if (!GTK_IS_WIDGET (object)) - { - gtk_widget_hide (GTK_WIDGET (pl)); - return TRUE; - } - - parent = gtk_widget_get_parent (GTK_WIDGET (object)); - if (!parent) - { - gtk_widget_hide (GTK_WIDGET (pl)); - return TRUE; - } - - gtk_tree_view_column_set_visible (pl->priv->attribute_column, FALSE); - - props = gtk_container_class_list_child_properties (G_OBJECT_GET_CLASS (parent), &num_properties); - } - else - { - gtk_tree_view_column_set_visible (pl->priv->attribute_column, GTK_IS_CELL_RENDERER (object)); - - props = g_object_class_list_properties (G_OBJECT_GET_CLASS (object), &num_properties); - } - - for (i = 0; i < num_properties; i++) - { - GParamSpec *prop = props[i]; - - if (! (prop->flags & G_PARAM_READABLE)) - continue; - - gtk_list_store_append (pl->priv->model, &iter); - gtk_inspector_prop_list_update_prop (pl, &iter, prop); - - g_hash_table_insert (pl->priv->prop_iters, (gpointer) prop->name, gtk_tree_iter_copy (&iter)); - } - - /* Listen for updates */ - pl->priv->notify_handler_id = - g_signal_connect (object, - pl->priv->child_properties ? "child-notify" : "notify", - G_CALLBACK (gtk_inspector_prop_list_prop_changed_cb), - pl); - - gtk_widget_show (GTK_WIDGET (pl)); - return TRUE; -} - -// vim: set et sw=2 ts=2: diff --git a/modules/inspector/prop-list.h b/modules/inspector/prop-list.h deleted file mode 100644 index 6552c4ef61..0000000000 --- a/modules/inspector/prop-list.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2008-2009 Christian Hammond - * Copyright (c) 2008-2009 David Trowbridge - * - * 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. - */ -#ifndef _GTK_INSPECTOR_PROP_LIST_H_ -#define _GTK_INSPECTOR_PROP_LIST_H_ - - -#include <gtk/gtk.h> - -#define GTK_TYPE_INSPECTOR_PROP_LIST (gtk_inspector_prop_list_get_type()) -#define GTK_INSPECTOR_PROP_LIST(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GTK_TYPE_INSPECTOR_PROP_LIST, GtkInspectorPropList)) -#define GTK_INSPECTOR_PROP_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GTK_TYPE_INSPECTOR_PROP_LIST, GtkInspectorPropListClass)) -#define GTK_INSPECTOR_IS_PROP_LIST(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GTK_TYPE_INSPECTOR_PROP_LIST)) -#define GTK_INSPECTOR_IS_PROP_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GTK_TYPE_INSPECTOR_PROP_LIST)) -#define GTK_INSPECTOR_PROP_LIST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GTK_TYPE_INSPECTOR_PROP_LIST, GtkInspectorPropListClass)) - - -typedef struct _GtkInspectorPropListPrivate GtkInspectorPropListPrivate; - -typedef struct _GtkInspectorPropList -{ - GtkBox parent; - GtkInspectorPropListPrivate *priv; -} GtkInspectorPropList; - -typedef struct _GtkInspectorPropListClass -{ - GtkBoxClass parent; -} GtkInspectorPropListClass; - - -G_BEGIN_DECLS - -GType gtk_inspector_prop_list_get_type (void); -GtkWidget *gtk_inspector_prop_list_new (GtkWidget *widget_tree, - gboolean child_properties); -gboolean gtk_inspector_prop_list_set_object (GtkInspectorPropList *pl, - GObject *object); - -G_END_DECLS - -#endif // _GTK_INSPECTOR_PROP_LIST_H_ - -// vim: set et sw=2 ts=2: diff --git a/modules/inspector/prop-list.ui b/modules/inspector/prop-list.ui deleted file mode 100644 index d477c75406..0000000000 --- a/modules/inspector/prop-list.ui +++ /dev/null @@ -1,101 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<interface domain="gtk30"> - <object class="GtkListStore" id="model"> - <columns> - <column type="gchararray"/> - <column type="gchararray"/> - <column type="gchararray"/> - <column type="GObject"/> - <column type="gchararray"/> - <column type="gboolean"/> - <column type="gchararray"/> - </columns> - </object> - <template class="GtkInspectorPropList" parent="GtkBox"> - <property name="orientation">vertical</property> - <child> - <object class="GtkScrolledWindow"> - <property name="visible">True</property> - <property name="expand">True</property> - <property name="hscrollbar-policy">automatic</property> - <property name="vscrollbar-policy">always</property> - <property name="shadow-type">in</property> - <property name="width-request">250</property> - <child> - <object class="GtkTreeView" id="tree"> - <property name="visible">True</property> - <property name="model">model</property> - <property name="tooltip-column">4</property> - <child> - <object class="GtkTreeViewColumn"> - <property name="title" translatable="yes">Property</property> - <property name="resizable">True</property> - <property name="sort-order">ascending</property> - <property name="sort-column-id">0</property> - <child> - <object class="GtkCellRendererText"> - <property name="scale">0.8</property> - </object> - <attributes> - <attribute name="text">0</attribute> - <attribute name="sensitive">5</attribute> - </attributes> - </child> - </object> - </child> - <child> - <object class="GtkTreeViewColumn"> - <property name="title" translatable="yes">Value</property> - <property name="resizable">True</property> - <child> - <object class="GtkInspectorPropertyCellRenderer" id="value_renderer"> - <property name="scale">0.8</property> - <property name="editable">True</property> - <property name="width-chars">20</property> - <property name="ellipsize">end</property> - </object> - <attributes> - <attribute name="text">1</attribute> - <attribute name="object">3</attribute> - <attribute name="name">0</attribute> - <attribute name="sensitive">5</attribute> - </attributes> - </child> - </object> - </child> - <child> - <object class="GtkTreeViewColumn" id="attribute_column"> - <property name="title" translatable="yes">Attribute</property> - <property name="resizable">True</property> - <child> - <object class="GtkCellRendererText"> - <property name="scale">0.8</property> - <property name="editable">False</property> - </object> - <attributes> - <attribute name="text">6</attribute> - <attribute name="sensitive">5</attribute> - </attributes> - </child> - </object> - </child> - <child> - <object class="GtkTreeViewColumn"> - <property name="title" translatable="yes">Defined At</property> - <child> - <object class="GtkCellRendererText"> - <property name="scale">0.8</property> - </object> - <attributes> - <attribute name="text">2</attribute> - <attribute name="sensitive">5</attribute> - </attributes> - </child> - </object> - </child> - </object> - </child> - </object> - </child> - </template> -</interface> diff --git a/modules/inspector/property-cell-renderer.c b/modules/inspector/property-cell-renderer.c deleted file mode 100644 index 770554a5c2..0000000000 --- a/modules/inspector/property-cell-renderer.c +++ /dev/null @@ -1,466 +0,0 @@ -/* - * Copyright (c) 2008-2009 Christian Hammond - * Copyright (c) 2008-2009 David Trowbridge - * - * 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. - */ - -#include "property-cell-renderer.h" -#include "widget-tree.h" - -struct _GtkInspectorPropertyCellRendererPrivate -{ - GObject *object; - char *name; - gboolean is_child_property; -}; - -enum -{ - PROP_0, - PROP_OBJECT, - PROP_NAME, - PROP_IS_CHILD_PROPERTY -}; - -G_DEFINE_TYPE_WITH_PRIVATE (GtkInspectorPropertyCellRenderer, gtk_inspector_property_cell_renderer, GTK_TYPE_CELL_RENDERER_TEXT); - -static void -gtk_inspector_property_cell_renderer_init(GtkInspectorPropertyCellRenderer *renderer) -{ - renderer->priv = gtk_inspector_property_cell_renderer_get_instance_private (renderer); -} - -static void -get_property (GObject *object, - guint param_id, - GValue *value, - GParamSpec *pspec) -{ - GtkInspectorPropertyCellRenderer *r = GTK_INSPECTOR_PROPERTY_CELL_RENDERER (object); - - switch (param_id) - { - case PROP_OBJECT: - g_value_set_object(value, r->priv->object); - break; - - case PROP_NAME: - g_value_set_string(value, r->priv->name); - break; - - case PROP_IS_CHILD_PROPERTY: - g_value_set_boolean (value, r->priv->is_child_property); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, param_id, pspec); - break; - } -} - -static void -set_property (GObject *object, - guint param_id, - const GValue *value, - GParamSpec *pspec) -{ - GtkInspectorPropertyCellRenderer *r = GTK_INSPECTOR_PROPERTY_CELL_RENDERER (object); - - switch (param_id) - { - case PROP_OBJECT: - r->priv->object = g_value_get_object (value); - break; - - case PROP_NAME: - g_free (r->priv->name); - r->priv->name = g_value_dup_string (value); - break; - - case PROP_IS_CHILD_PROPERTY: - r->priv->is_child_property = g_value_get_boolean (value); - g_object_notify (object, "is-child-property"); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, param_id, pspec); - break; - } -} - -static GParamSpec * -find_property (GtkCellRenderer *renderer) -{ - GtkInspectorPropertyCellRenderer *r = GTK_INSPECTOR_PROPERTY_CELL_RENDERER (renderer); - - if (r->priv->is_child_property) - { - GtkWidget *parent; - - parent = gtk_widget_get_parent (GTK_WIDGET (r->priv->object)); - - return gtk_container_class_find_child_property (G_OBJECT_GET_CLASS (parent), r->priv->name); - } - - return g_object_class_find_property (G_OBJECT_GET_CLASS (r->priv->object), r->priv->name); -} - -static void -get_value (GtkCellRenderer *renderer, - GValue *gvalue) -{ - GtkInspectorPropertyCellRenderer *r = GTK_INSPECTOR_PROPERTY_CELL_RENDERER (renderer); - - if (r->priv->is_child_property) - { - GtkWidget *widget; - GtkWidget *parent; - - widget = GTK_WIDGET (r->priv->object); - parent = gtk_widget_get_parent (widget); - - gtk_container_child_get_property (GTK_CONTAINER (parent), widget, r->priv->name, gvalue); - } - else - g_object_get_property (r->priv->object, r->priv->name, gvalue); -} - -static void -set_value (GtkCellRenderer *renderer, - GValue *gvalue) -{ - GtkInspectorPropertyCellRenderer *r = GTK_INSPECTOR_PROPERTY_CELL_RENDERER (renderer); - - if (r->priv->is_child_property) - { - GtkWidget *widget; - GtkWidget *parent; - - widget = GTK_WIDGET (r->priv->object); - parent = gtk_widget_get_parent (widget); - - gtk_container_child_set_property (GTK_CONTAINER (parent), widget, r->priv->name, gvalue); - } - else - g_object_set_property (r->priv->object, r->priv->name, gvalue); -} - -static void -stop_editing (GtkCellEditable *editable, - GtkCellRenderer *renderer) -{ - GValue gvalue = {0}; - GParamSpec *prop; - - prop = find_property (renderer); - g_value_init(&gvalue, prop->value_type); - - if (GTK_IS_ENTRY(editable)) - { - gboolean canceled; - - g_object_get (editable, "editing-canceled", &canceled, NULL); - gtk_cell_renderer_stop_editing (renderer, canceled); - - if (canceled) - return; - - if (GTK_IS_SPIN_BUTTON(editable)) - { - gdouble value = g_ascii_strtod (gtk_entry_get_text (GTK_ENTRY (editable)), NULL); - - if (G_IS_PARAM_SPEC_INT (prop)) - g_value_set_int (&gvalue, (gint)value); - else if G_IS_PARAM_SPEC_UINT (prop) - g_value_set_uint (&gvalue, (guint)value); - else if G_IS_PARAM_SPEC_INT64 (prop) - g_value_set_int64 (&gvalue, (gint64)value); - else if G_IS_PARAM_SPEC_UINT64 (prop) - g_value_set_uint64 (&gvalue, (guint64)value); - else if G_IS_PARAM_SPEC_LONG (prop) - g_value_set_long (&gvalue, (glong)value); - else if G_IS_PARAM_SPEC_ULONG (prop) - g_value_set_ulong (&gvalue, (gulong)value); - else if G_IS_PARAM_SPEC_DOUBLE (prop) - g_value_set_double (&gvalue, (gdouble)value); - else - return; - } - else - { - g_value_set_string (&gvalue, gtk_entry_get_text (GTK_ENTRY (editable))); - } - } - else if (GTK_IS_COMBO_BOX (editable)) - { - /* We have no way of getting the canceled state for a GtkComboBox */ - gtk_cell_renderer_stop_editing (renderer, FALSE); - - if (G_IS_PARAM_SPEC_BOOLEAN (prop)) - { - g_value_set_boolean (&gvalue, gtk_combo_box_get_active (GTK_COMBO_BOX (editable)) == 1); - } - else if (G_IS_PARAM_SPEC_ENUM (prop)) - { - gchar *enum_name = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (editable)); - GEnumClass *enum_class; - GEnumValue *enum_value; - - if (enum_name == NULL) - return; - - enum_class = G_PARAM_SPEC_ENUM (prop)->enum_class; - enum_value = g_enum_get_value_by_name (enum_class, enum_name); - g_value_set_enum (&gvalue, enum_value->value); - - g_free (enum_name); - } - } - - set_value (renderer, &gvalue); - g_value_unset (&gvalue); -} - -static GtkCellEditable * -start_editing (GtkCellRenderer *renderer, - GdkEvent *event, - GtkWidget *widget, - const gchar *path, - const GdkRectangle *background_area, - const GdkRectangle *cell_area, - GtkCellRendererState flags) -{ - PangoFontDescription *font_desc; - GtkCellEditable *editable = NULL; - GValue gvalue = {0}; - GParamSpec *prop; - GtkInspectorPropertyCellRenderer *r = GTK_INSPECTOR_PROPERTY_CELL_RENDERER (renderer); - - prop = find_property (renderer); - - g_value_init (&gvalue, prop->value_type); - - get_value (renderer, &gvalue); - - if (G_VALUE_HOLDS_OBJECT (&gvalue)) - { - GtkInspectorWidgetTree *widget_tree = g_object_get_data (G_OBJECT (renderer), "gtk-inspector-widget-tree"); - GObject *prop_object = g_value_get_object (&gvalue); - GtkTreeIter iter; - - if (prop_object) - { - /* First check if the value is already in the tree (happens with 'parent' for instance) */ - if (gtk_inspector_widget_tree_find_object (widget_tree, prop_object, &iter)) - { - gtk_inspector_widget_tree_select_object (widget_tree, prop_object); - } - else if (gtk_inspector_widget_tree_find_object (widget_tree, r->priv->object, &iter)) - { - gtk_inspector_widget_tree_append_object (widget_tree, prop_object, &iter, prop->name); - gtk_inspector_widget_tree_select_object (widget_tree, prop_object); - } - else - { - g_warning ("GtkInspector: couldn't find the widget in the tree"); - } - } - g_value_unset (&gvalue); - return NULL; - } - else - { - if (!(prop->flags & G_PARAM_WRITABLE)) - return NULL; - - if (G_VALUE_HOLDS_ENUM (&gvalue) || G_VALUE_HOLDS_BOOLEAN (&gvalue)) - { - GtkWidget *combobox; - GList *renderers; - - combobox = gtk_combo_box_text_new (); - gtk_widget_show (combobox); - g_object_set (G_OBJECT (combobox), "has-frame", FALSE, NULL); - - if (G_VALUE_HOLDS_BOOLEAN (&gvalue)) - { - gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combobox), "FALSE"); - gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combobox), "TRUE"); - - gtk_combo_box_set_active (GTK_COMBO_BOX (combobox), g_value_get_boolean (&gvalue) ? 1 : 0); - } - else if (G_VALUE_HOLDS_ENUM(&gvalue)) - { - gint value = g_value_get_enum (&gvalue); - GEnumClass *enum_class = G_PARAM_SPEC_ENUM (prop)->enum_class; - guint i; - - for (i = 0; i < enum_class->n_values; i++) - { - GEnumValue *enum_value = &enum_class->values[i]; - - gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combobox), - enum_value->value_name); - - if (enum_value->value == value) - gtk_combo_box_set_active(GTK_COMBO_BOX(combobox), i); - } - } - - renderers = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (combobox)); - g_object_set (G_OBJECT (renderers->data), "scale", 0.8, NULL); - g_list_free (renderers); - - editable = GTK_CELL_EDITABLE (combobox); - } - else if (G_VALUE_HOLDS_STRING (&gvalue)) - { - GtkWidget *entry; - - entry = gtk_entry_new (); - gtk_widget_show (entry); - gtk_entry_set_text (GTK_ENTRY (entry), g_value_get_string (&gvalue)); - - editable = GTK_CELL_EDITABLE (entry); - } - else if (G_VALUE_HOLDS_INT (&gvalue) || - G_VALUE_HOLDS_UINT (&gvalue) || - G_VALUE_HOLDS_INT64 (&gvalue) || - G_VALUE_HOLDS_UINT64 (&gvalue) || - G_VALUE_HOLDS_LONG (&gvalue) || - G_VALUE_HOLDS_ULONG (&gvalue) || - G_VALUE_HOLDS_DOUBLE (&gvalue)) - { - gdouble min, max, value; - GtkWidget *spinbutton; - guint digits = 0; - - if (G_VALUE_HOLDS_INT (&gvalue)) - { - GParamSpecInt *paramspec = G_PARAM_SPEC_INT (prop); - min = paramspec->minimum; - max = paramspec->maximum; - value = g_value_get_int (&gvalue); - } - else if (G_VALUE_HOLDS_UINT (&gvalue)) - { - GParamSpecUInt *paramspec = G_PARAM_SPEC_UINT (prop); - min = paramspec->minimum; - max = paramspec->maximum; - value = g_value_get_uint (&gvalue); - } - else if (G_VALUE_HOLDS_INT64 (&gvalue)) - { - GParamSpecInt64 *paramspec = G_PARAM_SPEC_INT64 (prop); - min = paramspec->minimum; - max = paramspec->maximum; - value = g_value_get_int64 (&gvalue); - } - else if (G_VALUE_HOLDS_UINT64 (&gvalue)) - { - GParamSpecUInt64 *paramspec = G_PARAM_SPEC_UINT64 (prop); - min = paramspec->minimum; - max = paramspec->maximum; - value = g_value_get_uint64 (&gvalue); - } - else if (G_VALUE_HOLDS_LONG (&gvalue)) - { - GParamSpecLong *paramspec = G_PARAM_SPEC_LONG (prop); - min = paramspec->minimum; - max = paramspec->maximum; - value = g_value_get_long (&gvalue); - } - else if (G_VALUE_HOLDS_ULONG (&gvalue)) - { - GParamSpecULong *paramspec = G_PARAM_SPEC_ULONG (prop); - min = paramspec->minimum; - max = paramspec->maximum; - value = g_value_get_ulong (&gvalue); - } - else if (G_VALUE_HOLDS_DOUBLE (&gvalue)) - { - GParamSpecDouble *paramspec = G_PARAM_SPEC_DOUBLE (prop); - min = paramspec->minimum; - max = paramspec->maximum; - value = g_value_get_double (&gvalue); - digits = 2; - } - else - { - /* Shouldn't really be able to happen. */ - return NULL; - } - - spinbutton = gtk_spin_button_new_with_range (min, max, 1); - gtk_widget_show (spinbutton); - gtk_spin_button_set_value (GTK_SPIN_BUTTON (spinbutton), value); - gtk_spin_button_set_digits (GTK_SPIN_BUTTON (spinbutton), digits); - - editable = GTK_CELL_EDITABLE(spinbutton); - } - } - - g_value_unset (&gvalue); - - if (!editable) - return NULL; - - font_desc = pango_font_description_new (); - pango_font_description_set_size (font_desc, 8 * PANGO_SCALE); - gtk_widget_override_font (GTK_WIDGET (editable), font_desc); - pango_font_description_free (font_desc); - - g_signal_connect (editable, "editing-done", G_CALLBACK (stop_editing), renderer); - - return editable; -} - -static void -gtk_inspector_property_cell_renderer_class_init (GtkInspectorPropertyCellRendererClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - GtkCellRendererClass *cell_class = GTK_CELL_RENDERER_CLASS (klass); - - object_class->get_property = get_property; - object_class->set_property = set_property; - - cell_class->start_editing = start_editing; - - g_object_class_install_property (object_class, PROP_OBJECT, - g_param_spec_object ("object", "Object", "The object owning the property", - G_TYPE_OBJECT, G_PARAM_READWRITE)); - - g_object_class_install_property (object_class, PROP_NAME, - g_param_spec_string ("name", "Name", "The property name", - NULL, G_PARAM_READWRITE)); - - g_object_class_install_property (object_class, PROP_IS_CHILD_PROPERTY, - g_param_spec_boolean ("is-child-property", "Child property", "Child property", - FALSE, G_PARAM_READWRITE)); -} - -GtkCellRenderer * -gtk_inspector_property_cell_renderer_new (void) -{ - return g_object_new (GTK_TYPE_INSPECTOR_PROPERTY_CELL_RENDERER, NULL); -} - - -// vim: set et ts=2: diff --git a/modules/inspector/property-cell-renderer.h b/modules/inspector/property-cell-renderer.h deleted file mode 100644 index c8afeeeda0..0000000000 --- a/modules/inspector/property-cell-renderer.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2008-2009 Christian Hammond - * Copyright (c) 2008-2009 David Trowbridge - * - * 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. - */ -#ifndef _GTK_INSPECTOR_PROPERTY_CELL_RENDERER_H_ -#define _GTK_INSPECTOR_PROPERTY_CELL_RENDERER_H_ - - -#include <gtk/gtk.h> - - -#define GTK_TYPE_INSPECTOR_PROPERTY_CELL_RENDERER (gtk_inspector_property_cell_renderer_get_type()) -#define GTK_INSPECTOR_PROPERTY_CELL_RENDERER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GTK_TYPE_INSPECTOR_PROPERTY_CELL_RENDERER, GtkInspectorPropertyCellRenderer)) -#define GTK_INSPECTOR_PROPERTY_CELL_RENDERER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GTK_TYPE_INSPECTOR_PROPERTY_CELL_RENDERER, GtkInspectorPropertyCellRendererClass)) -#define GTK_INSPECTOR_IS_PROPERTY_CELL_RENDERER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GTK_TYPE_INSPECTOR_PROPERTY_CELL_RENDERER)) -#define GTK_INSPECTOR_IS_PROPERTY_CELL_RENDERER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GTK_TYPE_INSPECTOR_PROPERTY_CELL_RENDERER)) -#define GTK_INSPECTOR_PROPERTY_CELL_RENDERER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GTK_TYPE_INSPECTOR_PROPERTY_CELL_RENDERER, GtkInspectorPropertyCellRendererClass)) - -typedef struct _GtkInspectorPropertyCellRendererPrivate GtkInspectorPropertyCellRendererPrivate; - -typedef struct -{ - GtkCellRendererText parent; - GtkInspectorPropertyCellRendererPrivate *priv; -} GtkInspectorPropertyCellRenderer; - -typedef struct -{ - GtkCellRendererTextClass parent; -} GtkInspectorPropertyCellRendererClass; - - -G_BEGIN_DECLS - - -GType gtk_inspector_property_cell_renderer_get_type (void); -GtkCellRenderer *gtk_inspector_property_cell_renderer_new (void); - - -G_END_DECLS - - -#endif // _GTK_INSPECTOR_PROPERTY_CELL_RENDERER_H_ - -// vim: set et sw=2 ts=2: diff --git a/modules/inspector/python-hooks.c b/modules/inspector/python-hooks.c deleted file mode 100644 index 74d74fa991..0000000000 --- a/modules/inspector/python-hooks.c +++ /dev/null @@ -1,237 +0,0 @@ -/* - * Copyright (c) 2008-2009 Christian Hammond - * Copyright (c) 2008-2009 David Trowbridge - * - * 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. - */ -#include <dlfcn.h> -#include <signal.h> - -#ifdef ENABLE_PYTHON -# include <Python.h> -# include <pygobject.h> -#endif - -#include "python-hooks.h" - -static gboolean python_enabled = FALSE; - -#ifdef ENABLE_PYTHON -static GString *captured_stdout = NULL; -static GString *captured_stderr = NULL; - - -static PyObject * -capture_stdout(PyObject *self, PyObject *args) -{ - char *str = NULL; - - if (!PyArg_ParseTuple(args, "s", &str)) - return NULL; - - g_string_append(captured_stdout, str); - - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -capture_stderr(PyObject *self, PyObject *args) -{ - char *str = NULL; - - if (!PyArg_ParseTuple(args, "s", &str)) - return NULL; - - g_string_append(captured_stderr, str); - - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -wrap_gobj(PyObject *self, PyObject *args) -{ - void *addr; - GObject *obj; - - if (!PyArg_ParseTuple(args, "l", &addr)) - return NULL; - - if (!G_IS_OBJECT(addr)) - return NULL; // XXX - - obj = G_OBJECT(addr); - - if (!obj) - return NULL; // XXX - - return pygobject_new(obj); -} - -static PyMethodDef gtk_inspector_python_methods[] = { - {"capture_stdout", capture_stdout, METH_VARARGS, "Captures stdout"}, - {"capture_stderr", capture_stderr, METH_VARARGS, "Captures stderr"}, - {"gobj", wrap_gobj, METH_VARARGS, "Wraps a C GObject"}, - {NULL, NULL, 0, NULL} -}; - - -static gboolean -is_blacklisted(void) -{ - const char *prgname = g_get_prgname(); - - return (!strcmp(prgname, "gimp")); -} -#endif // ENABLE_PYTHON - -void -gtk_inspector_python_init(void) -{ -#ifdef ENABLE_PYTHON - int res; - struct sigaction old_sigint; - - if (is_blacklisted()) - return; - - /* This prevents errors such as "undefined symbol: PyExc_ImportError" */ - if (!dlopen(PYTHON_SHARED_LIB, RTLD_NOW | RTLD_GLOBAL)) - { - g_error("%s\n", dlerror()); - return; - } - - captured_stdout = g_string_new(""); - captured_stderr = g_string_new(""); - - /* Back up and later restore SIGINT so Python doesn't steal it from us. */ - res = sigaction(SIGINT, NULL, &old_sigint); - - if (!Py_IsInitialized()) - Py_Initialize(); - - res = sigaction(SIGINT, &old_sigint, NULL); - - Py_InitModule("gtk_inspector", gtk_inspector_python_methods); - PyRun_SimpleString( - "import gtk_inspector\n" - "import sys\n" - "\n" - "class StdoutCatcher:\n" - " def write(self, str):\n" - " gtk_inspector.capture_stdout(str)\n" - "\n" - "class StderrCatcher:\n" - " def write(self, str):\n" - " gtk_inspector.capture_stderr(str)\n" - "\n" - ); - - if (!pygobject_init(-1, -1, -1)) - { - fprintf(stderr, "Error initializing pygobject support.\n"); - PyErr_Print(); - return; - } - - char *argv[] = { "", NULL }; - PySys_SetArgv(0, argv); - - if (!PyImport_ImportModule("gi._gobject")) - { - PyErr_SetString(PyExc_ImportError, "could not import gi.gobject"); - return; - } - if (!PyImport_ImportModule("gi.repository")) - { - PyErr_SetString(PyExc_ImportError, "could not import gi.repository"); - return; - } - if (!PyImport_ImportModule("gi.repository.Gtk")) - { - PyErr_SetString(PyExc_ImportError, "could not import gtk"); - return; - } - - python_enabled = TRUE; -#endif // ENABLE_PYTHON -} - -void -gtk_inspector_python_run(const char *command, - GtkInspectorPythonLogger stdout_logger, - GtkInspectorPythonLogger stderr_logger, - gpointer user_data) -{ -#ifdef ENABLE_PYTHON - PyGILState_STATE gstate; - PyObject *module; - PyObject *dict; - PyObject *obj; - - gstate = PyGILState_Ensure(); - - module = PyImport_AddModule("__main__"); - dict = PyModule_GetDict(module); - - PyRun_SimpleString("old_stdout = sys.stdout\n" - "old_stderr = sys.stderr\n" - "sys.stdout = StdoutCatcher()\n" - "sys.stderr = StderrCatcher()\n"); - - obj = PyRun_String(command, Py_single_input, dict, dict); - - PyRun_SimpleString("sys.stdout = old_stdout\n" - "sys.stderr = old_stderr\n"); - - if (stdout_logger != NULL) - stdout_logger(captured_stdout->str, user_data); - - if (stderr_logger != NULL) - stderr_logger(captured_stderr->str, user_data); - - // Print any returned object - if (obj != NULL && obj != Py_None) { - PyObject *repr = PyObject_Repr(obj); - if (repr != NULL) { - char *string = PyString_AsString(repr); - - stdout_logger(string, user_data); - stdout_logger("\n", user_data); - } - - Py_XDECREF(repr); - } - Py_XDECREF(obj); - - PyGILState_Release(gstate); - g_string_erase(captured_stdout, 0, -1); - g_string_erase(captured_stderr, 0, -1); -#endif // ENABLE_PYTHON -} - -gboolean -gtk_inspector_python_is_enabled(void) -{ - return python_enabled; -} - -// vim: set et sw=4 ts=4: diff --git a/modules/inspector/python-hooks.h b/modules/inspector/python-hooks.h deleted file mode 100644 index 331fe74e9d..0000000000 --- a/modules/inspector/python-hooks.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2008-2009 Christian Hammond - * Copyright (c) 2008-2009 David Trowbridge - * - * 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. - */ -#ifndef _GTK_INSPECTOR_PYTHON_MODULE_H_ -#define _GTK_INSPECTOR_PYTHON_MODULE_H_ - -#include <glib.h> - - -typedef void (*GtkInspectorPythonLogger)(const char *text, gpointer user_data); - -void gtk_inspector_python_init(void); -void gtk_inspector_python_run(const char *command, - GtkInspectorPythonLogger stdout_logger, - GtkInspectorPythonLogger stderr_logger, - gpointer user_data); -gboolean gtk_inspector_python_is_enabled(void); - -#endif // _GTK_INSPECTOR_PYTHON_MODULE_H_ diff --git a/modules/inspector/python-shell.c b/modules/inspector/python-shell.c deleted file mode 100644 index 5d13f78a15..0000000000 --- a/modules/inspector/python-shell.c +++ /dev/null @@ -1,409 +0,0 @@ -/* - * Copyright (c) 2008-2009 Christian Hammond - * Copyright (c) 2008-2009 David Trowbridge - * - * 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. - */ -#include <gdk/gdkkeysyms.h> -#include <string.h> - -#include "python-hooks.h" -#include "python-shell.h" - -#define MAX_HISTORY_LENGTH 20 - -struct _GtkInspectorPythonShellPrivate -{ - GtkWidget *textview; - - GtkTextMark *scroll_mark; - GtkTextMark *line_start_mark; - - GQueue *history; - GList *cur_history_item; - - GString *pending_command; - gboolean in_block; -}; - -G_DEFINE_TYPE_WITH_PRIVATE (GtkInspectorPythonShell, gtk_inspector_python_shell, GTK_TYPE_BOX); - -/* Widget functions */ -static void gtk_inspector_python_shell_finalize (GObject *obj); - -/* Python integration */ -static void gtk_inspector_python_shell_write_prompt(GtkWidget *python_shell); -static char *gtk_inspector_python_shell_get_input(GtkWidget *python_shell); - -/* Callbacks */ -static gboolean gtk_inspector_python_shell_key_press_cb(GtkWidget *textview, - GdkEventKey *event, - GtkWidget *python_shell); -static void -gtk_inspector_python_shell_class_init(GtkInspectorPythonShellClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS(klass); - - object_class->finalize = gtk_inspector_python_shell_finalize; -} - -static void -gtk_inspector_python_shell_init (GtkInspectorPythonShell *python_shell) -{ - GtkWidget *swin; - GtkTextBuffer *buffer; - GtkTextIter iter; - PangoFontDescription *font_desc; - - python_shell->priv = gtk_inspector_python_shell_get_instance_private (python_shell); - - python_shell->priv->history = g_queue_new(); - - gtk_box_set_spacing(GTK_BOX(python_shell), 6); - - swin = gtk_scrolled_window_new(NULL, NULL); - gtk_widget_show(swin); - gtk_box_pack_start(GTK_BOX(python_shell), swin, TRUE, TRUE, 0); - gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(swin), - GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); - gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(swin), - GTK_SHADOW_IN); - - python_shell->priv->textview = gtk_text_view_new(); - gtk_widget_show(python_shell->priv->textview); - gtk_container_add(GTK_CONTAINER(swin), python_shell->priv->textview); - gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(python_shell->priv->textview), TRUE); - gtk_text_view_set_pixels_above_lines(GTK_TEXT_VIEW(python_shell->priv->textview), 3); - gtk_text_view_set_left_margin(GTK_TEXT_VIEW(python_shell->priv->textview), 3); - gtk_text_view_set_right_margin(GTK_TEXT_VIEW(python_shell->priv->textview), 3); - - g_signal_connect(python_shell->priv->textview, "key_press_event", - G_CALLBACK(gtk_inspector_python_shell_key_press_cb), - python_shell); - - /* Make the textview monospaced */ - font_desc = pango_font_description_from_string("monospace"); - pango_font_description_set_size(font_desc, 8 * PANGO_SCALE); - gtk_widget_override_font(python_shell->priv->textview, font_desc); - pango_font_description_free(font_desc); - - /* Create the end-of-buffer mark */ - buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(python_shell->priv->textview)); - gtk_text_buffer_get_end_iter(buffer, &iter); - python_shell->priv->scroll_mark = gtk_text_buffer_create_mark(buffer, "scroll_mark", - &iter, FALSE); - - /* Create the beginning-of-line mark */ - python_shell->priv->line_start_mark = gtk_text_buffer_create_mark(buffer, - "line_start_mark", - &iter, TRUE); - - /* Register some tags */ - gtk_text_buffer_create_tag(buffer, "stdout", NULL); - gtk_text_buffer_create_tag(buffer, "stderr", - "foreground", "red", - "paragraph-background", "#FFFFE0", - NULL); - gtk_text_buffer_create_tag(buffer, "prompt", - "foreground", "blue", - NULL); - - gtk_inspector_python_shell_write_prompt(GTK_WIDGET(python_shell)); -} - -static void -gtk_inspector_python_shell_finalize(GObject *python_shell) -{ - GtkInspectorPythonShellPrivate *priv = GTK_INSPECTOR_PYTHON_SHELL(python_shell)->priv; - - g_queue_free(priv->history); -} - -static void -gtk_inspector_python_shell_log_stdout(const char *text, gpointer python_shell) -{ - gtk_inspector_python_shell_append_text(GTK_INSPECTOR_PYTHON_SHELL(python_shell), - text, "stdout"); -} - -static void -gtk_inspector_python_shell_log_stderr(const char *text, gpointer python_shell) -{ - gtk_inspector_python_shell_append_text(GTK_INSPECTOR_PYTHON_SHELL(python_shell), - text, "stderr"); -} - -static void -gtk_inspector_python_shell_write_prompt(GtkWidget *python_shell) -{ - GtkInspectorPythonShellPrivate *priv = GTK_INSPECTOR_PYTHON_SHELL(python_shell)->priv; - GtkTextBuffer *buffer = - gtk_text_view_get_buffer(GTK_TEXT_VIEW(priv->textview)); - GtkTextIter iter; - const char *prompt = (priv->pending_command == NULL ? ">>> " : "... "); - - gtk_inspector_python_shell_append_text(GTK_INSPECTOR_PYTHON_SHELL(python_shell), - prompt, "prompt"); - - gtk_text_buffer_get_end_iter(buffer, &iter); - gtk_text_buffer_move_mark(buffer, priv->line_start_mark, &iter); -} - -static void -gtk_inspector_python_shell_process_line(GtkWidget *python_shell) -{ - GtkInspectorPythonShellPrivate *priv = GTK_INSPECTOR_PYTHON_SHELL(python_shell)->priv; - char *command = gtk_inspector_python_shell_get_input(python_shell); - char last_char; - - gtk_inspector_python_shell_append_text(GTK_INSPECTOR_PYTHON_SHELL(python_shell), - "\n", NULL); - - if (*command != '\0') - { - /* Save this command in the history. */ - g_queue_push_head(priv->history, command); - priv->cur_history_item = NULL; - - if (g_queue_get_length(priv->history) > MAX_HISTORY_LENGTH) - g_free(g_queue_pop_tail(priv->history)); - } - - last_char = command[MAX(0, strlen(command) - 1)]; - - if (last_char == ':' || last_char == '\\' || - (priv->in_block && g_ascii_isspace(command[0]))) - { - printf("in block.. %c, %d, %d\n", - last_char, priv->in_block, - g_ascii_isspace(command[0])); - /* This is a multi-line expression */ - if (priv->pending_command == NULL) - priv->pending_command = g_string_new(command); - else - g_string_append(priv->pending_command, command); - - g_string_append_c(priv->pending_command, '\n'); - - if (last_char == ':') - priv->in_block = TRUE; - } - else - { - if (priv->pending_command != NULL) - { - g_string_append(priv->pending_command, command); - g_string_append_c(priv->pending_command, '\n'); - - /* We're not actually leaking this. It's in the history. */ - command = g_string_free(priv->pending_command, FALSE); - } - - gtk_inspector_python_run(command, - gtk_inspector_python_shell_log_stdout, - gtk_inspector_python_shell_log_stderr, - python_shell); - - if (priv->pending_command != NULL) - { - /* Now do the cleanup. */ - g_free(command); - priv->pending_command = NULL; - priv->in_block = FALSE; - } - } - - gtk_inspector_python_shell_write_prompt(python_shell); -} - -static void -gtk_inspector_python_shell_replace_input(GtkWidget *python_shell, - const char *text) -{ - GtkInspectorPythonShellPrivate *priv = GTK_INSPECTOR_PYTHON_SHELL(python_shell)->priv; - GtkTextBuffer *buffer = - gtk_text_view_get_buffer(GTK_TEXT_VIEW(priv->textview)); - GtkTextIter start_iter; - GtkTextIter end_iter; - - gtk_text_buffer_get_iter_at_mark(buffer, &start_iter, - priv->line_start_mark); - gtk_text_buffer_get_end_iter(buffer, &end_iter); - - gtk_text_buffer_delete(buffer, &start_iter, &end_iter); - gtk_text_buffer_insert(buffer, &end_iter, text, -1); -} - -static char * -gtk_inspector_python_shell_get_input(GtkWidget *python_shell) -{ - GtkInspectorPythonShellPrivate *priv = GTK_INSPECTOR_PYTHON_SHELL(python_shell)->priv; - GtkTextBuffer *buffer = - gtk_text_view_get_buffer(GTK_TEXT_VIEW(priv->textview)); - GtkTextIter start_iter; - GtkTextIter end_iter; - - gtk_text_buffer_get_iter_at_mark(buffer, &start_iter, - priv->line_start_mark); - gtk_text_buffer_get_end_iter(buffer, &end_iter); - - return gtk_text_buffer_get_text(buffer, &start_iter, &end_iter, FALSE); -} - -static const char * -gtk_inspector_python_shell_get_history_back(GtkWidget *python_shell) -{ - GtkInspectorPythonShellPrivate *priv = GTK_INSPECTOR_PYTHON_SHELL(python_shell)->priv; - - if (priv->cur_history_item == NULL) - { - priv->cur_history_item = g_queue_peek_head_link(priv->history); - - if (priv->cur_history_item == NULL) - return ""; - } - else if (priv->cur_history_item->next != NULL) - priv->cur_history_item = priv->cur_history_item->next; - - return (const char *)priv->cur_history_item->data; -} - -static const char * -gtk_inspector_python_shell_get_history_forward(GtkWidget *python_shell) -{ - GtkInspectorPythonShellPrivate *priv = GTK_INSPECTOR_PYTHON_SHELL(python_shell)->priv; - - if (priv->cur_history_item == NULL || priv->cur_history_item->prev == NULL) - { - priv->cur_history_item = NULL; - return ""; - } - - priv->cur_history_item = priv->cur_history_item->prev; - - return (const char *)priv->cur_history_item->data; -} - -static gboolean -gtk_inspector_python_shell_key_press_cb(GtkWidget *textview, - GdkEventKey *event, - GtkWidget *python_shell) -{ - if (event->keyval == GDK_KEY_Return) - { - gtk_inspector_python_shell_process_line(python_shell); - return TRUE; - } - else if (event->keyval == GDK_KEY_Up) - { - gtk_inspector_python_shell_replace_input(python_shell, - gtk_inspector_python_shell_get_history_back(python_shell)); - return TRUE; - } - else if (event->keyval == GDK_KEY_Down) - { - gtk_inspector_python_shell_replace_input(python_shell, - gtk_inspector_python_shell_get_history_forward(python_shell)); - return TRUE; - } - else if (event->string != NULL) - { - GtkInspectorPythonShellPrivate *priv = GTK_INSPECTOR_PYTHON_SHELL(python_shell)->priv; - GtkTextBuffer *buffer = - gtk_text_view_get_buffer(GTK_TEXT_VIEW(priv->textview)); - GtkTextMark *insert_mark = gtk_text_buffer_get_insert(buffer); - GtkTextMark *selection_mark = - gtk_text_buffer_get_selection_bound(buffer); - GtkTextIter insert_iter; - GtkTextIter selection_iter; - GtkTextIter start_iter; - gint cmp_start_insert; - gint cmp_start_select; - gint cmp_insert_select; - - gtk_text_buffer_get_iter_at_mark(buffer, &start_iter, - priv->line_start_mark); - gtk_text_buffer_get_iter_at_mark(buffer, &insert_iter, insert_mark); - gtk_text_buffer_get_iter_at_mark(buffer, &selection_iter, - selection_mark); - - cmp_start_insert = gtk_text_iter_compare(&start_iter, &insert_iter); - cmp_start_select = gtk_text_iter_compare(&start_iter, &selection_iter); - cmp_insert_select = gtk_text_iter_compare(&insert_iter, - &selection_iter); - - if (cmp_start_insert == 0 && cmp_start_select == 0 && - (event->keyval == GDK_KEY_BackSpace || - event->keyval == GDK_KEY_Left)) - { - return TRUE; - } - if (cmp_start_insert <= 0 && cmp_start_select <= 0) - { - return FALSE; - } - else if (cmp_start_insert > 0 && cmp_start_select > 0) - { - gtk_text_buffer_place_cursor(buffer, &start_iter); - } - else if (cmp_insert_select < 0) - { - gtk_text_buffer_move_mark(buffer, insert_mark, &start_iter); - } - else if (cmp_insert_select > 0) - { - gtk_text_buffer_move_mark(buffer, selection_mark, &start_iter); - } - } - - return FALSE; -} - -GtkWidget * -gtk_inspector_python_shell_new(void) -{ - return g_object_new(GTK_TYPE_INSPECTOR_PYTHON_SHELL, NULL); -} - -void -gtk_inspector_python_shell_append_text(GtkInspectorPythonShell *python_shell, - const char *str, - const char *tag) -{ - GtkInspectorPythonShellPrivate *priv = python_shell->priv; - - GtkTextIter end; - GtkTextBuffer *buffer = - gtk_text_view_get_buffer(GTK_TEXT_VIEW(priv->textview)); - GtkTextMark *mark = gtk_text_buffer_get_insert(buffer); - - gtk_text_buffer_get_end_iter(buffer, &end); - gtk_text_buffer_move_mark(buffer, mark, &end); - gtk_text_buffer_insert_with_tags_by_name(buffer, &end, str, -1, tag, NULL); - gtk_text_view_scroll_to_mark(GTK_TEXT_VIEW(priv->textview), mark, - 0, TRUE, 0, 1); -} - -void -gtk_inspector_python_shell_focus(GtkInspectorPythonShell *python_shell) -{ - gtk_widget_grab_focus (python_shell->priv->textview); -} - -// vim: set et ts=4: diff --git a/modules/inspector/python-shell.h b/modules/inspector/python-shell.h deleted file mode 100644 index 9e002a943c..0000000000 --- a/modules/inspector/python-shell.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2008-2009 Christian Hammond - * Copyright (c) 2008-2009 David Trowbridge - * - * 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. - */ -#ifndef _GTK_INSPECTOR_PYTHON_SHELL_H_ -#define _GTK_INSPECTOR_PYTHON_SHELL_H_ - -typedef struct _GtkInspectorPythonShell GtkInspectorPythonShell; -typedef struct _GtkInspectorPythonShellClass GtkInspectorPythonShellClass; -typedef struct _GtkInspectorPythonShellPrivate GtkInspectorPythonShellPrivate; - -#include <gtk/gtk.h> - -#define GTK_TYPE_INSPECTOR_PYTHON_SHELL (gtk_inspector_python_shell_get_type()) -#define GTK_INSPECTOR_PYTHON_SHELL(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST((obj), GTK_TYPE_INSPECTOR_PYTHON_SHELL, GtkInspectorPythonShell)) -#define GTK_INSPECTOR_PYTHON_SHELL_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST((klass), GTK_TYPE_INSPECTOR_PYTHON_SHELL, GtkInspectorPythonShellClass)) -#define GTK_INSPECTOR_IS_PYTHON_SHELL(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE((obj), GTK_TYPE_INSPECTOR_PYTHON_SHELL)) -#define GTK_INSPECTOR_IS_PYTHON_SHELL_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE((klass), GTK_TYPE_INSPECTOR_PYTHON_SHELL)) -#define GTK_INSPECTOR_PYTHON_SHELL_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_INSPECTOR_PYTHON_SHELL, GtkInspectorPythonShellClass)) - - -struct _GtkInspectorPythonShell -{ - GtkBox parent_object; - GtkInspectorPythonShellPrivate *priv; -}; - -struct _GtkInspectorPythonShellClass -{ - GtkBoxClass parent_class; -}; - -G_BEGIN_DECLS - -GType gtk_inspector_python_shell_get_type(void); - -GtkWidget *gtk_inspector_python_shell_new(void); -void gtk_inspector_python_shell_append_text(GtkInspectorPythonShell *python_shell, - const char *str, - const char *tag); -void gtk_inspector_python_shell_focus(GtkInspectorPythonShell *python_shell); - -G_END_DECLS - -#endif // _GTK_INSPECTOR_PYTHON_SHELL_H_ diff --git a/modules/inspector/signals-list.c b/modules/inspector/signals-list.c deleted file mode 100644 index e132a7df13..0000000000 --- a/modules/inspector/signals-list.c +++ /dev/null @@ -1,346 +0,0 @@ -/* - * 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/>. - */ - -#include "config.h" -#include <glib/gi18n-lib.h> -#include "signals-list.h" - -enum -{ - COLUMN_NAME, - COLUMN_CLASS, - COLUMN_CONNECTED, - COLUMN_COUNT, - COLUMN_NO_HOOKS, - COLUMN_SIGNAL_ID, - COLUMN_HOOK_ID -}; - -struct _GtkInspectorSignalsListPrivate -{ - GtkWidget *view; - GtkListStore *model; - GtkTextBuffer *text; - GtkWidget *log_win; - GtkWidget *trace_button; - GtkTreeViewColumn *count_column; - GtkCellRenderer *count_renderer; - GObject *object; - GHashTable *iters; - gboolean tracing; -}; - -G_DEFINE_TYPE_WITH_PRIVATE (GtkInspectorSignalsList, gtk_inspector_signals_list, GTK_TYPE_PANED) - -static GType * -get_types (GObject *object, guint *length) -{ - GHashTable *seen; - GType *ret; - GType type; - GType *iface; - gint i; - - seen = g_hash_table_new (g_direct_hash, g_direct_equal); - - type = ((GTypeInstance*)object)->g_class->g_type; - while (type) - { - g_hash_table_add (seen, GSIZE_TO_POINTER (type)); - iface = g_type_interfaces (type, NULL); - for (i = 0; iface[i]; i++) - g_hash_table_add (seen, GSIZE_TO_POINTER (iface[i])); - g_free (iface); - type = g_type_parent (type); - } - - ret = (GType *)g_hash_table_get_keys_as_array (seen, length); - g_hash_table_unref (seen); - - return ret; -} - -static void -add_signals (GtkInspectorSignalsList *sl, - GType type, - GObject *object) -{ - guint *ids; - guint n_ids; - gint i; - GSignalQuery query; - GtkTreeIter iter; - gboolean has_handler; - - if (!G_TYPE_IS_INSTANTIATABLE (type) && !G_TYPE_IS_INTERFACE (type)) - return; - - ids = g_signal_list_ids (type, &n_ids); - for (i = 0; i < n_ids; i++) - { - g_signal_query (ids[i], &query); - has_handler = g_signal_has_handler_pending (object, ids[i], 0, TRUE); - gtk_list_store_append (sl->priv->model, &iter); - gtk_list_store_set (sl->priv->model, &iter, - COLUMN_NAME, query.signal_name, - COLUMN_CLASS, g_type_name (type), - COLUMN_CONNECTED, has_handler ? _("Yes") : "", - COLUMN_COUNT, 0, - COLUMN_NO_HOOKS, (query.signal_flags & G_SIGNAL_NO_HOOKS) != 0, - COLUMN_SIGNAL_ID, ids[i], - COLUMN_HOOK_ID, 0, - -1); - g_hash_table_insert (sl->priv->iters, - GINT_TO_POINTER (ids[i]), gtk_tree_iter_copy (&iter)); - } - g_free (ids); -} - -static void -read_signals_from_object (GtkInspectorSignalsList *sl, - GObject *object) -{ - GType *types; - guint length; - gint i; - - types = get_types (object, &length); - for (i = 0; i < length; i++) - add_signals (sl, types[i], object); - g_free (types); -} - -static void stop_tracing (GtkInspectorSignalsList *sl); - -void -gtk_inspector_signals_list_set_object (GtkInspectorSignalsList *sl, - GObject *object) -{ - if (sl->priv->object == object) - return; - - stop_tracing (sl); - gtk_list_store_clear (sl->priv->model); - g_hash_table_remove_all (sl->priv->iters); - - sl->priv->object = object; - - if (object) - read_signals_from_object (sl, object); -} - -static void -render_count (GtkTreeViewColumn *column, - GtkCellRenderer *renderer, - GtkTreeModel *model, - GtkTreeIter *iter, - gpointer data) -{ - gint count; - gboolean no_hooks; - gchar text[100]; - - gtk_tree_model_get (model, iter, - COLUMN_COUNT, &count, - COLUMN_NO_HOOKS, &no_hooks, - -1); - if (no_hooks) - { - g_object_set (renderer, "markup", "<i>(untraceable)</i>", NULL); - } - else if (count != 0) - { - g_snprintf (text, 100, "%d", count); - g_object_set (renderer, "text", text, NULL); - } - else - g_object_set (renderer, "text", "", NULL); -} - -static void -gtk_inspector_signals_list_init (GtkInspectorSignalsList *sl) -{ - sl->priv = gtk_inspector_signals_list_get_instance_private (sl); - gtk_widget_init_template (GTK_WIDGET (sl)); - - gtk_tree_view_column_set_cell_data_func (sl->priv->count_column, - sl->priv->count_renderer, - render_count, - NULL, NULL); - - sl->priv->iters = g_hash_table_new_full (g_direct_hash, - g_direct_equal, - NULL, - (GDestroyNotify) gtk_tree_iter_free); -} - -static gboolean -trace_hook (GSignalInvocationHint *ihint, - guint n_param_values, - const GValue *param_values, - gpointer data) -{ - GtkInspectorSignalsList *sl = data; - GObject *object; - - object = g_value_get_object (param_values); - - if (object == sl->priv->object) - { - gint count; - GtkTreeIter *iter; - - iter = (GtkTreeIter *)g_hash_table_lookup (sl->priv->iters, GINT_TO_POINTER (ihint->signal_id)); - - gtk_tree_model_get (GTK_TREE_MODEL (sl->priv->model), iter, COLUMN_COUNT, &count, -1); - gtk_list_store_set (sl->priv->model, iter, COLUMN_COUNT, count + 1, -1); - } - - return TRUE; -} - -static gboolean -start_tracing_cb (GtkTreeModel *model, - GtkTreePath *path, - GtkTreeIter *iter, - gpointer data) -{ - GtkInspectorSignalsList *sl = data; - guint signal_id; - gulong hook_id; - gboolean no_hooks; - - gtk_tree_model_get (model, iter, - COLUMN_SIGNAL_ID, &signal_id, - COLUMN_HOOK_ID, &hook_id, - COLUMN_NO_HOOKS, &no_hooks, - -1); - - g_assert (signal_id != 0); - g_assert (hook_id == 0); - - if (!no_hooks) - { - hook_id = g_signal_add_emission_hook (signal_id, 0, trace_hook, sl, NULL); - - gtk_list_store_set (GTK_LIST_STORE (model), iter, - COLUMN_COUNT, 0, - COLUMN_HOOK_ID, hook_id, - -1); - } - - return FALSE; -} - -static gboolean -stop_tracing_cb (GtkTreeModel *model, - GtkTreePath *path, - GtkTreeIter *iter, - gpointer data) -{ - guint signal_id; - gulong hook_id; - - gtk_tree_model_get (model, iter, - COLUMN_SIGNAL_ID, &signal_id, - COLUMN_HOOK_ID, &hook_id, - -1); - - g_assert (signal_id != 0); - - if (hook_id != 0) - { - g_signal_remove_emission_hook (signal_id, hook_id); - gtk_list_store_set (GTK_LIST_STORE (model), iter, - COLUMN_HOOK_ID, 0, - -1); - } - - return FALSE; -} - -static void -start_tracing (GtkInspectorSignalsList *sl) -{ - sl->priv->tracing = TRUE; - gtk_tree_model_foreach (GTK_TREE_MODEL (sl->priv->model), start_tracing_cb, sl); -} - -static void -stop_tracing (GtkInspectorSignalsList *sl) -{ - sl->priv->tracing = FALSE; - gtk_tree_model_foreach (GTK_TREE_MODEL (sl->priv->model), stop_tracing_cb, sl); - gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (sl->priv->trace_button), FALSE); -} - -static void -toggle_tracing (GtkToggleToolButton *button, GtkInspectorSignalsList *sl) -{ - if (gtk_toggle_tool_button_get_active (button) == sl->priv->tracing) - return; - - //gtk_widget_show (sl->priv->log_win); - - if (gtk_toggle_tool_button_get_active (button)) - start_tracing (sl); - else - stop_tracing (sl); -} - -static gboolean -clear_log_cb (GtkTreeModel *model, - GtkTreePath *path, - GtkTreeIter *iter, - gpointer data) -{ - gtk_list_store_set (GTK_LIST_STORE (model), iter, COLUMN_COUNT, 0, -1); - return FALSE; -} - -static void -clear_log (GtkToolButton *button, GtkInspectorSignalsList *sl) -{ - gtk_text_buffer_set_text (sl->priv->text, "", -1); - - gtk_tree_model_foreach (GTK_TREE_MODEL (sl->priv->model), clear_log_cb, sl); -} - -static void -gtk_inspector_signals_list_class_init (GtkInspectorSignalsListClass *klass) -{ - GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); - - gtk_widget_class_set_template_from_resource (widget_class, "/org/gtk/inspector/signals-list.ui"); - gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorSignalsList, view); - gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorSignalsList, model); - gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorSignalsList, text); - gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorSignalsList, log_win); - gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorSignalsList, count_column); - gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorSignalsList, count_renderer); - gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorSignalsList, trace_button); - gtk_widget_class_bind_template_callback (widget_class, toggle_tracing); - gtk_widget_class_bind_template_callback (widget_class, clear_log); -} - -GtkWidget * -gtk_inspector_signals_list_new (void) -{ - return GTK_WIDGET (g_object_new (GTK_TYPE_INSPECTOR_SIGNALS_LIST, NULL)); -} - -// vim: set et sw=2 ts=2: diff --git a/modules/inspector/signals-list.h b/modules/inspector/signals-list.h deleted file mode 100644 index 9d90f561e5..0000000000 --- a/modules/inspector/signals-list.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * 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/>. - */ - -#ifndef _GTK_INSPECTOR_SIGNALS_LIST_H_ -#define _GTK_INSPECTOR_SIGNALS_LIST_H_ - -#include <gtk/gtk.h> - -#define GTK_TYPE_INSPECTOR_SIGNALS_LIST (gtk_inspector_signals_list_get_type()) -#define GTK_INSPECTOR_SIGNALS_LIST(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GTK_TYPE_INSPECTOR_SIGNALS_LIST, GtkInspectorSignalsList)) -#define GTK_INSPECTOR_SIGNALS_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GTK_TYPE_INSPECTOR_SIGNALS_LIST, GtkInspectorSignalsListClass)) -#define GTK_INSPECTOR_IS_SIGNALS_LIST(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GTK_TYPE_INSPECTOR_SIGNALS_LIST)) -#define GTK_INSPECTOR_IS_SIGNALS_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GTK_TYPE_INSPECTOR_SIGNALS_LIST)) -#define GTK_INSPECTOR_SIGNALS_LIST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GTK_TYPE_INSPECTOR_SIGNALS_LIST, GtkInspectorSignalsListClass)) - - -typedef struct _GtkInspectorSignalsListPrivate GtkInspectorSignalsListPrivate; - -typedef struct _GtkInspectorSignalsList -{ - GtkPaned parent; - GtkInspectorSignalsListPrivate *priv; -} GtkInspectorSignalsList; - -typedef struct _GtkInspectorSignalsListClass -{ - GtkPanedClass parent; -} GtkInspectorSignalsListClass; - -G_BEGIN_DECLS - -GType gtk_inspector_signals_list_get_type (void); -GtkWidget *gtk_inspector_signals_list_new (void); -void gtk_inspector_signals_list_set_object (GtkInspectorSignalsList *sl, - GObject *object); - -G_END_DECLS - -#endif // _GTK_INSPECTOR_SIGNALS_LIST_H_ - -// vim: set et sw=2 ts=2: diff --git a/modules/inspector/signals-list.ui b/modules/inspector/signals-list.ui deleted file mode 100644 index a7844420b1..0000000000 --- a/modules/inspector/signals-list.ui +++ /dev/null @@ -1,126 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<interface domain="gtk30"> - <object class="GtkListStore" id="model"> - <columns> - <column type="gchararray"/> - <column type="gchararray"/> - <column type="gchararray"/> - <column type="gint"/> - <column type="gboolean"/> - <column type="guint"/> - <column type="gulong"/> - </columns> - </object> - <object class="GtkTextBuffer" id="text"> - </object> - <template class="GtkInspectorSignalsList" parent="GtkPaned"> - <property name="orientation">vertical</property> - <child> - <object class="GtkBox"> - <property name="orientation">vertical</property> - <property name="visible">True</property> - <child> - <object class="GtkToolbar" id="toolbar"> - <property name="visible">True</property> - <property name="icon-size">small-toolbar</property> - <child> - <object class="GtkToggleToolButton" id="trace_button"> - <property name="visible">True</property> - <property name="icon-name">media-record</property> - <property name="tooltip-text" translatable="yes">Trace signal emissions on this object</property> - <signal name="toggled" handler="toggle_tracing"/> - </object> - </child> - <child> - <object class="GtkToolButton" id="clear_button"> - <property name="visible">True</property> - <property name="icon-name">edit-clear</property> - <property name="tooltip-text" translatable="yes">Clear log</property> - <signal name="clicked" handler="clear_log"/> - </object> - </child> - </object> - </child> - <child> - <object class="GtkScrolledWindow"> - <property name="visible">True</property> - <property name="expand">True</property> - <property name="hscrollbar-policy">automatic</property> - <property name="vscrollbar-policy">always</property> - <property name="shadow-type">in</property> - <child> - <object class="GtkTreeView" id="view"> - <property name="visible">True</property> - <property name="model">model</property> - <child> - <object class="GtkTreeViewColumn"> - <property name="title" translatable="yes">Name</property> - <child> - <object class="GtkCellRendererText"> - <property name="scale">0.8</property> - </object> - <attributes> - <attribute name="text">0</attribute> - </attributes> - </child> - </object> - </child> - <child> - <object class="GtkTreeViewColumn"> - <property name="title" translatable="yes">Connected</property> - <child> - <object class="GtkCellRendererText"> - <property name="scale">0.8</property> - </object> - <attributes> - <attribute name="text">2</attribute> - </attributes> - </child> - </object> - </child> - <child> - <object class="GtkTreeViewColumn" id="count_column"> - <property name="title" translatable="yes">Count</property> - <child> - <object class="GtkCellRendererText" id="count_renderer"> - <property name="scale">0.8</property> - </object> - </child> - </object> - </child> - <child> - <object class="GtkTreeViewColumn"> - <property name="title" translatable="yes">Defined At</property> - <child> - <object class="GtkCellRendererText"> - <property name="scale">0.8</property> - </object> - <attributes> - <attribute name="text">1</attribute> - </attributes> - </child> - </object> - </child> - </object> - </child> - </object> - </child> - </object> - </child> - <child> - <object class="GtkScrolledWindow" id="log_win"> - <property name="expand">True</property> - <property name="hscrollbar-policy">automatic</property> - <property name="vscrollbar-policy">always</property> - <property name="shadow-type">in</property> - <child> - <object class="GtkTextView"> - <property name="visible">True</property> - <property name="buffer">text</property> - <property name="editable">False</property> - </object> - </child> - </object> - </child> - </template> -</interface> diff --git a/modules/inspector/themes.c b/modules/inspector/themes.c deleted file mode 100644 index f2cb438a1b..0000000000 --- a/modules/inspector/themes.c +++ /dev/null @@ -1,205 +0,0 @@ -/* - * 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. - */ - -#include "themes.h" - -struct _GtkInspectorThemesPrivate -{ - GtkWidget *dark_switch; - GtkWidget *theme_combo; - GtkWidget *icon_combo; -}; - -G_DEFINE_TYPE_WITH_PRIVATE (GtkInspectorThemes, gtk_inspector_themes, GTK_TYPE_LIST_BOX) - -static void -init_dark (GtkInspectorThemes *pt) -{ - g_object_bind_property (pt->priv->dark_switch, "active", - gtk_settings_get_default (), "gtk-application-prefer-dark-theme", - G_BINDING_BIDIRECTIONAL); -} - -static void -fill_gtk (const gchar *path, - GHashTable *t) -{ - const gchar *dir_entry; - GDir *dir = g_dir_open (path, 0, NULL); - - if (!dir) - return; - - while ((dir_entry = g_dir_read_name (dir))) - { - gchar *filename = g_build_filename (path, dir_entry, "gtk-3.0", "gtk.css", NULL); - - 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); - } -} - -static void -init_theme (GtkInspectorThemes *pt) -{ - GHashTable *t; - GHashTableIter iter; - gchar *theme, *current_theme, *path; - gint i, pos; - GSettings *settings; - - t = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); - g_hash_table_add (t, g_strdup ("Raleigh")); - - fill_gtk (GTK_DATADIR "/themes", t); - path = g_build_filename (g_get_user_data_dir (), "themes", NULL); - fill_gtk (path, t); - g_free (path); - - settings = g_settings_new ("org.gnome.desktop.interface"); - current_theme = g_settings_get_string (settings, "gtk-theme"); - g_object_unref (settings); - - g_hash_table_iter_init (&iter, t); - pos = i = 0; - while (g_hash_table_iter_next (&iter, (gpointer *)&theme, NULL)) - { - gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (pt->priv->theme_combo), theme); - if (g_strcmp0 (theme, current_theme) == 0) - pos = i; - i++; - } - g_hash_table_destroy (t); - - gtk_combo_box_set_active (GTK_COMBO_BOX (pt->priv->theme_combo), pos); -} - -static void -fill_icons (const gchar *path, - GHashTable *t) -{ - const gchar *dir_entry; - GDir *dir = g_dir_open (path, 0, NULL); - - if (!dir) - return; - - while ((dir_entry = g_dir_read_name (dir))) - { - gchar *filename = g_build_filename (path, dir_entry, "index.theme", NULL); - - 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); - } -} - -static void -init_icons (GtkInspectorThemes *pt) -{ - GHashTable *t; - GHashTableIter iter; - gchar *theme, *current_theme, *path; - gint i, pos; - GSettings *settings; - - t = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); - - fill_icons (GTK_DATADIR "/icons", t); - path = g_build_filename (g_get_user_data_dir (), "icons", NULL); - fill_icons (path, t); - g_free (path); - - settings = g_settings_new ("org.gnome.desktop.interface"); - current_theme = g_settings_get_string (settings, "icon-theme"); - g_object_unref (settings); - - g_hash_table_iter_init (&iter, t); - pos = i = 0; - while (g_hash_table_iter_next (&iter, (gpointer *)&theme, NULL)) - { - gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (pt->priv->icon_combo), theme); - if (g_strcmp0 (theme, current_theme) == 0) - pos = i; - i++; - } - g_hash_table_destroy (t); - - gtk_combo_box_set_active (GTK_COMBO_BOX (pt->priv->icon_combo), pos); -} - -static void -theme_changed (GtkComboBox *c, - GtkInspectorThemes *pt) -{ - gchar *theme = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (c)); - g_object_set (gtk_settings_get_default (), "gtk-theme-name", theme, NULL); - g_free (theme); -} - -static void -icons_changed (GtkComboBox *c, - GtkInspectorThemes *pt) -{ - gchar *theme = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (c)); - g_object_set (gtk_settings_get_default (), "gtk-icon-theme-name", theme, NULL); - g_free (theme); -} - -static void -gtk_inspector_themes_init (GtkInspectorThemes *pt) -{ - pt->priv = gtk_inspector_themes_get_instance_private (pt); - gtk_widget_init_template (GTK_WIDGET (pt)); - - init_dark (pt); - init_theme (pt); - init_icons (pt); -} - -static void -gtk_inspector_themes_class_init (GtkInspectorThemesClass *klass) -{ - GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); - - gtk_widget_class_set_template_from_resource (widget_class, "/org/gtk/inspector/themes.ui"); - gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorThemes, dark_switch); - gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorThemes, theme_combo); - gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorThemes, icon_combo); - - gtk_widget_class_bind_template_callback (widget_class, theme_changed); - gtk_widget_class_bind_template_callback (widget_class, icons_changed); -} - -GtkWidget * -gtk_inspector_themes_new (void) -{ - return GTK_WIDGET (g_object_new (GTK_TYPE_INSPECTOR_THEMES, NULL)); -} - -// vim: set et sw=2 ts=2: diff --git a/modules/inspector/themes.h b/modules/inspector/themes.h deleted file mode 100644 index f70fb791b1..0000000000 --- a/modules/inspector/themes.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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. - */ - -#ifndef _GTK_INSPECTOR_THEMES_H_ -#define _GTK_INSPECTOR_THEMES_H_ - -#include <gtk/gtk.h> - -#define GTK_TYPE_INSPECTOR_THEMES (gtk_inspector_themes_get_type()) -#define GTK_INSPECTOR_THEMES(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GTK_TYPE_INSPECTOR_THEMES, GtkInspectorThemes)) -#define GTK_INSPECTOR_THEMES_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GTK_TYPE_INSPECTOR_THEMES, GtkInspectorThemesClass)) -#define GTK_INSPECTOR_IS_THEMES(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GTK_TYPE_INSPECTOR_THEMES)) -#define GTK_INSPECTOR_IS_THEMES_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GTK_TYPE_INSPECTOR_THEMES)) -#define GTK_INSPECTOR_THEMES_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GTK_TYPE_INSPECTOR_THEMES, GtkInspectorThemesClass)) - - -typedef struct _GtkInspectorThemesPrivate GtkInspectorThemesPrivate; - -typedef struct _GtkInspectorThemes -{ - GtkListBox parent; - GtkInspectorThemesPrivate *priv; -} GtkInspectorThemes; - -typedef struct _GtkInspectorThemesClass -{ - GtkListBoxClass parent; -} GtkInspectorThemesClass; - -G_BEGIN_DECLS - -GType gtk_inspector_themes_get_type (void); -GtkWidget *gtk_inspector_themes_new (void); - -G_END_DECLS - -#endif // _GTK_INSPECTOR_THEMES_H_ - -// vim: set et sw=2 ts=2: diff --git a/modules/inspector/themes.ui b/modules/inspector/themes.ui deleted file mode 100644 index 73ca432a46..0000000000 --- a/modules/inspector/themes.ui +++ /dev/null @@ -1,68 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<interface domain="gtk30"> - <template class="GtkInspectorThemes" parent="GtkListBox"> - <property name="selection-mode">none</property> - <child> - <object class="GtkBox"> - <property name="visible">True</property> - <property name="orientation">horizontal</property> - <property name="margin">10</property> - <child> - <object class="GtkLabel"> - <property name="visible">True</property> - <property name="label" translatable="yes">Use dark variant</property> - <property name="hexpand">True</property> - <property name="xalign">0.0</property> - </object> - </child> - <child> - <object class="GtkSwitch" id="dark_switch"> - <property name="visible">True</property> - </object> - </child> - </object> - </child> - <child> - <object class="GtkBox"> - <property name="visible">True</property> - <property name="orientation">horizontal</property> - <property name="margin">10</property> - <child> - <object class="GtkLabel"> - <property name="visible">True</property> - <property name="label" translatable="yes">GTK+ Theme</property> - <property name="hexpand">True</property> - <property name="xalign">0.0</property> - </object> - </child> - <child> - <object class="GtkComboBoxText" id="theme_combo"> - <property name="visible">True</property> - <signal name="changed" handler="theme_changed"/> - </object> - </child> - </object> - </child> - <child> - <object class="GtkBox"> - <property name="visible">True</property> - <property name="orientation">horizontal</property> - <property name="margin">10</property> - <child> - <object class="GtkLabel"> - <property name="visible">True</property> - <property name="label" translatable="yes">Icon Theme</property> - <property name="hexpand">True</property> - <property name="xalign">0.0</property> - </object> - </child> - <child> - <object class="GtkComboBoxText" id="icon_combo"> - <property name="visible">True</property> - <signal name="changed" handler="icons_changed"/> - </object> - </child> - </object> - </child> - </template> -</interface> diff --git a/modules/inspector/visual.c b/modules/inspector/visual.c deleted file mode 100644 index 7b2fed7de2..0000000000 --- a/modules/inspector/visual.c +++ /dev/null @@ -1,148 +0,0 @@ -/* - * 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/>. - */ - -#include "visual.h" - -struct _GtkInspectorVisualPrivate -{ - GtkWidget *updates_switch; - GtkWidget *direction_combo; - GtkWidget *baselines_switch; - GtkWidget *pixelcache_switch; -}; - -G_DEFINE_TYPE_WITH_PRIVATE (GtkInspectorVisual, gtk_inspector_visual, GTK_TYPE_LIST_BOX) - -static void -updates_activate (GtkSwitch *sw) -{ - gdk_window_set_debug_updates (gtk_switch_get_active (sw)); -} - -static void -fix_direction_recurse (GtkWidget *widget, gpointer data) -{ - GtkTextDirection dir = GPOINTER_TO_INT (data); - - g_object_ref (widget); - - gtk_widget_set_direction (widget, dir); - if (GTK_IS_CONTAINER (widget)) - gtk_container_forall (GTK_CONTAINER (widget), fix_direction_recurse, data); - - g_object_unref (widget); -} - -static GtkTextDirection initial_direction; - -static void -fix_direction (GtkWidget *iw) -{ - fix_direction_recurse (iw, GINT_TO_POINTER (initial_direction)); -} - -static void -direction_changed (GtkComboBox *combo) -{ - GtkWidget *iw; - const gchar *direction; - - iw = gtk_widget_get_toplevel (GTK_WIDGET (combo)); - fix_direction (iw); - - direction = gtk_combo_box_get_active_id (combo); - if (g_strcmp0 (direction, "ltr") == 0) - 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) -{ - const gchar *direction; - - initial_direction = gtk_widget_get_default_direction (); - if (initial_direction == GTK_TEXT_DIR_LTR) - direction = "ltr"; - else - direction = "rtl"; - gtk_combo_box_set_active_id (GTK_COMBO_BOX (vis->priv->direction_combo), direction); -} - -static void -baselines_activate (GtkSwitch *sw) -{ - guint flags; - - flags = gtk_get_debug_flags (); - - if (gtk_switch_get_active (sw)) - flags |= GTK_DEBUG_BASELINES; - else - flags &= ~GTK_DEBUG_BASELINES; - - gtk_set_debug_flags (flags); -} - -static void -pixelcache_activate (GtkSwitch *sw) -{ - guint flags; - - flags = gtk_get_debug_flags (); - - if (gtk_switch_get_active (sw)) - flags |= GTK_DEBUG_PIXEL_CACHE; - else - flags &= ~GTK_DEBUG_PIXEL_CACHE; - - gtk_set_debug_flags (flags); -} - -static void -gtk_inspector_visual_init (GtkInspectorVisual *pt) -{ - pt->priv = gtk_inspector_visual_get_instance_private (pt); - gtk_widget_init_template (GTK_WIDGET (pt)); - - init_direction (pt); -} - -static void -gtk_inspector_visual_class_init (GtkInspectorVisualClass *klass) -{ - GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); - - gtk_widget_class_set_template_from_resource (widget_class, "/org/gtk/inspector/visual.ui"); - gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorVisual, updates_switch); - gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorVisual, direction_combo); - gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorVisual, baselines_switch); - gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorVisual, pixelcache_switch); - gtk_widget_class_bind_template_callback (widget_class, updates_activate); - gtk_widget_class_bind_template_callback (widget_class, direction_changed); - gtk_widget_class_bind_template_callback (widget_class, baselines_activate); - gtk_widget_class_bind_template_callback (widget_class, pixelcache_activate); -} - -GtkWidget * -gtk_inspector_visual_new (void) -{ - return GTK_WIDGET (g_object_new (GTK_TYPE_INSPECTOR_VISUAL, NULL)); -} - -// vim: set et sw=2 ts=2: diff --git a/modules/inspector/visual.h b/modules/inspector/visual.h deleted file mode 100644 index 2227d3f668..0000000000 --- a/modules/inspector/visual.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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/>. - */ - -#ifndef _GTK_INSPECTOR_VISUAL_H_ -#define _GTK_INSPECTOR_VISUAL_H_ - -#include <gtk/gtk.h> - -#define GTK_TYPE_INSPECTOR_VISUAL (gtk_inspector_visual_get_type()) -#define GTK_INSPECTOR_VISUAL(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GTK_TYPE_INSPECTOR_VISUAL, GtkInspectorVisual)) -#define GTK_INSPECTOR_VISUAL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GTK_TYPE_INSPECTOR_VISUAL, GtkInspectorVisualClass)) -#define GTK_INSPECTOR_IS_VISUAL(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GTK_TYPE_INSPECTOR_VISUAL)) -#define GTK_INSPECTOR_IS_VISUAL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GTK_TYPE_INSPECTOR_VISUAL)) -#define GTK_INSPECTOR_VISUAL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GTK_TYPE_INSPECTOR_VISUAL, GtkInspectorVisualClass)) - - -typedef struct _GtkInspectorVisualPrivate GtkInspectorVisualPrivate; - -typedef struct _GtkInspectorVisual -{ - GtkListBox parent; - GtkInspectorVisualPrivate *priv; -} GtkInspectorVisual; - -typedef struct _GtkInspectorVisualClass -{ - GtkListBoxClass parent; -} GtkInspectorVisualClass; - -G_BEGIN_DECLS - -GType gtk_inspector_visual_get_type (void); -GtkWidget *gtk_inspector_visual_new (void); - -G_END_DECLS - -#endif // _GTK_INSPECTOR_VISUAL_H_ - -// vim: set et sw=2 ts=2: diff --git a/modules/inspector/visual.ui b/modules/inspector/visual.ui deleted file mode 100644 index da2162ada9..0000000000 --- a/modules/inspector/visual.ui +++ /dev/null @@ -1,94 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<interface domain="gtk30"> - <template class="GtkInspectorVisual" parent="GtkListBox"> - <property name="selection-mode">none</property> - <child> - <object class="GtkBox"> - <property name="visible">True</property> - <property name="orientation">horizontal</property> - <property name="margin">10</property> - <child> - <object class="GtkLabel"> - <property name="visible">True</property> - <property name="label" translatable="yes">Text Direction</property> - <property name="hexpand">True</property> - <property name="xalign">0.0</property> - </object> - </child> - <child> - <object class="GtkComboBoxText" id="direction_combo"> - <property name="visible">True</property> - <signal name="changed" handler="direction_changed"/> - <items> - <item translatable="yes" id="ltr">Left-to-Right</item> - <item translatable="yes" id="rtl">Right-to-Left</item> - </items> - </object> - </child> - </object> - </child> - <child> - <object class="GtkBox"> - <property name="visible">True</property> - <property name="orientation">horizontal</property> - <property name="margin">10</property> - <child> - <object class="GtkLabel"> - <property name="visible">True</property> - <property name="label" translatable="yes">Show Graphic Updates</property> - <property name="hexpand">True</property> - <property name="xalign">0.0</property> - </object> - </child> - <child> - <object class="GtkSwitch" id="updates_switch"> - <property name="visible">True</property> - <signal name="notify::active" handler="updates_activate"/> - </object> - </child> - </object> - </child> - <child> - <object class="GtkBox"> - <property name="visible">True</property> - <property name="orientation">horizontal</property> - <property name="margin">10</property> - <child> - <object class="GtkLabel"> - <property name="visible">True</property> - <property name="label" translatable="yes">Show Baselines</property> - <property name="hexpand">True</property> - <property name="xalign">0.0</property> - </object> - </child> - <child> - <object class="GtkSwitch" id="baselines_switch"> - <property name="visible">True</property> - <signal name="notify::active" handler="baselines_activate"/> - </object> - </child> - </object> - </child> - <child> - <object class="GtkBox"> - <property name="visible">True</property> - <property name="orientation">horizontal</property> - <property name="margin">10</property> - <child> - <object class="GtkLabel"> - <property name="visible">True</property> - <property name="label" translatable="yes">Show Pixel Cache</property> - <property name="hexpand">True</property> - <property name="xalign">0.0</property> - </object> - </child> - <child> - <object class="GtkSwitch" id="pixelcache_switch"> - <property name="visible">True</property> - <signal name="notify::active" handler="pixelcache_activate"/> - </object> - </child> - </object> - </child> - </template> -</interface> diff --git a/modules/inspector/widget-tree.c b/modules/inspector/widget-tree.c deleted file mode 100644 index 0244422ce5..0000000000 --- a/modules/inspector/widget-tree.c +++ /dev/null @@ -1,447 +0,0 @@ -/* - * 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. - */ - -#include "prop-list.h" -#include "widget-tree.h" -#include <string.h> - -enum -{ - OBJECT, - OBJECT_TYPE, - OBJECT_NAME, - OBJECT_LABEL, - OBJECT_ADDRESS, - SENSITIVE -}; - - -enum -{ - WIDGET_CHANGED, - LAST_SIGNAL -}; - - -struct _GtkInspectorWidgetTreePrivate -{ - GtkTreeStore *model; - GHashTable *iters; -}; - -static guint widget_tree_signals[LAST_SIGNAL] = { 0 }; - -G_DEFINE_TYPE_WITH_PRIVATE (GtkInspectorWidgetTree, gtk_inspector_widget_tree, GTK_TYPE_TREE_VIEW) - -static void -on_widget_selected (GtkTreeSelection *selection, - GtkInspectorWidgetTree *wt) -{ - g_signal_emit (wt, widget_tree_signals[WIDGET_CHANGED], 0); -} - -typedef struct -{ - GtkInspectorWidgetTree *wt; - GObject *object; - GtkTreeRowReference *row; - gulong map_handler; - gulong unmap_handler; -} ObjectData; - -static void -remove_dead_object (gpointer data, GObject *dead_object) -{ - ObjectData *od = data; - - if (gtk_tree_row_reference_valid (od->row)) - { - GtkTreePath *path; - GtkTreeIter iter; - path = gtk_tree_row_reference_get_path (od->row); - gtk_tree_model_get_iter (GTK_TREE_MODEL (od->wt->priv->model), &iter, path); - gtk_tree_store_remove (od->wt->priv->model, &iter); - gtk_tree_path_free (path); - } - od->object = NULL; - g_hash_table_remove (od->wt->priv->iters, dead_object); -} - -static void -object_data_free (gpointer data) -{ - ObjectData *od = data; - - gtk_tree_row_reference_free (od->row); - - if (od->object) - g_object_weak_unref (od->object, remove_dead_object, od); - - if (od->object && od->map_handler) - { - g_signal_handler_disconnect (od->object, od->map_handler); - g_signal_handler_disconnect (od->object, od->unmap_handler); - } - - g_free (od); -} - -static void -gtk_inspector_widget_tree_init (GtkInspectorWidgetTree *wt) -{ - wt->priv = gtk_inspector_widget_tree_get_instance_private (wt); - wt->priv->iters = g_hash_table_new_full (g_direct_hash, - g_direct_equal, - NULL, - (GDestroyNotify) object_data_free); - gtk_widget_init_template (GTK_WIDGET (wt)); - - gtk_inspector_widget_tree_append_object (wt, G_OBJECT (gtk_settings_get_default ()), NULL, NULL); -} - -static void -gtk_inspector_widget_tree_class_init (GtkInspectorWidgetTreeClass *klass) -{ - GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); - - klass->widget_changed = NULL; - - widget_tree_signals[WIDGET_CHANGED] = - g_signal_new ("widget-changed", - G_OBJECT_CLASS_TYPE(klass), - G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE, - G_STRUCT_OFFSET(GtkInspectorWidgetTreeClass, widget_changed), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - - gtk_widget_class_set_template_from_resource (widget_class, "/org/gtk/inspector/widget-tree.ui"); - gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorWidgetTree, model); - gtk_widget_class_bind_template_callback (widget_class, on_widget_selected); -} - -GtkWidget * -gtk_inspector_widget_tree_new (void) -{ - return g_object_new (GTK_TYPE_INSPECTOR_WIDGET_TREE, NULL); -} - - -GObject * -gtk_inspector_widget_tree_get_selected_object (GtkInspectorWidgetTree *wt) -{ - GtkTreeIter iter; - GtkTreeSelection *sel; - GtkTreeModel *model; - - sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (wt)); - - if (gtk_tree_selection_get_selected (sel, &model, &iter)) - { - GObject *object; - gtk_tree_model_get (model, &iter, - OBJECT, &object, - -1); - return object; - } - - return NULL; -} - -static void -map_or_unmap (GtkWidget *widget, GtkInspectorWidgetTree *wt) -{ - GtkTreeIter iter; - - if (gtk_inspector_widget_tree_find_object (wt, G_OBJECT (widget), &iter)) - { - gtk_tree_store_set (wt->priv->model, &iter, - SENSITIVE, gtk_widget_get_mapped (widget), - -1); - } -} - -typedef struct -{ - GtkInspectorWidgetTree *wt; - GtkTreeIter *iter; - GObject *parent; -} FindAllData; - -static void -child_callback (GtkWidget *widget, - gpointer data) -{ - FindAllData *d = data; - - gtk_inspector_widget_tree_append_object (d->wt, G_OBJECT (widget), d->iter, NULL); -} - -static gboolean -cell_callback (GtkCellRenderer *renderer, - gpointer data) -{ - FindAllData *d = data; - - g_object_set_data (G_OBJECT (renderer), "gtk-inspector-cell-area", d->parent); - gtk_inspector_widget_tree_append_object (d->wt, G_OBJECT (renderer), d->iter, NULL); - - return FALSE; -} - -static void -tag_callback (GtkTextTag *tag, - gpointer data) -{ - FindAllData *d = data; - gchar *name; - - g_object_get (tag, "name", &name, NULL); - gtk_inspector_widget_tree_append_object (d->wt, G_OBJECT (tag), d->iter, name); - g_free (name); -} - -void -gtk_inspector_widget_tree_append_object (GtkInspectorWidgetTree *wt, - GObject *object, - GtkTreeIter *parent_iter, - const gchar *name) -{ - GtkTreeIter iter; - GtkTreePath *path; - const gchar *class_name = G_OBJECT_CLASS_NAME (G_OBJECT_GET_CLASS (object)); - gchar *address; - gboolean mapped; - ObjectData *od; - const gchar *label; - - label = NULL; - mapped = FALSE; - - if (GTK_IS_WIDGET (object)) - { - GtkWidget *widget = GTK_WIDGET (object); - if (name == NULL) - name = gtk_widget_get_name (GTK_WIDGET (object)); - mapped = gtk_widget_get_mapped (widget); - } - - if (name == NULL || g_strcmp0 (name, class_name) == 0) - { - if (GTK_IS_BUILDABLE (object)) - name = gtk_buildable_get_name (GTK_BUILDABLE (object)); - } - - if (name == NULL) - name = ""; - - if (GTK_IS_LABEL (object)) - label = gtk_label_get_text (GTK_LABEL (object)); - else if (GTK_IS_BUTTON (object)) - label = gtk_button_get_label (GTK_BUTTON (object)); - else if (GTK_IS_WINDOW (object)) - label = gtk_window_get_title (GTK_WINDOW (object)); - else if (GTK_IS_TREE_VIEW_COLUMN (object)) - label = gtk_tree_view_column_get_title (GTK_TREE_VIEW_COLUMN (object)); - else - label = ""; - - address = g_strdup_printf ("%p", object); - - gtk_tree_store_append (wt->priv->model, &iter, parent_iter); - gtk_tree_store_set (wt->priv->model, &iter, - OBJECT, object, - OBJECT_TYPE, class_name, - OBJECT_NAME, name, - OBJECT_LABEL, label, - OBJECT_ADDRESS, address, - SENSITIVE, !GTK_IS_WIDGET (object) || mapped, - -1); - - od = g_new0 (ObjectData, 1); - od->wt = wt; - od->object = object; - path = gtk_tree_model_get_path (GTK_TREE_MODEL (wt->priv->model), &iter); - od->row = gtk_tree_row_reference_new (GTK_TREE_MODEL (wt->priv->model), path); - gtk_tree_path_free (path); - if (GTK_IS_WIDGET (object)) - { - od->map_handler = g_signal_connect (object, "map", G_CALLBACK (map_or_unmap), wt); - od->unmap_handler = g_signal_connect (object, "unmap", G_CALLBACK (map_or_unmap), wt); - } - - g_hash_table_insert (wt->priv->iters, object, od); - g_object_weak_ref (object, remove_dead_object, od); - - g_free (address); - - if (GTK_IS_CONTAINER (object)) - { - FindAllData data; - - data.wt = wt; - data.iter = &iter; - data.parent = object; - - gtk_container_forall (GTK_CONTAINER (object), child_callback, &data); - } - - /* Below are special cases for dependent objects which are not - * children in the GtkContainer sense, but which we still want - * to show in the tree right away. - */ - if (GTK_IS_TREE_VIEW (object)) - { - gint n_columns, i; - GObject *child; - - child = G_OBJECT (gtk_tree_view_get_model (GTK_TREE_VIEW (object))); - if (child) - gtk_inspector_widget_tree_append_object (wt, child, &iter, "model"); - - n_columns = gtk_tree_view_get_n_columns (GTK_TREE_VIEW (object)); - for (i = 0; i < n_columns; i++) - { - child = G_OBJECT (gtk_tree_view_get_column (GTK_TREE_VIEW (object), i)); - gtk_inspector_widget_tree_append_object (wt, child, &iter, NULL); - } - } - - if (GTK_IS_ICON_VIEW (object)) - { - GObject *child; - - child = G_OBJECT (gtk_icon_view_get_model (GTK_ICON_VIEW (object))); - if (child) - gtk_inspector_widget_tree_append_object (wt, child, &iter, "model"); - } - - if (GTK_IS_COMBO_BOX (object)) - { - GObject *child; - - child = G_OBJECT (gtk_combo_box_get_model (GTK_COMBO_BOX (object))); - if (child) - gtk_inspector_widget_tree_append_object (wt, child, &iter, "model"); - } - - if (GTK_IS_CELL_AREA (object)) - { - FindAllData data; - - data.wt = wt; - data.iter = &iter; - data.parent = object; - - gtk_cell_area_foreach (GTK_CELL_AREA (object), cell_callback, &data); - } - else if (GTK_IS_CELL_LAYOUT (object)) - { - GtkCellArea *area; - - area = gtk_cell_layout_get_area (GTK_CELL_LAYOUT (object)); - gtk_inspector_widget_tree_append_object (wt, G_OBJECT (area), &iter, "cell-area"); - } - - if (GTK_IS_TEXT_VIEW (object)) - { - GtkTextBuffer *buffer; - - buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (object)); - gtk_inspector_widget_tree_append_object (wt, G_OBJECT (buffer), &iter, "buffer"); - } - - if (GTK_IS_TEXT_BUFFER (object)) - { - GtkTextTagTable *tags; - - tags = gtk_text_buffer_get_tag_table (GTK_TEXT_BUFFER (object)); - gtk_inspector_widget_tree_append_object (wt, G_OBJECT (tags), &iter, "tag-table"); - } - - if (GTK_IS_TEXT_TAG_TABLE (object)) - { - FindAllData data; - - data.wt = wt; - data.iter = &iter; - data.parent = object; - - gtk_text_tag_table_foreach (GTK_TEXT_TAG_TABLE (object), tag_callback, &data); - } -} - -void -gtk_inspector_widget_tree_scan (GtkInspectorWidgetTree *wt, - GtkWidget *window) -{ - gtk_tree_store_clear (wt->priv->model); - g_hash_table_remove_all (wt->priv->iters); - gtk_inspector_widget_tree_append_object (wt, G_OBJECT (gtk_settings_get_default ()), NULL, NULL); - if (g_application_get_default ()) - gtk_inspector_widget_tree_append_object (wt, G_OBJECT (g_application_get_default ()), NULL, NULL); - gtk_inspector_widget_tree_append_object (wt, G_OBJECT (window), NULL, NULL); - - gtk_tree_view_columns_autosize (GTK_TREE_VIEW (wt)); -} - -gboolean -gtk_inspector_widget_tree_find_object (GtkInspectorWidgetTree *wt, - GObject *object, - GtkTreeIter *iter) -{ - ObjectData *od; - - od = g_hash_table_lookup (wt->priv->iters, object); - if (od && gtk_tree_row_reference_valid (od->row)) - { - GtkTreePath *path; - - path = gtk_tree_row_reference_get_path (od->row); - gtk_tree_model_get_iter (GTK_TREE_MODEL (wt->priv->model), iter, path); - gtk_tree_path_free (path); - - return TRUE; - } - - return FALSE; -} - -void -gtk_inspector_widget_tree_select_object (GtkInspectorWidgetTree *wt, - GObject *object) -{ - GtkTreeIter iter; - - if (gtk_inspector_widget_tree_find_object (wt, object, &iter)) - { - GtkTreePath *path = gtk_tree_model_get_path (GTK_TREE_MODEL (wt->priv->model), &iter); - gtk_tree_view_expand_to_path (GTK_TREE_VIEW (wt), path); - gtk_tree_selection_select_iter (gtk_tree_view_get_selection (GTK_TREE_VIEW (wt)), &iter); - gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (wt), path, NULL, FALSE, 0, 0); - } -} - - -// vim: set et sw=2 ts=2: diff --git a/modules/inspector/widget-tree.h b/modules/inspector/widget-tree.h deleted file mode 100644 index 5a880a6d56..0000000000 --- a/modules/inspector/widget-tree.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2008-2009 Christian Hammond - * Copyright (c) 2008-2009 David Trowbridge - * - * 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. - */ -#ifndef _GTK_INSPECTOR_WIDGET_TREE_H_ -#define _GTK_INSPECTOR_WIDGET_TREE_H_ - - -#include <gtk/gtk.h> - - -#define GTK_TYPE_INSPECTOR_WIDGET_TREE (gtk_inspector_widget_tree_get_type()) -#define GTK_INSPECTOR_WIDGET_TREE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GTK_TYPE_INSPECTOR_WIDGET_TREE, GtkInspectorWidgetTree)) -#define GTK_INSPECTOR_WIDGET_TREE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GTK_TYPE_INSPECTOR_WIDGET_TREE, GtkInspectorWidgetTreeClass)) -#define GTK_INSPECTOR_IS_WIDGET_TREE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GTK_TYPE_INSPECTOR_WIDGET_TREE)) -#define GTK_INSPECTOR_IS_WIDGET_TREE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GTK_TYPE_INSPECTOR_WIDGET_TREE)) -#define GTK_INSPECTOR_WIDGET_TREE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GTK_TYPE_INSPECTOR_WIDGET_TREE, GtkInspectorWidgetTreeClass)) - - -typedef struct _GtkInspectorWidgetTreePrivate GtkInspectorWidgetTreePrivate; - -typedef struct _GtkInspectorWidgetTree -{ - GtkTreeView parent; - GtkInspectorWidgetTreePrivate *priv; -} GtkInspectorWidgetTree; - -typedef struct _GtkInspectorWidgetTreeClass -{ - GtkTreeViewClass parent; - - void (*widget_changed) (GtkInspectorWidgetTree *tree); -} GtkInspectorWidgetTreeClass; - - -G_BEGIN_DECLS - - -GType gtk_inspector_widget_tree_get_type (void); -GtkWidget *gtk_inspector_widget_tree_new (void); - -GObject *gtk_inspector_widget_tree_get_selected_object (GtkInspectorWidgetTree *wt); - -void gtk_inspector_widget_tree_scan (GtkInspectorWidgetTree *wt, - GtkWidget *window); -void gtk_inspector_widget_tree_select_object (GtkInspectorWidgetTree *wt, - GObject *object); -void gtk_inspector_widget_tree_append_object (GtkInspectorWidgetTree *wt, - GObject *object, - GtkTreeIter *parent_iter, - const gchar *name); -gboolean gtk_inspector_widget_tree_find_object (GtkInspectorWidgetTree *wt, - GObject *object, - GtkTreeIter *iter); - -G_END_DECLS - - -#endif // _GTK_INSPECTOR_WIDGETTREE_H_ - -// vim: set et sw=2 ts=2: diff --git a/modules/inspector/widget-tree.ui b/modules/inspector/widget-tree.ui deleted file mode 100644 index 74518847a9..0000000000 --- a/modules/inspector/widget-tree.ui +++ /dev/null @@ -1,84 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<interface domain="gtk30"> - <object class="GtkTreeStore" id="model"> - <columns> - <column type="gpointer"/> - <column type="gchararray"/> - <column type="gchararray"/> - <column type="gchararray"/> - <column type="gchararray"/> - <column type="gboolean"/> - </columns> - </object> - <template class="GtkInspectorWidgetTree" parent="GtkTreeView"> - <property name="model">model</property> - <property name="enable-search">True</property> - <property name="search-column">2</property> - <child internal-child="selection"> - <object class="GtkTreeSelection"> - <signal name="changed" handler="on_widget_selected"/> - </object> - </child> - <child> - <object class="GtkTreeViewColumn"> - <property name="title" translatable="yes">Object</property> - <property name="resizable">True</property> - <child> - <object class="GtkCellRendererText"> - <property name="scale">0.8</property> - </object> - <attributes> - <attribute name="text">1</attribute> - <attribute name="sensitive">5</attribute> - </attributes> - </child> - </object> - </child> - <child> - <object class="GtkTreeViewColumn"> - <property name="title" translatable="yes">Name</property> - <property name="resizable">True</property> - <child> - <object class="GtkCellRendererText"> - <property name="scale">0.8</property> - </object> - <attributes> - <attribute name="text">2</attribute> - <attribute name="sensitive">5</attribute> - </attributes> - </child> - </object> - </child> - <child> - <object class="GtkTreeViewColumn"> - <property name="title" translatable="yes">Label</property> - <property name="resizable">True</property> - <child> - <object class="GtkCellRendererText"> - <property name="scale">0.8</property> - </object> - <attributes> - <attribute name="text">3</attribute> - <attribute name="sensitive">5</attribute> - </attributes> - </child> - </object> - </child> - <child> - <object class="GtkTreeViewColumn"> - <property name="title" translatable="yes">Address</property> - <property name="resizable">True</property> - <child> - <object class="GtkCellRendererText"> - <property name="scale">0.8</property> - <property name="family">monospace</property> - </object> - <attributes> - <attribute name="text">4</attribute> - <attribute name="sensitive">5</attribute> - </attributes> - </child> - </object> - </child> - </template> -</interface> diff --git a/modules/inspector/window.c b/modules/inspector/window.c deleted file mode 100644 index f1928b6e04..0000000000 --- a/modules/inspector/window.c +++ /dev/null @@ -1,183 +0,0 @@ -/* - * 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. - */ - -#include "config.h" -#include <glib/gi18n-lib.h> -#include <stdlib.h> -#include "window.h" -#include "prop-list.h" -#include "property-cell-renderer.h" -#include "classes-list.h" -#include "css-editor.h" -#include "object-hierarchy.h" -#include "widget-tree.h" -#include "python-hooks.h" -#include "python-shell.h" -#include "button-path.h" -#include "data-list.h" -#include "themes.h" -#include "signals-list.h" - -G_DEFINE_TYPE (GtkInspectorWindow, gtk_inspector_window, GTK_TYPE_WINDOW) - -extern void on_inspect (GtkWidget *button, GtkInspectorWindow *iw); - -static gboolean -on_widget_tree_button_press (GtkInspectorWidgetTree *wt, - GdkEventButton *event, - GtkInspectorWindow *iw) -{ - if (event->button == 3) - gtk_menu_popup (GTK_MENU (iw->widget_popup), NULL, NULL, - NULL, NULL, event->button, event->time); - - return FALSE; -} - -static void -on_widget_tree_selection_changed (GtkInspectorWidgetTree *wt, - GtkInspectorWindow *iw) -{ - GObject *selected = gtk_inspector_widget_tree_get_selected_object (wt); - - 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); - 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); - gtk_inspector_button_path_set_object (GTK_INSPECTOR_BUTTON_PATH (iw->button_path), selected); - 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); - gtk_inspector_data_list_set_object (GTK_INSPECTOR_DATA_LIST (iw->data_list), selected); - if (GTK_IS_WIDGET (selected)) - gtk_inspector_flash_widget (iw, GTK_WIDGET (selected)); -} - -static void -on_send_widget_to_shell_activate (GtkWidget *menuitem, - GtkInspectorWindow *iw) -{ - gchar *str; - GObject *object; - - object = gtk_inspector_widget_tree_get_selected_object (GTK_INSPECTOR_WIDGET_TREE (iw->widget_tree)); - - if (!object) - return; - - str = g_strdup_printf ("gtk_inspector.gobj(%p)", object); - gtk_inspector_python_shell_append_text (GTK_INSPECTOR_PYTHON_SHELL (iw->python_shell), - str, - NULL); - - g_free (str); - gtk_inspector_python_shell_focus (GTK_INSPECTOR_PYTHON_SHELL (iw->python_shell)); -} - -static void -gtk_inspector_window_init (GtkInspectorWindow *iw) -{ - gchar *title; - - gtk_widget_init_template (GTK_WIDGET (iw)); - - gtk_window_group_add_window (gtk_window_group_new (), GTK_WINDOW (iw)); - - title = g_strdup_printf (_("GTK+ Inspector — %s"), g_get_application_name ()); - gtk_window_set_title (GTK_WINDOW (iw), title); - g_free (title); - - if (gtk_inspector_python_is_enabled ()) - { - gtk_widget_show (iw->python_shell); - g_signal_connect (G_OBJECT (iw->widget_tree), "button-press-event", - G_CALLBACK (on_widget_tree_button_press), iw); - } -} - -static void -gtk_inspector_window_select_initially (GtkInspectorWindow *iw) -{ - GList *toplevels, *l; - GtkWidget *widget; - - toplevels = gtk_window_list_toplevels (); - widget = NULL; - for (l = toplevels; l; l = l->next) - { - if (gtk_widget_get_mapped (GTK_WIDGET (l->data)) && - GTK_IS_WINDOW (l->data) && - !GTK_INSPECTOR_IS_WINDOW (l->data)) - { - widget = l->data; - break; - } - } - g_list_free (toplevels); - - if (widget) - gtk_inspector_widget_tree_scan (GTK_INSPECTOR_WIDGET_TREE (iw->widget_tree), widget); -} - -static void -gtk_inspector_window_constructed (GObject *object) -{ - gtk_inspector_window_select_initially (GTK_INSPECTOR_WINDOW (object)); -} - -static void -gtk_inspector_window_class_init (GtkInspectorWindowClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); - - object_class->constructed = gtk_inspector_window_constructed; - - gtk_widget_class_set_template_from_resource (widget_class, "/org/gtk/inspector/window.ui"); - - gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, widget_tree); - gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, prop_list); - gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, child_prop_list); - gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, signals_list); - gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, button_path); - gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, classes_list); - gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, widget_css_editor); - gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, object_hierarchy); - gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, python_shell); - gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, widget_popup); - gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, data_list); - - gtk_widget_class_bind_template_callback (widget_class, on_inspect); - gtk_widget_class_bind_template_callback (widget_class, on_widget_tree_selection_changed); - gtk_widget_class_bind_template_callback (widget_class, on_send_widget_to_shell_activate); -} - -GtkWidget * -gtk_inspector_window_new (void) -{ - return GTK_WIDGET (g_object_new (GTK_TYPE_INSPECTOR_WINDOW, NULL)); -} - -// vim: set et sw=2 ts=2: diff --git a/modules/inspector/window.h b/modules/inspector/window.h deleted file mode 100644 index da2742fe42..0000000000 --- a/modules/inspector/window.h +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (c) 2008-2009 Christian Hammond - * Copyright (c) 2008-2009 David Trowbridge - * - * 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. - */ -#ifndef _GTK_INSPECTOR_WINDOW_H_ -#define _GTK_INSPECTOR_WINDOW_H_ - - -#include <gtk/gtk.h> - -#define GTK_TYPE_INSPECTOR_WINDOW (gtk_inspector_window_get_type()) -#define GTK_INSPECTOR_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GTK_TYPE_INSPECTOR_WINDOW, GtkInspectorWindow)) -#define GTK_INSPECTOR_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GTK_TYPE_INSPECTOR_WINDOW, GtkInspectorWindowClass)) -#define GTK_INSPECTOR_IS_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GTK_TYPE_INSPECTOR_WINDOW)) -#define GTK_INSPECTOR_IS_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GTK_TYPE_INSPECTOR_WINDOW)) -#define GTK_INSPECTOR_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GTK_TYPE_INSPECTOR_WINDOW, GtkInspectorWindowClass)) - - -#define TREE_TEXT_SCALE 0.8 -#define TREE_CHECKBOX_SIZE (gint)(0.8 * 13) - -typedef struct -{ - GtkWindow parent; - - GtkWidget *widget_tree; - GtkWidget *prop_list; - GtkWidget *child_prop_list; - GtkWidget *signals_list; - GtkWidget *python_shell; - GtkWidget *button_path; - GtkWidget *classes_list; - GtkWidget *widget_css_editor; - GtkWidget *object_hierarchy; - GtkWidget *data_list; - - GtkWidget *widget_popup; - - GtkWidget *selected_widget; - GtkWidget *flash_widget; - - gint flash_count; - gint flash_cnx; - -} GtkInspectorWindow; - -typedef struct -{ - GtkWindowClass parent; -} GtkInspectorWindowClass; - - -G_BEGIN_DECLS - -GType gtk_inspector_window_get_type (void); -GtkWidget *gtk_inspector_window_new (void); - -void gtk_inspector_flash_widget (GtkInspectorWindow *iw, - GtkWidget *widget); - -G_END_DECLS - - -#endif // _GTK_INSPECTOR_WINDOW_H_ - -// vim: set et sw=2 ts=2: diff --git a/modules/inspector/window.ui b/modules/inspector/window.ui deleted file mode 100644 index f8007b28c2..0000000000 --- a/modules/inspector/window.ui +++ /dev/null @@ -1,238 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<interface domain="gtk30"> - <object class="GtkImage" id="inspect_image"> - <property name="visible">True</property> - <property name="icon-name">edit-find</property> - <property name="icon-size">4</property> - </object> - <object class="GtkMenu" id="widget_popup"> - <property name="visible">True</property> - <child> - <object class="GtkMenuItem"> - <property name="visible">True</property> - <property name="label" translatable="yes">Send Widget to Shell</property> - <signal name="activate" handler="on_send_widget_to_shell_activate"/> - </object> - </child> - </object> - <template class="GtkInspectorWindow" parent="GtkWindow"> - <property name="default-height">500</property> - <property name="default-width">1000</property> - <child type="titlebar"> - <object class="GtkHeaderBar"> - <property name="visible">True</property> - <property name="show-close-button">True</property> - <child> - <object class="GtkBox"> - <property name="visible">True</property> - <style> - <class name="linked"/> - </style> - <child> - <object class="GtkButton"> - <property name="visible">True</property> - <property name="image">inspect_image</property> - <property name="tooltip-text" translatable="yes">Select an Object</property> - <signal name="clicked" handler="on_inspect"/> - </object> - </child> - </object> - <packing> - <property name="pack-type">start</property> - </packing> - </child> - </object> - </child> - <child> - <object class="GtkNotebook"> - <property name="visible">True</property> - <property name="show-border">False</property> - <child> - <object class="GtkBox"> - <property name="visible">True</property> - <property name="orientation">vertical</property> - <child> - <object class="GtkInspectorButtonPath" id="button_path"> - <property name="visible">True</property> - </object> - </child> - <child> - <object class="GtkPaned"> - <property name="visible">True</property> - <property name="orientation">horizontal</property> - <child> - <object class="GtkPaned"> - <property name="visible">True</property> - <property name="orientation">vertical</property> - <child> - <object class="GtkScrolledWindow"> - <property name="visible">True</property> - <property name="hscrollbar-policy">automatic</property> - <property name="vscrollbar-policy">always</property> - <property name="shadow-type">in</property> - <property name="width-request">250</property> - <property name="expand">True</property> - <child> - <object class="GtkInspectorWidgetTree" id="widget_tree"> - <property name="visible">True</property> - <signal name="widget-changed" handler="on_widget_tree_selection_changed"/> - </object> - </child> - </object> - <packing> - <property name="resize">True</property> - <property name="shrink">False</property> - </packing> - </child> - <child> - <object class="GtkInspectorPythonShell" id="python_shell"> - <property name="visible">False</property> - </object> - <packing> - <property name="resize">False</property> - <property name="shrink">False</property> - </packing> - </child> - </object> - <packing> - <property name="resize">True</property> - <property name="shrink">True</property> - </packing> - </child> - <child> - <object class="GtkNotebook"> - <property name="visible">True</property> - <property name="show-border">False</property> - <property name="scrollable">True</property> - <child> - <object class="GtkInspectorPropList" id="prop_list"> - <property name="visible">True</property> - <property name="child-properties">False</property> - <property name="widget-tree">widget_tree</property> - </object> - </child> - <child type="tab"> - <object class="GtkLabel"> - <property name="visible">True</property> - <property name="label" translatable="yes">Properties</property> - </object> - </child> - <child> - <object class="GtkInspectorSignalsList" id="signals_list"> - <property name="visible">True</property> - </object> - </child> - <child type="tab"> - <object class="GtkLabel"> - <property name="visible">True</property> - <property name="label" translatable="yes">Signals</property> - </object> - </child> - <child> - <object class="GtkInspectorObjectHierarchy" id="object_hierarchy"> - <property name="visible">True</property> - </object> - </child> - <child type="tab"> - <object class="GtkLabel"> - <property name="visible">True</property> - <property name="label" translatable="yes">Hierarchy</property> - </object> - </child> - <child> - <object class="GtkInspectorPropList" id="child_prop_list"> - <property name="child-properties">True</property> - <property name="widget-tree">widget_tree</property> - </object> - </child> - <child type="tab"> - <object class="GtkLabel"> - <property name="visible">True</property> - <property name="label" translatable="yes">Child Properties</property> - </object> - </child> - <child> - <object class="GtkInspectorClassesList" id="classes_list"> - </object> - </child> - <child type="tab"> - <object class="GtkLabel"> - <property name="visible">True</property> - <property name="label" translatable="yes">CSS Classes</property> - </object> - </child> - <child> - <object class="GtkInspectorCssEditor" id="widget_css_editor"> - <property name="global">False</property> - </object> - </child> - <child type="tab"> - <object class="GtkLabel"> - <property name="visible">True</property> - <property name="label" translatable="yes">Custom CSS</property> - </object> - </child> - <child> - <object class="GtkInspectorDataList" id="data_list"> - </object> - </child> - <child type="tab"> - <object class="GtkLabel"> - <property name="visible">True</property> - <property name="label" translatable="yes">Data</property> - </object> - </child> - </object> - <packing> - <property name="resize">True</property> - <property name="shrink">True</property> - </packing> - </child> - </object> - </child> - </object> - </child> - <child type="tab"> - <object class="GtkLabel"> - <property name="visible">True</property> - <property name="label" translatable="yes">Objects</property> - </object> - </child> - <child> - <object class="GtkInspectorVisual"> - <property name="visible">True</property> - </object> - </child> - <child type="tab"> - <object class="GtkLabel"> - <property name="visible">True</property> - <property name="label" translatable="yes">Visual</property> - </object> - </child> - <child> - <object class="GtkInspectorThemes"> - <property name="visible">True</property> - </object> - </child> - <child type="tab"> - <object class="GtkLabel"> - <property name="visible">True</property> - <property name="label" translatable="yes">Themes</property> - </object> - </child> - <child> - <object class="GtkInspectorCssEditor"> - <property name="visible">True</property> - <property name="global">True</property> - </object> - </child> - <child type="tab"> - <object class="GtkLabel"> - <property name="visible">True</property> - <property name="label" translatable="yes">Custom CSS</property> - </object> - </child> - </object> - </child> - </template> -</interface> |