comparison pidgin/plugins/themeedit.c @ 26659: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 37aca5864715
children e9e253607e35
comparison
equal deleted inserted replaced
26658:80f2d19e524f 26659:4fca203e33be
61 if (prop_type_is_color(theme, prop)) { 61 if (prop_type_is_color(theme, prop)) {
62 g_object_set(G_OBJECT(theme), prop, &color, NULL); 62 g_object_set(G_OBJECT(theme), prop, &color, NULL);
63 } else { 63 } else {
64 PidginThemeFont *font = NULL; 64 PidginThemeFont *font = NULL;
65 g_object_get(G_OBJECT(theme), prop, &font, NULL); 65 g_object_get(G_OBJECT(theme), prop, &font, NULL);
66 pidgin_theme_font_set_color(font, &color); 66 if (!font) {
67 font = pidgin_theme_font_new(NULL, &color);
68 g_object_set(G_OBJECT(theme), prop, font, NULL);
69 pidgin_theme_font_free(font);
70 } else {
71 pidgin_theme_font_set_color(font, &color);
72 }
67 } 73 }
68 pidgin_blist_set_theme(theme); 74 pidgin_blist_set_theme(theme);
69 } 75 }
70 76
71 gtk_widget_destroy(GTK_WIDGET(dialog)); 77 gtk_widget_destroy(GTK_WIDGET(dialog));
86 theme_font_select_face(GtkWidget *widget, gpointer prop) 92 theme_font_select_face(GtkWidget *widget, gpointer prop)
87 { 93 {
88 GtkWidget *dialog; 94 GtkWidget *dialog;
89 PidginBlistTheme *theme; 95 PidginBlistTheme *theme;
90 PidginThemeFont *font = NULL; 96 PidginThemeFont *font = NULL;
97 const char *face;
91 98
92 theme = pidgin_blist_get_theme(); 99 theme = pidgin_blist_get_theme();
93 g_object_get(G_OBJECT(theme), prop, &font, NULL); 100 g_object_get(G_OBJECT(theme), prop, &font, NULL);
94 101
102 if (!font) {
103 font = pidgin_theme_font_new(NULL, NULL);
104 g_object_set(G_OBJECT(theme), prop, font, NULL);
105 pidgin_theme_font_free(font);
106 g_object_get(G_OBJECT(theme), prop, &font, NULL);
107 }
108
109 face = pidgin_theme_font_get_font_face(font);
95 dialog = gtk_font_selection_dialog_new(_("Select Font")); 110 dialog = gtk_font_selection_dialog_new(_("Select Font"));
96 gtk_font_selection_set_font_name(GTK_FONT_SELECTION(GTK_FONT_SELECTION_DIALOG(dialog)->fontsel), 111 if (face && *face)
97 pidgin_theme_font_get_font_face(font)); 112 gtk_font_selection_set_font_name(GTK_FONT_SELECTION(GTK_FONT_SELECTION_DIALOG(dialog)->fontsel),
113 face);
98 g_signal_connect(G_OBJECT(dialog), "response", G_CALLBACK(theme_font_face_selected), 114 g_signal_connect(G_OBJECT(dialog), "response", G_CALLBACK(theme_font_face_selected),
99 font); 115 font);
100 gtk_widget_show_all(dialog); 116 gtk_widget_show_all(dialog);
101 } 117 }
102 118
217 233
218 dialog = pidgin_create_dialog(_("Pidgin Buddylist Theme Editor"), 0, "theme-editor", FALSE); 234 dialog = pidgin_create_dialog(_("Pidgin Buddylist Theme Editor"), 0, "theme-editor", FALSE);
219 box = pidgin_dialog_get_vbox(GTK_DIALOG(dialog)); 235 box = pidgin_dialog_get_vbox(GTK_DIALOG(dialog));
220 236
221 theme = pidgin_blist_get_theme(); 237 theme = pidgin_blist_get_theme();
222 if (!theme) 238 if (!theme) {
223 return; 239 theme = g_object_new(PIDGIN_TYPE_BLIST_THEME, "type", "blist",
240 "author", getlogin(),
241 NULL);
242 pidgin_blist_set_theme(theme);
243 }
224 klass = G_OBJECT_CLASS(PIDGIN_BLIST_THEME_GET_CLASS(theme)); 244 klass = G_OBJECT_CLASS(PIDGIN_BLIST_THEME_GET_CLASS(theme));
225 245
226 group = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); 246 group = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
227 for (i = 0; sections[i].header; i++) { 247 for (i = 0; sections[i].header; i++) {
228 GtkWidget *vbox; 248 GtkWidget *vbox;