changeset 26577:4fca203e33be

Allow editing the theme when no theme is selected (the default).
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Sat, 18 Apr 2009 18:13:04 +0000
parents 80f2d19e524f
children e9e253607e35
files pidgin/plugins/themeedit.c
diffstat 1 files changed, 25 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/pidgin/plugins/themeedit.c	Sat Apr 18 18:11:28 2009 +0000
+++ b/pidgin/plugins/themeedit.c	Sat Apr 18 18:13:04 2009 +0000
@@ -63,7 +63,13 @@
 		} else {
 			PidginThemeFont *font = NULL;
 			g_object_get(G_OBJECT(theme), prop, &font, NULL);
-			pidgin_theme_font_set_color(font, &color);
+			if (!font) {
+				font = pidgin_theme_font_new(NULL, &color);
+				g_object_set(G_OBJECT(theme), prop, font, NULL);
+				pidgin_theme_font_free(font);
+			} else {
+				pidgin_theme_font_set_color(font, &color);
+			}
 		}
 		pidgin_blist_set_theme(theme);
 	}
@@ -88,13 +94,23 @@
 	GtkWidget *dialog;
 	PidginBlistTheme *theme;
 	PidginThemeFont *font = NULL;
+	const char *face;
 
 	theme = pidgin_blist_get_theme();
 	g_object_get(G_OBJECT(theme), prop, &font, NULL);
 
+	if (!font) {
+		font = pidgin_theme_font_new(NULL, NULL);
+		g_object_set(G_OBJECT(theme), prop, font, NULL);
+		pidgin_theme_font_free(font);
+		g_object_get(G_OBJECT(theme), prop, &font, NULL);
+	}
+
+	face = pidgin_theme_font_get_font_face(font);
 	dialog = gtk_font_selection_dialog_new(_("Select Font"));
-	gtk_font_selection_set_font_name(GTK_FONT_SELECTION(GTK_FONT_SELECTION_DIALOG(dialog)->fontsel),
-			pidgin_theme_font_get_font_face(font));
+	if (face && *face)
+		gtk_font_selection_set_font_name(GTK_FONT_SELECTION(GTK_FONT_SELECTION_DIALOG(dialog)->fontsel),
+				face);
 	g_signal_connect(G_OBJECT(dialog), "response", G_CALLBACK(theme_font_face_selected),
 			font);
 	gtk_widget_show_all(dialog);
@@ -219,8 +235,12 @@
 	box = pidgin_dialog_get_vbox(GTK_DIALOG(dialog));
 
 	theme = pidgin_blist_get_theme();
-	if (!theme)
-		return;
+	if (!theme) {
+		theme = g_object_new(PIDGIN_TYPE_BLIST_THEME, "type", "blist",
+				"author", getlogin(),
+				NULL);
+		pidgin_blist_set_theme(theme);
+	}
 	klass = G_OBJECT_CLASS(PIDGIN_BLIST_THEME_GET_CLASS(theme));
 
 	group = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);