[gtk+/gtk-style-context: 47/206] GtkThemingEngine: Add vmethod to render sliders.



commit be40b022e93375c81a54c4c4b9f82b5f7150b82a
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sat Mar 27 21:20:21 2010 +0100

    GtkThemingEngine: Add vmethod to render sliders.

 gtk/gtkthemingengine.c |   37 +++++++++++++++++++++++++++++++++++++
 gtk/gtkthemingengine.h |    7 +++++++
 2 files changed, 44 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c
index 9d175db..f824dfe 100644
--- a/gtk/gtkthemingengine.c
+++ b/gtk/gtkthemingengine.c
@@ -96,6 +96,13 @@ static void gtk_theming_engine_render_line     (GtkThemingEngine *engine,
                                                 gdouble           y0,
                                                 gdouble           x1,
                                                 gdouble           y1);
+static void gtk_theming_engine_render_slider   (GtkThemingEngine *engine,
+                                                cairo_t          *cr,
+                                                gdouble           x,
+                                                gdouble           y,
+                                                gdouble           width,
+                                                gdouble           height,
+                                                GtkOrientation    orientation);
 
 G_DEFINE_TYPE (GtkThemingEngine, gtk_theming_engine, G_TYPE_OBJECT)
 
@@ -136,6 +143,7 @@ gtk_theming_engine_class_init (GtkThemingEngineClass *klass)
   klass->render_focus = gtk_theming_engine_render_focus;
   klass->render_layout = gtk_theming_engine_render_layout;
   klass->render_line = gtk_theming_engine_render_line;
+  klass->render_slider = gtk_theming_engine_render_slider;
 
   g_type_class_add_private (object_class, sizeof (GtkThemingEnginePrivate));
 }
@@ -1074,5 +1082,34 @@ gtk_theming_engine_render_layout (GtkThemingEngine *engine,
   gdk_color_free (fg_color);
 }
 
+static void
+gtk_theming_engine_render_slider (GtkThemingEngine *engine,
+                                  cairo_t          *cr,
+                                  gdouble           x,
+                                  gdouble           y,
+                                  gdouble           width,
+                                  gdouble           height,
+                                  GtkOrientation    orientation)
+{
+  const GtkWidgetPath *path;
+
+  path = gtk_theming_engine_get_path (engine);
+
+  gtk_theming_engine_render_background (engine, cr, x, y, width, height);
+  gtk_theming_engine_render_frame (engine, cr, x, y, width, height);
+
+  if (gtk_widget_path_has_parent (path, GTK_TYPE_SCALE))
+    {
+      if (orientation == GTK_ORIENTATION_VERTICAL)
+        gtk_theming_engine_render_line (engine, cr,
+                                        x + 2, y + height / 2 - 1,
+                                        x + width - 4, y + height / 2 - 1);
+      else
+        gtk_theming_engine_render_line (engine, cr,
+                                        x + width / 2 - 1, y + 4,
+                                        x + width / 2 - 1, y + height - 4);
+    }
+}
+
 #define __GTK_THEMING_ENGINE_C__
 #include "gtkaliasdef.c"
diff --git a/gtk/gtkthemingengine.h b/gtk/gtkthemingengine.h
index 12270a1..dd02bc5 100644
--- a/gtk/gtkthemingengine.h
+++ b/gtk/gtkthemingengine.h
@@ -102,6 +102,13 @@ struct GtkThemingEngineClass
                           gdouble           x,
                           gdouble           y,
                           PangoLayout      *layout);
+  void (* render_slider) (GtkThemingEngine *engine,
+                          cairo_t          *cr,
+                          gdouble           x,
+                          gdouble           y,
+                          gdouble           width,
+                          gdouble           height,
+                          GtkOrientation    orientation);
 };
 
 GType gtk_theming_engine_get_type (void) G_GNUC_CONST;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]