Mercurial > pidgin
comparison libpurple/theme-loader.c @ 25776:e0a596a0a020
propagate from branch 'im.pidgin.pidgin' (head 69cdb2b9e20a69a98389b47c672718d5be222338)
to branch 'im.pidgin.soc.2008.themes' (head 76c4c8e60f9192eff589f0416652aaab2ae9521d)
author | Gary Kramlich <grim@reaperworld.com> |
---|---|
date | Thu, 28 Aug 2008 13:00:23 +0000 |
parents | b37ccfd1697b |
children | 1eacf60a73dd |
comparison
equal
deleted
inserted
replaced
24000:e9eb71dc21af | 25776:e0a596a0a020 |
---|---|
1 /* | |
2 * ThemeLoaders for LibPurple | |
3 * | |
4 * Pidgin is the legal property of its developers, whose names are too numerous | |
5 * to list here. Please refer to the COPYRIGHT file distributed with this | |
6 * source distribution. | |
7 * | |
8 * This program is free software; you can redistribute it and/or modify | |
9 * it under the terms of the GNU General Public License as published by | |
10 * the Free Software Foundation; either version 2 of the License, or | |
11 * (at your option) any later version. | |
12 * | |
13 * This program is distributed in the hope that it will be useful, | |
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 * GNU General Public License for more details. | |
17 * | |
18 * You should have received a copy of the GNU General Public License | |
19 * along with this program; if not, write to the Free Software | |
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA | |
21 * | |
22 */ | |
23 | |
24 #include "theme-loader.h" | |
25 | |
26 #define PURPLE_THEME_LOADER_GET_PRIVATE(PurpleThemeLoader) \ | |
27 ((PurpleThemeLoaderPrivate *) ((PurpleThemeLoader)->priv)) | |
28 | |
29 void purple_theme_loader_set_type_string(PurpleThemeLoader *loader, const gchar *type); | |
30 /****************************************************************************** | |
31 * Structs | |
32 *****************************************************************************/ | |
33 typedef struct { | |
34 gchar *type; | |
35 } PurpleThemeLoaderPrivate; | |
36 | |
37 /****************************************************************************** | |
38 * Globals | |
39 *****************************************************************************/ | |
40 | |
41 static GObjectClass *parent_class = NULL; | |
42 | |
43 /****************************************************************************** | |
44 * Enums | |
45 *****************************************************************************/ | |
46 | |
47 enum { | |
48 PROP_ZERO = 0, | |
49 PROP_TYPE, | |
50 }; | |
51 | |
52 /****************************************************************************** | |
53 * GObject Stuff * | |
54 *****************************************************************************/ | |
55 | |
56 static void | |
57 purple_theme_loader_get_property(GObject *obj, guint param_id, GValue *value, | |
58 GParamSpec *psec) | |
59 { | |
60 PurpleThemeLoader *theme_loader = PURPLE_THEME_LOADER(obj); | |
61 | |
62 switch(param_id) { | |
63 case PROP_TYPE: | |
64 g_value_set_string(value, purple_theme_loader_get_type_string(theme_loader)); | |
65 default: | |
66 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, psec); | |
67 break; | |
68 } | |
69 } | |
70 | |
71 static void | |
72 purple_theme_loader_set_property(GObject *obj, guint param_id, const GValue *value, | |
73 GParamSpec *psec) | |
74 { | |
75 PurpleThemeLoader *loader = PURPLE_THEME_LOADER(obj); | |
76 | |
77 switch(param_id) { | |
78 case PROP_TYPE: | |
79 purple_theme_loader_set_type_string(loader, g_value_get_string(value)); | |
80 break; | |
81 default: | |
82 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, psec); | |
83 break; | |
84 } | |
85 } | |
86 | |
87 static void | |
88 purple_theme_loader_init(GTypeInstance *instance, | |
89 gpointer klass) | |
90 { | |
91 PurpleThemeLoader *loader = PURPLE_THEME_LOADER(instance); | |
92 loader->priv = g_new0(PurpleThemeLoaderPrivate, 1); | |
93 } | |
94 | |
95 static void | |
96 purple_theme_loader_finalize(GObject *obj) | |
97 { | |
98 PurpleThemeLoader *loader = PURPLE_THEME_LOADER(obj); | |
99 PurpleThemeLoaderPrivate *priv = PURPLE_THEME_LOADER_GET_PRIVATE(loader); | |
100 | |
101 g_free(priv->type); | |
102 | |
103 parent_class->finalize (obj); | |
104 } | |
105 | |
106 static void | |
107 purple_theme_loader_class_init (PurpleThemeLoaderClass *klass) | |
108 { | |
109 GObjectClass *obj_class = G_OBJECT_CLASS(klass); | |
110 GParamSpec *pspec; | |
111 | |
112 parent_class = g_type_class_peek_parent (klass); | |
113 | |
114 obj_class->get_property = purple_theme_loader_get_property; | |
115 obj_class->set_property = purple_theme_loader_set_property; | |
116 obj_class->finalize = purple_theme_loader_finalize; | |
117 | |
118 /* TYPE STRING (read only) */ | |
119 pspec = g_param_spec_string("type", "Type", | |
120 "The string represtenting the type of the theme", | |
121 NULL, | |
122 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY); | |
123 g_object_class_install_property(obj_class, PROP_TYPE, pspec); | |
124 } | |
125 | |
126 | |
127 GType | |
128 purple_theme_loader_get_type (void) | |
129 { | |
130 static GType type = 0; | |
131 if (type == 0) { | |
132 static const GTypeInfo info = { | |
133 sizeof (PurpleThemeLoaderClass), | |
134 NULL, /* base_init */ | |
135 NULL, /* base_finalize */ | |
136 (GClassInitFunc)purple_theme_loader_class_init, /* class_init */ | |
137 NULL, /* class_finalize */ | |
138 NULL, /* class_data */ | |
139 sizeof (PurpleThemeLoader), | |
140 0, /* n_preallocs */ | |
141 purple_theme_loader_init, /* instance_init */ | |
142 NULL, /* value table */ | |
143 }; | |
144 type = g_type_register_static (G_TYPE_OBJECT, | |
145 "PurpleThemeLoader", | |
146 &info, G_TYPE_FLAG_ABSTRACT); | |
147 } | |
148 return type; | |
149 } | |
150 | |
151 | |
152 /***************************************************************************** | |
153 * Public API functions | |
154 *****************************************************************************/ | |
155 | |
156 | |
157 const gchar * | |
158 purple_theme_loader_get_type_string (PurpleThemeLoader *theme_loader) | |
159 { | |
160 PurpleThemeLoaderPrivate *priv = NULL; | |
161 | |
162 g_return_val_if_fail(PURPLE_IS_THEME_LOADER(theme_loader), NULL); | |
163 | |
164 priv = PURPLE_THEME_LOADER_GET_PRIVATE(theme_loader); | |
165 return priv->type; | |
166 } | |
167 | |
168 /* < private > */ | |
169 void | |
170 purple_theme_loader_set_type_string(PurpleThemeLoader *loader, const gchar *type) | |
171 { | |
172 PurpleThemeLoaderPrivate *priv; | |
173 | |
174 g_return_if_fail(PURPLE_IS_THEME_LOADER(loader)); | |
175 | |
176 priv = PURPLE_THEME_LOADER_GET_PRIVATE(loader); | |
177 | |
178 g_free(priv->type); | |
179 priv->type = g_strdup(type); | |
180 } | |
181 | |
182 PurpleTheme * | |
183 purple_theme_loader_build(PurpleThemeLoader *loader, const gchar *dir) | |
184 { | |
185 return PURPLE_THEME_LOADER_GET_CLASS(loader)->purple_theme_loader_build(dir); | |
186 } |