Simplify handling of GG xfer auth queue.
[pidgin-git.git] / pidgin / gtkblist-theme.c
blob3a556ba1ec5d9e63c408ccc00bec376cbb046be0
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 /******************************************************************************
29 * Structs
30 *****************************************************************************/
32 /**
33 * PidginBlistTheme:
35 * A pidgin buddy list theme.
36 * This is an object for Purple to represent a buddy list theme.
38 * PidginBlistTheme is a PurpleTheme Object.
40 struct _PidginBlistTheme
42 PurpleTheme parent;
45 typedef struct {
46 /* Buddy list */
47 gdouble opacity;
48 GdkRGBA *bgcolor;
49 PidginBlistLayout *layout;
51 /* groups */
52 GdkRGBA *expanded_color;
53 PidginThemeFont *expanded;
55 GdkRGBA *collapsed_color;
56 PidginThemeFont *collapsed;
58 /* buddy */
59 GdkRGBA *contact_color;
61 PidginThemeFont *contact;
63 PidginThemeFont *online;
64 PidginThemeFont *away;
65 PidginThemeFont *offline;
66 PidginThemeFont *idle;
67 PidginThemeFont *message;
68 PidginThemeFont *message_nick_said;
70 PidginThemeFont *status;
72 } PidginBlistThemePrivate;
74 struct _PidginThemeFont
76 gchar *font;
77 gchar color[10];
78 GdkRGBA *gdkcolor;
81 /******************************************************************************
82 * Enums
83 *****************************************************************************/
85 enum {
86 PROP_ZERO = 0,
87 PROP_BACKGROUND_COLOR,
88 PROP_OPACITY,
89 PROP_LAYOUT,
90 PROP_EXPANDED_COLOR,
91 PROP_EXPANDED_TEXT,
92 PROP_COLLAPSED_COLOR,
93 PROP_COLLAPSED_TEXT,
94 PROP_CONTACT_COLOR,
95 PROP_CONTACT,
96 PROP_ONLINE,
97 PROP_AWAY,
98 PROP_OFFLINE,
99 PROP_IDLE,
100 PROP_MESSAGE,
101 PROP_MESSAGE_NICK_SAID,
102 PROP_STATUS,
103 PROP_LAST
106 /******************************************************************************
107 * Globals
108 *****************************************************************************/
110 static GParamSpec *properties[PROP_LAST];
112 G_DEFINE_TYPE_WITH_PRIVATE(PidginBlistTheme, pidgin_blist_theme,
113 PURPLE_TYPE_THEME);
115 /******************************************************************************
116 * Helpers
117 *****************************************************************************/
119 PidginThemeFont *
120 pidgin_theme_font_new(const gchar *face, GdkRGBA *color)
122 PidginThemeFont *font = g_new0(PidginThemeFont, 1);
123 font->font = g_strdup(face);
124 if (color)
125 pidgin_theme_font_set_color(font, color);
126 return font;
129 void
130 pidgin_theme_font_free(PidginThemeFont *pair)
132 if (pair != NULL) {
133 g_free(pair->font);
134 if (pair->gdkcolor)
135 gdk_rgba_free(pair->gdkcolor);
136 g_free(pair);
140 static PidginThemeFont *
141 copy_font_and_color(const PidginThemeFont *pair)
143 PidginThemeFont *copy;
145 if (pair == NULL)
146 return NULL;
148 copy = g_new0(PidginThemeFont, 1);
149 copy->font = g_strdup(pair->font);
150 strncpy(copy->color, pair->color, sizeof(copy->color) - 1);
151 if (pair->gdkcolor) {
152 copy->gdkcolor = gdk_rgba_copy(pair->gdkcolor);
154 return copy;
157 void
158 pidgin_theme_font_set_font_face(PidginThemeFont *font, const gchar *face)
160 g_return_if_fail(font);
161 g_return_if_fail(face);
163 g_free(font->font);
164 font->font = g_strdup(face);
167 void
168 pidgin_theme_font_set_color(PidginThemeFont *font, const GdkRGBA *color)
170 g_return_if_fail(font);
172 if (font->gdkcolor)
173 gdk_rgba_free(font->gdkcolor);
175 font->gdkcolor = color ? gdk_rgba_copy(color) : NULL;
176 if (color)
177 g_snprintf(font->color, sizeof(font->color),
178 "#%02x%02x%02x",
179 (unsigned int)(color->red * 255),
180 (unsigned int)(color->green * 255),
181 (unsigned int)(color->blue * 255));
182 else
183 font->color[0] = '\0';
186 const gchar *
187 pidgin_theme_font_get_font_face(PidginThemeFont *font)
189 g_return_val_if_fail(font, NULL);
190 return font->font;
193 const GdkRGBA *
194 pidgin_theme_font_get_color(PidginThemeFont *font)
196 g_return_val_if_fail(font, NULL);
197 return font->gdkcolor;
200 const gchar *
201 pidgin_theme_font_get_color_describe(PidginThemeFont *font)
203 g_return_val_if_fail(font, NULL);
204 return font->color[0] ? font->color : NULL;
207 /******************************************************************************
208 * GObject Stuff
209 *****************************************************************************/
211 static void
212 pidgin_blist_theme_get_property(GObject *obj, guint param_id, GValue *value,
213 GParamSpec *psec)
215 PidginBlistTheme *theme = PIDGIN_BLIST_THEME(obj);
217 switch (param_id) {
218 case PROP_BACKGROUND_COLOR:
219 g_value_set_boxed(value, pidgin_blist_theme_get_background_color(theme));
220 break;
221 case PROP_OPACITY:
222 g_value_set_double(value, pidgin_blist_theme_get_opacity(theme));
223 break;
224 case PROP_LAYOUT:
225 g_value_set_pointer(value, pidgin_blist_theme_get_layout(theme));
226 break;
227 case PROP_EXPANDED_COLOR:
228 g_value_set_boxed(value, pidgin_blist_theme_get_expanded_background_color(theme));
229 break;
230 case PROP_EXPANDED_TEXT:
231 g_value_set_pointer(value, pidgin_blist_theme_get_expanded_text_info(theme));
232 break;
233 case PROP_COLLAPSED_COLOR:
234 g_value_set_boxed(value, pidgin_blist_theme_get_collapsed_background_color(theme));
235 break;
236 case PROP_COLLAPSED_TEXT:
237 g_value_set_pointer(value, pidgin_blist_theme_get_collapsed_text_info(theme));
238 break;
239 case PROP_CONTACT_COLOR:
240 g_value_set_boxed(value, pidgin_blist_theme_get_contact_color(theme));
241 break;
242 case PROP_CONTACT:
243 g_value_set_pointer(value, pidgin_blist_theme_get_contact_text_info(theme));
244 break;
245 case PROP_ONLINE:
246 g_value_set_pointer(value, pidgin_blist_theme_get_online_text_info(theme));
247 break;
248 case PROP_AWAY:
249 g_value_set_pointer(value, pidgin_blist_theme_get_away_text_info(theme));
250 break;
251 case PROP_OFFLINE:
252 g_value_set_pointer(value, pidgin_blist_theme_get_offline_text_info(theme));
253 break;
254 case PROP_IDLE:
255 g_value_set_pointer(value, pidgin_blist_theme_get_idle_text_info(theme));
256 break;
257 case PROP_MESSAGE:
258 g_value_set_pointer(value, pidgin_blist_theme_get_unread_message_text_info(theme));
259 break;
260 case PROP_MESSAGE_NICK_SAID:
261 g_value_set_pointer(value, pidgin_blist_theme_get_unread_message_nick_said_text_info(theme));
262 break;
263 case PROP_STATUS:
264 g_value_set_pointer(value, pidgin_blist_theme_get_status_text_info(theme));
265 break;
266 default:
267 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, psec);
268 break;
272 static void
273 pidgin_blist_theme_set_property(GObject *obj, guint param_id, const GValue *value,
274 GParamSpec *psec)
276 PidginBlistTheme *theme = PIDGIN_BLIST_THEME(obj);
278 switch (param_id) {
279 case PROP_BACKGROUND_COLOR:
280 pidgin_blist_theme_set_background_color(theme, g_value_get_boxed(value));
281 break;
282 case PROP_OPACITY:
283 pidgin_blist_theme_set_opacity(theme, g_value_get_double(value));
284 break;
285 case PROP_LAYOUT:
286 pidgin_blist_theme_set_layout(theme, g_value_get_pointer(value));
287 break;
288 case PROP_EXPANDED_COLOR:
289 pidgin_blist_theme_set_expanded_background_color(theme, g_value_get_boxed(value));
290 break;
291 case PROP_EXPANDED_TEXT:
292 pidgin_blist_theme_set_expanded_text_info(theme, g_value_get_pointer(value));
293 break;
294 case PROP_COLLAPSED_COLOR:
295 pidgin_blist_theme_set_collapsed_background_color(theme, g_value_get_boxed(value));
296 break;
297 case PROP_COLLAPSED_TEXT:
298 pidgin_blist_theme_set_collapsed_text_info(theme, g_value_get_pointer(value));
299 break;
300 case PROP_CONTACT_COLOR:
301 pidgin_blist_theme_set_contact_color(theme, g_value_get_boxed(value));
302 break;
303 case PROP_CONTACT:
304 pidgin_blist_theme_set_contact_text_info(theme, g_value_get_pointer(value));
305 break;
306 case PROP_ONLINE:
307 pidgin_blist_theme_set_online_text_info(theme, g_value_get_pointer(value));
308 break;
309 case PROP_AWAY:
310 pidgin_blist_theme_set_away_text_info(theme, g_value_get_pointer(value));
311 break;
312 case PROP_OFFLINE:
313 pidgin_blist_theme_set_offline_text_info(theme, g_value_get_pointer(value));
314 break;
315 case PROP_IDLE:
316 pidgin_blist_theme_set_idle_text_info(theme, g_value_get_pointer(value));
317 break;
318 case PROP_MESSAGE:
319 pidgin_blist_theme_set_unread_message_text_info(theme, g_value_get_pointer(value));
320 break;
321 case PROP_MESSAGE_NICK_SAID:
322 pidgin_blist_theme_set_unread_message_nick_said_text_info(theme, g_value_get_pointer(value));
323 break;
324 case PROP_STATUS:
325 pidgin_blist_theme_set_status_text_info(theme, g_value_get_pointer(value));
326 break;
327 default:
328 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, psec);
329 break;
333 static void
334 pidgin_blist_theme_finalize(GObject *obj)
336 PidginBlistThemePrivate *priv;
338 priv = pidgin_blist_theme_get_instance_private(
339 PIDGIN_BLIST_THEME(obj));
341 /* Buddy List */
342 if (priv->bgcolor)
343 gdk_rgba_free(priv->bgcolor);
344 g_free(priv->layout);
346 /* Group */
347 if (priv->expanded_color)
348 gdk_rgba_free(priv->expanded_color);
349 pidgin_theme_font_free(priv->expanded);
350 if (priv->collapsed_color)
351 gdk_rgba_free(priv->collapsed_color);
352 pidgin_theme_font_free(priv->collapsed);
354 /* Buddy */
355 if (priv->contact_color)
356 gdk_rgba_free(priv->contact_color);
357 pidgin_theme_font_free(priv->contact);
358 pidgin_theme_font_free(priv->online);
359 pidgin_theme_font_free(priv->away);
360 pidgin_theme_font_free(priv->offline);
361 pidgin_theme_font_free(priv->idle);
362 pidgin_theme_font_free(priv->message);
363 pidgin_theme_font_free(priv->message_nick_said);
364 pidgin_theme_font_free(priv->status);
366 G_OBJECT_CLASS(pidgin_blist_theme_parent_class)->finalize (obj);
369 static void
370 pidgin_blist_theme_init(PidginBlistTheme *theme)
372 PidginBlistThemePrivate *priv =
373 pidgin_blist_theme_get_instance_private(theme);
375 priv->opacity = 1.0;
378 static void
379 pidgin_blist_theme_class_init(PidginBlistThemeClass *klass)
381 GObjectClass *obj_class = G_OBJECT_CLASS(klass);
383 obj_class->get_property = pidgin_blist_theme_get_property;
384 obj_class->set_property = pidgin_blist_theme_set_property;
385 obj_class->finalize = pidgin_blist_theme_finalize;
387 /* Buddy List */
388 properties[PROP_BACKGROUND_COLOR] = g_param_spec_boxed("background-color",
389 "Background Color",
390 "The background color for the buddy list",
391 GDK_TYPE_RGBA, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
393 properties[PROP_OPACITY] = g_param_spec_double("opacity", "Opacity",
394 "The opacity of the buddy list",
395 0.0, 1.0, 1.0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
397 properties[PROP_LAYOUT] = g_param_spec_pointer("layout", "Layout",
398 "The layout of icons, name, and status of the buddy list",
399 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
401 /* Group */
402 properties[PROP_EXPANDED_COLOR] = g_param_spec_boxed("expanded-color",
403 "Expanded Background Color",
404 "The background color of an expanded group",
405 GDK_TYPE_RGBA, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
407 properties[PROP_EXPANDED_TEXT] = g_param_spec_pointer("expanded-text",
408 "Expanded Text",
409 "The text information for when a group is expanded",
410 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
412 properties[PROP_COLLAPSED_COLOR] = g_param_spec_boxed("collapsed-color",
413 "Collapsed Background Color",
414 "The background color of a collapsed group",
415 GDK_TYPE_RGBA, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
417 properties[PROP_COLLAPSED_TEXT] = g_param_spec_pointer("collapsed-text",
418 "Collapsed Text",
419 "The text information for when a group is collapsed",
420 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
422 /* Buddy */
423 properties[PROP_CONTACT_COLOR] = g_param_spec_boxed("contact-color",
424 "Contact/Chat Background Color",
425 "The background color of a contact or chat",
426 GDK_TYPE_RGBA, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
428 properties[PROP_CONTACT] = g_param_spec_pointer("contact",
429 "Contact Text",
430 "The text information for when a contact is expanded",
431 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
433 properties[PROP_ONLINE] = g_param_spec_pointer("online",
434 "Online Text",
435 "The text information for when a buddy is online",
436 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
438 properties[PROP_AWAY] = g_param_spec_pointer("away",
439 "Away Text",
440 "The text information for when a buddy is away",
441 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
443 properties[PROP_OFFLINE] = g_param_spec_pointer("offline",
444 "Offline Text",
445 "The text information for when a buddy is offline",
446 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
448 properties[PROP_IDLE] = g_param_spec_pointer("idle",
449 "Idle Text",
450 "The text information for when a buddy is idle",
451 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
453 properties[PROP_MESSAGE] = g_param_spec_pointer("message",
454 "Message Text",
455 "The text information for when a buddy has an unread message",
456 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
458 properties[PROP_MESSAGE_NICK_SAID] = g_param_spec_pointer("message-nick-said",
459 "Message (Nick Said) Text",
460 "The text information for when a chat has an unread message that mentions your nickname",
461 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
463 properties[PROP_STATUS] = g_param_spec_pointer("status",
464 "Status Text",
465 "The text information for a buddy's status",
466 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
468 g_object_class_install_properties(obj_class, PROP_LAST, properties);
471 /**************************************************************************
472 * GBoxed Stuff
473 **************************************************************************/
475 static PidginThemeFont *
476 pidgin_theme_font_copy(PidginThemeFont *font)
478 g_return_val_if_fail(font != NULL, NULL);
480 return pidgin_theme_font_new(font->font, font->gdkcolor);
483 GType
484 pidgin_theme_font_get_type(void)
486 static GType type = 0;
488 if (type == 0) {
489 type = g_boxed_type_register_static("PidginThemeFont",
490 (GBoxedCopyFunc)pidgin_theme_font_copy,
491 (GBoxedFreeFunc)pidgin_theme_font_free);
494 return type;
497 static PidginBlistLayout *
498 pidgin_blist_layout_copy(const PidginBlistLayout *layout)
500 g_return_val_if_fail(layout != NULL, NULL);
502 return g_memdup(layout, sizeof(PidginBlistLayout));
505 GType
506 pidgin_blist_layout_get_type(void)
508 static GType type = 0;
510 if (type == 0) {
511 type = g_boxed_type_register_static("PidginBlistLayout",
512 (GBoxedCopyFunc)pidgin_blist_layout_copy,
513 (GBoxedFreeFunc)g_free);
516 return type;
520 /*****************************************************************************
521 * Public API functions
522 *****************************************************************************/
524 /* get methods */
526 GdkRGBA *
527 pidgin_blist_theme_get_background_color(PidginBlistTheme *theme)
529 PidginBlistThemePrivate *priv;
531 g_return_val_if_fail(PIDGIN_IS_BLIST_THEME(theme), NULL);
533 priv = pidgin_blist_theme_get_instance_private(theme);
535 return priv->bgcolor;
538 gdouble
539 pidgin_blist_theme_get_opacity(PidginBlistTheme *theme)
541 PidginBlistThemePrivate *priv;
543 g_return_val_if_fail(PIDGIN_IS_BLIST_THEME(theme), 1.0);
545 priv = pidgin_blist_theme_get_instance_private(theme);
547 return priv->opacity;
550 PidginBlistLayout *
551 pidgin_blist_theme_get_layout(PidginBlistTheme *theme)
553 PidginBlistThemePrivate *priv;
555 g_return_val_if_fail(PIDGIN_IS_BLIST_THEME(theme), NULL);
557 priv = pidgin_blist_theme_get_instance_private(theme);
559 return priv->layout;
562 GdkRGBA *
563 pidgin_blist_theme_get_expanded_background_color(PidginBlistTheme *theme)
565 PidginBlistThemePrivate *priv;
567 g_return_val_if_fail(PIDGIN_IS_BLIST_THEME(theme), NULL);
569 priv = pidgin_blist_theme_get_instance_private(theme);
571 return priv->expanded_color;
574 PidginThemeFont *
575 pidgin_blist_theme_get_expanded_text_info(PidginBlistTheme *theme)
577 PidginBlistThemePrivate *priv;
579 g_return_val_if_fail(PIDGIN_IS_BLIST_THEME(theme), NULL);
581 priv = pidgin_blist_theme_get_instance_private(theme);
583 return priv->expanded;
586 GdkRGBA *
587 pidgin_blist_theme_get_collapsed_background_color(PidginBlistTheme *theme)
589 PidginBlistThemePrivate *priv;
591 g_return_val_if_fail(PIDGIN_IS_BLIST_THEME(theme), NULL);
593 priv = pidgin_blist_theme_get_instance_private(theme);
595 return priv->collapsed_color;
598 PidginThemeFont *
599 pidgin_blist_theme_get_collapsed_text_info(PidginBlistTheme *theme)
601 PidginBlistThemePrivate *priv;
603 g_return_val_if_fail(PIDGIN_IS_BLIST_THEME(theme), NULL);
605 priv = pidgin_blist_theme_get_instance_private(theme);
607 return priv->collapsed;
610 GdkRGBA *
611 pidgin_blist_theme_get_contact_color(PidginBlistTheme *theme)
613 PidginBlistThemePrivate *priv;
615 g_return_val_if_fail(PIDGIN_IS_BLIST_THEME(theme), NULL);
617 priv = pidgin_blist_theme_get_instance_private(theme);
619 return priv->contact_color;
622 PidginThemeFont *
623 pidgin_blist_theme_get_contact_text_info(PidginBlistTheme *theme)
625 PidginBlistThemePrivate *priv;
627 g_return_val_if_fail(PIDGIN_IS_BLIST_THEME(theme), NULL);
629 priv = pidgin_blist_theme_get_instance_private(theme);
631 return priv->contact;
634 PidginThemeFont *
635 pidgin_blist_theme_get_online_text_info(PidginBlistTheme *theme)
637 PidginBlistThemePrivate *priv;
639 g_return_val_if_fail(PIDGIN_IS_BLIST_THEME(theme), NULL);
641 priv = pidgin_blist_theme_get_instance_private(theme);
643 return priv->online;
646 PidginThemeFont *
647 pidgin_blist_theme_get_away_text_info(PidginBlistTheme *theme)
649 PidginBlistThemePrivate *priv;
651 g_return_val_if_fail(PIDGIN_IS_BLIST_THEME(theme), NULL);
653 priv = pidgin_blist_theme_get_instance_private(theme);
655 return priv->away;
658 PidginThemeFont *
659 pidgin_blist_theme_get_offline_text_info(PidginBlistTheme *theme)
661 PidginBlistThemePrivate *priv;
663 g_return_val_if_fail(PIDGIN_IS_BLIST_THEME(theme), NULL);
665 priv = pidgin_blist_theme_get_instance_private(theme);
667 return priv->offline;
670 PidginThemeFont *
671 pidgin_blist_theme_get_idle_text_info(PidginBlistTheme *theme)
673 PidginBlistThemePrivate *priv;
675 g_return_val_if_fail(PIDGIN_IS_BLIST_THEME(theme), NULL);
677 priv = pidgin_blist_theme_get_instance_private(theme);
679 return priv->idle;
682 PidginThemeFont *
683 pidgin_blist_theme_get_unread_message_text_info(PidginBlistTheme *theme)
685 PidginBlistThemePrivate *priv;
687 g_return_val_if_fail(PIDGIN_IS_BLIST_THEME(theme), NULL);
689 priv = pidgin_blist_theme_get_instance_private(theme);
691 return priv->message;
694 PidginThemeFont *
695 pidgin_blist_theme_get_unread_message_nick_said_text_info(PidginBlistTheme *theme)
697 PidginBlistThemePrivate *priv;
699 g_return_val_if_fail(PIDGIN_IS_BLIST_THEME(theme), NULL);
701 priv = pidgin_blist_theme_get_instance_private(theme);
703 return priv->message_nick_said;
706 PidginThemeFont *
707 pidgin_blist_theme_get_status_text_info(PidginBlistTheme *theme)
709 PidginBlistThemePrivate *priv;
711 g_return_val_if_fail(PIDGIN_IS_BLIST_THEME(theme), NULL);
713 priv = pidgin_blist_theme_get_instance_private(theme);
715 return priv->status;
718 /* Set Methods */
719 void
720 pidgin_blist_theme_set_background_color(PidginBlistTheme *theme, const GdkRGBA *color)
722 PidginBlistThemePrivate *priv;
724 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme));
726 priv = pidgin_blist_theme_get_instance_private(theme);
728 if (priv->bgcolor)
729 gdk_rgba_free(priv->bgcolor);
730 priv->bgcolor = color ? gdk_rgba_copy(color) : NULL;
732 g_object_notify_by_pspec(G_OBJECT(theme), properties[PROP_BACKGROUND_COLOR]);
735 void
736 pidgin_blist_theme_set_opacity(PidginBlistTheme *theme, gdouble opacity)
738 PidginBlistThemePrivate *priv;
740 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme) || opacity < 0.0 || opacity > 1.0);
742 priv = pidgin_blist_theme_get_instance_private(theme);
744 priv->opacity = opacity;
746 g_object_notify_by_pspec(G_OBJECT(theme), properties[PROP_OPACITY]);
749 void
750 pidgin_blist_theme_set_layout(PidginBlistTheme *theme, const PidginBlistLayout *layout)
752 PidginBlistThemePrivate *priv;
754 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme));
756 priv = pidgin_blist_theme_get_instance_private(theme);
758 g_free(priv->layout);
759 priv->layout = pidgin_blist_layout_copy(layout);
761 g_object_notify_by_pspec(G_OBJECT(theme), properties[PROP_LAYOUT]);
764 void
765 pidgin_blist_theme_set_expanded_background_color(PidginBlistTheme *theme, const GdkRGBA *color)
767 PidginBlistThemePrivate *priv;
769 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme));
771 priv = pidgin_blist_theme_get_instance_private(theme);
773 if (priv->expanded_color)
774 gdk_rgba_free(priv->expanded_color);
775 priv->expanded_color = color ? gdk_rgba_copy(color) : NULL;
777 g_object_notify_by_pspec(G_OBJECT(theme), properties[PROP_EXPANDED_COLOR]);
780 void
781 pidgin_blist_theme_set_expanded_text_info(PidginBlistTheme *theme, const PidginThemeFont *pair)
783 PidginBlistThemePrivate *priv;
785 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme));
787 priv = pidgin_blist_theme_get_instance_private(theme);
789 pidgin_theme_font_free(priv->expanded);
790 priv->expanded = copy_font_and_color(pair);
792 g_object_notify_by_pspec(G_OBJECT(theme), properties[PROP_EXPANDED_TEXT]);
795 void
796 pidgin_blist_theme_set_collapsed_background_color(PidginBlistTheme *theme, const GdkRGBA *color)
798 PidginBlistThemePrivate *priv;
800 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme));
802 priv = pidgin_blist_theme_get_instance_private(theme);
804 if (priv->collapsed_color)
805 gdk_rgba_free(priv->collapsed_color);
806 priv->collapsed_color = color ? gdk_rgba_copy(color) : NULL;
808 g_object_notify_by_pspec(G_OBJECT(theme), properties[PROP_COLLAPSED_COLOR]);
811 void
812 pidgin_blist_theme_set_collapsed_text_info(PidginBlistTheme *theme, const PidginThemeFont *pair)
814 PidginBlistThemePrivate *priv;
816 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme));
818 priv = pidgin_blist_theme_get_instance_private(theme);
820 pidgin_theme_font_free(priv->collapsed);
821 priv->collapsed = copy_font_and_color(pair);
823 g_object_notify_by_pspec(G_OBJECT(theme), properties[PROP_COLLAPSED_TEXT]);
826 void
827 pidgin_blist_theme_set_contact_color(PidginBlistTheme *theme, const GdkRGBA *color)
829 PidginBlistThemePrivate *priv;
831 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme));
833 priv = pidgin_blist_theme_get_instance_private(theme);
835 if (priv->contact_color)
836 gdk_rgba_free(priv->contact_color);
837 priv->contact_color = color ? gdk_rgba_copy(color) : NULL;
839 g_object_notify_by_pspec(G_OBJECT(theme), properties[PROP_CONTACT_COLOR]);
842 void
843 pidgin_blist_theme_set_contact_text_info(PidginBlistTheme *theme, const PidginThemeFont *pair)
845 PidginBlistThemePrivate *priv;
847 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme));
849 priv = pidgin_blist_theme_get_instance_private(theme);
851 pidgin_theme_font_free(priv->contact);
852 priv->contact = copy_font_and_color(pair);
854 g_object_notify_by_pspec(G_OBJECT(theme), properties[PROP_CONTACT]);
857 void
858 pidgin_blist_theme_set_online_text_info(PidginBlistTheme *theme, const PidginThemeFont *pair)
860 PidginBlistThemePrivate *priv;
862 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme));
864 priv = pidgin_blist_theme_get_instance_private(theme);
866 pidgin_theme_font_free(priv->online);
867 priv->online = copy_font_and_color(pair);
869 g_object_notify_by_pspec(G_OBJECT(theme), properties[PROP_ONLINE]);
872 void
873 pidgin_blist_theme_set_away_text_info(PidginBlistTheme *theme, const PidginThemeFont *pair)
875 PidginBlistThemePrivate *priv;
877 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme));
879 priv = pidgin_blist_theme_get_instance_private(theme);
881 pidgin_theme_font_free(priv->away);
882 priv->away = copy_font_and_color(pair);
884 g_object_notify_by_pspec(G_OBJECT(theme), properties[PROP_AWAY]);
887 void
888 pidgin_blist_theme_set_offline_text_info(PidginBlistTheme *theme, const PidginThemeFont *pair)
890 PidginBlistThemePrivate *priv;
892 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme));
894 priv = pidgin_blist_theme_get_instance_private(theme);
896 pidgin_theme_font_free(priv->offline);
897 priv->offline = copy_font_and_color(pair);
899 g_object_notify_by_pspec(G_OBJECT(theme), properties[PROP_OFFLINE]);
902 void
903 pidgin_blist_theme_set_idle_text_info(PidginBlistTheme *theme, const PidginThemeFont *pair)
905 PidginBlistThemePrivate *priv;
907 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme));
909 priv = pidgin_blist_theme_get_instance_private(theme);
911 pidgin_theme_font_free(priv->idle);
912 priv->idle = copy_font_and_color(pair);
914 g_object_notify_by_pspec(G_OBJECT(theme), properties[PROP_IDLE]);
917 void
918 pidgin_blist_theme_set_unread_message_text_info(PidginBlistTheme *theme, const PidginThemeFont *pair)
920 PidginBlistThemePrivate *priv;
922 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme));
924 priv = pidgin_blist_theme_get_instance_private(theme);
926 pidgin_theme_font_free(priv->message);
927 priv->message = copy_font_and_color(pair);
929 g_object_notify_by_pspec(G_OBJECT(theme), properties[PROP_MESSAGE]);
932 void
933 pidgin_blist_theme_set_unread_message_nick_said_text_info(PidginBlistTheme *theme, const PidginThemeFont *pair)
935 PidginBlistThemePrivate *priv;
937 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme));
939 priv = pidgin_blist_theme_get_instance_private(theme);
941 pidgin_theme_font_free(priv->message_nick_said);
942 priv->message_nick_said = copy_font_and_color(pair);
944 g_object_notify_by_pspec(G_OBJECT(theme), properties[PROP_MESSAGE_NICK_SAID]);
947 void
948 pidgin_blist_theme_set_status_text_info(PidginBlistTheme *theme, const PidginThemeFont *pair)
950 PidginBlistThemePrivate *priv;
952 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme));
954 priv = pidgin_blist_theme_get_instance_private(theme);
956 pidgin_theme_font_free(priv->status);
957 priv->status = copy_font_and_color(pair);
959 g_object_notify_by_pspec(G_OBJECT(theme), properties[PROP_STATUS]);