Replace strcmp() with purple_strequal()
[pidgin-git.git] / pidgin / gtkblist-theme.c
blob83585aa0bd6b7b61aed3ab4304a1982ac78e5fe1
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 "gtkblist-theme.h"
26 #define PIDGIN_BLIST_THEME_GET_PRIVATE(Gobject) \
27 ((PidginBlistThemePrivate *) ((PIDGIN_BLIST_THEME(Gobject))->priv))
29 /******************************************************************************
30 * Structs
31 *****************************************************************************/
33 typedef struct {
34 /* Buddy list */
35 gdouble opacity;
36 GdkColor *bgcolor;
37 PidginBlistLayout *layout;
39 /* groups */
40 GdkColor *expanded_color;
41 PidginThemeFont *expanded;
43 GdkColor *collapsed_color;
44 PidginThemeFont *collapsed;
46 /* buddy */
47 GdkColor *contact_color;
49 PidginThemeFont *contact;
51 PidginThemeFont *online;
52 PidginThemeFont *away;
53 PidginThemeFont *offline;
54 PidginThemeFont *idle;
55 PidginThemeFont *message;
56 PidginThemeFont *message_nick_said;
58 PidginThemeFont *status;
60 } PidginBlistThemePrivate;
62 struct _PidginThemeFont
64 gchar *font;
65 gchar color[10];
66 GdkColor *gdkcolor;
69 /******************************************************************************
70 * Globals
71 *****************************************************************************/
73 static GObjectClass *parent_class = NULL;
75 /******************************************************************************
76 * Enums
77 *****************************************************************************/
79 enum {
80 PROP_ZERO = 0,
81 PROP_BACKGROUND_COLOR,
82 PROP_OPACITY,
83 PROP_LAYOUT,
84 PROP_EXPANDED_COLOR,
85 PROP_EXPANDED_TEXT,
86 PROP_COLLAPSED_COLOR,
87 PROP_COLLAPSED_TEXT,
88 PROP_CONTACT_COLOR,
89 PROP_CONTACT,
90 PROP_ONLINE,
91 PROP_AWAY,
92 PROP_OFFLINE,
93 PROP_IDLE,
94 PROP_MESSAGE,
95 PROP_MESSAGE_NICK_SAID,
96 PROP_STATUS,
99 /******************************************************************************
100 * Helpers
101 *****************************************************************************/
103 PidginThemeFont *
104 pidgin_theme_font_new(const gchar *face, GdkColor *color)
106 PidginThemeFont *font = g_new0(PidginThemeFont, 1);
107 font->font = g_strdup(face);
108 if (color)
109 pidgin_theme_font_set_color(font, color);
110 return font;
113 void
114 pidgin_theme_font_free(PidginThemeFont *pair)
116 if (pair != NULL) {
117 g_free(pair->font);
118 if (pair->gdkcolor)
119 gdk_color_free(pair->gdkcolor);
120 g_free(pair);
124 static PidginThemeFont *
125 copy_font_and_color(const PidginThemeFont *pair)
127 PidginThemeFont *copy;
129 if (pair == NULL)
130 return NULL;
132 copy = g_new0(PidginThemeFont, 1);
133 copy->font = g_strdup(pair->font);
134 strncpy(copy->color, pair->color, sizeof(copy->color) - 1);
135 if (pair->gdkcolor)
136 copy->gdkcolor = pair->gdkcolor ? gdk_color_copy(pair->gdkcolor) : NULL;
137 return copy;
140 void
141 pidgin_theme_font_set_font_face(PidginThemeFont *font, const gchar *face)
143 g_return_if_fail(font);
144 g_return_if_fail(face);
146 g_free(font->font);
147 font->font = g_strdup(face);
150 void
151 pidgin_theme_font_set_color(PidginThemeFont *font, const GdkColor *color)
153 g_return_if_fail(font);
155 if (font->gdkcolor)
156 gdk_color_free(font->gdkcolor);
158 font->gdkcolor = color ? gdk_color_copy(color) : NULL;
159 if (color)
160 g_snprintf(font->color, sizeof(font->color),
161 "#%02x%02x%02x", color->red >> 8, color->green >> 8, color->blue >> 8);
162 else
163 font->color[0] = '\0';
166 const gchar *
167 pidgin_theme_font_get_font_face(PidginThemeFont *font)
169 g_return_val_if_fail(font, NULL);
170 return font->font;
173 const GdkColor *
174 pidgin_theme_font_get_color(PidginThemeFont *font)
176 g_return_val_if_fail(font, NULL);
177 return font->gdkcolor;
180 const gchar *
181 pidgin_theme_font_get_color_describe(PidginThemeFont *font)
183 g_return_val_if_fail(font, NULL);
184 return font->color[0] ? font->color : NULL;
187 /******************************************************************************
188 * GObject Stuff
189 *****************************************************************************/
191 static void
192 pidgin_blist_theme_init(GTypeInstance *instance,
193 gpointer klass)
195 (PIDGIN_BLIST_THEME(instance))->priv = g_new0(PidginBlistThemePrivate, 1);
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_color_free(priv->bgcolor);
330 g_free(priv->layout);
332 /* Group */
333 if (priv->expanded_color)
334 gdk_color_free(priv->expanded_color);
335 pidgin_theme_font_free(priv->expanded);
336 if (priv->collapsed_color)
337 gdk_color_free(priv->collapsed_color);
338 pidgin_theme_font_free(priv->collapsed);
340 /* Buddy */
341 if (priv->contact_color)
342 gdk_color_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 g_free(priv);
354 parent_class->finalize (obj);
357 static void
358 pidgin_blist_theme_class_init(PidginBlistThemeClass *klass)
360 GObjectClass *obj_class = G_OBJECT_CLASS(klass);
361 GParamSpec *pspec;
363 parent_class = g_type_class_peek_parent (klass);
365 obj_class->get_property = pidgin_blist_theme_get_property;
366 obj_class->set_property = pidgin_blist_theme_set_property;
367 obj_class->finalize = pidgin_blist_theme_finalize;
369 /* Buddy List */
370 pspec = g_param_spec_boxed("background-color", _("Background Color"),
371 _("The background color for the buddy list"),
372 GDK_TYPE_COLOR, G_PARAM_READWRITE);
373 g_object_class_install_property(obj_class, PROP_BACKGROUND_COLOR, pspec);
375 pspec = g_param_spec_pointer("layout", _("Layout"),
376 _("The layout of icons, name, and status of the buddy list"),
377 G_PARAM_READWRITE);
379 g_object_class_install_property(obj_class, PROP_LAYOUT, pspec);
381 /* Group */
382 /* Note to translators: These two strings refer to the background color
383 of a buddy list group when in its expanded state */
384 pspec = g_param_spec_boxed("expanded-color", _("Expanded Background Color"),
385 _("The background color of an expanded group"),
386 GDK_TYPE_COLOR, G_PARAM_READWRITE);
387 g_object_class_install_property(obj_class, PROP_EXPANDED_COLOR, pspec);
389 /* Note to translators: These two strings refer to the font and color
390 of a buddy list group when in its expanded state */
391 pspec = g_param_spec_pointer("expanded-text", _("Expanded Text"),
392 _("The text information for when a group is expanded"),
393 G_PARAM_READWRITE);
394 g_object_class_install_property(obj_class, PROP_EXPANDED_TEXT, pspec);
396 /* Note to translators: These two strings refer to the background color
397 of a buddy list group when in its collapsed state */
398 pspec = g_param_spec_boxed("collapsed-color", _("Collapsed Background Color"),
399 _("The background color of a collapsed group"),
400 GDK_TYPE_COLOR, G_PARAM_READWRITE);
401 g_object_class_install_property(obj_class, PROP_COLLAPSED_COLOR, pspec);
403 /* Note to translators: These two strings refer to the font and color
404 of a buddy list group when in its collapsed state */
405 pspec = g_param_spec_pointer("collapsed-text", _("Collapsed Text"),
406 _("The text information for when a group is collapsed"),
407 G_PARAM_READWRITE);
408 g_object_class_install_property(obj_class, PROP_COLLAPSED_TEXT, pspec);
410 /* Buddy */
411 /* Note to translators: These two strings refer to the background color
412 of a buddy list contact or chat room */
413 pspec = g_param_spec_boxed("contact-color", _("Contact/Chat Background Color"),
414 _("The background color of a contact or chat"),
415 GDK_TYPE_COLOR, G_PARAM_READWRITE);
416 g_object_class_install_property(obj_class, PROP_CONTACT_COLOR, pspec);
418 /* Note to translators: These two strings refer to the font and color
419 of a buddy list contact when in its expanded state */
420 pspec = g_param_spec_pointer("contact", _("Contact Text"),
421 _("The text information for when a contact is expanded"),
422 G_PARAM_READWRITE);
423 g_object_class_install_property(obj_class, PROP_CONTACT, pspec);
425 /* Note to translators: These two strings refer to the font and color
426 of a buddy list buddy when it is online */
427 pspec = g_param_spec_pointer("online", _("Online Text"),
428 _("The text information for when a buddy is online"),
429 G_PARAM_READWRITE);
430 g_object_class_install_property(obj_class, PROP_ONLINE, pspec);
432 /* Note to translators: These two strings refer to the font and color
433 of a buddy list buddy when it is away */
434 pspec = g_param_spec_pointer("away", _("Away Text"),
435 _("The text information for when a buddy is away"),
436 G_PARAM_READWRITE);
437 g_object_class_install_property(obj_class, PROP_AWAY, pspec);
439 /* Note to translators: These two strings refer to the font and color
440 of a buddy list buddy when it is offline */
441 pspec = g_param_spec_pointer("offline", _("Offline Text"),
442 _("The text information for when a buddy is offline"),
443 G_PARAM_READWRITE);
444 g_object_class_install_property(obj_class, PROP_OFFLINE, pspec);
446 /* Note to translators: These two strings refer to the font and color
447 of a buddy list buddy when it is idle */
448 pspec = g_param_spec_pointer("idle", _("Idle Text"),
449 _("The text information for when a buddy is idle"),
450 G_PARAM_READWRITE);
451 g_object_class_install_property(obj_class, PROP_IDLE, pspec);
453 /* Note to translators: These two strings refer to the font and color
454 of a buddy list buddy when they have sent you a new message */
455 pspec = g_param_spec_pointer("message", _("Message Text"),
456 _("The text information for when a buddy has an unread message"),
457 G_PARAM_READWRITE);
458 g_object_class_install_property(obj_class, PROP_MESSAGE, pspec);
460 /* Note to translators: These two strings refer to the font and color
461 of a buddy list buddy when they have sent you a new message */
462 pspec = g_param_spec_pointer("message_nick_said", _("Message (Nick Said) Text"),
463 _("The text information for when a chat has an unread message that mentions your nickname"),
464 G_PARAM_READWRITE);
465 g_object_class_install_property(obj_class, PROP_MESSAGE_NICK_SAID, pspec);
467 pspec = g_param_spec_pointer("status", _("Status Text"),
468 _("The text information for a buddy's status"),
469 G_PARAM_READWRITE);
470 g_object_class_install_property(obj_class, PROP_STATUS, pspec);
473 GType
474 pidgin_blist_theme_get_type (void)
476 static GType type = 0;
477 if (type == 0) {
478 static GTypeInfo info = {
479 sizeof(PidginBlistThemeClass),
480 NULL, /* base_init */
481 NULL, /* base_finalize */
482 (GClassInitFunc)pidgin_blist_theme_class_init, /* class_init */
483 NULL, /* class_finalize */
484 NULL, /* class_data */
485 sizeof(PidginBlistTheme),
486 0, /* n_preallocs */
487 pidgin_blist_theme_init, /* instance_init */
488 NULL, /* value table */
490 type = g_type_register_static (PURPLE_TYPE_THEME,
491 "PidginBlistTheme", &info, 0);
493 return type;
497 /*****************************************************************************
498 * Public API functions
499 *****************************************************************************/
501 /* get methods */
503 GdkColor *
504 pidgin_blist_theme_get_background_color(PidginBlistTheme *theme)
506 PidginBlistThemePrivate *priv;
508 g_return_val_if_fail(PIDGIN_IS_BLIST_THEME(theme), NULL);
510 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme));
512 return priv->bgcolor;
515 gdouble
516 pidgin_blist_theme_get_opacity(PidginBlistTheme *theme)
518 PidginBlistThemePrivate *priv;
520 g_return_val_if_fail(PIDGIN_IS_BLIST_THEME(theme), 1.0);
522 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme));
524 return priv->opacity;
527 PidginBlistLayout *
528 pidgin_blist_theme_get_layout(PidginBlistTheme *theme)
530 PidginBlistThemePrivate *priv;
532 g_return_val_if_fail(PIDGIN_IS_BLIST_THEME(theme), NULL);
534 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme));
536 return priv->layout;
539 GdkColor *
540 pidgin_blist_theme_get_expanded_background_color(PidginBlistTheme *theme)
542 PidginBlistThemePrivate *priv;
544 g_return_val_if_fail(PIDGIN_IS_BLIST_THEME(theme), NULL);
546 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme));
548 return priv->expanded_color;
551 PidginThemeFont *
552 pidgin_blist_theme_get_expanded_text_info(PidginBlistTheme *theme)
554 PidginBlistThemePrivate *priv;
556 g_return_val_if_fail(PIDGIN_IS_BLIST_THEME(theme), NULL);
558 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme));
560 return priv->expanded;
563 GdkColor *
564 pidgin_blist_theme_get_collapsed_background_color(PidginBlistTheme *theme)
566 PidginBlistThemePrivate *priv;
568 g_return_val_if_fail(PIDGIN_IS_BLIST_THEME(theme), NULL);
570 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme));
572 return priv->collapsed_color;
575 PidginThemeFont *
576 pidgin_blist_theme_get_collapsed_text_info(PidginBlistTheme *theme)
578 PidginBlistThemePrivate *priv;
580 g_return_val_if_fail(PIDGIN_IS_BLIST_THEME(theme), NULL);
582 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme));
584 return priv->collapsed;
587 GdkColor *
588 pidgin_blist_theme_get_contact_color(PidginBlistTheme *theme)
590 PidginBlistThemePrivate *priv;
592 g_return_val_if_fail(PIDGIN_IS_BLIST_THEME(theme), NULL);
594 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme));
596 return priv->contact_color;
599 PidginThemeFont *
600 pidgin_blist_theme_get_contact_text_info(PidginBlistTheme *theme)
602 PidginBlistThemePrivate *priv;
604 g_return_val_if_fail(PIDGIN_IS_BLIST_THEME(theme), NULL);
606 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme));
608 return priv->contact;
611 PidginThemeFont *
612 pidgin_blist_theme_get_online_text_info(PidginBlistTheme *theme)
614 PidginBlistThemePrivate *priv;
616 g_return_val_if_fail(PIDGIN_IS_BLIST_THEME(theme), NULL);
618 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme));
620 return priv->online;
623 PidginThemeFont *
624 pidgin_blist_theme_get_away_text_info(PidginBlistTheme *theme)
626 PidginBlistThemePrivate *priv;
628 g_return_val_if_fail(PIDGIN_IS_BLIST_THEME(theme), NULL);
630 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme));
632 return priv->away;
635 PidginThemeFont *
636 pidgin_blist_theme_get_offline_text_info(PidginBlistTheme *theme)
638 PidginBlistThemePrivate *priv;
640 g_return_val_if_fail(PIDGIN_IS_BLIST_THEME(theme), NULL);
642 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme));
644 return priv->offline;
647 PidginThemeFont *
648 pidgin_blist_theme_get_idle_text_info(PidginBlistTheme *theme)
650 PidginBlistThemePrivate *priv;
652 g_return_val_if_fail(PIDGIN_IS_BLIST_THEME(theme), NULL);
654 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme));
656 return priv->idle;
659 PidginThemeFont *
660 pidgin_blist_theme_get_unread_message_text_info(PidginBlistTheme *theme)
662 PidginBlistThemePrivate *priv;
664 g_return_val_if_fail(PIDGIN_IS_BLIST_THEME(theme), NULL);
666 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme));
668 return priv->message;
671 PidginThemeFont *
672 pidgin_blist_theme_get_unread_message_nick_said_text_info(PidginBlistTheme *theme)
674 PidginBlistThemePrivate *priv;
676 g_return_val_if_fail(PIDGIN_IS_BLIST_THEME(theme), NULL);
678 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme));
680 return priv->message_nick_said;
683 PidginThemeFont *
684 pidgin_blist_theme_get_status_text_info(PidginBlistTheme *theme)
686 PidginBlistThemePrivate *priv;
688 g_return_val_if_fail(PIDGIN_IS_BLIST_THEME(theme), NULL);
690 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme));
692 return priv->status;
695 /* Set Methods */
696 void
697 pidgin_blist_theme_set_background_color(PidginBlistTheme *theme, const GdkColor *color)
699 PidginBlistThemePrivate *priv;
701 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme));
703 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme));
705 if (priv->bgcolor)
706 gdk_color_free(priv->bgcolor);
707 priv->bgcolor = color ? gdk_color_copy(color) : NULL;
710 void
711 pidgin_blist_theme_set_opacity(PidginBlistTheme *theme, gdouble opacity)
713 PidginBlistThemePrivate *priv;
715 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme) || opacity < 0.0 || opacity > 1.0);
717 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme));
719 priv->opacity = opacity;
722 void
723 pidgin_blist_theme_set_layout(PidginBlistTheme *theme, const PidginBlistLayout *layout)
725 PidginBlistThemePrivate *priv;
727 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme));
729 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme));
731 g_free(priv->layout);
732 priv->layout = g_memdup(layout, sizeof(PidginBlistLayout));
735 void
736 pidgin_blist_theme_set_expanded_background_color(PidginBlistTheme *theme, const GdkColor *color)
738 PidginBlistThemePrivate *priv;
740 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme));
742 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme));
744 if (priv->expanded_color)
745 gdk_color_free(priv->expanded_color);
746 priv->expanded_color = color ? gdk_color_copy(color) : NULL;
749 void
750 pidgin_blist_theme_set_expanded_text_info(PidginBlistTheme *theme, const PidginThemeFont *pair)
752 PidginBlistThemePrivate *priv;
754 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme));
756 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme));
758 pidgin_theme_font_free(priv->expanded);
759 priv->expanded = copy_font_and_color(pair);
762 void
763 pidgin_blist_theme_set_collapsed_background_color(PidginBlistTheme *theme, const GdkColor *color)
765 PidginBlistThemePrivate *priv;
767 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme));
769 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme));
771 if (priv->collapsed_color)
772 gdk_color_free(priv->collapsed_color);
773 priv->collapsed_color = color ? gdk_color_copy(color) : NULL;
776 void
777 pidgin_blist_theme_set_collapsed_text_info(PidginBlistTheme *theme, const PidginThemeFont *pair)
779 PidginBlistThemePrivate *priv;
781 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme));
783 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme));
785 pidgin_theme_font_free(priv->collapsed);
786 priv->collapsed = copy_font_and_color(pair);
789 void
790 pidgin_blist_theme_set_contact_color(PidginBlistTheme *theme, const GdkColor *color)
792 PidginBlistThemePrivate *priv;
794 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme));
796 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme));
798 if (priv->contact_color)
799 gdk_color_free(priv->contact_color);
800 priv->contact_color = color ? gdk_color_copy(color) : NULL;
803 void
804 pidgin_blist_theme_set_contact_text_info(PidginBlistTheme *theme, const PidginThemeFont *pair)
806 PidginBlistThemePrivate *priv;
808 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme));
810 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme));
812 pidgin_theme_font_free(priv->contact);
813 priv->contact = copy_font_and_color(pair);
816 void
817 pidgin_blist_theme_set_online_text_info(PidginBlistTheme *theme, const PidginThemeFont *pair)
819 PidginBlistThemePrivate *priv;
821 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme));
823 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme));
825 pidgin_theme_font_free(priv->online);
826 priv->online = copy_font_and_color(pair);
829 void
830 pidgin_blist_theme_set_away_text_info(PidginBlistTheme *theme, const PidginThemeFont *pair)
832 PidginBlistThemePrivate *priv;
834 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme));
836 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme));
838 pidgin_theme_font_free(priv->away);
839 priv->away = copy_font_and_color(pair);
842 void
843 pidgin_blist_theme_set_offline_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_PRIVATE(G_OBJECT(theme));
851 pidgin_theme_font_free(priv->offline);
852 priv->offline = copy_font_and_color(pair);
855 void
856 pidgin_blist_theme_set_idle_text_info(PidginBlistTheme *theme, const PidginThemeFont *pair)
858 PidginBlistThemePrivate *priv;
860 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme));
862 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme));
864 pidgin_theme_font_free(priv->idle);
865 priv->idle = copy_font_and_color(pair);
868 void
869 pidgin_blist_theme_set_unread_message_text_info(PidginBlistTheme *theme, const PidginThemeFont *pair)
871 PidginBlistThemePrivate *priv;
873 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme));
875 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme));
877 pidgin_theme_font_free(priv->message);
878 priv->message = copy_font_and_color(pair);
881 void
882 pidgin_blist_theme_set_unread_message_nick_said_text_info(PidginBlistTheme *theme, const PidginThemeFont *pair)
884 PidginBlistThemePrivate *priv;
886 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme));
888 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme));
890 pidgin_theme_font_free(priv->message_nick_said);
891 priv->message_nick_said = copy_font_and_color(pair);
894 void
895 pidgin_blist_theme_set_status_text_info(PidginBlistTheme *theme, const PidginThemeFont *pair)
897 PidginBlistThemePrivate *priv;
899 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme));
901 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme));
903 pidgin_theme_font_free(priv->status);
904 priv->status = copy_font_and_color(pair);