[gtk+/wip/css: 15/16] gtk-demo: Make CSS a resource
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/css: 15/16] gtk-demo: Make CSS a resource
- Date: Wed, 23 May 2012 16:21:06 +0000 (UTC)
commit a2567cddef158abb9a02eca34ae0e0a3750a066e
Author: Benjamin Otte <otte redhat com>
Date: Sun May 13 21:23:41 2012 +0200
gtk-demo: Make CSS a resource
Also, improve the CSS to give you that basic feel.
demos/gtk-demo/Makefile.am | 24 +++++++------
demos/gtk-demo/css_basics.c | 22 +++---------
demos/gtk-demo/css_basics.css | 22 ++++++++++++
demos/gtk-demo/demo.gresource.xml | 6 +++
demos/gtk-demo/reset.css | 68 +++++++++++++++++++++++++++++++++++++
5 files changed, 114 insertions(+), 28 deletions(-)
---
diff --git a/demos/gtk-demo/Makefile.am b/demos/gtk-demo/Makefile.am
index 3697bdd..3d6e540 100644
--- a/demos/gtk-demo/Makefile.am
+++ b/demos/gtk-demo/Makefile.am
@@ -75,12 +75,8 @@ BUILT_SOURCES = demos.h demo_resources.c
EXTRA_DIST += \
$(IMAGEFILES) \
demo.ui \
- demo.gresource.xml \
- application.ui \
- menus.ui \
- theming.ui \
- gtk-logo-24.png \
- gtk-logo-48.png \
+ demo.gresource.xml \
+ $(RESOURCES) \
org.gtk.Demo.gschema.xml
gsettings_SCHEMAS = \
@@ -108,9 +104,17 @@ gtk3_demo_application_SOURCES = \
gtk3_demo_application_LDADD = $(LDADDS)
-demo_resources.c: demo.gresource.xml gtk-logo-24.png gtk-logo-48.png application.ui menus.ui
+demo_resources.c: demo.gresource.xml $(RESOURCES)
$(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir) --generate-source $(srcdir)/demo.gresource.xml
+RESOURCES= application.ui \
+ menus.ui \
+ theming.ui \
+ gtk-logo-24.png \
+ gtk-logo-48.png \
+ css_basics.css \
+ reset.css
+
IMAGEFILES= alphatest.png \
apple-red.png \
background.jpg \
@@ -129,10 +133,8 @@ IMAGEFILES= alphatest.png \
democode_DATA = \
$(demos) \
$(IMAGEFILES) \
- demo.ui \
- menus.ui \
- application.ui \
- theming.ui
+ $(RESOURCES) \
+ demo.ui
DISTCLEANFILES = demos.h
diff --git a/demos/gtk-demo/css_basics.c b/demos/gtk-demo/css_basics.c
index 0cbabbe..3eb5e3b 100644
--- a/demos/gtk-demo/css_basics.c
+++ b/demos/gtk-demo/css_basics.c
@@ -9,20 +9,6 @@
static GtkWidget *window = NULL;
-#define DEFAULT_CSS \
- "/* You can edit the CSS to change the appearance of this Window */\n" \
- "\n" \
- "GtkWindow {\n" \
- " engine: none;\n" \
- " background-image: none;\n" \
- " background-color: brown;\n" \
- "}\n" \
- "\n" \
- "GtkTextView {\n" \
- " color: green;\n" \
- "}\n" \
- "\n"
-
static void
show_parsing_error (GtkCssProvider *provider,
GtkCssSection *section,
@@ -83,6 +69,7 @@ do_css_basics (GtkWidget *do_widget)
GtkWidget *container, *child;
GtkStyleProvider *provider;
GtkTextBuffer *text;
+ GBytes *bytes;
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (do_widget));
@@ -110,9 +97,10 @@ do_css_basics (GtkWidget *do_widget)
"changed",
G_CALLBACK (css_text_changed),
provider);
- gtk_text_buffer_set_text (text,
- DEFAULT_CSS,
- -1);
+
+ bytes = g_resources_lookup_data ("/css_basics/gtk.css", 0, NULL);
+ gtk_text_buffer_set_text (text, g_bytes_get_data (bytes, NULL), g_bytes_get_size (bytes));
+
g_signal_connect (provider,
"parsing-error",
G_CALLBACK (show_parsing_error),
diff --git a/demos/gtk-demo/css_basics.css b/demos/gtk-demo/css_basics.css
new file mode 100644
index 0000000..bd6a694
--- /dev/null
+++ b/demos/gtk-demo/css_basics.css
@@ -0,0 +1,22 @@
+/* You can edit the text in this window to change the
+ * appearance of this Window.
+ * Be careful, if you screw it up, nothing might be visible
+ * anymore. :)
+ */
+
+/* This CSS resets all properties to their defaults values
+ * and overrides all user settings and the theme in use */
+ import url("reset.css");
+
+/* Set a very futuristic style by default */
+* {
+ color: green;
+ font-family: Monospace;
+ border: 1px solid;
+}
+
+/* Make sure selections are visible */
+:selected {
+ background-color: darkGreen;
+ color: black;
+}
diff --git a/demos/gtk-demo/demo.gresource.xml b/demos/gtk-demo/demo.gresource.xml
index d4a5aec..b86960c 100644
--- a/demos/gtk-demo/demo.gresource.xml
+++ b/demos/gtk-demo/demo.gresource.xml
@@ -8,4 +8,10 @@
<file preprocess="xml-stripblanks">application.ui</file>
<file preprocess="xml-stripblanks">menus.ui</file>
</gresource>
+ <gresource prefix="/">
+ <file>reset.css</file>
+ </gresource>
+ <gresource prefix="/css_basics">
+ <file alias="gtk.css">css_basics.css</file>
+ </gresource>
</gresources>
diff --git a/demos/gtk-demo/reset.css b/demos/gtk-demo/reset.css
new file mode 100644
index 0000000..1c27a8e
--- /dev/null
+++ b/demos/gtk-demo/reset.css
@@ -0,0 +1,68 @@
+/* @import this colorsheet to get the default values for every property.
+ * This is useful when writing special CSS tests that should not be
+ * inluenced by themes - not even the default ones.
+ * Keep in mind that the output will be very ugly and not look like
+ * anything GTK.
+ * Also, when adding new style properties, please add them here.
+ */
+
+* {
+ color: inherit;
+ font-size: inherit;
+ background-color: initial;
+ font-family: inherit;
+ font-style: inherit;
+ font-variant: inherit;
+ font-weight: inherit;
+ text-shadow: inherit;
+ icon-shadow: inherit;
+ box-shadow: initial;
+ margin-top: initial;
+ margin-left: initial;
+ margin-bottom: initial;
+ margin-right: initial;
+ padding-top: initial;
+ padding-left: initial;
+ padding-bottom: initial;
+ padding-right: initial;
+ border-top-style: initial;
+ border-top-width: initial;
+ border-left-style: initial;
+ border-left-width: initial;
+ border-bottom-style: initial;
+ border-bottom-width: initial;
+ border-right-style: initial;
+ border-right-width: initial;
+ border-top-left-radius: initial;
+ border-top-right-radius: initial;
+ border-bottom-right-radius: initial;
+ border-bottom-left-radius: initial;
+ outline-style: initial;
+ outline-width: initial;
+ outline-offset: initial;
+ background-clip: initial;
+ background-origin: initial;
+ background-size: initial;
+ background-position: initial;
+ border-top-color: initial;
+ border-right-color: initial;
+ border-bottom-color: initial;
+ border-left-color: initial;
+ outline-color: initial;
+ background-repeat: initial;
+ background-image: initial;
+ border-image-source: initial;
+ border-image-repeat: initial;
+ border-image-slice: initial;
+ border-image-width: initial;
+ transition-property: initial;
+ transition-duration: initial;
+ transition-timing-function: initial;
+ transition-delay: initial;
+ engine: initial;
+ gtk-key-bindings: initial;
+
+ -GtkWidget-focus-line-width: 0;
+ -GtkWidget-focus-padding: 0;
+ -GtkNotebook-initial-gap: 0;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]