]> Pileus Git - ~andy/gtk/blob - gtk/gtkstyleprovider.c
Updated Russian translation
[~andy/gtk] / gtk / gtkstyleprovider.c
1 /* GTK - The GIMP Toolkit
2  * Copyright (C) 2010 Carlos Garnacho <carlosg@gnome.org>
3  *
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.
8  *
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.
13  *
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/>.
16  */
17
18 #include "config.h"
19
20 #include "gtkprivate.h"
21 #include "gtkstyleprovider.h"
22 #include "gtkintl.h"
23
24 /**
25  * SECTION:gtkstyleprovider
26  * @Short_description: Interface to provide style information to GtkStyleContext
27  * @Title: GtkStyleProvider
28  * @See_also: #GtkStyleContext, #GtkCssProvider
29  *
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().
32  */
33
34 static void gtk_style_provider_iface_init (gpointer g_iface);
35
36 GType
37 gtk_style_provider_get_type (void)
38 {
39   static GType style_provider_type = 0;
40
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,
46                                                          0, NULL, 0);
47   return style_provider_type;
48 }
49
50 static void
51 gtk_style_provider_iface_init (gpointer g_iface)
52 {
53 }
54
55 /**
56  * gtk_style_provider_get_style:
57  * @provider: a #GtkStyleProvider
58  * @path: #GtkWidgetPath to query
59  *
60  * Returns the style settings affecting a widget defined by @path, or %NULL if
61  * @provider doesn't contemplate styling @path.
62  *
63  * Returns: (transfer full): a #GtkStyleProperties containing the
64  * style settings affecting @path
65  *
66  * Since: 3.0
67  **/
68 GtkStyleProperties *
69 gtk_style_provider_get_style (GtkStyleProvider *provider,
70                               GtkWidgetPath    *path)
71 {
72   GtkStyleProviderIface *iface;
73
74   g_return_val_if_fail (GTK_IS_STYLE_PROVIDER (provider), NULL);
75
76   iface = GTK_STYLE_PROVIDER_GET_IFACE (provider);
77
78   if (!iface->get_style)
79     return NULL;
80
81   return iface->get_style (provider, path);
82 }
83
84 /**
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
91  *
92  * Looks up a widget style property as defined by @provider for
93  * the widget represented by @path.
94  *
95  * Returns: %TRUE if the property was found and has a value, %FALSE otherwise
96  **/
97 gboolean
98 gtk_style_provider_get_style_property (GtkStyleProvider *provider,
99                                        GtkWidgetPath    *path,
100                                        GtkStateFlags     state,
101                                        GParamSpec       *pspec,
102                                        GValue           *value)
103 {
104   GtkStyleProviderIface *iface;
105
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);
111
112   iface = GTK_STYLE_PROVIDER_GET_IFACE (provider);
113
114   if (!iface->get_style_property)
115     return FALSE;
116
117   return iface->get_style_property (provider, path, state, pspec, value);
118 }
119
120 /**
121  * gtk_style_provider_get_icon_factory:
122  * @provider: a #GtkStyleProvider
123  * @path: #GtkWidgetPath to query
124  *
125  * Returns the #GtkIconFactory defined to be in use for @path, or %NULL if none
126  * is defined.
127  *
128  * Returns: (transfer none): The icon factory to use for @path, or %NULL
129  *
130  * Since: 3.0
131  **/
132 GtkIconFactory *
133 gtk_style_provider_get_icon_factory (GtkStyleProvider *provider,
134                                      GtkWidgetPath    *path)
135 {
136   GtkStyleProviderIface *iface;
137
138   g_return_val_if_fail (GTK_IS_STYLE_PROVIDER (provider), NULL);
139   g_return_val_if_fail (path != NULL, NULL);
140
141   iface = GTK_STYLE_PROVIDER_GET_IFACE (provider);
142
143   if (!iface->get_icon_factory)
144     return NULL;
145
146   return iface->get_icon_factory (provider, path);
147 }