From ae624a0048109dedc5b7095823b61fd93ccd4a24 Mon Sep 17 00:00:00 2001 From: Bertrand Lorentz Date: Fri, 30 May 2014 14:42:32 +0200 Subject: [PATCH] GtkDemo: Add demo for theming style classes This also demonstrates the use of Gtk.Builder to load .ui files. Also simplify handling of resources in GtkDemo build: we don't need to make a distinction between images and other resources. --- sample/GtkDemo/DemoThemingStyleClasses.cs | 38 +++ sample/GtkDemo/Makefile.am | 30 +- sample/GtkDemo/theming.ui | 319 ++++++++++++++++++++++ sample/sample.csproj | 1 + 4 files changed, 372 insertions(+), 16 deletions(-) create mode 100644 sample/GtkDemo/DemoThemingStyleClasses.cs create mode 100644 sample/GtkDemo/theming.ui diff --git a/sample/GtkDemo/DemoThemingStyleClasses.cs b/sample/GtkDemo/DemoThemingStyleClasses.cs new file mode 100644 index 000000000..6ad3263c9 --- /dev/null +++ b/sample/GtkDemo/DemoThemingStyleClasses.cs @@ -0,0 +1,38 @@ +/* CSS Theming/Style Classes + * + * 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. + */ + +using System; +using Gtk; + +namespace GtkDemo +{ + [Demo ("Style Classes", "DemoThemingStyleClasses.cs", "CSS Theming")] + public class DemoThemingStyleClasses : Window + { + public DemoThemingStyleClasses () : base ("Style Classes") + { + BorderWidth = 12; + var builder = new Builder ("theming.ui"); + + var grid = (Widget)builder.GetObject ("grid"); + grid.ShowAll (); + Add (grid); + + Show (); + } + + protected override bool OnDeleteEvent (Gdk.Event evt) + { + Destroy (); + return true; + } + } +} + diff --git a/sample/GtkDemo/Makefile.am b/sample/GtkDemo/Makefile.am index 98d5a3213..0b162eae7 100644 --- a/sample/GtkDemo/Makefile.am +++ b/sample/GtkDemo/Makefile.am @@ -13,7 +13,7 @@ DEBUGS = $(addsuffix .mdb, $(TARGETS)) CLEANFILES = $(TARGETS) $(DEBUGS) noinst_SCRIPTS = $(TARGETS) -EXTRA_DIST = $(sources) $(image_names) $(css_names) +EXTRA_DIST = $(sources) $(resource_files) sources = \ DemoApplicationWindow.cs \ @@ -40,11 +40,14 @@ sources = \ DemoSpinner.cs \ DemoStockBrowser.cs \ DemoTextView.cs \ + DemoThemingStyleClasses.cs \ DemoTreeStore.cs \ DemoUIManager.cs \ DemoPrinting.cs -images = \ +resource_ids = \ + css/css_basics.css,css_basics.css \ + css/reset.css,reset.css \ images/gnome-foot.png,gnome-foot.png \ images/MonoIcon.png,MonoIcon.png \ images/gnome-calendar.png,gnome-calendar.png \ @@ -57,9 +60,12 @@ images = \ images/apple-red.png,apple-red.png \ images/background.jpg,background.jpg \ images/gtk-logo-rgb.gif,gtk-logo-rgb.gif \ - images/floppybuddy.gif,floppybuddy.gif + images/floppybuddy.gif,floppybuddy.gif \ + theming.ui,theming.ui -image_names = \ +resource_files = \ + css/css_basics.css \ + css/reset.css \ images/gnome-foot.png \ images/MonoIcon.png \ images/gnome-calendar.png \ @@ -72,20 +78,12 @@ image_names = \ images/apple-red.png \ images/background.jpg \ images/gtk-logo-rgb.gif \ - images/floppybuddy.gif - -css = \ - css/css_basics.css,css_basics.css \ - css/reset.css,reset.css - -css_names = \ - css/css_basics.css \ - css/reset.css + images/floppybuddy.gif \ + theming.ui build_sources = $(addprefix $(srcdir)/, $(sources)) -build_images = $(addprefix $(srcdir)/, $(images)) -build_css = $(addprefix $(srcdir)/, $(css)) -resources = $(addprefix -resource:, $(build_sources), $(build_images), $(build_css)) +build_resources = $(addprefix $(srcdir)/, $(resource_ids)) +resources = $(addprefix -resource:, $(build_sources), $(build_resources)) GtkDemo.exe: $(build_sources) $(assemblies) $(CSC) $(CSFLAGS) -out:GtkDemo.exe $(build_sources) $(references) $(resources) diff --git a/sample/GtkDemo/theming.ui b/sample/GtkDemo/theming.ui new file mode 100644 index 000000000..728b1d1cf --- /dev/null +++ b/sample/GtkDemo/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 + + + + + + diff --git a/sample/sample.csproj b/sample/sample.csproj index 89df6a06f..2f541562a 100644 --- a/sample/sample.csproj +++ b/sample/sample.csproj @@ -111,6 +111,7 @@ +