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.
This commit is contained in:
Bertrand Lorentz 2014-05-30 14:42:32 +02:00
parent f6003f94a4
commit ae624a0048
4 changed files with 372 additions and 16 deletions

View File

@ -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;
}
}
}

View File

@ -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)

319
sample/GtkDemo/theming.ui Normal file
View File

@ -0,0 +1,319 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<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="show-arrow">False</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="toolbutton5">
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Raised</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">Raised 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="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>
<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>
<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="GtkBox" id="box1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">horizontal</property>
<property name="valign">center</property>
<property name="halign">center</property>
<style>
<class name="linked"/>
</style>
<child>
<object class="GtkButton" id="button1">
<property name="label" translatable="yes">Hi, I am a button</property>
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_action_appearance">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="button2">
<property name="label" translatable="yes">And I'm another button</property>
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_action_appearance">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="button3">
<property name="label" translatable="yes">This is a button party!</property>
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_action_appearance">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
</child>
<child>
<object class="GtkToolbar" id="itoolbar1">
<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="itoolbutton1">
<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="itoolbutton2">
<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="itoolbutton3">
<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="itoolbutton4">
<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="itoolbutton5">
<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="itoolbutton6">
<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>
</interface>

View File

@ -111,6 +111,7 @@
<Compile Include="valtest\Gtksharp\Valobj.cs" />
<Compile Include="GtkDemo\DemoSpinner.cs" />
<Compile Include="GtkDemo\DemoCssBasics.cs" />
<Compile Include="GtkDemo\DemoThemingStyleClasses.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>