1 /* GTK - The GIMP Toolkit
2 * Copyright (C) 2010 Carlos Garnacho <carlosg@gnome.org>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
25 #include <gtk/gtkthemingengine.h>
26 #include <gtk/gtkstylecontext.h>
27 #include <gtk/gtkintl.h>
29 #include "gtkprivate.h"
30 #include "gtkmodulesprivate.h"
31 #include "gtkborderimageprivate.h"
33 #include "gtkshadowprivate.h"
34 #include "gtkcsstypesprivate.h"
35 #include "gtkthemingengineprivate.h"
36 #include "gtkroundedboxprivate.h"
39 * SECTION:gtkthemingengine
40 * @Short_description: Theming renderers
41 * @Title: GtkThemingEngine
42 * @See_also: #GtkStyleContext
44 * #GtkThemingEngine is the object used for rendering themed content
45 * in GTK+ widgets. Even though GTK+ has a default implementation,
46 * it can be overridden in CSS files by enforcing a #GtkThemingEngine
47 * object to be loaded as a module.
49 * In order to implement a theming engine, a #GtkThemingEngine subclass
50 * must be created, alongside the CSS file that will reference it, the
51 * theming engine would be created as an .so library, and installed in
52 * $(gtk-modules-dir)/theming-engines/.
54 * #GtkThemingEngine<!-- -->s have limited access to the object they are
55 * rendering, the #GtkThemingEngine API has read-only accessors to the
56 * style information contained in the rendered object's #GtkStyleContext.
72 struct GtkThemingEnginePrivate
74 GtkStyleContext *context;
78 #define GTK_THEMING_ENGINE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GTK_TYPE_THEMING_ENGINE, GtkThemingEnginePrivate))
80 static void gtk_theming_engine_finalize (GObject *object);
81 static void gtk_theming_engine_impl_set_property (GObject *object,
85 static void gtk_theming_engine_impl_get_property (GObject *object,
90 static void gtk_theming_engine_render_check (GtkThemingEngine *engine,
96 static void gtk_theming_engine_render_option (GtkThemingEngine *engine,
102 static void gtk_theming_engine_render_arrow (GtkThemingEngine *engine,
108 static void gtk_theming_engine_render_background (GtkThemingEngine *engine,
114 static void gtk_theming_engine_render_frame (GtkThemingEngine *engine,
120 static void gtk_theming_engine_render_expander (GtkThemingEngine *engine,
126 static void gtk_theming_engine_render_focus (GtkThemingEngine *engine,
132 static void gtk_theming_engine_render_layout (GtkThemingEngine *engine,
136 PangoLayout *layout);
137 static void gtk_theming_engine_render_line (GtkThemingEngine *engine,
143 static void gtk_theming_engine_render_slider (GtkThemingEngine *engine,
149 GtkOrientation orientation);
150 static void gtk_theming_engine_render_frame_gap (GtkThemingEngine *engine,
156 GtkPositionType gap_side,
159 static void gtk_theming_engine_render_extension (GtkThemingEngine *engine,
165 GtkPositionType gap_side);
166 static void gtk_theming_engine_render_handle (GtkThemingEngine *engine,
172 static void gtk_theming_engine_render_activity (GtkThemingEngine *engine,
178 static GdkPixbuf * gtk_theming_engine_render_icon_pixbuf (GtkThemingEngine *engine,
179 const GtkIconSource *source,
181 static void gtk_theming_engine_render_icon (GtkThemingEngine *engine,
187 G_DEFINE_TYPE (GtkThemingEngine, gtk_theming_engine, G_TYPE_OBJECT)
190 typedef struct GtkThemingModule GtkThemingModule;
191 typedef struct GtkThemingModuleClass GtkThemingModuleClass;
193 struct GtkThemingModule
195 GTypeModule parent_instance;
199 void (*init) (GTypeModule *module);
201 GtkThemingEngine * (*create_engine) (void);
204 struct GtkThemingModuleClass
206 GTypeModuleClass parent_class;
209 #define GTK_TYPE_THEMING_MODULE (gtk_theming_module_get_type ())
210 #define GTK_THEMING_MODULE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GTK_TYPE_THEMING_MODULE, GtkThemingModule))
211 #define GTK_IS_THEMING_MODULE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTK_TYPE_THEMING_MODULE))
213 G_DEFINE_TYPE (GtkThemingModule, gtk_theming_module, G_TYPE_TYPE_MODULE);
216 gtk_theming_engine_class_init (GtkThemingEngineClass *klass)
218 GObjectClass *object_class = G_OBJECT_CLASS (klass);
220 object_class->finalize = gtk_theming_engine_finalize;
221 object_class->set_property = gtk_theming_engine_impl_set_property;
222 object_class->get_property = gtk_theming_engine_impl_get_property;
224 klass->render_icon = gtk_theming_engine_render_icon;
225 klass->render_check = gtk_theming_engine_render_check;
226 klass->render_option = gtk_theming_engine_render_option;
227 klass->render_arrow = gtk_theming_engine_render_arrow;
228 klass->render_background = gtk_theming_engine_render_background;
229 klass->render_frame = gtk_theming_engine_render_frame;
230 klass->render_expander = gtk_theming_engine_render_expander;
231 klass->render_focus = gtk_theming_engine_render_focus;
232 klass->render_layout = gtk_theming_engine_render_layout;
233 klass->render_line = gtk_theming_engine_render_line;
234 klass->render_slider = gtk_theming_engine_render_slider;
235 klass->render_frame_gap = gtk_theming_engine_render_frame_gap;
236 klass->render_extension = gtk_theming_engine_render_extension;
237 klass->render_handle = gtk_theming_engine_render_handle;
238 klass->render_activity = gtk_theming_engine_render_activity;
239 klass->render_icon_pixbuf = gtk_theming_engine_render_icon_pixbuf;
242 * GtkThemingEngine:name:
244 * The theming engine name, this name will be used when registering
245 * custom properties, for a theming engine named "Clearlooks" registering
246 * a "glossy" custom property, it could be referenced in the CSS file as
249 * -Clearlooks-glossy: true;
254 g_object_class_install_property (object_class,
256 g_param_spec_string ("name",
258 P_("Theming engine name"),
260 G_PARAM_CONSTRUCT_ONLY | GTK_PARAM_READWRITE));
262 g_type_class_add_private (object_class, sizeof (GtkThemingEnginePrivate));
266 gtk_theming_engine_init (GtkThemingEngine *engine)
268 engine->priv = GTK_THEMING_ENGINE_GET_PRIVATE (engine);
272 gtk_theming_engine_finalize (GObject *object)
274 GtkThemingEnginePrivate *priv;
276 priv = GTK_THEMING_ENGINE (object)->priv;
279 G_OBJECT_GET_CLASS (gtk_theming_engine_parent_class)->finalize (object);
283 gtk_theming_engine_impl_set_property (GObject *object,
288 GtkThemingEnginePrivate *priv;
290 priv = GTK_THEMING_ENGINE (object)->priv;
298 priv->name = g_value_dup_string (value);
301 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
307 gtk_theming_engine_impl_get_property (GObject *object,
312 GtkThemingEnginePrivate *priv;
314 priv = GTK_THEMING_ENGINE (object)->priv;
319 g_value_set_string (value, priv->name);
322 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
328 _gtk_theming_engine_set_context (GtkThemingEngine *engine,
329 GtkStyleContext *context)
331 GtkThemingEnginePrivate *priv;
333 g_return_if_fail (GTK_IS_THEMING_ENGINE (engine));
334 g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
337 priv->context = context;
341 * gtk_theming_engine_register_property: (skip)
342 * @name_space: namespace for the property name
343 * @parse_func: parsing function to use, or %NULL
344 * @pspec: the #GParamSpec for the new property
346 * Registers a property so it can be used in the CSS file format,
347 * on the CSS file the property will look like
348 * "-${@name_space}-${property_name}". being
349 * ${property_name} the given to @pspec. @name_space will usually
350 * be the theme engine name.
352 * For any type a @parse_func may be provided, being this function
353 * used for turning any property value (between ':' and ';') in
354 * CSS to the #GValue needed. For basic types there is already
355 * builtin parsing support, so %NULL may be provided for these
359 * Engines must ensure property registration happens exactly once,
360 * usually GTK+ deals with theming engines as singletons, so this
361 * should be guaranteed to happen once, but bear this in mind
362 * when creating #GtkThemeEngine<!-- -->s yourself.
366 * In order to make use of the custom registered properties in
367 * the CSS file, make sure the engine is loaded first by specifying
368 * the engine property, either in a previous rule or within the same
372 * engine: someengine;
373 * -SomeEngine-custom-property: 2;
381 gtk_theming_engine_register_property (const gchar *name_space,
382 GtkStylePropertyParser parse_func,
387 g_return_if_fail (name_space != NULL);
388 g_return_if_fail (strchr (name_space, ' ') == NULL);
389 g_return_if_fail (G_IS_PARAM_SPEC (pspec));
391 /* FIXME: hack hack hack, replacing pspec->name to include namespace */
392 name = g_strdup_printf ("-%s-%s", name_space, pspec->name);
393 pspec->name = (char *)g_intern_string (name);
396 gtk_style_properties_register_property (parse_func, pspec);
400 * gtk_theming_engine_get_property:
401 * @engine: a #GtkThemingEngine
402 * @property: the property name
403 * @state: state to retrieve the value for
404 * @value: (out) (transfer full): return location for the property value,
405 * you must free this memory using g_value_unset() once you are
408 * Gets a property value as retrieved from the style settings that apply
409 * to the currently rendered element.
414 gtk_theming_engine_get_property (GtkThemingEngine *engine,
415 const gchar *property,
419 GtkThemingEnginePrivate *priv;
421 g_return_if_fail (GTK_IS_THEMING_ENGINE (engine));
422 g_return_if_fail (property != NULL);
423 g_return_if_fail (value != NULL);
426 gtk_style_context_get_property (priv->context, property, state, value);
430 * gtk_theming_engine_get_valist:
431 * @engine: a #GtkThemingEngine
432 * @state: state to retrieve values for
433 * @args: va_list of property name/return location pairs, followed by %NULL
435 * Retrieves several style property values that apply to the currently
441 gtk_theming_engine_get_valist (GtkThemingEngine *engine,
445 GtkThemingEnginePrivate *priv;
447 g_return_if_fail (GTK_IS_THEMING_ENGINE (engine));
450 gtk_style_context_get_valist (priv->context, state, args);
454 _gtk_theming_engine_get (GtkThemingEngine *engine,
456 GtkStylePropertyContext *property_context,
459 GtkThemingEnginePrivate *priv;
462 g_return_if_fail (GTK_IS_THEMING_ENGINE (engine));
466 va_start (args, property_context);
467 _gtk_style_context_get_valist (priv->context, state, property_context, args);
473 * gtk_theming_engine_get:
474 * @engine: a #GtkThemingEngine
475 * @state: state to retrieve values for
476 * @...: property name /return value pairs, followed by %NULL
478 * Retrieves several style property values that apply to the currently
484 gtk_theming_engine_get (GtkThemingEngine *engine,
488 GtkThemingEnginePrivate *priv;
491 g_return_if_fail (GTK_IS_THEMING_ENGINE (engine));
495 va_start (args, state);
496 gtk_style_context_get_valist (priv->context, state, args);
501 * gtk_theming_engine_get_style_property:
502 * @engine: a #GtkThemingEngine
503 * @property_name: the name of the widget style property
504 * @value: Return location for the property value, free with
505 * g_value_unset() after use.
507 * Gets the value for a widget style property.
512 gtk_theming_engine_get_style_property (GtkThemingEngine *engine,
513 const gchar *property_name,
516 GtkThemingEnginePrivate *priv;
518 g_return_if_fail (GTK_IS_THEMING_ENGINE (engine));
519 g_return_if_fail (property_name != NULL);
522 gtk_style_context_get_style_property (priv->context, property_name, value);
526 * gtk_theming_engine_get_style_valist:
527 * @engine: a #GtkThemingEngine
528 * @args: va_list of property name/return location pairs, followed by %NULL
530 * Retrieves several widget style properties from @engine according to the
531 * currently rendered content's style.
536 gtk_theming_engine_get_style_valist (GtkThemingEngine *engine,
539 GtkThemingEnginePrivate *priv;
541 g_return_if_fail (GTK_IS_THEMING_ENGINE (engine));
544 gtk_style_context_get_style_valist (priv->context, args);
548 * gtk_theming_engine_get_style:
549 * @engine: a #GtkThemingEngine
550 * @...: property name /return value pairs, followed by %NULL
552 * Retrieves several widget style properties from @engine according
553 * to the currently rendered content's style.
558 gtk_theming_engine_get_style (GtkThemingEngine *engine,
561 GtkThemingEnginePrivate *priv;
564 g_return_if_fail (GTK_IS_THEMING_ENGINE (engine));
568 va_start (args, engine);
569 gtk_style_context_get_style_valist (priv->context, args);
574 * gtk_theming_engine_lookup_color:
575 * @engine: a #GtkThemingEngine
576 * @color_name: color name to lookup
577 * @color: (out): Return location for the looked up color
579 * Looks up and resolves a color name in the current style's color map.
581 * Returns: %TRUE if @color_name was found and resolved, %FALSE otherwise
584 gtk_theming_engine_lookup_color (GtkThemingEngine *engine,
585 const gchar *color_name,
588 GtkThemingEnginePrivate *priv;
590 g_return_val_if_fail (GTK_IS_THEMING_ENGINE (engine), FALSE);
591 g_return_val_if_fail (color_name != NULL, FALSE);
594 return gtk_style_context_lookup_color (priv->context, color_name, color);
598 * gtk_theming_engine_get_state:
599 * @engine: a #GtkThemingEngine
601 * returns the state used when rendering.
603 * Returns: the state flags
608 gtk_theming_engine_get_state (GtkThemingEngine *engine)
610 GtkThemingEnginePrivate *priv;
612 g_return_val_if_fail (GTK_IS_THEMING_ENGINE (engine), 0);
615 return gtk_style_context_get_state (priv->context);
619 * gtk_theming_engine_state_is_running:
620 * @engine: a #GtkThemingEngine
621 * @state: a widget state
622 * @progress: (out): return location for the transition progress
624 * Returns %TRUE if there is a transition animation running for the
625 * current region (see gtk_style_context_push_animatable_region()).
627 * If @progress is not %NULL, the animation progress will be returned
628 * there, 0.0 means the state is closest to being %FALSE, while 1.0 means
629 * it's closest to being %TRUE. This means transition animations will
630 * run from 0 to 1 when @state is being set to %TRUE and from 1 to 0 when
631 * it's being set to %FALSE.
633 * Returns: %TRUE if there is a running transition animation for @state.
638 gtk_theming_engine_state_is_running (GtkThemingEngine *engine,
642 GtkThemingEnginePrivate *priv;
644 g_return_val_if_fail (GTK_IS_THEMING_ENGINE (engine), FALSE);
647 return gtk_style_context_state_is_running (priv->context, state, progress);
651 * gtk_theming_engine_get_path:
652 * @engine: a #GtkThemingEngine
654 * Returns the widget path used for style matching.
656 * Returns: (transfer none): A #GtkWidgetPath
660 const GtkWidgetPath *
661 gtk_theming_engine_get_path (GtkThemingEngine *engine)
663 GtkThemingEnginePrivate *priv;
665 g_return_val_if_fail (GTK_IS_THEMING_ENGINE (engine), NULL);
668 return gtk_style_context_get_path (priv->context);
672 * gtk_theming_engine_has_class:
673 * @engine: a #GtkThemingEngine
674 * @style_class: class name to look up
676 * Returns %TRUE if the currently rendered contents have
677 * defined the given class name.
679 * Returns: %TRUE if @engine has @class_name defined
684 gtk_theming_engine_has_class (GtkThemingEngine *engine,
685 const gchar *style_class)
687 GtkThemingEnginePrivate *priv;
689 g_return_val_if_fail (GTK_IS_THEMING_ENGINE (engine), FALSE);
692 return gtk_style_context_has_class (priv->context, style_class);
696 * gtk_theming_engine_has_region:
697 * @engine: a #GtkThemingEngine
698 * @style_region: a region name
699 * @flags: (out) (allow-none): return location for region flags
701 * Returns %TRUE if the currently rendered contents have the
702 * region defined. If @flags_return is not %NULL, it is set
703 * to the flags affecting the region.
705 * Returns: %TRUE if region is defined
710 gtk_theming_engine_has_region (GtkThemingEngine *engine,
711 const gchar *style_region,
712 GtkRegionFlags *flags)
714 GtkThemingEnginePrivate *priv;
719 g_return_val_if_fail (GTK_IS_THEMING_ENGINE (engine), FALSE);
722 return gtk_style_context_has_region (priv->context, style_region, flags);
726 * gtk_theming_engine_get_direction:
727 * @engine: a #GtkThemingEngine
729 * Returns the widget direction used for rendering.
731 * Returns: the widget direction
736 gtk_theming_engine_get_direction (GtkThemingEngine *engine)
738 GtkThemingEnginePrivate *priv;
740 g_return_val_if_fail (GTK_IS_THEMING_ENGINE (engine), GTK_TEXT_DIR_LTR);
743 return gtk_style_context_get_direction (priv->context);
747 * gtk_theming_engine_get_junction_sides:
748 * @engine: a #GtkThemingEngine
750 * Returns the widget direction used for rendering.
752 * Returns: the widget direction
757 gtk_theming_engine_get_junction_sides (GtkThemingEngine *engine)
759 GtkThemingEnginePrivate *priv;
761 g_return_val_if_fail (GTK_IS_THEMING_ENGINE (engine), 0);
764 return gtk_style_context_get_junction_sides (priv->context);
768 * gtk_theming_engine_get_color:
769 * @engine: a #GtkThemingEngine
770 * @state: state to retrieve the color for
771 * @color: (out): return value for the foreground color
773 * Gets the foreground color for a given state.
778 gtk_theming_engine_get_color (GtkThemingEngine *engine,
782 GtkThemingEnginePrivate *priv;
784 g_return_if_fail (GTK_IS_THEMING_ENGINE (engine));
787 gtk_style_context_get_color (priv->context, state, color);
791 * gtk_theming_engine_get_background_color:
792 * @engine: a #GtkThemingEngine
793 * @state: state to retrieve the color for
794 * @color: (out): return value for the background color
796 * Gets the background color for a given state.
801 gtk_theming_engine_get_background_color (GtkThemingEngine *engine,
805 GtkThemingEnginePrivate *priv;
807 g_return_if_fail (GTK_IS_THEMING_ENGINE (engine));
810 gtk_style_context_get_background_color (priv->context, state, color);
814 * gtk_theming_engine_get_border_color:
815 * @engine: a #GtkThemingEngine
816 * @state: state to retrieve the color for
817 * @color: (out): return value for the border color
819 * Gets the border color for a given state.
824 gtk_theming_engine_get_border_color (GtkThemingEngine *engine,
828 GtkThemingEnginePrivate *priv;
830 g_return_if_fail (GTK_IS_THEMING_ENGINE (engine));
833 gtk_style_context_get_border_color (priv->context, state, color);
837 * gtk_theming_engine_get_border:
838 * @engine: a #GtkthemingEngine
839 * @state: state to retrieve the border for
840 * @border: (out): return value for the border settings
842 * Gets the border for a given state as a #GtkBorder.
847 gtk_theming_engine_get_border (GtkThemingEngine *engine,
851 GtkThemingEnginePrivate *priv;
853 g_return_if_fail (GTK_IS_THEMING_ENGINE (engine));
856 gtk_style_context_get_border (priv->context, state, border);
860 * gtk_theming_engine_get_padding:
861 * @engine: a #GtkthemingEngine
862 * @state: state to retrieve the padding for
863 * @padding: (out): return value for the padding settings
865 * Gets the padding for a given state as a #GtkBorder.
870 gtk_theming_engine_get_padding (GtkThemingEngine *engine,
874 GtkThemingEnginePrivate *priv;
876 g_return_if_fail (GTK_IS_THEMING_ENGINE (engine));
879 gtk_style_context_get_padding (priv->context, state, padding);
883 * gtk_theming_engine_get_margin:
884 * @engine: a #GtkThemingEngine
885 * @state: state to retrieve the border for
886 * @margin: (out): return value for the margin settings
888 * Gets the margin for a given state as a #GtkBorder.
893 gtk_theming_engine_get_margin (GtkThemingEngine *engine,
897 GtkThemingEnginePrivate *priv;
899 g_return_if_fail (GTK_IS_THEMING_ENGINE (engine));
902 gtk_style_context_get_margin (priv->context, state, margin);
906 * gtk_theming_engine_get_font:
907 * @engine: a #GtkThemingEngine
908 * @state: state to retrieve the font for
910 * Returns the font description for a given state.
912 * Returns: (transfer none): the #PangoFontDescription for the given
913 * state. This object is owned by GTK+ and should not be
918 const PangoFontDescription *
919 gtk_theming_engine_get_font (GtkThemingEngine *engine,
922 GtkThemingEnginePrivate *priv;
924 g_return_val_if_fail (GTK_IS_THEMING_ENGINE (engine), NULL);
927 return gtk_style_context_get_font (priv->context, state);
930 /* GtkThemingModule */
933 gtk_theming_module_load (GTypeModule *type_module)
935 GtkThemingModule *theming_module;
937 gchar *name, *module_path;
939 theming_module = GTK_THEMING_MODULE (type_module);
940 name = theming_module->name;
941 module_path = _gtk_find_module (name, "theming-engines");
946 module = g_module_open (module_path, G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL);
947 g_free (module_path);
952 if (!g_module_symbol (module, "theme_init",
953 (gpointer *) &theming_module->init) ||
954 !g_module_symbol (module, "theme_exit",
955 (gpointer *) &theming_module->exit) ||
956 !g_module_symbol (module, "create_engine",
957 (gpointer *) &theming_module->create_engine))
959 g_module_close (module);
964 theming_module->module = module;
966 theming_module->init (G_TYPE_MODULE (theming_module));
972 gtk_theming_module_unload (GTypeModule *type_module)
974 GtkThemingModule *theming_module;
976 theming_module = GTK_THEMING_MODULE (type_module);
978 theming_module->exit ();
980 g_module_close (theming_module->module);
982 theming_module->module = NULL;
983 theming_module->init = NULL;
984 theming_module->exit = NULL;
985 theming_module->create_engine = NULL;
989 gtk_theming_module_class_init (GtkThemingModuleClass *klass)
991 GTypeModuleClass *module_class = G_TYPE_MODULE_CLASS (klass);
993 module_class->load = gtk_theming_module_load;
994 module_class->unload = gtk_theming_module_unload;
998 gtk_theming_module_init (GtkThemingModule *module)
1003 * gtk_theming_engine_load:
1004 * @name: Theme engine name to load
1006 * Loads and initializes a theming engine module from the
1007 * standard directories.
1009 * Returns: (transfer none): A theming engine, or %NULL if
1010 * the engine @name doesn't exist.
1013 gtk_theming_engine_load (const gchar *name)
1015 static GHashTable *engines = NULL;
1016 static GtkThemingEngine *default_engine;
1017 GtkThemingEngine *engine = NULL;
1022 engines = g_hash_table_new (g_str_hash, g_str_equal);
1024 engine = g_hash_table_lookup (engines, name);
1028 GtkThemingModule *module;
1030 module = g_object_new (GTK_TYPE_THEMING_MODULE, NULL);
1031 g_type_module_set_name (G_TYPE_MODULE (module), name);
1032 module->name = g_strdup (name);
1034 if (module && g_type_module_use (G_TYPE_MODULE (module)))
1036 engine = (module->create_engine) ();
1039 g_hash_table_insert (engines, module->name, engine);
1045 if (G_UNLIKELY (!default_engine))
1046 default_engine = g_object_new (GTK_TYPE_THEMING_ENGINE, NULL);
1048 engine = default_engine;
1055 * gtk_theming_engine_get_screen:
1056 * @engine: a #GtkThemingEngine
1058 * Returns the #GdkScreen to which @engine currently rendering to.
1060 * Returns: (transfer none): a #GdkScreen, or %NULL.
1063 gtk_theming_engine_get_screen (GtkThemingEngine *engine)
1065 GtkThemingEnginePrivate *priv;
1067 g_return_val_if_fail (GTK_IS_THEMING_ENGINE (engine), NULL);
1069 priv = engine->priv;
1070 return gtk_style_context_get_screen (priv->context);
1073 /* Paint method implementations */
1075 gtk_theming_engine_render_check (GtkThemingEngine *engine,
1082 GdkRGBA fg_color, bg_color;
1083 GtkStateFlags flags;
1084 gint exterior_size, interior_size, thickness, pad;
1085 GtkBorderStyle border_style;
1089 flags = gtk_theming_engine_get_state (engine);
1092 gtk_theming_engine_get_color (engine, flags, &fg_color);
1093 gtk_theming_engine_get_background_color (engine, flags, &bg_color);
1094 gtk_theming_engine_get_border (engine, flags, &border);
1096 gtk_theming_engine_get (engine, flags,
1097 "border-style", &border_style,
1100 border_width = MIN (MIN (border.top, border.bottom),
1101 MIN (border.left, border.right));
1102 exterior_size = MIN (width, height);
1104 if (exterior_size % 2 == 0) /* Ensure odd */
1107 /* FIXME: thickness */
1109 pad = thickness + MAX (1, (exterior_size - 2 * thickness) / 9);
1110 interior_size = MAX (1, exterior_size - 2 * pad);
1112 if (interior_size < 7)
1115 pad = MAX (0, (exterior_size - interior_size) / 2);
1118 x -= (1 + exterior_size - (gint) width) / 2;
1119 y -= (1 + exterior_size - (gint) height) / 2;
1121 if (border_style == GTK_BORDER_STYLE_SOLID)
1123 GdkRGBA border_color;
1125 cairo_set_line_width (cr, border_width);
1126 gtk_theming_engine_get_border_color (engine, flags, &border_color);
1128 cairo_rectangle (cr, x + 0.5, y + 0.5, exterior_size - 1, exterior_size - 1);
1129 gdk_cairo_set_source_rgba (cr, &bg_color);
1130 cairo_fill_preserve (cr);
1132 gdk_cairo_set_source_rgba (cr, &border_color);
1136 gdk_cairo_set_source_rgba (cr, &fg_color);
1138 if (flags & GTK_STATE_FLAG_INCONSISTENT)
1140 int line_thickness = MAX (1, (3 + interior_size * 2) / 7);
1142 cairo_rectangle (cr,
1144 y + pad + (1 + interior_size - line_thickness) / 2,
1154 running = gtk_theming_engine_state_is_running (engine, GTK_STATE_ACTIVE, &progress);
1156 if ((flags & GTK_STATE_FLAG_ACTIVE) || running)
1161 cairo_translate (cr,
1164 cairo_scale (cr, interior_size / 7., interior_size / 7.);
1166 cairo_rectangle (cr, 0, 0, 7 * progress, 7);
1169 cairo_move_to (cr, 7.0, 0.0);
1170 cairo_line_to (cr, 7.5, 1.0);
1171 cairo_curve_to (cr, 5.3, 2.0,
1174 cairo_curve_to (cr, 3.0, 5.7,
1177 cairo_line_to (cr, 0.2, 3.5);
1178 cairo_curve_to (cr, 1.1, 3.5,
1181 cairo_curve_to (cr, 1.0, 3.9,
1184 cairo_curve_to (cr, 3.5, 3.1,
1196 gtk_theming_engine_render_option (GtkThemingEngine *engine,
1203 GtkStateFlags flags;
1204 GdkRGBA fg_color, bg_color;
1205 gint exterior_size, interior_size, pad, thickness, border_width;
1206 GtkBorderStyle border_style;
1209 flags = gtk_theming_engine_get_state (engine);
1213 gtk_theming_engine_get_color (engine, flags, &fg_color);
1214 gtk_theming_engine_get_background_color (engine, flags, &bg_color);
1215 gtk_theming_engine_get_border (engine, flags, &border);
1217 gtk_theming_engine_get (engine, flags,
1218 "border-style", &border_style,
1221 exterior_size = MIN (width, height);
1222 border_width = MIN (MIN (border.top, border.bottom),
1223 MIN (border.left, border.right));
1225 if (exterior_size % 2 == 0) /* Ensure odd */
1228 x -= (1 + exterior_size - width) / 2;
1229 y -= (1 + exterior_size - height) / 2;
1231 if (border_style == GTK_BORDER_STYLE_SOLID)
1233 GdkRGBA border_color;
1235 cairo_set_line_width (cr, border_width);
1236 gtk_theming_engine_get_border_color (engine, flags, &border_color);
1238 cairo_new_sub_path (cr);
1240 x + exterior_size / 2.,
1241 y + exterior_size / 2.,
1242 (exterior_size - 1) / 2.,
1245 gdk_cairo_set_source_rgba (cr, &bg_color);
1246 cairo_fill_preserve (cr);
1248 gdk_cairo_set_source_rgba (cr, &border_color);
1252 gdk_cairo_set_source_rgba (cr, &fg_color);
1254 /* FIXME: thickness */
1257 if (flags & GTK_STATE_FLAG_INCONSISTENT)
1259 gint line_thickness;
1261 pad = thickness + MAX (1, (exterior_size - 2 * thickness) / 9);
1262 interior_size = MAX (1, exterior_size - 2 * pad);
1264 if (interior_size < 7)
1267 pad = MAX (0, (exterior_size - interior_size) / 2);
1270 line_thickness = MAX (1, (3 + interior_size * 2) / 7);
1272 cairo_rectangle (cr,
1274 y + pad + (interior_size - line_thickness) / 2.,
1279 if (flags & GTK_STATE_FLAG_ACTIVE)
1281 pad = thickness + MAX (1, 2 * (exterior_size - 2 * thickness) / 9);
1282 interior_size = MAX (1, exterior_size - 2 * pad);
1284 if (interior_size < 5)
1287 pad = MAX (0, (exterior_size - interior_size) / 2);
1290 cairo_new_sub_path (cr);
1292 x + pad + interior_size / 2.,
1293 y + pad + interior_size / 2.,
1303 add_path_arrow (cairo_t *cr,
1311 cairo_translate (cr, x + (size / 2), y + (size / 2));
1312 cairo_rotate (cr, angle);
1314 cairo_move_to (cr, 0, - (size / 4));
1315 cairo_line_to (cr, - (size / 2), (size / 4));
1316 cairo_line_to (cr, (size / 2), (size / 4));
1317 cairo_close_path (cr);
1323 gtk_theming_engine_render_arrow (GtkThemingEngine *engine,
1330 GtkStateFlags flags;
1335 flags = gtk_theming_engine_get_state (engine);
1336 gtk_theming_engine_get_color (engine, flags, &fg_color);
1338 if (flags & GTK_STATE_FLAG_INSENSITIVE)
1340 add_path_arrow (cr, angle, x + 1, y + 1, size);
1341 cairo_set_source_rgb (cr, 1, 1, 1);
1345 add_path_arrow (cr, angle, x, y, size);
1346 gdk_cairo_set_source_rgba (cr, &fg_color);
1353 add_path_line (cairo_t *cr,
1359 /* Adjust endpoints */
1373 cairo_move_to (cr, x1, y1);
1374 cairo_line_to (cr, x2, y2);
1378 color_shade (const GdkRGBA *color,
1380 GdkRGBA *color_return)
1382 GtkSymbolicColor *literal, *shade;
1384 literal = gtk_symbolic_color_new_literal (color);
1385 shade = gtk_symbolic_color_new_shade (literal, factor);
1386 gtk_symbolic_color_unref (literal);
1388 gtk_symbolic_color_resolve (shade, NULL, color_return);
1389 gtk_symbolic_color_unref (shade);
1393 render_background_internal (GtkThemingEngine *engine,
1399 GtkJunctionSides junction)
1402 cairo_pattern_t *pattern;
1403 GtkCssBackgroundRepeat *repeat;
1404 GtkStateFlags flags;
1407 GtkRoundedBox border_box;
1408 GtkShadow *box_shadow;
1411 flags = gtk_theming_engine_get_state (engine);
1413 gtk_theming_engine_get_background_color (engine, flags, &bg_color);
1415 gtk_theming_engine_get (engine, flags,
1416 "background-image", &pattern,
1417 "background-repeat", &repeat,
1418 "box-shadow", &box_shadow,
1422 cairo_translate (cr, x, y);
1424 running = gtk_theming_engine_state_is_running (engine, GTK_STATE_PRELIGHT, &progress);
1426 if (gtk_theming_engine_has_class (engine, "background"))
1428 cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, 0.0); /* transparent */
1429 cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
1435 cairo_pattern_t *other_pattern;
1436 GtkStateFlags other_flags;
1438 cairo_pattern_t *new_pattern = NULL;
1440 if (flags & GTK_STATE_FLAG_PRELIGHT)
1442 other_flags = flags & ~(GTK_STATE_FLAG_PRELIGHT);
1443 progress = 1 - progress;
1446 other_flags = flags | GTK_STATE_FLAG_PRELIGHT;
1448 gtk_theming_engine_get_background_color (engine, other_flags, &other_bg);
1449 gtk_theming_engine_get (engine, other_flags,
1450 "background-image", &other_pattern,
1453 if (pattern && other_pattern)
1455 cairo_pattern_type_t type, other_type;
1458 cairo_pattern_get_color_stop_count (pattern, &n0);
1459 cairo_pattern_get_color_stop_count (other_pattern, &n1);
1460 type = cairo_pattern_get_type (pattern);
1461 other_type = cairo_pattern_get_type (other_pattern);
1463 if (type == other_type && n0 == n1)
1465 gdouble offset0, red0, green0, blue0, alpha0;
1466 gdouble offset1, red1, green1, blue1, alpha1;
1467 gdouble x00, x01, y00, y01, x10, x11, y10, y11;
1468 gdouble r00, r01, r10, r11;
1471 if (type == CAIRO_PATTERN_TYPE_LINEAR)
1473 cairo_pattern_get_linear_points (pattern, &x00, &y00, &x01, &y01);
1474 cairo_pattern_get_linear_points (other_pattern, &x10, &y10, &x11, &y11);
1476 new_pattern = cairo_pattern_create_linear (x00 + (x10 - x00) * progress,
1477 y00 + (y10 - y00) * progress,
1478 x01 + (x11 - x01) * progress,
1479 y01 + (y11 - y01) * progress);
1483 cairo_pattern_get_radial_circles (pattern, &x00, &y00, &r00, &x01, &y01, &r01);
1484 cairo_pattern_get_radial_circles (other_pattern, &x10, &y10, &r10, &x11, &y11, &r11);
1486 new_pattern = cairo_pattern_create_radial (x00 + (x10 - x00) * progress,
1487 y00 + (y10 - y00) * progress,
1488 r00 + (r10 - r00) * progress,
1489 x01 + (x11 - x01) * progress,
1490 y01 + (y11 - y01) * progress,
1491 r01 + (r11 - r01) * progress);
1494 cairo_pattern_set_filter (new_pattern, CAIRO_FILTER_FAST);
1497 /* Blend both gradients into one */
1498 while (i < n0 && i < n1)
1500 cairo_pattern_get_color_stop_rgba (pattern, i,
1502 &red0, &green0, &blue0,
1504 cairo_pattern_get_color_stop_rgba (other_pattern, i,
1506 &red1, &green1, &blue1,
1509 cairo_pattern_add_color_stop_rgba (new_pattern,
1510 offset0 + ((offset1 - offset0) * progress),
1511 red0 + ((red1 - red0) * progress),
1512 green0 + ((green1 - green0) * progress),
1513 blue0 + ((blue1 - blue0) * progress),
1514 alpha0 + ((alpha1 - alpha0) * progress));
1522 cairo_rectangle (cr, 0, 0, width, height);
1525 cairo_push_group (cr);
1527 cairo_scale (cr, width, height);
1528 cairo_set_source (cr, other_pattern);
1529 cairo_paint_with_alpha (cr, progress);
1530 cairo_set_source (cr, pattern);
1531 cairo_paint_with_alpha (cr, 1.0 - progress);
1533 new_pattern = cairo_pop_group (cr);
1538 else if (pattern || other_pattern)
1542 gdouble x0, y0, x1, y1, r0, r1;
1545 /* Blend a pattern with a color */
1550 progress = 1 - progress;
1558 if (cairo_pattern_get_type (p) == CAIRO_PATTERN_TYPE_LINEAR)
1560 cairo_pattern_get_linear_points (p, &x0, &y0, &x1, &y1);
1561 new_pattern = cairo_pattern_create_linear (x0, y0, x1, y1);
1565 cairo_pattern_get_radial_circles (p, &x0, &y0, &r0, &x1, &y1, &r1);
1566 new_pattern = cairo_pattern_create_radial (x0, y0, r0, x1, y1, r1);
1569 cairo_pattern_get_color_stop_count (p, &n);
1571 for (i = 0; i < n; i++)
1573 gdouble red1, green1, blue1, alpha1;
1576 cairo_pattern_get_color_stop_rgba (p, i,
1578 &red1, &green1, &blue1,
1580 cairo_pattern_add_color_stop_rgba (new_pattern, offset,
1581 c->red + ((red1 - c->red) * progress),
1582 c->green + ((green1 - c->green) * progress),
1583 c->blue + ((blue1 - c->blue) * progress),
1584 c->alpha + ((alpha1 - c->alpha) * progress));
1589 /* Merge just colors */
1590 new_pattern = cairo_pattern_create_rgba (CLAMP (bg_color.red + ((other_bg.red - bg_color.red) * progress), 0, 1),
1591 CLAMP (bg_color.green + ((other_bg.green - bg_color.green) * progress), 0, 1),
1592 CLAMP (bg_color.blue + ((other_bg.blue - bg_color.blue) * progress), 0, 1),
1593 CLAMP (bg_color.alpha + ((other_bg.alpha - bg_color.alpha) * progress), 0, 1));
1598 /* Replace pattern to use */
1599 cairo_pattern_destroy (pattern);
1600 pattern = new_pattern;
1604 cairo_pattern_destroy (other_pattern);
1607 gtk_theming_engine_get_border (engine, flags, &border);
1609 /* In the CSS box model, by default the background positioning area is
1610 * the padding-box, i.e. all the border-box minus the borders themselves,
1611 * which determines also its default size, see
1612 * http://dev.w3.org/csswg/css3-background/#background-origin
1614 * In the future we might want to support different origins or clips, but
1615 * right now we just shrink to the default.
1617 _gtk_rounded_box_init_rect (&border_box, 0, 0, width, height);
1618 _gtk_rounded_box_apply_border_radius (&border_box, engine, flags, junction);
1619 _gtk_rounded_box_shrink (&border_box,
1620 border.top, border.right,
1621 border.bottom, border.left);
1622 _gtk_rounded_box_path (&border_box, cr);
1626 cairo_surface_t *surface;
1627 int scale_width, scale_height;
1629 if (cairo_pattern_get_surface (pattern, &surface) != CAIRO_STATUS_SUCCESS)
1632 if (surface && repeat &&
1633 repeat->repeat != GTK_CSS_BACKGROUND_REPEAT_STYLE_NONE)
1635 scale_width = cairo_image_surface_get_width (surface);
1636 scale_height = cairo_image_surface_get_height (surface);
1637 if (repeat->repeat == GTK_CSS_BACKGROUND_REPEAT_STYLE_REPEAT)
1638 cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT);
1639 else if (repeat->repeat == GTK_CSS_BACKGROUND_REPEAT_STYLE_NO_REPEAT)
1640 cairo_pattern_set_extend (pattern, CAIRO_EXTEND_NONE);
1644 cairo_pattern_set_extend (pattern, CAIRO_EXTEND_PAD);
1645 scale_width = width;
1646 scale_height = height;
1649 cairo_scale (cr, scale_width, scale_height);
1650 cairo_set_source (cr, pattern);
1651 cairo_scale (cr, 1.0 / scale_width, 1.0 / scale_height);
1654 gdk_cairo_set_source_rgba (cr, &bg_color);
1659 cairo_pattern_destroy (pattern);
1664 if (box_shadow != NULL)
1666 _gtk_box_shadow_render (box_shadow, cr, &border_box);
1667 _gtk_shadow_unref (box_shadow);
1674 gtk_theming_engine_render_background (GtkThemingEngine *engine,
1681 GtkJunctionSides junction;
1683 junction = gtk_theming_engine_get_junction_sides (engine);
1685 render_background_internal (engine, cr,
1686 x, y, width, height,
1691 gtk_theming_engine_hide_border_sides (GtkBorder *border,
1694 if (hidden_side & SIDE_TOP)
1696 if (hidden_side & SIDE_RIGHT)
1698 if (hidden_side & SIDE_BOTTOM)
1700 if (hidden_side & SIDE_LEFT)
1705 render_frame_internal (GtkThemingEngine *engine,
1712 GtkJunctionSides junction)
1714 GtkStateFlags state;
1715 GtkBorderStyle border_style;
1716 GtkRoundedBox border_box, padding_box;
1720 static const guint current_side[4] = { SIDE_TOP, SIDE_RIGHT, SIDE_BOTTOM, SIDE_LEFT };
1724 state = gtk_theming_engine_get_state (engine);
1726 gtk_theming_engine_get_border (engine, state, &border);
1727 gtk_theming_engine_hide_border_sides (&border, hidden_side);
1729 gtk_theming_engine_get (engine, state,
1730 "border-style", &border_style,
1731 "border-top-color", &colors[0],
1732 "border-right-color", &colors[1],
1733 "border-bottom-color", &colors[2],
1734 "border-left-color", &colors[3],
1737 running = gtk_theming_engine_state_is_running (engine, GTK_STATE_PRELIGHT, &progress);
1741 GtkStateFlags other_state;
1742 GdkRGBA *other_colors[4];
1744 if (state & GTK_STATE_FLAG_PRELIGHT)
1746 other_state = state & ~(GTK_STATE_FLAG_PRELIGHT);
1747 progress = 1 - progress;
1750 other_state = state | GTK_STATE_FLAG_PRELIGHT;
1752 gtk_theming_engine_get (engine, other_state,
1753 "border-top-color", &other_colors[0],
1754 "border-right-color", &other_colors[1],
1755 "border-bottom-color", &other_colors[2],
1756 "border-left-color", &other_colors[3],
1759 for (i = 0; i < 4; i++)
1761 colors[i]->red = CLAMP (colors[i]->red + ((other_colors[i]->red - colors[i]->red) * progress), 0, 1);
1762 colors[i]->green = CLAMP (colors[i]->green + ((other_colors[i]->green - colors[i]->green) * progress), 0, 1);
1763 colors[i]->blue = CLAMP (colors[i]->blue + ((other_colors[i]->blue - colors[i]->blue) * progress), 0, 1);
1764 colors[i]->alpha = CLAMP (colors[i]->alpha + ((other_colors[i]->alpha - colors[i]->alpha) * progress), 0, 1);
1765 gdk_rgba_free (other_colors[i]);
1769 switch (border_style)
1772 g_assert_not_reached ();
1773 case GTK_BORDER_STYLE_NONE:
1774 case GTK_BORDER_STYLE_SOLID:
1776 case GTK_BORDER_STYLE_INSET:
1777 color_shade (colors[1], 1.8, colors[1]);
1778 color_shade (colors[2], 1.8, colors[2]);
1780 case GTK_BORDER_STYLE_OUTSET:
1781 color_shade (colors[0], 1.8, colors[0]);
1782 color_shade (colors[3], 1.8, colors[3]);
1788 cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
1790 _gtk_rounded_box_init_rect (&border_box, x, y, width, height);
1791 _gtk_rounded_box_apply_border_radius (&border_box, engine, state, junction);
1792 padding_box = border_box;
1793 _gtk_rounded_box_shrink (&padding_box, border.top, border.right, border.bottom, border.left);
1795 switch (border_style)
1797 case GTK_BORDER_STYLE_NONE:
1799 case GTK_BORDER_STYLE_SOLID:
1800 case GTK_BORDER_STYLE_INSET:
1801 case GTK_BORDER_STYLE_OUTSET:
1803 if (gdk_rgba_equal (colors[0], colors[1]) &&
1804 gdk_rgba_equal (colors[0], colors[2]) &&
1805 gdk_rgba_equal (colors[0], colors[3]))
1807 gdk_cairo_set_source_rgba (cr, colors[0]);
1809 _gtk_rounded_box_path (&border_box, cr);
1810 _gtk_rounded_box_path (&padding_box, cr);
1815 for (i = 0; i < 4; i++)
1817 if (hidden_side & current_side[i])
1820 for (j = 0; j < 4; j++)
1822 if (hidden_side & current_side[j])
1826 gdk_rgba_equal (colors[i], colors[j]))
1828 /* We were already painted when i == j */
1833 _gtk_rounded_box_path_top (&border_box, &padding_box, cr);
1835 _gtk_rounded_box_path_right (&border_box, &padding_box, cr);
1837 _gtk_rounded_box_path_bottom (&border_box, &padding_box, cr);
1839 _gtk_rounded_box_path_left (&border_box, &padding_box, cr);
1842 /* We were already painted when i == j */
1846 gdk_cairo_set_source_rgba (cr, colors[i]);
1856 for (i = 0; i < 4; i++)
1857 gdk_rgba_free (colors[i]);
1861 gtk_theming_engine_render_frame (GtkThemingEngine *engine,
1868 GtkStateFlags flags;
1869 GtkBorderStyle border_style;
1870 GtkJunctionSides junction;
1871 GtkBorderImage *border_image;
1874 flags = gtk_theming_engine_get_state (engine);
1875 junction = gtk_theming_engine_get_junction_sides (engine);
1876 gtk_theming_engine_get_border (engine, flags, &border);
1878 gtk_theming_engine_get (engine, flags,
1879 "border-image", &border_image,
1880 "border-style", &border_style,
1883 if (border_image != NULL)
1885 _gtk_border_image_render (border_image, &border,
1886 cr, x, y, width, height);
1887 _gtk_border_image_unref (border_image);
1889 else if (border_style != GTK_BORDER_STYLE_NONE)
1890 render_frame_internal (engine, cr,
1891 x, y, width, height,
1896 gtk_theming_engine_render_expander (GtkThemingEngine *engine,
1903 GtkStateFlags flags;
1904 GdkRGBA outline_color, fg_color;
1905 double vertical_overshoot;
1908 double interp; /* interpolation factor for center position */
1909 double x_double_horz, y_double_horz;
1910 double x_double_vert, y_double_vert;
1911 double x_double, y_double;
1914 gboolean running, is_rtl;
1918 flags = gtk_theming_engine_get_state (engine);
1920 gtk_theming_engine_get_color (engine, flags, &fg_color);
1921 gtk_theming_engine_get_border_color (engine, flags, &outline_color);
1923 running = gtk_theming_engine_state_is_running (engine, GTK_STATE_ACTIVE, &progress);
1924 is_rtl = (gtk_theming_engine_get_direction (engine) == GTK_TEXT_DIR_RTL);
1928 progress = (flags & GTK_STATE_FLAG_ACTIVE) ? 1 : 0;
1930 if (!gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_HORIZONTAL))
1933 angle = (G_PI) - ((G_PI / 2) * progress);
1935 angle = (G_PI / 2) * progress;
1940 angle = (G_PI / 2) + ((G_PI / 2) * progress);
1942 angle = (G_PI / 2) - ((G_PI / 2) * progress);
1947 /* Compute distance that the stroke extends beyonds the end
1948 * of the triangle we draw.
1950 vertical_overshoot = line_width / 2.0 * (1. / tan (G_PI / 8));
1952 /* For odd line widths, we end the vertical line of the triangle
1953 * at a half pixel, so we round differently.
1955 if (line_width % 2 == 1)
1956 vertical_overshoot = ceil (0.5 + vertical_overshoot) - 0.5;
1958 vertical_overshoot = ceil (vertical_overshoot);
1960 /* Adjust the size of the triangle we draw so that the entire stroke fits
1962 diameter = (gint) MAX (3, width - 2 * vertical_overshoot);
1964 /* If the line width is odd, we want the diameter to be even,
1965 * and vice versa, so force the sum to be odd. This relationship
1966 * makes the point of the triangle look right.
1968 diameter -= (1 - (diameter + line_width) % 2);
1970 radius = diameter / 2.;
1972 /* Adjust the center so that the stroke is properly aligned with
1973 * the pixel grid. The center adjustment is different for the
1974 * horizontal and vertical orientations. For intermediate positions
1975 * we interpolate between the two.
1977 x_double_vert = floor ((x + width / 2) - (radius + line_width) / 2.) + (radius + line_width) / 2.;
1978 y_double_vert = (y + height / 2) - 0.5;
1980 x_double_horz = (x + width / 2) - 0.5;
1981 y_double_horz = floor ((y + height / 2) - (radius + line_width) / 2.) + (radius + line_width) / 2.;
1983 x_double = x_double_vert * (1 - interp) + x_double_horz * interp;
1984 y_double = y_double_vert * (1 - interp) + y_double_horz * interp;
1986 cairo_translate (cr, x_double, y_double);
1987 cairo_rotate (cr, angle);
1989 cairo_move_to (cr, - radius / 2., - radius);
1990 cairo_line_to (cr, radius / 2., 0);
1991 cairo_line_to (cr, - radius / 2., radius);
1992 cairo_close_path (cr);
1994 cairo_set_line_width (cr, line_width);
1996 gdk_cairo_set_source_rgba (cr, &fg_color);
1998 cairo_fill_preserve (cr);
2000 gdk_cairo_set_source_rgba (cr, &outline_color);
2007 gtk_theming_engine_render_focus (GtkThemingEngine *engine,
2014 GtkStateFlags flags;
2020 flags = gtk_theming_engine_get_state (engine);
2022 gtk_theming_engine_get_color (engine, flags, &color);
2024 gtk_theming_engine_get_style (engine,
2025 "focus-line-width", &line_width,
2026 "focus-line-pattern", (gchar *) &dash_list,
2029 cairo_set_line_width (cr, (gdouble) line_width);
2033 gint n_dashes = strlen ((const gchar *) dash_list);
2034 gdouble *dashes = g_new (gdouble, n_dashes);
2035 gdouble total_length = 0;
2036 gdouble dash_offset;
2039 for (i = 0; i < n_dashes; i++)
2041 dashes[i] = dash_list[i];
2042 total_length += dash_list[i];
2045 /* The dash offset here aligns the pattern to integer pixels
2046 * by starting the dash at the right side of the left border
2047 * Negative dash offsets in cairo don't work
2048 * (https://bugs.freedesktop.org/show_bug.cgi?id=2729)
2050 dash_offset = - line_width / 2.;
2052 while (dash_offset < 0)
2053 dash_offset += total_length;
2055 cairo_set_dash (cr, dashes, n_dashes, dash_offset);
2059 cairo_rectangle (cr,
2060 x + line_width / 2.,
2061 y + line_width / 2.,
2063 height - line_width);
2065 gdk_cairo_set_source_rgba (cr, &color);
2074 gtk_theming_engine_render_line (GtkThemingEngine *engine,
2082 GtkStateFlags flags;
2084 flags = gtk_theming_engine_get_state (engine);
2087 gtk_theming_engine_get_color (engine, flags, &color);
2089 cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE);
2090 cairo_set_line_width (cr, 1);
2092 cairo_move_to (cr, x0 + 0.5, y0 + 0.5);
2093 cairo_line_to (cr, x1 + 0.5, y1 + 0.5);
2095 gdk_cairo_set_source_rgba (cr, &color);
2102 prepare_context_for_layout (cairo_t *cr,
2105 PangoLayout *layout)
2107 const PangoMatrix *matrix;
2109 matrix = pango_context_get_matrix (pango_layout_get_context (layout));
2111 cairo_move_to (cr, x, y);
2115 cairo_matrix_t cairo_matrix;
2117 cairo_matrix_init (&cairo_matrix,
2118 matrix->xx, matrix->yx,
2119 matrix->xy, matrix->yy,
2120 matrix->x0, matrix->y0);
2122 cairo_transform (cr, &cairo_matrix);
2127 gtk_theming_engine_render_layout (GtkThemingEngine *engine,
2131 PangoLayout *layout)
2134 GtkShadow *text_shadow = NULL;
2135 GtkStateFlags flags;
2140 flags = gtk_theming_engine_get_state (engine);
2141 gtk_theming_engine_get_color (engine, flags, &fg_color);
2143 running = gtk_theming_engine_state_is_running (engine, GTK_STATE_PRELIGHT, &progress);
2147 GtkStateFlags other_flags;
2150 if (flags & GTK_STATE_FLAG_PRELIGHT)
2152 other_flags = flags & ~(GTK_STATE_FLAG_PRELIGHT);
2153 progress = 1 - progress;
2156 other_flags = flags | GTK_STATE_FLAG_PRELIGHT;
2158 gtk_theming_engine_get_color (engine, other_flags, &other_fg);
2160 fg_color.red = CLAMP (fg_color.red + ((other_fg.red - fg_color.red) * progress), 0, 1);
2161 fg_color.green = CLAMP (fg_color.green + ((other_fg.green - fg_color.green) * progress), 0, 1);
2162 fg_color.blue = CLAMP (fg_color.blue + ((other_fg.blue - fg_color.blue) * progress), 0, 1);
2163 fg_color.alpha = CLAMP (fg_color.alpha + ((other_fg.alpha - fg_color.alpha) * progress), 0, 1);
2166 gtk_theming_engine_get (engine, flags,
2167 "text-shadow", &text_shadow,
2170 prepare_context_for_layout (cr, x, y, layout);
2172 if (text_shadow != NULL)
2174 _gtk_text_shadow_paint_layout (text_shadow, cr, layout);
2175 _gtk_shadow_unref (text_shadow);
2178 gdk_cairo_set_source_rgba (cr, &fg_color);
2179 pango_cairo_show_layout (cr, layout);
2185 gtk_theming_engine_render_slider (GtkThemingEngine *engine,
2191 GtkOrientation orientation)
2193 const GtkWidgetPath *path;
2196 path = gtk_theming_engine_get_path (engine);
2198 gtk_theming_engine_render_background (engine, cr, x, y, width, height);
2199 gtk_theming_engine_render_frame (engine, cr, x, y, width, height);
2201 /* FIXME: thickness */
2204 if (gtk_widget_path_is_type (path, GTK_TYPE_SCALE))
2206 if (orientation == GTK_ORIENTATION_VERTICAL)
2207 gtk_theming_engine_render_line (engine, cr,
2209 y + (gint) height / 2,
2210 x + width - thickness - 1,
2211 y + (gint) height / 2);
2213 gtk_theming_engine_render_line (engine, cr,
2214 x + (gint) width / 2,
2216 x + (gint) width / 2,
2217 y + height - thickness - 1);
2222 gtk_theming_engine_render_frame_gap (GtkThemingEngine *engine,
2228 GtkPositionType gap_side,
2232 GtkJunctionSides junction;
2233 GtkStateFlags state;
2235 GtkCssBorderCornerRadius *top_left_radius, *top_right_radius;
2236 GtkCssBorderCornerRadius *bottom_left_radius, *bottom_right_radius;
2237 GtkCssBorderRadius border_radius = { { 0, }, };
2238 gdouble x0, y0, x1, y1, xc, yc, wc, hc;
2241 xc = yc = wc = hc = 0;
2242 state = gtk_theming_engine_get_state (engine);
2243 junction = gtk_theming_engine_get_junction_sides (engine);
2245 gtk_theming_engine_get_border (engine, state, &border);
2246 gtk_theming_engine_get (engine, state,
2247 /* Can't use border-radius as it's an int for
2248 * backwards compat */
2249 "border-top-left-radius", &top_left_radius,
2250 "border-top-right-radius", &top_right_radius,
2251 "border-bottom-right-radius", &bottom_right_radius,
2252 "border-bottom-left-radius", &bottom_left_radius,
2255 if (top_left_radius)
2256 border_radius.top_left = *top_left_radius;
2257 g_free (top_left_radius);
2258 if (top_right_radius)
2259 border_radius.top_right = *top_right_radius;
2260 g_free (top_right_radius);
2261 if (bottom_right_radius)
2262 border_radius.bottom_right = *bottom_right_radius;
2263 g_free (bottom_right_radius);
2264 if (bottom_left_radius)
2265 border_radius.bottom_left = *bottom_left_radius;
2266 g_free (bottom_left_radius);
2268 border_width = MIN (MIN (border.top, border.bottom),
2269 MIN (border.left, border.right));
2276 xc = x + xy0_gap + border_width;
2278 wc = MAX (xy1_gap - xy0_gap - 2 * border_width, 0);
2281 if (xy0_gap < border_radius.top_left.horizontal)
2282 junction |= GTK_JUNCTION_CORNER_TOPLEFT;
2284 if (xy1_gap > width - border_radius.top_right.horizontal)
2285 junction |= GTK_JUNCTION_CORNER_TOPRIGHT;
2287 case GTK_POS_BOTTOM:
2288 xc = x + xy0_gap + border_width;
2289 yc = y + height - border_width;
2290 wc = MAX (xy1_gap - xy0_gap - 2 * border_width, 0);
2293 if (xy0_gap < border_radius.bottom_left.horizontal)
2294 junction |= GTK_JUNCTION_CORNER_BOTTOMLEFT;
2296 if (xy1_gap > width - border_radius.bottom_right.horizontal)
2297 junction |= GTK_JUNCTION_CORNER_BOTTOMRIGHT;
2302 yc = y + xy0_gap + border_width;
2304 hc = MAX (xy1_gap - xy0_gap - 2 * border_width, 0);
2306 if (xy0_gap < border_radius.top_left.vertical)
2307 junction |= GTK_JUNCTION_CORNER_TOPLEFT;
2309 if (xy1_gap > height - border_radius.bottom_left.vertical)
2310 junction |= GTK_JUNCTION_CORNER_BOTTOMLEFT;
2314 xc = x + width - border_width;
2315 yc = y + xy0_gap + border_width;
2317 hc = MAX (xy1_gap - xy0_gap - 2 * border_width, 0);
2319 if (xy0_gap < border_radius.top_right.vertical)
2320 junction |= GTK_JUNCTION_CORNER_TOPRIGHT;
2322 if (xy1_gap > height - border_radius.bottom_right.vertical)
2323 junction |= GTK_JUNCTION_CORNER_BOTTOMRIGHT;
2328 cairo_clip_extents (cr, &x0, &y0, &x1, &y1);
2329 cairo_rectangle (cr, x0, y0, x1 - x0, yc - y0);
2330 cairo_rectangle (cr, x0, yc, xc - x0, hc);
2331 cairo_rectangle (cr, xc + wc, yc, x1 - (xc + wc), hc);
2332 cairo_rectangle (cr, x0, yc + hc, x1 - x0, y1 - (yc + hc));
2335 render_frame_internal (engine, cr,
2336 x, y, width, height,
2343 gtk_theming_engine_render_extension (GtkThemingEngine *engine,
2349 GtkPositionType gap_side)
2351 GtkJunctionSides junction = 0;
2352 guint hidden_side = 0;
2359 junction = GTK_JUNCTION_LEFT;
2360 hidden_side = SIDE_LEFT;
2362 cairo_translate (cr, x + width, y);
2363 cairo_rotate (cr, G_PI / 2);
2366 junction = GTK_JUNCTION_RIGHT;
2367 hidden_side = SIDE_RIGHT;
2369 cairo_translate (cr, x, y + height);
2370 cairo_rotate (cr, - G_PI / 2);
2373 junction = GTK_JUNCTION_TOP;
2374 hidden_side = SIDE_TOP;
2376 cairo_translate (cr, x + width, y + height);
2377 cairo_rotate (cr, G_PI);
2379 case GTK_POS_BOTTOM:
2380 junction = GTK_JUNCTION_BOTTOM;
2381 hidden_side = SIDE_BOTTOM;
2383 cairo_translate (cr, x, y);
2387 if (gap_side == GTK_POS_TOP ||
2388 gap_side == GTK_POS_BOTTOM)
2389 render_background_internal (engine, cr,
2390 0, 0, width, height,
2391 GTK_JUNCTION_BOTTOM);
2393 render_background_internal (engine, cr,
2394 0, 0, height, width,
2395 GTK_JUNCTION_BOTTOM);
2400 render_frame_internal (engine, cr,
2401 x, y, width, height,
2402 hidden_side, junction);
2408 render_dot (cairo_t *cr,
2409 const GdkRGBA *lighter,
2410 const GdkRGBA *darker,
2415 size = CLAMP ((gint) size, 2, 3);
2419 gdk_cairo_set_source_rgba (cr, lighter);
2420 cairo_rectangle (cr, x, y, 1, 1);
2421 cairo_rectangle (cr, x + 1, y + 1, 1, 1);
2426 gdk_cairo_set_source_rgba (cr, lighter);
2427 cairo_rectangle (cr, x, y, 2, 1);
2428 cairo_rectangle (cr, x, y, 1, 2);
2431 gdk_cairo_set_source_rgba (cr, darker);
2432 cairo_rectangle (cr, x + 1, y + 1, 2, 1);
2433 cairo_rectangle (cr, x + 2, y, 1, 2);
2439 gtk_theming_engine_render_handle (GtkThemingEngine *engine,
2446 GtkStateFlags flags;
2447 GdkRGBA bg_color, lighter, darker;
2448 GtkJunctionSides sides;
2452 flags = gtk_theming_engine_get_state (engine);
2454 cairo_set_line_width (cr, 1.0);
2455 sides = gtk_theming_engine_get_junction_sides (engine);
2456 gtk_theming_engine_get_background_color (engine, flags, &bg_color);
2458 color_shade (&bg_color, 0.7, &darker);
2459 color_shade (&bg_color, 1.3, &lighter);
2461 render_background_internal (engine, cr, x, y, width, height, sides);
2463 if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_GRIP))
2465 /* reduce confusing values to a meaningful state */
2466 if ((sides & (GTK_JUNCTION_CORNER_TOPLEFT | GTK_JUNCTION_CORNER_BOTTOMRIGHT)) == (GTK_JUNCTION_CORNER_TOPLEFT | GTK_JUNCTION_CORNER_BOTTOMRIGHT))
2467 sides &= ~GTK_JUNCTION_CORNER_TOPLEFT;
2469 if ((sides & (GTK_JUNCTION_CORNER_TOPRIGHT | GTK_JUNCTION_CORNER_BOTTOMLEFT)) == (GTK_JUNCTION_CORNER_TOPRIGHT | GTK_JUNCTION_CORNER_BOTTOMLEFT))
2470 sides &= ~GTK_JUNCTION_CORNER_TOPRIGHT;
2473 sides = GTK_JUNCTION_CORNER_BOTTOMRIGHT;
2475 /* align drawing area to the connected side */
2476 if (sides == GTK_JUNCTION_LEFT)
2481 else if (sides == GTK_JUNCTION_CORNER_TOPLEFT)
2485 else if (height < width)
2488 else if (sides == GTK_JUNCTION_CORNER_BOTTOMLEFT)
2490 /* make it square, aligning to bottom left */
2493 y += (height - width);
2496 else if (height < width)
2499 else if (sides == GTK_JUNCTION_RIGHT)
2501 /* aligning to right */
2504 x += (width - height);
2508 else if (sides == GTK_JUNCTION_CORNER_TOPRIGHT)
2512 else if (height < width)
2514 x += (width - height);
2518 else if (sides == GTK_JUNCTION_CORNER_BOTTOMRIGHT)
2520 /* make it square, aligning to bottom right */
2523 y += (height - width);
2526 else if (height < width)
2528 x += (width - height);
2532 else if (sides == GTK_JUNCTION_TOP)
2537 else if (sides == GTK_JUNCTION_BOTTOM)
2539 /* align to bottom */
2542 y += (height - width);
2547 g_assert_not_reached ();
2549 if (sides == GTK_JUNCTION_LEFT ||
2550 sides == GTK_JUNCTION_RIGHT)
2556 while (xi < x + width)
2558 gdk_cairo_set_source_rgba (cr, &lighter);
2559 add_path_line (cr, x, y, x, y + height);
2563 gdk_cairo_set_source_rgba (cr, &darker);
2564 add_path_line (cr, xi, y, xi, y + height);
2569 else if (sides == GTK_JUNCTION_TOP ||
2570 sides == GTK_JUNCTION_BOTTOM)
2576 while (yi < y + height)
2578 gdk_cairo_set_source_rgba (cr, &lighter);
2579 add_path_line (cr, x, yi, x + width, yi);
2583 gdk_cairo_set_source_rgba (cr, &darker);
2584 add_path_line (cr, x, yi, x + width, yi);
2589 else if (sides == GTK_JUNCTION_CORNER_TOPLEFT)
2598 gdk_cairo_set_source_rgba (cr, &darker);
2599 add_path_line (cr, xi, y, x, yi);
2605 add_path_line (cr, xi, y, x, yi);
2611 gdk_cairo_set_source_rgba (cr, &lighter);
2612 add_path_line (cr, xi, y, x, yi);
2619 else if (sides == GTK_JUNCTION_CORNER_TOPRIGHT)
2626 while (xi < (x + width - 3))
2628 gdk_cairo_set_source_rgba (cr, &lighter);
2629 add_path_line (cr, xi, y, x + width, yi);
2635 gdk_cairo_set_source_rgba (cr, &darker);
2636 add_path_line (cr, xi, y, x + width, yi);
2642 add_path_line (cr, xi, y, x + width, yi);
2649 else if (sides == GTK_JUNCTION_CORNER_BOTTOMLEFT)
2658 gdk_cairo_set_source_rgba (cr, &darker);
2659 add_path_line (cr, x, yi, xi, y + height);
2665 add_path_line (cr, x, yi, xi, y + height);
2671 gdk_cairo_set_source_rgba (cr, &lighter);
2672 add_path_line (cr, x, yi, xi, y + height);
2679 else if (sides == GTK_JUNCTION_CORNER_BOTTOMRIGHT)
2686 while (xi < (x + width - 3))
2688 gdk_cairo_set_source_rgba (cr, &lighter);
2689 add_path_line (cr, xi, y + height, x + width, yi);
2695 gdk_cairo_set_source_rgba (cr, &darker);
2696 add_path_line (cr, xi, y + height, x + width, yi);
2702 add_path_line (cr, xi, y + height, x + width, yi);
2710 else if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_PANE_SEPARATOR))
2713 for (xx = x + width / 2 - 15; xx <= x + width / 2 + 15; xx += 5)
2714 render_dot (cr, &lighter, &darker, xx, y + height / 2 - 1, 3);
2716 for (yy = y + height / 2 - 15; yy <= y + height / 2 + 15; yy += 5)
2717 render_dot (cr, &lighter, &darker, x + width / 2 - 1, yy, 3);
2721 for (yy = y; yy < y + height; yy += 3)
2722 for (xx = x; xx < x + width; xx += 6)
2724 render_dot (cr, &lighter, &darker, xx, yy, 2);
2725 render_dot (cr, &lighter, &darker, xx + 3, yy + 1, 2);
2733 _gtk_theming_engine_paint_spinner (cairo_t *cr,
2738 guint num_steps, step;
2745 step = (guint) (progress * num_steps);
2751 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
2752 cairo_set_line_width (cr, 2.0);
2754 half = num_steps / 2;
2756 for (i = 0; i < num_steps; i++)
2758 gint inset = 0.7 * radius;
2760 /* transparency is a function of time and intial value */
2761 gdouble t = 1.0 - (gdouble) ((i + step) % num_steps) / num_steps;
2762 gdouble xscale = - sin (i * G_PI / half);
2763 gdouble yscale = - cos (i * G_PI / half);
2765 cairo_set_source_rgba (cr,
2772 (radius - inset) * xscale,
2773 (radius - inset) * yscale);
2785 render_spinner (GtkThemingEngine *engine,
2792 GtkStateFlags state;
2798 state = gtk_theming_engine_get_state (engine);
2800 if (!gtk_theming_engine_state_is_running (engine, GTK_STATE_ACTIVE, &progress))
2803 radius = MIN (width / 2, height / 2);
2805 gtk_theming_engine_get_color (engine, state, &color);
2806 gtk_theming_engine_get (engine, state,
2807 "icon-shadow", &shadow,
2811 cairo_translate (cr, x + width / 2, y + height / 2);
2815 _gtk_icon_shadow_paint_spinner (shadow, cr,
2818 _gtk_shadow_unref (shadow);
2821 _gtk_theming_engine_paint_spinner (cr,
2830 gtk_theming_engine_render_activity (GtkThemingEngine *engine,
2837 if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_SPINNER))
2839 render_spinner (engine, cr, x, y, width, height);
2843 gtk_theming_engine_render_background (engine, cr, x, y, width, height);
2844 gtk_theming_engine_render_frame (engine, cr, x, y, width, height);
2849 scale_or_ref (GdkPixbuf *src,
2853 if (width == gdk_pixbuf_get_width (src) &&
2854 height == gdk_pixbuf_get_height (src))
2855 return g_object_ref (src);
2857 return gdk_pixbuf_scale_simple (src,
2859 GDK_INTERP_BILINEAR);
2863 lookup_icon_size (GtkThemingEngine *engine,
2869 GtkSettings *settings;
2871 screen = gtk_theming_engine_get_screen (engine);
2872 settings = gtk_settings_get_for_screen (screen);
2874 return gtk_icon_size_lookup_for_settings (settings, size, width, height);
2878 colorshift_source (cairo_t *cr,
2881 cairo_pattern_t *source;
2886 source = cairo_pattern_reference (cairo_get_source (cr));
2888 cairo_set_source_rgb (cr, shift, shift, shift);
2889 cairo_set_operator (cr, CAIRO_OPERATOR_COLOR_DODGE);
2891 cairo_mask (cr, source);
2893 cairo_pattern_destroy (source);
2898 gtk_theming_engine_render_icon_pixbuf (GtkThemingEngine *engine,
2899 const GtkIconSource *source,
2904 GdkPixbuf *base_pixbuf;
2905 GtkStateFlags state;
2909 cairo_surface_t *surface;
2911 base_pixbuf = gtk_icon_source_get_pixbuf (source);
2912 state = gtk_theming_engine_get_state (engine);
2914 g_return_val_if_fail (base_pixbuf != NULL, NULL);
2916 if (size != (GtkIconSize) -1 &&
2917 !lookup_icon_size (engine, size, &width, &height))
2919 g_warning (G_STRLOC ": invalid icon size '%d'", size);
2923 /* If the size was wildcarded, and we're allowed to scale, then scale; otherwise,
2926 if (size != (GtkIconSize) -1 &&
2927 gtk_icon_source_get_size_wildcarded (source))
2928 scaled = scale_or_ref (base_pixbuf, width, height);
2930 scaled = g_object_ref (base_pixbuf);
2932 /* If the state was wildcarded, then generate a state. */
2933 if (gtk_icon_source_get_state_wildcarded (source))
2935 if (state & GTK_STATE_FLAG_INSENSITIVE)
2937 surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
2938 gdk_pixbuf_get_width (scaled),
2939 gdk_pixbuf_get_height (scaled));
2940 cr = cairo_create (surface);
2941 gdk_cairo_set_source_pixbuf (cr, scaled, 0, 0);
2942 cairo_paint_with_alpha (cr, 0.5);
2946 g_object_unref (scaled);
2947 stated = gdk_pixbuf_get_from_surface (surface, 0, 0,
2948 cairo_image_surface_get_width (surface),
2949 cairo_image_surface_get_height (surface));
2950 cairo_surface_destroy (surface);
2952 else if (state & GTK_STATE_FLAG_PRELIGHT)
2954 surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
2955 gdk_pixbuf_get_width (scaled),
2956 gdk_pixbuf_get_height (scaled));
2958 cr = cairo_create (surface);
2959 gdk_cairo_set_source_pixbuf (cr, scaled, 0, 0);
2960 colorshift_source (cr, 0.10);
2964 g_object_unref (scaled);
2965 stated = gdk_pixbuf_get_from_surface (surface, 0, 0,
2966 cairo_image_surface_get_width (surface),
2967 cairo_image_surface_get_height (surface));
2968 cairo_surface_destroy (surface);
2980 gtk_theming_engine_render_icon (GtkThemingEngine *engine,
2986 GtkStateFlags state;
2987 GtkShadow *icon_shadow;
2989 state = gtk_theming_engine_get_state (engine);
2993 gdk_cairo_set_source_pixbuf (cr, pixbuf, x, y);
2995 gtk_theming_engine_get (engine, state,
2996 "icon-shadow", &icon_shadow,
2999 if (icon_shadow != NULL)
3001 _gtk_icon_shadow_paint (icon_shadow, cr);
3002 _gtk_shadow_unref (icon_shadow);