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.
22 #include "gtkprivate.h"
23 #include "gtkstyleprovider.h"
27 * SECTION:gtkstyleprovider
28 * @Short_description: Interface to provide style information to #GtkStyleContext
29 * @Title: GtkStyleProvider
30 * @See_also: #GtkStyleContext, #GtkCssProvider
32 * #GtkStyleProvider is an interface used to provide style information to a #GtkStyleContext,
33 * see gtk_style_context_add_provider() and gtk_style_context_add_provider_for_screen().
36 static void gtk_style_provider_iface_init (gpointer g_iface);
39 gtk_style_provider_get_type (void)
41 static GType style_provider_type = 0;
43 if (!style_provider_type)
44 style_provider_type = g_type_register_static_simple (G_TYPE_INTERFACE,
45 I_("GtkStyleProvider"),
46 sizeof (GtkStyleProviderIface),
47 (GClassInitFunc) gtk_style_provider_iface_init,
49 return style_provider_type;
53 gtk_style_provider_iface_init (gpointer g_iface)
58 * gtk_style_provider_get_style:
59 * @provider: a #GtkStyleProvider
60 * @path: #GtkWidgetPath to query
62 * Returns the style settings affecting a widget defined by @path, or %NULL if
63 * @provider doesn't contemplate styling @path.
65 * Returns: a #GtkStyleSet containing the style settings affecting @path
70 gtk_style_provider_get_style (GtkStyleProvider *provider,
73 GtkStyleProviderIface *iface;
75 g_return_val_if_fail (GTK_IS_STYLE_PROVIDER (provider), NULL);
77 iface = GTK_STYLE_PROVIDER_GET_IFACE (provider);
79 if (!iface->get_style)
82 return iface->get_style (provider, path);
86 * gtk_style_provider_get_style_property:
87 * @provider: a #GtkStyleProvider
88 * @path: #GtkWidgetPath to query
89 * @property_name: the property name
90 * @value: (out): return location for the property value
92 * Looks up a widget style property as defined by @provider for
93 * the widget represented by @widget_path.
95 * Returns: %TRUE if the property was found and has a value, %FALSE otherwise
98 gtk_style_provider_get_style_property (GtkStyleProvider *provider,
100 const gchar *property_name,
103 GtkStyleProviderIface *iface;
105 g_return_val_if_fail (GTK_IS_STYLE_PROVIDER (provider), FALSE);
106 g_return_val_if_fail (path != NULL, FALSE);
107 g_return_val_if_fail (property_name != NULL, FALSE);
108 g_return_val_if_fail (value != NULL, FALSE);
110 iface = GTK_STYLE_PROVIDER_GET_IFACE (provider);
112 if (!iface->get_style_property)
115 return iface->get_style_property (provider, path, property_name, value);
119 * gtk_style_provider_get_icon_factory:
120 * @provider: a #GtkStyleProvider
121 * @path: #GtkWidgetPath to query
123 * Returns the #GtkIconFactory defined to be in use for @path, or %NULL if none
126 * Returns: The icon factory to use for @path, or %NULL
131 gtk_style_provider_get_icon_factory (GtkStyleProvider *provider,
134 GtkStyleProviderIface *iface;
136 g_return_val_if_fail (GTK_IS_STYLE_PROVIDER (provider), NULL);
137 g_return_val_if_fail (path != NULL, NULL);
139 iface = GTK_STYLE_PROVIDER_GET_IFACE (provider);
141 if (!iface->get_icon_factory)
144 return iface->get_icon_factory (provider, path);