]> Pileus Git - ~andy/gtk/blob - gtk/gtkstyleprovider.c
2c23a80edb94361b1f8a2e8642cf548aded970a8
[~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, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20 #include "config.h"
21
22 #include "gtkprivate.h"
23 #include "gtkstyleprovider.h"
24 #include "gtkintl.h"
25
26 static void gtk_style_provider_iface_init (gpointer g_iface);
27
28 GType
29 gtk_style_provider_get_type (void)
30 {
31   static GType style_provider_type = 0;
32
33   if (!style_provider_type)
34     style_provider_type = g_type_register_static_simple (G_TYPE_INTERFACE,
35                                                          I_("GtkStyleProvider"),
36                                                          sizeof (GtkStyleProviderIface),
37                                                          (GClassInitFunc) gtk_style_provider_iface_init,
38                                                          0, NULL, 0);
39   return style_provider_type;
40 }
41
42 static void
43 gtk_style_provider_iface_init (gpointer g_iface)
44 {
45 }
46
47 GtkStyleSet *
48 gtk_style_provider_get_style (GtkStyleProvider *provider,
49                               GtkWidgetPath    *path)
50 {
51   GtkStyleProviderIface *iface;
52
53   g_return_val_if_fail (GTK_IS_STYLE_PROVIDER (provider), NULL);
54
55   iface = GTK_STYLE_PROVIDER_GET_IFACE (provider);
56
57   if (!iface->get_style)
58     return NULL;
59
60   return iface->get_style (provider, path);
61 }
62
63 gboolean
64 gtk_style_provider_get_style_property (GtkStyleProvider *provider,
65                                        GtkWidgetPath    *widget_path,
66                                        const gchar      *property_name,
67                                        GValue           *value)
68 {
69   GtkStyleProviderIface *iface;
70
71   g_return_val_if_fail (GTK_IS_STYLE_PROVIDER (provider), FALSE);
72   g_return_val_if_fail (widget_path != NULL, FALSE);
73   g_return_val_if_fail (property_name != NULL, FALSE);
74   g_return_val_if_fail (value != NULL, FALSE);
75
76   iface = GTK_STYLE_PROVIDER_GET_IFACE (provider);
77
78   if (!iface->get_style_property)
79     return FALSE;
80
81   return iface->get_style_property (provider, widget_path, property_name, value);
82 }
83
84 GtkIconFactory *
85 gtk_style_provider_get_icon_factory (GtkStyleProvider *provider,
86                                      GtkWidgetPath    *path)
87 {
88   GtkStyleProviderIface *iface;
89
90   g_return_val_if_fail (GTK_IS_STYLE_PROVIDER (provider), NULL);
91   g_return_val_if_fail (path != NULL, NULL);
92
93   iface = GTK_STYLE_PROVIDER_GET_IFACE (provider);
94
95   if (!iface->get_icon_factory)
96     return NULL;
97
98   return iface->get_icon_factory (provider, path);
99 }