[gtk+/gtk-style-context: 461/540] Add a background example to the docs
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/gtk-style-context: 461/540] Add a background example to the docs
- Date: Fri, 3 Dec 2010 03:14:52 +0000 (UTC)
commit 5b30e04811761e921d09418d0f794ca92e5c4204
Author: Matthias Clasen <mclasen redhat com>
Date: Tue Nov 23 13:36:44 2010 -0500
Add a background example to the docs
docs/reference/gtk/Makefile.am | 3 +-
docs/reference/gtk/gtk-docs.sgml | 2 +
docs/reference/gtk/images/background.png | Bin 0 -> 1400 bytes
gtk/gtkstylecontext.c | 6 +++
tests/styleexamples.c | 57 +++++++++++++++++++++++++++++-
5 files changed, 66 insertions(+), 2 deletions(-)
---
diff --git a/docs/reference/gtk/Makefile.am b/docs/reference/gtk/Makefile.am
index fb96f41..9af5bd6 100644
--- a/docs/reference/gtk/Makefile.am
+++ b/docs/reference/gtk/Makefile.am
@@ -345,7 +345,8 @@ HTML_IMAGES = \
$(srcdir)/images/checks.png \
$(srcdir)/images/options.png \
$(srcdir)/images/arrows.png \
- $(srcdir)/images/expanders.png
+ $(srcdir)/images/expanders.png \
+ $(srcdir)/images/background.png
# Extra options to supply to gtkdoc-fixref
FIXXREF_OPTIONS=--extra-dir=../gdk/html \
diff --git a/docs/reference/gtk/gtk-docs.sgml b/docs/reference/gtk/gtk-docs.sgml
index 5214878..505531a 100644
--- a/docs/reference/gtk/gtk-docs.sgml
+++ b/docs/reference/gtk/gtk-docs.sgml
@@ -3,6 +3,8 @@
"http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
<!ENTITY % local.common.attrib "xmlns:xi CDATA #FIXED 'http://www.w3.org/2003/XInclude'">
<!ENTITY version SYSTEM "version.xml">
+<!ENTITY pi "π">
+<!ENTITY solidus "⁄">
]>
<book id="index" xmlns:xi="http://www.w3.org/2003/XInclude">
<bookinfo>
diff --git a/docs/reference/gtk/images/background.png b/docs/reference/gtk/images/background.png
new file mode 100644
index 0000000..ad6ea36
Binary files /dev/null and b/docs/reference/gtk/images/background.png differ
diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c
index 1099b70..dbde623 100644
--- a/gtk/gtkstylecontext.c
+++ b/gtk/gtkstylecontext.c
@@ -3027,6 +3027,12 @@ gtk_render_arrow (GtkStyleContext *context,
*
* Renders the background of an element.
*
+ * <example>
+ * <title>Typical background rendering, showing the effect of
+ * @border-image, @border-width and @border-radius</title>
+ * <inlinegraphic fileref="background.png" format="PNG"/>
+ * </example>
+ *
* Since: 3.0.
**/
void
diff --git a/tests/styleexamples.c b/tests/styleexamples.c
index 13c57d8..a382c88 100644
--- a/tests/styleexamples.c
+++ b/tests/styleexamples.c
@@ -94,6 +94,57 @@ draw_cb_expanders (GtkWidget *widget, cairo_t *cr)
return TRUE;
}
+static gboolean
+draw_cb_background (GtkWidget *widget, cairo_t *cr)
+{
+ GtkStyleProvider *provider;
+ GtkStyleContext *context;
+
+ context = gtk_widget_get_style_context (widget);
+
+ gtk_style_context_save (context);
+
+ provider = (GtkStyleProvider *)gtk_css_provider_new ();
+ gtk_css_provider_load_from_data (GTK_CSS_PROVIDER (provider),
+ "* {\n"
+ " border-radius: 10;\n"
+ " border-width: 0;\n"
+ " background-image: -gtk-gradient (linear, left top, right bottom, from(#ff00ff), to(#aabbcc));\n"
+ "}\n", -1, NULL);
+ gtk_style_context_add_provider (context, provider, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+ gtk_style_context_set_junction_sides (context, 0);
+ gtk_render_background (context, cr, 12, 12, 100, 100);
+ gtk_style_context_remove_provider (context, provider);
+ gtk_style_context_restore (context);
+
+ return TRUE;
+}
+
+static gboolean
+draw_cb_frame (GtkWidget *widget, cairo_t *cr)
+{
+ GtkStyleProvider *provider;
+ GtkStyleContext *context;
+
+ context = gtk_widget_get_style_context (widget);
+
+ gtk_style_context_save (context);
+
+ provider = (GtkStyleProvider *)gtk_css_provider_new ();
+ gtk_css_provider_load_from_data (GTK_CSS_PROVIDER (provider),
+ ".frame {\n"
+ " border-image: url('gradient1.png') 10 10 10 10 stretch;\n"
+ " border-style; solid\n"
+ "}\n", -1, NULL);
+ gtk_style_context_add_provider (context, provider, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+ gtk_style_context_set_junction_sides (context, 0);
+ gtk_render_frame (context, cr, 12, 12, 25, 25);
+ gtk_style_context_remove_provider (context, provider);
+ gtk_style_context_restore (context);
+
+ return TRUE;
+}
+
static char *what;
static gboolean
@@ -106,7 +157,11 @@ draw_cb (GtkWidget *widget, cairo_t *cr)
else if (strcmp (what, "arrow") == 0)
return draw_cb_arrows (widget, cr);
else if (strcmp (what, "expander") == 0)
- return draw_cb_expanders (widget ,cr);
+ return draw_cb_expanders (widget, cr);
+ else if (strcmp (what, "background") == 0)
+ return draw_cb_background (widget, cr);
+ else if (strcmp (what, "frame") == 0)
+ return draw_cb_frame (widget, cr);
return FALSE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]