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, see <http://www.gnu.org/licenses/>.
20 #include "gtkprivate.h"
21 #include "gtkstyleprovider.h"
25 * SECTION:gtkstyleprovider
26 * @Short_description: Interface to provide style information to GtkStyleContext
27 * @Title: GtkStyleProvider
28 * @See_also: #GtkStyleContext, #GtkCssProvider
30 * GtkStyleProvider is an interface used to provide style information to a #GtkStyleContext.
31 * See gtk_style_context_add_provider() and gtk_style_context_add_provider_for_screen().
34 static void gtk_style_provider_iface_init (gpointer g_iface);
37 gtk_style_provider_get_type (void)
39 static GType style_provider_type = 0;
41 if (!style_provider_type)
42 style_provider_type = g_type_register_static_simple (G_TYPE_INTERFACE,
43 I_("GtkStyleProvider"),
44 sizeof (GtkStyleProviderIface),
45 (GClassInitFunc) gtk_style_provider_iface_init,
47 return style_provider_type;
51 gtk_style_provider_iface_init (gpointer g_iface)
56 * gtk_style_provider_get_style:
57 * @provider: a #GtkStyleProvider
58 * @path: #GtkWidgetPath to query
60 * Returns the style settings affecting a widget defined by @path, or %NULL if
61 * @provider doesn't contemplate styling @path.
63 * Returns: (transfer full): a #GtkStyleProperties containing the
64 * style settings affecting @path
69 gtk_style_provider_get_style (GtkStyleProvider *provider,
72 GtkStyleProviderIface *iface;
74 g_return_val_if_fail (GTK_IS_STYLE_PROVIDER (provider), NULL);
76 iface = GTK_STYLE_PROVIDER_GET_IFACE (provider);
78 if (!iface->get_style)
81 return iface->get_style (provider, path);
85 * gtk_style_provider_get_style_property:
86 * @provider: a #GtkStyleProvider
87 * @path: #GtkWidgetPath to query
88 * @state: state to query the style property for
89 * @pspec: The #GParamSpec to query
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 @path.
95 * Returns: %TRUE if the property was found and has a value, %FALSE otherwise
98 gtk_style_provider_get_style_property (GtkStyleProvider *provider,
104 GtkStyleProviderIface *iface;
106 g_return_val_if_fail (GTK_IS_STYLE_PROVIDER (provider), FALSE);
107 g_return_val_if_fail (G_IS_PARAM_SPEC (pspec), FALSE);
108 g_return_val_if_fail (path != NULL, FALSE);
109 g_return_val_if_fail (g_type_is_a (gtk_widget_path_get_object_type (path), pspec->owner_type), FALSE);
110 g_return_val_if_fail (value != NULL, FALSE);
112 iface = GTK_STYLE_PROVIDER_GET_IFACE (provider);
114 if (!iface->get_style_property)
117 return iface->get_style_property (provider, path, state, pspec, value);
121 * gtk_style_provider_get_icon_factory:
122 * @provider: a #GtkStyleProvider
123 * @path: #GtkWidgetPath to query
125 * Returns the #GtkIconFactory defined to be in use for @path, or %NULL if none
128 * Returns: (transfer none): The icon factory to use for @path, or %NULL
133 gtk_style_provider_get_icon_factory (GtkStyleProvider *provider,
136 GtkStyleProviderIface *iface;
138 g_return_val_if_fail (GTK_IS_STYLE_PROVIDER (provider), NULL);
139 g_return_val_if_fail (path != NULL, NULL);
141 iface = GTK_STYLE_PROVIDER_GET_IFACE (provider);
143 if (!iface->get_icon_factory)
146 return iface->get_icon_factory (provider, path);