diff --git a/modules/inspector/Makefile.am b/modules/inspector/Makefile.am index bda97bd339..30b7495383 100644 --- a/modules/inspector/Makefile.am +++ b/modules/inspector/Makefile.am @@ -44,7 +44,9 @@ libgtkinspector_la_SOURCES = \ signals-list.h \ signals-list.c \ data-list.h \ - data-list.c + data-list.c \ + visual.h \ + visual.c libgtkinspector_la_CPPFLAGS = \ -I$(top_srcdir) \ @@ -76,6 +78,7 @@ templates = \ prop-list.ui \ signals-list.ui \ themes.ui \ + visual.ui \ widget-tree.ui \ window.ui diff --git a/modules/inspector/inspector.gresource.xml b/modules/inspector/inspector.gresource.xml index 752d2cdac5..fb65fad987 100644 --- a/modules/inspector/inspector.gresource.xml +++ b/modules/inspector/inspector.gresource.xml @@ -2,14 +2,15 @@ button-path.ui - object-hierarchy.ui - css-editor.ui classes-list.ui - widget-tree.ui - prop-list.ui - themes.ui - window.ui - signals-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 diff --git a/modules/inspector/module.c b/modules/inspector/module.c index 0e7a25fb33..1082dedb6a 100644 --- a/modules/inspector/module.c +++ b/modules/inspector/module.c @@ -34,6 +34,7 @@ #include "resources.h" #include "signals-list.h" #include "themes.h" +#include "visual.h" #include "widget-tree.h" #include "window.h" @@ -46,18 +47,19 @@ gtk_module_init (gint *argc, gchar ***argv) gtk_inspector_register_resource (); - g_type_ensure (GTK_TYPE_INSPECTOR_THEMES); - g_type_ensure (GTK_TYPE_INSPECTOR_CSS_EDITOR); g_type_ensure (GTK_TYPE_INSPECTOR_BUTTON_PATH); - g_type_ensure (GTK_TYPE_INSPECTOR_WIDGET_TREE); - g_type_ensure (GTK_TYPE_INSPECTOR_PROP_LIST); - g_type_ensure (GTK_TYPE_INSPECTOR_OBJECT_HIERARCHY); g_type_ensure (GTK_TYPE_INSPECTOR_CLASSES_LIST); - g_type_ensure (GTK_TYPE_INSPECTOR_PYTHON_SHELL); - g_type_ensure (GTK_TYPE_INSPECTOR_PROPERTY_CELL_RENDERER); - g_type_ensure (GTK_TYPE_INSPECTOR_WINDOW); - g_type_ensure (GTK_TYPE_INSPECTOR_SIGNALS_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); } diff --git a/modules/inspector/visual.c b/modules/inspector/visual.c new file mode 100644 index 0000000000..7b2fed7de2 --- /dev/null +++ b/modules/inspector/visual.c @@ -0,0 +1,148 @@ +/* + * 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 . + */ + +#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 new file mode 100644 index 0000000000..2227d3f668 --- /dev/null +++ b/modules/inspector/visual.h @@ -0,0 +1,53 @@ +/* + * 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 . + */ + +#ifndef _GTK_INSPECTOR_VISUAL_H_ +#define _GTK_INSPECTOR_VISUAL_H_ + +#include + +#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 new file mode 100644 index 0000000000..da2162ada9 --- /dev/null +++ b/modules/inspector/visual.ui @@ -0,0 +1,94 @@ + + + + diff --git a/modules/inspector/window.c b/modules/inspector/window.c index 9434580bba..f1928b6e04 100644 --- a/modules/inspector/window.c +++ b/modules/inspector/window.c @@ -43,47 +43,6 @@ G_DEFINE_TYPE (GtkInspectorWindow, gtk_inspector_window, GTK_TYPE_WINDOW) extern void on_inspect (GtkWidget *button, GtkInspectorWindow *iw); -static void -on_graphic_updates_toggled (GtkToggleButton *button, - GtkInspectorWindow *iw) -{ - gdk_window_set_debug_updates (gtk_toggle_button_get_active (button)); -} - -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 (GtkInspectorWindow *iw) -{ - fix_direction_recurse (GTK_WIDGET (iw), GINT_TO_POINTER (initial_direction)); -} - -static void -on_flip (GtkButton *button, - GtkInspectorWindow *iw) -{ - fix_direction (iw); - - if (gtk_widget_get_default_direction () == GTK_TEXT_DIR_LTR) - gtk_widget_set_default_direction (GTK_TEXT_DIR_RTL); - else - gtk_widget_set_default_direction (GTK_TEXT_DIR_LTR); -} - static gboolean on_widget_tree_button_press (GtkInspectorWidgetTree *wt, GdkEventButton *event, @@ -156,8 +115,6 @@ gtk_inspector_window_init (GtkInspectorWindow *iw) g_signal_connect (G_OBJECT (iw->widget_tree), "button-press-event", G_CALLBACK (on_widget_tree_button_press), iw); } - - initial_direction = gtk_widget_get_default_direction (); } static void @@ -213,8 +170,6 @@ gtk_inspector_window_class_init (GtkInspectorWindowClass *klass) 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_graphic_updates_toggled); - gtk_widget_class_bind_template_callback (widget_class, on_flip); 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); } diff --git a/modules/inspector/window.ui b/modules/inspector/window.ui index 1e36598775..f8007b28c2 100644 --- a/modules/inspector/window.ui +++ b/modules/inspector/window.ui @@ -5,16 +5,6 @@ edit-find 4 - - True - view-refresh - 4 - - - True - object-flip-horizontal - 4 - True @@ -46,22 +36,6 @@ - - - True - update_image - Show Graphic Updates - - - - - - True - flip_image - Change Text Direction - - - start @@ -224,6 +198,17 @@ Objects + + + True + + + + + True + Visual + + True diff --git a/po/POTFILES.in b/po/POTFILES.in index 4ba727ecba..bb7a01b31e 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -294,6 +294,7 @@ modules/inspector/object-hierarchy.ui.h modules/inspector/prop-list.ui.h modules/inspector/signals-list.ui.h modules/inspector/themes.ui.h +modules/inspector/visual.ui.h modules/inspector/widget-tree.ui.h modules/inspector/window.ui.h modules/printbackends/cloudprint/gtkprintbackendcloudprint.c