From 6480f3c685bbcfa04f62d054e04447ab88eaa340 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Fri, 18 May 2012 01:23:45 -0400 Subject: [PATCH] gtk-demo: Add a theming example --- demos/gtk-demo/Makefile.am | 10 +- demos/gtk-demo/theming.c | 61 +++++++ demos/gtk-demo/theming.ui | 319 +++++++++++++++++++++++++++++++++++++ 3 files changed, 389 insertions(+), 1 deletion(-) create mode 100644 demos/gtk-demo/theming.c create mode 100644 demos/gtk-demo/theming.ui diff --git a/demos/gtk-demo/Makefile.am b/demos/gtk-demo/Makefile.am index dacedd2d0..0c4da0f2f 100644 --- a/demos/gtk-demo/Makefile.am +++ b/demos/gtk-demo/Makefile.am @@ -43,6 +43,7 @@ demos = \ stock_browser.c \ textview.c \ textscroll.c \ + theming.c \ toolpalette.c \ transparent.c \ tree_store.c \ @@ -76,6 +77,7 @@ EXTRA_DIST += \ application.gresource.xml \ application.ui \ menus.ui \ + theming.ui \ gtk-logo-24.png \ gtk-logo-48.png \ org.gtk.Demo.gschema.xml @@ -122,7 +124,13 @@ IMAGEFILES= alphatest.png \ gnu-keys.png \ gtk-logo-rgb.gif -democode_DATA = $(demos) $(IMAGEFILES) demo.ui menus.ui application.ui +democode_DATA = \ + $(demos) \ + $(IMAGEFILES) \ + demo.ui \ + menus.ui \ + application.ui \ + theming.ui DISTCLEANFILES = demos.h diff --git a/demos/gtk-demo/theming.c b/demos/gtk-demo/theming.c new file mode 100644 index 000000000..a74ec6cb5 --- /dev/null +++ b/demos/gtk-demo/theming.c @@ -0,0 +1,61 @@ +/* Theming :: theming.ui + * + * GTK+ uses CSS for theming. Style classes can be associated + * with widgets to inform the theme about intended rendering. + * + * This demo shows some common examples where theming features + * of GTK+ are used for certain effects: primary toolbars, + * inline toolbars and linked buttons. + */ + +#include +#include "demo-common.h" + +static GtkWidget *window = NULL; + +GtkWidget * +do_theming (GtkWidget *do_widget) +{ + GtkWidget *grid; + GtkBuilder *builder; + gchar *filename; + GError *err = NULL; + + if (!window) + { + window = gtk_window_new (GTK_WINDOW_TOPLEVEL); + gtk_window_set_screen (GTK_WINDOW (window), + gtk_widget_get_screen (do_widget)); + gtk_window_set_title (GTK_WINDOW (window), "Theming"); + gtk_container_set_border_width (GTK_CONTAINER (window), 12); + g_signal_connect (window, "destroy", + G_CALLBACK (gtk_widget_destroyed), &window); + + builder = gtk_builder_new (); + filename = demo_find_file ("theming.ui", NULL); + gtk_builder_add_from_file (builder, filename, &err); + g_free (filename); + if (err) + { + g_error ("ERROR: %s\n", err->message); + return NULL; + } + + grid = (GtkWidget *)gtk_builder_get_object (builder, "grid"); + gtk_widget_show_all (grid); + gtk_container_add (GTK_CONTAINER (window), grid); + g_object_unref (builder); + } + + if (!gtk_widget_get_visible (window)) + { + gtk_widget_show (window); + } + else + { + gtk_widget_destroy (window); + window = NULL; + } + + return window; +} diff --git a/demos/gtk-demo/theming.ui b/demos/gtk-demo/theming.ui new file mode 100644 index 000000000..728b1d1cf --- /dev/null +++ b/demos/gtk-demo/theming.ui @@ -0,0 +1,319 @@ + + + + 6 + vertical + + + True + False + True + False + + + + False + True + False + False + Normal + True + True + edit-find + + + False + True + + + + + False + True + False + False + Active + True + True + edit-find + True + + + False + True + + + + + False + True + False + False + Insensitive + True + True + edit-find + + + False + True + + + + + False + True + False + Raised + True + True + edit-find-symbolic + + + + False + True + + + + + False + True + False + Raised Active + True + True + edit-find-symbolic + True + + + + False + True + + + + + False + True + False + False + Insensitive Active + True + edit-find + True + True + + + False + True + + + + + False + True + False + + + True + True + • + Search... + edit-find-symbolic + + + + + False + + + + + False + True + False + + + True + True + + + + + False + + + + + + + True + False + horizontal + center + center + + + + Hi, I am a button + False + True + True + True + False + + + False + True + 0 + + + + + And I'm another button + False + True + True + True + False + + + False + True + 1 + + + + + This is a button party! + False + True + True + True + False + + + False + True + 2 + + + + + + + True + False + True + 1 + + + + False + True + False + False + Normal + True + list-add-symbolic + + + False + True + + + + + False + True + False + False + Normal + True + list-add-symbolic + + + False + True + + + + + False + True + False + False + Active + True + list-remove-symbolic + True + + + False + True + + + + + False + True + False + False + Active + True + list-remove-symbolic + True + + + False + True + + + + + False + True + False + False + False + Insensitive + True + edit-find-symbolic + + + False + True + + + + + False + True + False + False + False + Insensitive Active + True + go-up-symbolic + True + + + False + True + + + + + + -- 2.43.2