changeset 26658:80f2d19e524f

Allow unsetting the color for a PidginThemeFont.
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Sat, 18 Apr 2009 18:11:28 +0000
parents 37aca5864715
children 4fca203e33be
files pidgin/gtkblist-theme.c pidgin/gtkblist-theme.h
diffstat 2 files changed, 13 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/pidgin/gtkblist-theme.c	Fri Apr 17 23:50:36 2009 +0000
+++ b/pidgin/gtkblist-theme.c	Sat Apr 18 18:11:28 2009 +0000
@@ -105,7 +105,8 @@
 {
 	PidginThemeFont *font = g_new0(PidginThemeFont, 1);
 	font->font = g_strdup(face);
-	pidgin_theme_font_set_color(font, color);
+	if (color)
+		pidgin_theme_font_set_color(font, color);
 	return font;
 }
 
@@ -144,13 +145,16 @@
 pidgin_theme_font_set_color(PidginThemeFont *font, const GdkColor *color)
 {
 	g_return_if_fail(font);
-	g_return_if_fail(color);
 
 	if (font->gdkcolor)
 		gdk_color_free(font->gdkcolor);
-	font->gdkcolor = gdk_color_copy(color);
-	g_snprintf(font->color, sizeof(font->color),
-			"#%02x%02x%02x", color->red >> 8, color->green >> 8, color->blue >> 8);
+
+	font->gdkcolor = color ? gdk_color_copy(color) : NULL;
+	if (color)
+		g_snprintf(font->color, sizeof(font->color),
+				"#%02x%02x%02x", color->red >> 8, color->green >> 8, color->blue >> 8);
+	else
+		font->color[0] = '\0';
 }
 
 const gchar *
@@ -171,7 +175,7 @@
 pidgin_theme_font_get_color_describe(PidginThemeFont *font)
 {
 	g_return_val_if_fail(font, NULL);
-	return font->color;
+	return font->color[0] ? font->color : NULL;
 }
 
 /******************************************************************************
--- a/pidgin/gtkblist-theme.h	Fri Apr 17 23:50:36 2009 +0000
+++ b/pidgin/gtkblist-theme.h	Sat Apr 18 18:11:28 2009 +0000
@@ -122,7 +122,7 @@
  *
  * @param font  The PidginThemeFont
  *
- * @return The font-face
+ * @return The font-face, or NULL if none is set.
  */
 const gchar * pidgin_theme_font_get_font_face(PidginThemeFont *font);
 
@@ -131,7 +131,7 @@
  *
  * @param font  The PidginThemeFont
  *
- * @return The color
+ * @return The color, or NULL if none is set.
  */
 const GdkColor * pidgin_theme_font_get_color(PidginThemeFont *font);
 
@@ -140,7 +140,7 @@
  *
  * @param font  The PidginThemeFont
  *
- * @return The color
+ * @return The color, or NULL if none is set.
  */
 const gchar * pidgin_theme_font_get_color_describe(PidginThemeFont *font);