[gtk+/gtk-style-context: 466/533] Add slider illustration
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/gtk-style-context: 466/533] Add slider illustration
- Date: Wed, 1 Dec 2010 02:45:00 +0000 (UTC)
commit bc7bfd0304dcb7002499bcced1a56fae0da152e2
Author: Matthias Clasen <mclasen redhat com>
Date: Tue Nov 23 17:38:28 2010 -0500
Add slider illustration
docs/reference/gtk/Makefile.am | 3 +-
docs/reference/gtk/images/sliders.png | Bin 0 -> 470 bytes
gtk/gtkstylecontext.c | 5 +++
tests/styleexamples.c | 45 ++++++++++++++++++++++++++++++---
4 files changed, 48 insertions(+), 5 deletions(-)
---
diff --git a/docs/reference/gtk/Makefile.am b/docs/reference/gtk/Makefile.am
index 62f4556..e45d342 100644
--- a/docs/reference/gtk/Makefile.am
+++ b/docs/reference/gtk/Makefile.am
@@ -347,7 +347,8 @@ HTML_IMAGES = \
$(srcdir)/images/arrows.png \
$(srcdir)/images/expanders.png \
$(srcdir)/images/background.png \
- $(srcdir)/images/frames.png
+ $(srcdir)/images/frames.png \
+ $(srcdir)/images/sliders.png
# Extra options to supply to gtkdoc-fixref
FIXXREF_OPTIONS=--extra-dir=../gdk/html \
diff --git a/docs/reference/gtk/images/sliders.png b/docs/reference/gtk/images/sliders.png
new file mode 100644
index 0000000..e832aa7
Binary files /dev/null and b/docs/reference/gtk/images/sliders.png differ
diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c
index 205a7e6..78957e6 100644
--- a/gtk/gtkstylecontext.c
+++ b/gtk/gtkstylecontext.c
@@ -3265,6 +3265,11 @@ gtk_render_line (GtkStyleContext *context,
* @width, @height. @orientation defines whether the slider is vertical
* or horizontal.
*
+ * <example>
+ * <title>Typical slider rendering</title>
+ * <inlinegraphic fileref="sliders.png" format="PNG"/>
+ * </example>
+ *
* Since: 3.0
**/
void
diff --git a/tests/styleexamples.c b/tests/styleexamples.c
index 248ca64..b66add5 100644
--- a/tests/styleexamples.c
+++ b/tests/styleexamples.c
@@ -177,21 +177,56 @@ static gboolean
draw_cb_activity (GtkWidget *widget, cairo_t *cr)
{
GtkStyleContext *context;
+ GtkWidgetPath *path;
context = gtk_widget_get_style_context (widget);
+ gtk_style_context_notify_state_change (context,
+ gtk_widget_get_window (widget),
+ NULL,
+ GTK_STATE_FLAG_ACTIVE,
+ TRUE);
+
gtk_style_context_save (context);
- gtk_style_context_add_class (context, "spinner");
- gtk_style_context_set_state (context, 0);
+ path = gtk_widget_path_new ();
+ gtk_widget_path_append_type (path, GTK_TYPE_SPINNER);
+ gtk_widget_path_iter_add_class (path, 0, "spinner");
+ gtk_style_context_set_path (context, path);
+ gtk_widget_path_free (path);
+
+ gtk_style_context_set_state (context, GTK_STATE_FLAG_ACTIVE);
gtk_render_activity (context, cr, 12, 12, 12, 12);
- gtk_style_context_set_state (context, GTK_STATE_FLAG_INSENSITIVE);
- gtk_render_activity (context, cr, 36, 12, 12, 12);
gtk_style_context_restore (context);
return TRUE;
}
+static gboolean
+draw_cb_slider (GtkWidget *widget, cairo_t *cr)
+{
+ GtkStyleContext *context;
+ GtkWidgetPath *path;
+
+ context = gtk_widget_get_style_context (widget);
+ gtk_style_context_save (context);
+
+ path = gtk_widget_path_new ();
+ gtk_widget_path_append_type (path, GTK_TYPE_SCALE);
+ gtk_widget_path_iter_add_class (path, 0, "slider");
+ gtk_widget_path_iter_add_class (path, 0, "scale");
+ gtk_style_context_set_path (context, path);
+ gtk_widget_path_free (path);
+
+ gtk_render_slider (context, cr, 12, 22, 30, 10, GTK_ORIENTATION_HORIZONTAL);
+ gtk_render_slider (context, cr, 54, 12, 10, 30, GTK_ORIENTATION_VERTICAL);
+
+ gtk_style_context_restore (context);
+
+ return TRUE;
+}
+
+
static char *what;
@@ -212,6 +247,8 @@ draw_cb (GtkWidget *widget, cairo_t *cr)
return draw_cb_frame (widget, cr);
else if (strcmp (what, "activity") == 0)
return draw_cb_activity (widget, cr);
+ else if (strcmp (what, "slider") == 0)
+ return draw_cb_slider (widget, cr);
return FALSE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]