diff options
author | Cosimo Cecchi <cosimoc@gnome.org> | 2012-01-12 17:03:54 -0500 |
---|---|---|
committer | Cosimo Cecchi <cosimoc@gnome.org> | 2012-01-12 17:05:36 -0500 |
commit | 9283ca93c521da43f54e6bb787a25539438c769c (patch) | |
tree | e14154ef17bf55ac87810a7004931f8c1af7ae2c /tests/visuals | |
parent | dc100a8e7b8f28c9c73924dd7cb2c8a7074d475a (diff) | |
download | gtk+-9283ca93c521da43f54e6bb787a25539438c769c.tar.gz |
visuals: add a runner for visual GtkBuilder files
This is useful to sketch out in GtkBuilder widgets in different states
all at once, so that we can check theming is right for them.
Add some initial UI files for primary-toolbar and inline-toolbar widgets.
Diffstat (limited to 'tests/visuals')
-rw-r--r-- | tests/visuals/Makefile.am | 28 | ||||
-rw-r--r-- | tests/visuals/inline-toolbar.ui | 120 | ||||
-rw-r--r-- | tests/visuals/primary-toolbar.ui | 213 | ||||
-rw-r--r-- | tests/visuals/visuals.c | 85 |
4 files changed, 446 insertions, 0 deletions
diff --git a/tests/visuals/Makefile.am b/tests/visuals/Makefile.am new file mode 100644 index 0000000000..aec9e3bf12 --- /dev/null +++ b/tests/visuals/Makefile.am @@ -0,0 +1,28 @@ +AM_CPPFLAGS = \ + -I$(top_srcdir) \ + -I$(top_builddir)/gdk \ + -I$(top_srcdir)/gdk \ + $(GTK_DEBUG_FLAGS) \ + $(GTK_DEP_CFLAGS) \ + $(GDK_DEP_CFLAGS) + +AM_CXXFLAGS = $(AM_CPPFLAGS) + +DEPS = \ + $(top_builddir)/gtk/libgtk-3.la + +LDADDS = \ + $(top_builddir)/gtk/libgtk-3.la \ + $(top_builddir)/gdk/libgdk-3.la \ + $(GTK_DEP_LIBS) \ + -lm + +noinst_PROGRAMS = visuals + +visuals_DEPENDENCIES = $(TEST_DEPS) +visuals_LDADD = $(LDADDS) +visuals_SOURCES = visuals.c + +EXTRA_DIST = \ + inline-toolbar.ui \ + primary-toolbar.ui
\ No newline at end of file diff --git a/tests/visuals/inline-toolbar.ui b/tests/visuals/inline-toolbar.ui new file mode 100644 index 0000000000..5421cbd505 --- /dev/null +++ b/tests/visuals/inline-toolbar.ui @@ -0,0 +1,120 @@ +<?xml version="1.0" encoding="UTF-8"?> +<interface> + <!-- interface-requires gtk+ 3.0 --> + <object class="GtkWindow" id="window1"> + <property name="can_focus">False</property> + <property name="default_width">600</property> + <child> + <object class="GtkGrid" id="grid"> + <property name="row-spacing">6</property> + <property name="orientation">vertical</property> + <child> + <object class="GtkToolbar" id="toolbar1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="hexpand">True</property> + <property name="icon_size">1</property> + <style> + <class name="inline-toolbar"/> + </style> + <child> + <object class="GtkToggleToolButton" id="toolbutton1"> + <property name="use_action_appearance">False</property> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="use_action_appearance">False</property> + <property name="label" translatable="yes">Normal</property> + <property name="use_underline">True</property> + <property name="icon_name">list-add-symbolic</property> + </object> + <packing> + <property name="expand">False</property> + <property name="homogeneous">True</property> + </packing> + </child> + <child> + <object class="GtkToggleToolButton" id="toolbutton2"> + <property name="use_action_appearance">False</property> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="use_action_appearance">False</property> + <property name="label" translatable="yes">Normal</property> + <property name="use_underline">True</property> + <property name="icon_name">list-add-symbolic</property> + </object> + <packing> + <property name="expand">False</property> + <property name="homogeneous">True</property> + </packing> + </child> + <child> + <object class="GtkToggleToolButton" id="toolbutton3"> + <property name="use_action_appearance">False</property> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="use_action_appearance">False</property> + <property name="label" translatable="yes">Active</property> + <property name="use_underline">True</property> + <property name="icon_name">list-remove-symbolic</property> + <property name="active">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="homogeneous">True</property> + </packing> + </child> + <child> + <object class="GtkToggleToolButton" id="toolbutton4"> + <property name="use_action_appearance">False</property> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="use_action_appearance">False</property> + <property name="label" translatable="yes">Active</property> + <property name="use_underline">True</property> + <property name="icon_name">list-remove-symbolic</property> + <property name="active">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="homogeneous">True</property> + </packing> + </child> + <child> + <object class="GtkToggleToolButton" id="toolbutton5"> + <property name="use_action_appearance">False</property> + <property name="visible">True</property> + <property name="sensitive">False</property> + <property name="can_focus">False</property> + <property name="use_action_appearance">False</property> + <property name="label" translatable="yes">Insensitive</property> + <property name="use_underline">True</property> + <property name="icon_name">edit-find-symbolic</property> + </object> + <packing> + <property name="expand">False</property> + <property name="homogeneous">True</property> + </packing> + </child> + <child> + <object class="GtkToggleToolButton" id="toolbutton6"> + <property name="use_action_appearance">False</property> + <property name="visible">True</property> + <property name="sensitive">False</property> + <property name="can_focus">False</property> + <property name="use_action_appearance">False</property> + <property name="label" translatable="yes">Insensitive Active</property> + <property name="use_underline">True</property> + <property name="icon_name">go-up-symbolic</property> + <property name="active">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="homogeneous">True</property> + </packing> + </child> + </object> + </child> + </object> + </child> + </object> +</interface> diff --git a/tests/visuals/primary-toolbar.ui b/tests/visuals/primary-toolbar.ui new file mode 100644 index 0000000000..1517fd7cf6 --- /dev/null +++ b/tests/visuals/primary-toolbar.ui @@ -0,0 +1,213 @@ +<?xml version="1.0" encoding="UTF-8"?> +<interface> + <!-- interface-requires gtk+ 3.0 --> + <object class="GtkWindow" id="window1"> + <property name="can_focus">False</property> + <property name="default_width">800</property> + <child> + <object class="GtkGrid" id="grid"> + <property name="row-spacing">6</property> + <property name="orientation">vertical</property> + <child> + <object class="GtkToolbar" id="toolbar1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="hexpand">True</property> + <style> + <class name="primary-toolbar"/> + </style> + <child> + <object class="GtkToggleToolButton" id="toolbutton1"> + <property name="use_action_appearance">False</property> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="use_action_appearance">False</property> + <property name="label" translatable="yes">Normal</property> + <property name="use_underline">True</property> + <property name="is_important">True</property> + <property name="icon_name">edit-find</property> + </object> + <packing> + <property name="expand">False</property> + <property name="homogeneous">True</property> + </packing> + </child> + <child> + <object class="GtkToggleToolButton" id="toolbutton2"> + <property name="use_action_appearance">False</property> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="use_action_appearance">False</property> + <property name="label" translatable="yes">Active</property> + <property name="use_underline">True</property> + <property name="is_important">True</property> + <property name="icon_name">edit-find</property> + <property name="active">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="homogeneous">True</property> + </packing> + </child> + <child> + <object class="GtkToggleToolButton" id="toolbutton3"> + <property name="use_action_appearance">False</property> + <property name="visible">True</property> + <property name="sensitive">False</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Insensitive</property> + <property name="use_underline">True</property> + <property name="is_important">True</property> + <property name="icon_name">edit-find</property> + </object> + <packing> + <property name="expand">False</property> + <property name="homogeneous">True</property> + </packing> + </child> + <child> + <object class="GtkToggleToolButton" id="toolbutton4"> + <property name="use_action_appearance">False</property> + <property name="visible">True</property> + <property name="sensitive">False</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Insensitive Active</property> + <property name="use_underline">True</property> + <property name="icon_name">edit-find</property> + <property name="is_important">True</property> + <property name="active">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="homogeneous">True</property> + </packing> + </child> + <child> + <object class="GtkToolItem" id="toolitementry"> + <property name="use_action_appearance">False</property> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="use_underline">True</property> + <child> + <object class="GtkEntry" id="entry1"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="invisible_char">•</property> + <property name="placeholder-text" translatable="yes">Search...</property> + <property name="secondary-icon-name">edit-find-symbolic</property> + </object> + </child> + </object> + <packing> + <property name="expand">False</property> + </packing> + </child> + <child> + <object class="GtkToolItem" id="toolitemswitch"> + <property name="use_action_appearance">False</property> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="use_underline">True</property> + <child> + <object class="GtkSwitch" id="switch1"> + <property name="visible">True</property> + <property name="can_focus">True</property> + </object> + </child> + </object> + <packing> + <property name="expand">False</property> + </packing> + </child> + </object> + </child> + <child> + <object class="GtkToolbar" id="toolbar2"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="hexpand">True</property> + <style> + <class name="primary-toolbar"/> + </style> + <child> + <object class="GtkToggleToolButton" id="toolbutton5"> + <property name="use_action_appearance">False</property> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Normal</property> + <property name="use_underline">True</property> + <property name="is_important">True</property> + <property name="icon_name">edit-find-symbolic</property> + <style> + <class name="raised"/> + </style> + </object> + <packing> + <property name="expand">False</property> + <property name="homogeneous">True</property> + </packing> + </child> + <child> + <object class="GtkToggleToolButton" id="toolbutton6"> + <property name="use_action_appearance">False</property> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Active</property> + <property name="use_underline">True</property> + <property name="is_important">True</property> + <property name="icon_name">edit-find-symbolic</property> + <property name="active">True</property> + <style> + <class name="raised"/> + </style> + </object> + <packing> + <property name="expand">False</property> + <property name="homogeneous">True</property> + </packing> + </child> + <child> + <object class="GtkToggleToolButton" id="toolbutton7"> + <property name="use_action_appearance">False</property> + <property name="visible">True</property> + <property name="sensitive">False</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Insensitive</property> + <property name="use_underline">True</property> + <property name="is_important">True</property> + <property name="icon_name">edit-find-symbolic</property> + <style> + <class name="raised"/> + </style> + </object> + <packing> + <property name="expand">False</property> + <property name="homogeneous">True</property> + </packing> + </child> + <child> + <object class="GtkToggleToolButton" id="toolbutton8"> + <property name="use_action_appearance">False</property> + <property name="visible">True</property> + <property name="sensitive">False</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Insensitive Active</property> + <property name="use_underline">True</property> + <property name="icon_name">edit-find-symbolic</property> + <property name="is_important">True</property> + <property name="active">True</property> + <style> + <class name="raised"/> + </style> + </object> + <packing> + <property name="expand">False</property> + <property name="homogeneous">True</property> + </packing> + </child> + </object> + </child> + </object> + </child> + </object> +</interface> diff --git a/tests/visuals/visuals.c b/tests/visuals/visuals.c new file mode 100644 index 0000000000..df65b5960f --- /dev/null +++ b/tests/visuals/visuals.c @@ -0,0 +1,85 @@ +/* visuals: UI runner for visual GtkBuilder files + * + * Copyright (C) 2012 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, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, + * MA 02110-1301, USA. + * + * Author: Cosimo Cecchi <cosimoc@gnome.org> + * + */ + +#include <gtk/gtk.h> + +static void +dark_button_toggled_cb (GtkToggleButton *button, + gpointer user_data) +{ + gboolean active = gtk_toggle_button_get_active (button); + GtkSettings *settings = gtk_settings_get_default (); + + g_object_set (settings, + "gtk-application-prefer-dark-theme", active, + NULL); +} + +static void +create_dark_popup (GtkWidget *parent) +{ + GtkWidget *popup = gtk_window_new (GTK_WINDOW_TOPLEVEL); + GtkWidget *button = gtk_toggle_button_new_with_label ("Dark"); + + gtk_window_set_decorated (GTK_WINDOW (popup), FALSE); + gtk_widget_set_size_request (popup, 100, 100); + gtk_window_set_resizable (GTK_WINDOW (popup), FALSE); + + g_signal_connect (popup, "delete-event", + G_CALLBACK (gtk_true), NULL); + + gtk_container_add (GTK_CONTAINER (popup), button); + g_signal_connect (button, "toggled", + G_CALLBACK (dark_button_toggled_cb), NULL); + + gtk_window_set_transient_for (GTK_WINDOW (popup), GTK_WINDOW (parent)); + + gtk_widget_show_all (popup); +} + +int +main (int argc, char *argv[]) +{ + GtkBuilder *builder; + GtkWidget *window; + const gchar *filename; + + gtk_init (&argc, &argv); + + if (argc > 1) + filename = argv[1]; + + builder = gtk_builder_new (); + gtk_builder_add_from_file (builder, filename, NULL); + + window = GTK_WIDGET (gtk_builder_get_object (builder, "window1")); + g_object_unref (G_OBJECT (builder)); + g_signal_connect (window, "destroy", + G_CALLBACK (gtk_main_quit), NULL); + gtk_widget_show_all (window); + + create_dark_popup (window); + gtk_main (); + + return 0; +} |