Migrate xmpp-caps.xml to XDG cache dir
[pidgin-git.git] / pidgin / gtkblist-theme.c
blobac1ecf811bf98ff0dcde5019c1d39137ed3b5b34
1 /*
2 * Buddy List Themes for Pidgin
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.
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.
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.
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
23 #include "internal.h"
24 #include "glibcompat.h"
26 #include "gtkblist-theme.h"
28 #define PIDGIN_BLIST_THEME_GET_PRIVATE(Gobject) \
29 (G_TYPE_INSTANCE_GET_PRIVATE((Gobject), PIDGIN_TYPE_BLIST_THEME, PidginBlistThemePrivate))
31 /******************************************************************************
32 * Structs
33 *****************************************************************************/
35 typedef struct {
36 /* Buddy list */
37 gdouble opacity;
38 GdkRGBA *bgcolor;
39 PidginBlistLayout *layout;
41 /* groups */
42 GdkRGBA *expanded_color;
43 PidginThemeFont *expanded;
45 GdkRGBA *collapsed_color;
46 PidginThemeFont *collapsed;
48 /* buddy */
49 GdkRGBA *contact_color;
51 PidginThemeFont *contact;
53 PidginThemeFont *online;
54 PidginThemeFont *away;
55 PidginThemeFont *offline;
56 PidginThemeFont *idle;
57 PidginThemeFont *message;
58 PidginThemeFont *message_nick_said;
60 PidginThemeFont *status;
62 } PidginBlistThemePrivate;
64 struct _PidginThemeFont
66 gchar *font;
67 gchar color[10];
68 GdkRGBA *gdkcolor;
71 /******************************************************************************
72 * Enums
73 *****************************************************************************/
75 enum {
76 PROP_ZERO = 0,
77 PROP_BACKGROUND_COLOR,
78 PROP_OPACITY,
79 PROP_LAYOUT,
80 PROP_EXPANDED_COLOR,
81 PROP_EXPANDED_TEXT,
82 PROP_COLLAPSED_COLOR,
83 PROP_COLLAPSED_TEXT,
84 PROP_CONTACT_COLOR,
85 PROP_CONTACT,
86 PROP_ONLINE,
87 PROP_AWAY,
88 PROP_OFFLINE,
89 PROP_IDLE,
90 PROP_MESSAGE,
91 PROP_MESSAGE_NICK_SAID,
92 PROP_STATUS,
93 PROP_LAST
96 /******************************************************************************
97 * Globals
98 *****************************************************************************/
100 static GObjectClass *parent_class = NULL;
101 static GParamSpec *properties[PROP_LAST];
103 /******************************************************************************
104 * Helpers
105 *****************************************************************************/
107 PidginThemeFont *
108 pidgin_theme_font_new(const gchar *face, GdkRGBA *color)
110 PidginThemeFont *font = g_new0(PidginThemeFont, 1);
111 font->font = g_strdup(face);
112 if (color)
113 pidgin_theme_font_set_color(font, color);
114 return font;
117 void
118 pidgin_theme_font_free(PidginThemeFont *pair)
120 if (pair != NULL) {
121 g_free(pair->font);
122 if (pair->gdkcolor)
123 gdk_rgba_free(pair->gdkcolor);
124 g_free(pair);
128 static PidginThemeFont *
129 copy_font_and_color(const PidginThemeFont *pair)
131 PidginThemeFont *copy;
133 if (pair == NULL)
134 return NULL;
136 copy = g_new0(PidginThemeFont, 1);
137 copy->font = g_strdup(pair->font);
138 strncpy(copy->color, pair->color, sizeof(copy->color) - 1);
139 if (pair->gdkcolor)
140 copy->gdkcolor = pair->gdkcolor ? gdk_rgba_copy(pair->gdkcolor) : NULL;
141 return copy;
144 void
145 pidgin_theme_font_set_font_face(PidginThemeFont *font, const gchar *face)
147 g_return_if_fail(font);
148 g_return_if_fail(face);
150 g_free(font->font);
151 font->font = g_strdup(face);
154 void
155 pidgin_theme_font_set_color(PidginThemeFont *font, const GdkRGBA *color)
157 g_return_if_fail(font);
159 if (font->gdkcolor)
160 gdk_rgba_free(font->gdkcolor);
162 font->gdkcolor = color ? gdk_rgba_copy(color) : NULL;
163 if (color)
164 g_snprintf(font->color, sizeof(font->color),
165 "#%02x%02x%02x",
166 (unsigned int)(color->red * 255),
167 (unsigned int)(color->green * 255),
168 (unsigned int)(color->blue * 255));
169 else
170 font->color[0] = '\0';
173 const gchar *
174 pidgin_theme_font_get_font_face(PidginThemeFont *font)
176 g_return_val_if_fail(font, NULL);
177 return font->font;
180 const GdkRGBA *
181 pidgin_theme_font_get_color(PidginThemeFont *font)
183 g_return_val_if_fail(font, NULL);
184 return font->gdkcolor;
187 const gchar *
188 pidgin_theme_font_get_color_describe(PidginThemeFont *font)
190 g_return_val_if_fail(font, NULL);
191 return font->color[0] ? font->color : NULL;
194 /******************************************************************************
195 * GObject Stuff
196 *****************************************************************************/
198 static void
199 pidgin_blist_theme_get_property(GObject *obj, guint param_id, GValue *value,
200 GParamSpec *psec)
202 PidginBlistTheme *theme = PIDGIN_BLIST_THEME(obj);
204 switch (param_id) {
205 case PROP_BACKGROUND_COLOR:
206 g_value_set_boxed(value, pidgin_blist_theme_get_background_color(theme));
207 break;
208 case PROP_OPACITY:
209 g_value_set_double(value, pidgin_blist_theme_get_opacity(theme));
210 break;
211 case PROP_LAYOUT:
212 g_value_set_pointer(value, pidgin_blist_theme_get_layout(theme));
213 break;
214 case PROP_EXPANDED_COLOR:
215 g_value_set_boxed(value, pidgin_blist_theme_get_expanded_background_color(theme));
216 break;
217 case PROP_EXPANDED_TEXT:
218 g_value_set_pointer(value, pidgin_blist_theme_get_expanded_text_info(theme));
219 break;
220 case PROP_COLLAPSED_COLOR:
221 g_value_set_boxed(value, pidgin_blist_theme_get_collapsed_background_color(theme));
222 break;
223 case PROP_COLLAPSED_TEXT:
224 g_value_set_pointer(value, pidgin_blist_theme_get_collapsed_text_info(theme));
225 break;
226 case PROP_CONTACT_COLOR:
227 g_value_set_boxed(value, pidgin_blist_theme_get_contact_color(theme));
228 break;
229 case PROP_CONTACT:
230 g_value_set_pointer(value, pidgin_blist_theme_get_contact_text_info(theme));
231 break;
232 case PROP_ONLINE:
233 g_value_set_pointer(value, pidgin_blist_theme_get_online_text_info(theme));
234 break;
235 case PROP_AWAY:
236 g_value_set_pointer(value, pidgin_blist_theme_get_away_text_info(theme));
237 break;
238 case PROP_OFFLINE:
239 g_value_set_pointer(value, pidgin_blist_theme_get_offline_text_info(theme));
240 break;
241 case PROP_IDLE:
242 g_value_set_pointer(value, pidgin_blist_theme_get_idle_text_info(theme));
243 break;
244 case PROP_MESSAGE:
245 g_value_set_pointer(value, pidgin_blist_theme_get_unread_message_text_info(theme));
246 break;
247 case PROP_MESSAGE_NICK_SAID:
248 g_value_set_pointer(value, pidgin_blist_theme_get_unread_message_nick_said_text_info(theme));
249 break;
250 case PROP_STATUS:
251 g_value_set_pointer(value, pidgin_blist_theme_get_status_text_info(theme));
252 break;
253 default:
254 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, psec);
255 break;
259 static void
260 pidgin_blist_theme_set_property(GObject *obj, guint param_id, const GValue *value,
261 GParamSpec *psec)
263 PidginBlistTheme *theme = PIDGIN_BLIST_THEME(obj);
265 switch (param_id) {
266 case PROP_BACKGROUND_COLOR:
267 pidgin_blist_theme_set_background_color(theme, g_value_get_boxed(value));
268 break;
269 case PROP_OPACITY:
270 pidgin_blist_theme_set_opacity(theme, g_value_get_double(value));
271 break;
272 case PROP_LAYOUT:
273 pidgin_blist_theme_set_layout(theme, g_value_get_pointer(value));
274 break;
275 case PROP_EXPANDED_COLOR:
276 pidgin_blist_theme_set_expanded_background_color(theme, g_value_get_boxed(value));
277 break;
278 case PROP_EXPANDED_TEXT:
279 pidgin_blist_theme_set_expanded_text_info(theme, g_value_get_pointer(value));
280 break;
281 case PROP_COLLAPSED_COLOR:
282 pidgin_blist_theme_set_collapsed_background_color(theme, g_value_get_boxed(value));
283 break;
284 case PROP_COLLAPSED_TEXT:
285 pidgin_blist_theme_set_collapsed_text_info(theme, g_value_get_pointer(value));
286 break;
287 case PROP_CONTACT_COLOR:
288 pidgin_blist_theme_set_contact_color(theme, g_value_get_boxed(value));
289 break;
290 case PROP_CONTACT:
291 pidgin_blist_theme_set_contact_text_info(theme, g_value_get_pointer(value));
292 break;
293 case PROP_ONLINE:
294 pidgin_blist_theme_set_online_text_info(theme, g_value_get_pointer(value));
295 break;
296 case PROP_AWAY:
297 pidgin_blist_theme_set_away_text_info(theme, g_value_get_pointer(value));
298 break;
299 case PROP_OFFLINE:
300 pidgin_blist_theme_set_offline_text_info(theme, g_value_get_pointer(value));
301 break;
302 case PROP_IDLE:
303 pidgin_blist_theme_set_idle_text_info(theme, g_value_get_pointer(value));
304 break;
305 case PROP_MESSAGE:
306 pidgin_blist_theme_set_unread_message_text_info(theme, g_value_get_pointer(value));
307 break;
308 case PROP_MESSAGE_NICK_SAID:
309 pidgin_blist_theme_set_unread_message_nick_said_text_info(theme, g_value_get_pointer(value));
310 break;
311 case PROP_STATUS:
312 pidgin_blist_theme_set_status_text_info(theme, g_value_get_pointer(value));
313 break;
314 default:
315 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, psec);
316 break;
320 static void
321 pidgin_blist_theme_finalize(GObject *obj)
323 PidginBlistThemePrivate *priv;
325 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(obj);
327 /* Buddy List */
328 if (priv->bgcolor)
329 gdk_rgba_free(priv->bgcolor);
330 g_free(priv->layout);
332 /* Group */
333 if (priv->expanded_color)
334 gdk_rgba_free(priv->expanded_color);
335 pidgin_theme_font_free(priv->expanded);
336 if (priv->collapsed_color)
337 gdk_rgba_free(priv->collapsed_color);
338 pidgin_theme_font_free(priv->collapsed);
340 /* Buddy */
341 if (priv->contact_color)
342 gdk_rgba_free(priv->contact_color);
343 pidgin_theme_font_free(priv->contact);
344 pidgin_theme_font_free(priv->online);
345 pidgin_theme_font_free(priv->away);
346 pidgin_theme_font_free(priv->offline);
347 pidgin_theme_font_free(priv->idle);
348 pidgin_theme_font_free(priv->message);
349 pidgin_theme_font_free(priv->message_nick_said);
350 pidgin_theme_font_free(priv->status);
352 parent_class->finalize (obj);
355 static void
356 pidgin_blist_theme_init(PidginBlistTheme *theme)
358 PIDGIN_BLIST_THEME_GET_PRIVATE(theme)->opacity = 1.0;
361 static void
362 pidgin_blist_theme_class_init(PidginBlistThemeClass *klass)
364 GObjectClass *obj_class = G_OBJECT_CLASS(klass);
366 parent_class = g_type_class_peek_parent (klass);
368 g_type_class_add_private(klass, sizeof(PidginBlistThemePrivate));
370 obj_class->get_property = pidgin_blist_theme_get_property;
371 obj_class->set_property = pidgin_blist_theme_set_property;
372 obj_class->finalize = pidgin_blist_theme_finalize;
374 /* Buddy List */
375 properties[PROP_BACKGROUND_COLOR] = g_param_spec_boxed("background-color",
376 "Background Color",
377 "The background color for the buddy list",
378 GDK_TYPE_RGBA, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
380 properties[PROP_OPACITY] = g_param_spec_double("opacity", "Opacity",
381 "The opacity of the buddy list",
382 0.0, 1.0, 1.0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
384 properties[PROP_LAYOUT] = g_param_spec_pointer("layout", "Layout",
385 "The layout of icons, name, and status of the buddy list",
386 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
388 /* Group */
389 properties[PROP_EXPANDED_COLOR] = g_param_spec_boxed("expanded-color",
390 "Expanded Background Color",
391 "The background color of an expanded group",
392 GDK_TYPE_RGBA, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
394 properties[PROP_EXPANDED_TEXT] = g_param_spec_pointer("expanded-text",
395 "Expanded Text",
396 "The text information for when a group is expanded",
397 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
399 properties[PROP_COLLAPSED_COLOR] = g_param_spec_boxed("collapsed-color",
400 "Collapsed Background Color",
401 "The background color of a collapsed group",
402 GDK_TYPE_RGBA, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
404 properties[PROP_COLLAPSED_TEXT] = g_param_spec_pointer("collapsed-text",
405 "Collapsed Text",
406 "The text information for when a group is collapsed",
407 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
409 /* Buddy */
410 properties[PROP_CONTACT_COLOR] = g_param_spec_boxed("contact-color",
411 "Contact/Chat Background Color",
412 "The background color of a contact or chat",
413 GDK_TYPE_RGBA, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
415 properties[PROP_CONTACT] = g_param_spec_pointer("contact",
416 "Contact Text",
417 "The text information for when a contact is expanded",
418 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
420 properties[PROP_ONLINE] = g_param_spec_pointer("online",
421 "Online Text",
422 "The text information for when a buddy is online",
423 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
425 properties[PROP_AWAY] = g_param_spec_pointer("away",
426 "Away Text",
427 "The text information for when a buddy is away",
428 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
430 properties[PROP_OFFLINE] = g_param_spec_pointer("offline",
431 "Offline Text",
432 "The text information for when a buddy is offline",
433 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
435 properties[PROP_IDLE] = g_param_spec_pointer("idle",
436 "Idle Text",
437 "The text information for when a buddy is idle",
438 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
440 properties[PROP_MESSAGE] = g_param_spec_pointer("message",
441 "Message Text",
442 "The text information for when a buddy has an unread message",
443 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
445 properties[PROP_MESSAGE_NICK_SAID] = g_param_spec_pointer("message-nick-said",
446 "Message (Nick Said) Text",
447 "The text information for when a chat has an unread message that mentions your nickname",
448 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
450 properties[PROP_STATUS] = g_param_spec_pointer("status",
451 "Status Text",
452 "The text information for a buddy's status",
453 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
455 g_object_class_install_properties(obj_class, PROP_LAST, properties);
458 GType
459 pidgin_blist_theme_get_type (void)
461 static GType type = 0;
462 if (type == 0) {
463 static GTypeInfo info = {
464 sizeof(PidginBlistThemeClass),
465 NULL, /* base_init */
466 NULL, /* base_finalize */
467 (GClassInitFunc)pidgin_blist_theme_class_init, /* class_init */
468 NULL, /* class_finalize */
469 NULL, /* class_data */
470 sizeof(PidginBlistTheme),
471 0, /* n_preallocs */
472 (GInstanceInitFunc)pidgin_blist_theme_init, /* instance_init */
473 NULL, /* value table */
475 type = g_type_register_static (PURPLE_TYPE_THEME,
476 "PidginBlistTheme", &info, 0);
478 return type;
481 /**************************************************************************
482 * GBoxed Stuff
483 **************************************************************************/
485 static PidginThemeFont *
486 pidgin_theme_font_copy(PidginThemeFont *font)
488 g_return_val_if_fail(font != NULL, NULL);
490 return pidgin_theme_font_new(font->font, font->gdkcolor);
493 GType
494 pidgin_theme_font_get_type(void)
496 static GType type = 0;
498 if (type == 0) {
499 type = g_boxed_type_register_static("PidginThemeFont",
500 (GBoxedCopyFunc)pidgin_theme_font_copy,
501 (GBoxedFreeFunc)pidgin_theme_font_free);
504 return type;
507 static PidginBlistLayout *
508 pidgin_blist_layout_copy(const PidginBlistLayout *layout)
510 g_return_val_if_fail(layout != NULL, NULL);
512 return g_memdup(layout, sizeof(PidginBlistLayout));
515 GType
516 pidgin_blist_layout_get_type(void)
518 static GType type = 0;
520 if (type == 0) {
521 type = g_boxed_type_register_static("PidginBlistLayout",
522 (GBoxedCopyFunc)pidgin_blist_layout_copy,
523 (GBoxedFreeFunc)g_free);
526 return type;
530 /*****************************************************************************
531 * Public API functions
532 *****************************************************************************/
534 /* get methods */
536 GdkRGBA *
537 pidgin_blist_theme_get_background_color(PidginBlistTheme *theme)
539 PidginBlistThemePrivate *priv;
541 g_return_val_if_fail(PIDGIN_IS_BLIST_THEME(theme), NULL);
543 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(theme);
545 return priv->bgcolor;
548 gdouble
549 pidgin_blist_theme_get_opacity(PidginBlistTheme *theme)
551 PidginBlistThemePrivate *priv;
553 g_return_val_if_fail(PIDGIN_IS_BLIST_THEME(theme), 1.0);
555 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(theme);
557 return priv->opacity;
560 PidginBlistLayout *
561 pidgin_blist_theme_get_layout(PidginBlistTheme *theme)
563 PidginBlistThemePrivate *priv;
565 g_return_val_if_fail(PIDGIN_IS_BLIST_THEME(theme), NULL);
567 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(theme);
569 return priv->layout;
572 GdkRGBA *
573 pidgin_blist_theme_get_expanded_background_color(PidginBlistTheme *theme)
575 PidginBlistThemePrivate *priv;
577 g_return_val_if_fail(PIDGIN_IS_BLIST_THEME(theme), NULL);
579 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(theme);
581 return priv->expanded_color;
584 PidginThemeFont *
585 pidgin_blist_theme_get_expanded_text_info(PidginBlistTheme *theme)
587 PidginBlistThemePrivate *priv;
589 g_return_val_if_fail(PIDGIN_IS_BLIST_THEME(theme), NULL);
591 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(theme);
593 return priv->expanded;
596 GdkRGBA *
597 pidgin_blist_theme_get_collapsed_background_color(PidginBlistTheme *theme)
599 PidginBlistThemePrivate *priv;
601 g_return_val_if_fail(PIDGIN_IS_BLIST_THEME(theme), NULL);
603 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(theme);
605 return priv->collapsed_color;
608 PidginThemeFont *
609 pidgin_blist_theme_get_collapsed_text_info(PidginBlistTheme *theme)
611 PidginBlistThemePrivate *priv;
613 g_return_val_if_fail(PIDGIN_IS_BLIST_THEME(theme), NULL);
615 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(theme);
617 return priv->collapsed;
620 GdkRGBA *
621 pidgin_blist_theme_get_contact_color(PidginBlistTheme *theme)
623 PidginBlistThemePrivate *priv;
625 g_return_val_if_fail(PIDGIN_IS_BLIST_THEME(theme), NULL);
627 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(theme);
629 return priv->contact_color;
632 PidginThemeFont *
633 pidgin_blist_theme_get_contact_text_info(PidginBlistTheme *theme)
635 PidginBlistThemePrivate *priv;
637 g_return_val_if_fail(PIDGIN_IS_BLIST_THEME(theme), NULL);
639 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(theme);
641 return priv->contact;
644 PidginThemeFont *
645 pidgin_blist_theme_get_online_text_info(PidginBlistTheme *theme)
647 PidginBlistThemePrivate *priv;
649 g_return_val_if_fail(PIDGIN_IS_BLIST_THEME(theme), NULL);
651 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(theme);
653 return priv->online;
656 PidginThemeFont *
657 pidgin_blist_theme_get_away_text_info(PidginBlistTheme *theme)
659 PidginBlistThemePrivate *priv;
661 g_return_val_if_fail(PIDGIN_IS_BLIST_THEME(theme), NULL);
663 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(theme);
665 return priv->away;
668 PidginThemeFont *
669 pidgin_blist_theme_get_offline_text_info(PidginBlistTheme *theme)
671 PidginBlistThemePrivate *priv;
673 g_return_val_if_fail(PIDGIN_IS_BLIST_THEME(theme), NULL);
675 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(theme);
677 return priv->offline;
680 PidginThemeFont *
681 pidgin_blist_theme_get_idle_text_info(PidginBlistTheme *theme)
683 PidginBlistThemePrivate *priv;
685 g_return_val_if_fail(PIDGIN_IS_BLIST_THEME(theme), NULL);
687 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(theme);
689 return priv->idle;
692 PidginThemeFont *
693 pidgin_blist_theme_get_unread_message_text_info(PidginBlistTheme *theme)
695 PidginBlistThemePrivate *priv;
697 g_return_val_if_fail(PIDGIN_IS_BLIST_THEME(theme), NULL);
699 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(theme);
701 return priv->message;
704 PidginThemeFont *
705 pidgin_blist_theme_get_unread_message_nick_said_text_info(PidginBlistTheme *theme)
707 PidginBlistThemePrivate *priv;
709 g_return_val_if_fail(PIDGIN_IS_BLIST_THEME(theme), NULL);
711 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(theme);
713 return priv->message_nick_said;
716 PidginThemeFont *
717 pidgin_blist_theme_get_status_text_info(PidginBlistTheme *theme)
719 PidginBlistThemePrivate *priv;
721 g_return_val_if_fail(PIDGIN_IS_BLIST_THEME(theme), NULL);
723 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(theme);
725 return priv->status;
728 /* Set Methods */
729 void
730 pidgin_blist_theme_set_background_color(PidginBlistTheme *theme, const GdkRGBA *color)
732 PidginBlistThemePrivate *priv;
734 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme));
736 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(theme);
738 if (priv->bgcolor)
739 gdk_rgba_free(priv->bgcolor);
740 priv->bgcolor = color ? gdk_rgba_copy(color) : NULL;
742 g_object_notify_by_pspec(G_OBJECT(theme), properties[PROP_BACKGROUND_COLOR]);
745 void
746 pidgin_blist_theme_set_opacity(PidginBlistTheme *theme, gdouble opacity)
748 PidginBlistThemePrivate *priv;
750 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme) || opacity < 0.0 || opacity > 1.0);
752 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(theme);
754 priv->opacity = opacity;
756 g_object_notify_by_pspec(G_OBJECT(theme), properties[PROP_OPACITY]);
759 void
760 pidgin_blist_theme_set_layout(PidginBlistTheme *theme, const PidginBlistLayout *layout)
762 PidginBlistThemePrivate *priv;
764 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme));
766 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(theme);
768 g_free(priv->layout);
769 priv->layout = pidgin_blist_layout_copy(layout);
771 g_object_notify_by_pspec(G_OBJECT(theme), properties[PROP_LAYOUT]);
774 void
775 pidgin_blist_theme_set_expanded_background_color(PidginBlistTheme *theme, const GdkRGBA *color)
777 PidginBlistThemePrivate *priv;
779 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme));
781 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(theme);
783 if (priv->expanded_color)
784 gdk_rgba_free(priv->expanded_color);
785 priv->expanded_color = color ? gdk_rgba_copy(color) : NULL;
787 g_object_notify_by_pspec(G_OBJECT(theme), properties[PROP_EXPANDED_COLOR]);
790 void
791 pidgin_blist_theme_set_expanded_text_info(PidginBlistTheme *theme, const PidginThemeFont *pair)
793 PidginBlistThemePrivate *priv;
795 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme));
797 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(theme);
799 pidgin_theme_font_free(priv->expanded);
800 priv->expanded = copy_font_and_color(pair);
802 g_object_notify_by_pspec(G_OBJECT(theme), properties[PROP_EXPANDED_TEXT]);
805 void
806 pidgin_blist_theme_set_collapsed_background_color(PidginBlistTheme *theme, const GdkRGBA *color)
808 PidginBlistThemePrivate *priv;
810 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme));
812 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(theme);
814 if (priv->collapsed_color)
815 gdk_rgba_free(priv->collapsed_color);
816 priv->collapsed_color = color ? gdk_rgba_copy(color) : NULL;
818 g_object_notify_by_pspec(G_OBJECT(theme), properties[PROP_COLLAPSED_COLOR]);
821 void
822 pidgin_blist_theme_set_collapsed_text_info(PidginBlistTheme *theme, const PidginThemeFont *pair)
824 PidginBlistThemePrivate *priv;
826 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme));
828 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(theme);
830 pidgin_theme_font_free(priv->collapsed);
831 priv->collapsed = copy_font_and_color(pair);
833 g_object_notify_by_pspec(G_OBJECT(theme), properties[PROP_COLLAPSED_TEXT]);
836 void
837 pidgin_blist_theme_set_contact_color(PidginBlistTheme *theme, const GdkRGBA *color)
839 PidginBlistThemePrivate *priv;
841 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme));
843 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(theme);
845 if (priv->contact_color)
846 gdk_rgba_free(priv->contact_color);
847 priv->contact_color = color ? gdk_rgba_copy(color) : NULL;
849 g_object_notify_by_pspec(G_OBJECT(theme), properties[PROP_CONTACT_COLOR]);
852 void
853 pidgin_blist_theme_set_contact_text_info(PidginBlistTheme *theme, const PidginThemeFont *pair)
855 PidginBlistThemePrivate *priv;
857 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme));
859 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(theme);
861 pidgin_theme_font_free(priv->contact);
862 priv->contact = copy_font_and_color(pair);
864 g_object_notify_by_pspec(G_OBJECT(theme), properties[PROP_CONTACT]);
867 void
868 pidgin_blist_theme_set_online_text_info(PidginBlistTheme *theme, const PidginThemeFont *pair)
870 PidginBlistThemePrivate *priv;
872 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme));
874 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(theme);
876 pidgin_theme_font_free(priv->online);
877 priv->online = copy_font_and_color(pair);
879 g_object_notify_by_pspec(G_OBJECT(theme), properties[PROP_ONLINE]);
882 void
883 pidgin_blist_theme_set_away_text_info(PidginBlistTheme *theme, const PidginThemeFont *pair)
885 PidginBlistThemePrivate *priv;
887 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme));
889 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(theme);
891 pidgin_theme_font_free(priv->away);
892 priv->away = copy_font_and_color(pair);
894 g_object_notify_by_pspec(G_OBJECT(theme), properties[PROP_AWAY]);
897 void
898 pidgin_blist_theme_set_offline_text_info(PidginBlistTheme *theme, const PidginThemeFont *pair)
900 PidginBlistThemePrivate *priv;
902 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme));
904 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(theme);
906 pidgin_theme_font_free(priv->offline);
907 priv->offline = copy_font_and_color(pair);
909 g_object_notify_by_pspec(G_OBJECT(theme), properties[PROP_OFFLINE]);
912 void
913 pidgin_blist_theme_set_idle_text_info(PidginBlistTheme *theme, const PidginThemeFont *pair)
915 PidginBlistThemePrivate *priv;
917 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme));
919 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(theme);
921 pidgin_theme_font_free(priv->idle);
922 priv->idle = copy_font_and_color(pair);
924 g_object_notify_by_pspec(G_OBJECT(theme), properties[PROP_IDLE]);
927 void
928 pidgin_blist_theme_set_unread_message_text_info(PidginBlistTheme *theme, const PidginThemeFont *pair)
930 PidginBlistThemePrivate *priv;
932 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme));
934 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(theme);
936 pidgin_theme_font_free(priv->message);
937 priv->message = copy_font_and_color(pair);
939 g_object_notify_by_pspec(G_OBJECT(theme), properties[PROP_MESSAGE]);
942 void
943 pidgin_blist_theme_set_unread_message_nick_said_text_info(PidginBlistTheme *theme, const PidginThemeFont *pair)
945 PidginBlistThemePrivate *priv;
947 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme));
949 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(theme);
951 pidgin_theme_font_free(priv->message_nick_said);
952 priv->message_nick_said = copy_font_and_color(pair);
954 g_object_notify_by_pspec(G_OBJECT(theme), properties[PROP_MESSAGE_NICK_SAID]);
957 void
958 pidgin_blist_theme_set_status_text_info(PidginBlistTheme *theme, const PidginThemeFont *pair)
960 PidginBlistThemePrivate *priv;
962 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme));
964 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(theme);
966 pidgin_theme_font_free(priv->status);
967 priv->status = copy_font_and_color(pair);
969 g_object_notify_by_pspec(G_OBJECT(theme), properties[PROP_STATUS]);