From 92994a0129af184d7b7b3be775dc3177b6f2084e Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 27 Mar 2010 20:21:55 +0100 Subject: [PATCH] GtkThemingEngine: Add vmethod to render layouts. --- gtk/gtkthemingengine.c | 40 ++++++++++++++++++++++++++++++++++++++++ gtk/gtkthemingengine.h | 5 +++++ 2 files changed, 45 insertions(+) diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index 49dbe44dd6..b56a86deaa 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -85,6 +85,11 @@ static void gtk_theming_engine_render_focus (GtkThemingEngine *engine, gdouble y, gdouble width, gdouble height); +static void gtk_theming_engine_render_layout (GtkThemingEngine *engine, + cairo_t *cr, + gdouble x, + gdouble y, + PangoLayout *layout); G_DEFINE_TYPE (GtkThemingEngine, gtk_theming_engine, G_TYPE_OBJECT) @@ -123,6 +128,7 @@ gtk_theming_engine_class_init (GtkThemingEngineClass *klass) klass->render_frame = gtk_theming_engine_render_frame; klass->render_expander = gtk_theming_engine_render_expander; klass->render_focus = gtk_theming_engine_render_focus; + klass->render_layout = gtk_theming_engine_render_layout; g_type_class_add_private (object_class, sizeof (GtkThemingEnginePrivate)); } @@ -913,5 +919,39 @@ gtk_theming_engine_render_focus (GtkThemingEngine *engine, gdk_color_free (base_color); } +static void +gtk_theming_engine_render_layout (GtkThemingEngine *engine, + cairo_t *cr, + gdouble x, + gdouble y, + PangoLayout *layout) +{ + GdkColor *fg_color; + GtkStateFlags flags; + GtkStateType state; + + cairo_save (cr); + flags = gtk_theming_engine_get_state (engine); + + if (flags & GTK_STATE_FLAG_PRELIGHT) + state = GTK_STATE_PRELIGHT; + else if (flags & GTK_STATE_FLAG_INSENSITIVE) + state = GTK_STATE_INSENSITIVE; + else + state = GTK_STATE_NORMAL; + + gtk_theming_engine_get (engine, state, + "foreground-color", &fg_color, + NULL); + + cairo_move_to (cr, x, y); + gdk_cairo_set_source_color (cr, fg_color); + pango_cairo_show_layout (cr, layout); + + cairo_restore (cr); + + gdk_color_free (fg_color); +} + #define __GTK_THEMING_ENGINE_C__ #include "gtkaliasdef.c" diff --git a/gtk/gtkthemingengine.h b/gtk/gtkthemingengine.h index 61dc7f3d79..6a79edc7ce 100644 --- a/gtk/gtkthemingengine.h +++ b/gtk/gtkthemingengine.h @@ -91,6 +91,11 @@ struct GtkThemingEngineClass gdouble y, gdouble width, gdouble height); + void (* render_layout) (GtkThemingEngine *engine, + cairo_t *cr, + gdouble x, + gdouble y, + PangoLayout *layout); }; GType gtk_theming_engine_get_type (void) G_GNUC_CONST;