pidgin/gtkprefs.c

changeset 32583
0308e54f7762
parent 32581
d86376d8e168
child 32589
0722927d76ce
equal deleted inserted replaced
32582:51ebd5886504 32583:0308e54f7762
83 83
84 /* Themes page */ 84 /* Themes page */
85 static GtkWidget *prefs_sound_themes_combo_box; 85 static GtkWidget *prefs_sound_themes_combo_box;
86 static GtkWidget *prefs_blist_themes_combo_box; 86 static GtkWidget *prefs_blist_themes_combo_box;
87 static GtkWidget *prefs_conv_themes_combo_box; 87 static GtkWidget *prefs_conv_themes_combo_box;
88 static GtkWidget *prefs_conv_variants_combo_box;
88 static GtkWidget *prefs_status_themes_combo_box; 89 static GtkWidget *prefs_status_themes_combo_box;
89 static GtkWidget *prefs_smiley_themes_combo_box; 90 static GtkWidget *prefs_smiley_themes_combo_box;
90 91
91 /* Sound theme specific */ 92 /* Sound theme specific */
92 static GtkWidget *sound_entry = NULL; 93 static GtkWidget *sound_entry = NULL;
95 96
96 /* These exist outside the lifetime of the prefs dialog */ 97 /* These exist outside the lifetime of the prefs dialog */
97 static GtkListStore *prefs_sound_themes; 98 static GtkListStore *prefs_sound_themes;
98 static GtkListStore *prefs_blist_themes; 99 static GtkListStore *prefs_blist_themes;
99 static GtkListStore *prefs_conv_themes; 100 static GtkListStore *prefs_conv_themes;
101 static GtkListStore *prefs_conv_variants;
100 static GtkListStore *prefs_status_icon_themes; 102 static GtkListStore *prefs_status_icon_themes;
101 static GtkListStore *prefs_smiley_themes; 103 static GtkListStore *prefs_smiley_themes;
102 104
103 /* 105 /*
104 * PROTOTYPES 106 * PROTOTYPES
341 prefs_sound_themes_loading = FALSE; 343 prefs_sound_themes_loading = FALSE;
342 344
343 prefs_sound_themes_combo_box = NULL; 345 prefs_sound_themes_combo_box = NULL;
344 prefs_blist_themes_combo_box = NULL; 346 prefs_blist_themes_combo_box = NULL;
345 prefs_conv_themes_combo_box = NULL; 347 prefs_conv_themes_combo_box = NULL;
348 prefs_conv_variants_combo_box = NULL;
346 prefs_status_themes_combo_box = NULL; 349 prefs_status_themes_combo_box = NULL;
347 prefs_smiley_themes_combo_box = NULL; 350 prefs_smiley_themes_combo_box = NULL;
348 351
349 sample_imhtml = NULL; 352 sample_imhtml = NULL;
350 353
494 g_free(markup); 497 g_free(markup);
495 if (pixbuf != NULL) 498 if (pixbuf != NULL)
496 g_object_unref(G_OBJECT(pixbuf)); 499 g_object_unref(G_OBJECT(pixbuf));
497 500
498 } else if (PIDGIN_IS_CONV_THEME(theme)) { 501 } else if (PIDGIN_IS_CONV_THEME(theme)) {
499 const GList *variants;
500
501 /* No image available? */ 502 /* No image available? */
502 503
503 name = purple_theme_get_name(theme); 504 name = purple_theme_get_name(theme);
504 /* No author available */ 505 /* No author available */
505 /* No description available */ 506 /* No description available */
506 507
507 /* We'll re-use the description field to show variants... 508 markup = get_theme_markup(name, FALSE, NULL, NULL);
508 * This is probably too long to be useful... Will fix later... 509
509 */ 510 gtk_list_store_append(prefs_conv_themes, &iter);
510 for (variants = pidgin_conversation_theme_get_variants(PIDGIN_CONV_THEME(theme)); 511 gtk_list_store_set(prefs_conv_themes, &iter, 1, markup, 2, name, -1);
511 variants;
512 variants = g_list_next(variants)) {
513
514 markup = get_theme_markup(name, FALSE, NULL, variants->data);
515
516 gtk_list_store_append(prefs_conv_themes, &iter);
517 gtk_list_store_set(prefs_conv_themes, &iter, 1, markup, 2, name, -1);
518 }
519 } 512 }
520 } 513 }
521 514
522 static void 515 static void
523 prefs_set_active_theme_combo(GtkWidget *combo_box, GtkListStore *store, const gchar *current_theme) 516 prefs_set_active_theme_combo(GtkWidget *combo_box, GtkListStore *store, const gchar *current_theme)
576 gtk_list_store_append(prefs_conv_themes, &iter); 569 gtk_list_store_append(prefs_conv_themes, &iter);
577 tmp = get_theme_markup(_("Default"), FALSE, _("Penguin Pimps"), 570 tmp = get_theme_markup(_("Default"), FALSE, _("Penguin Pimps"),
578 _("The default Pidgin conversation theme")); 571 _("The default Pidgin conversation theme"));
579 gtk_list_store_set(prefs_conv_themes, &iter, 0, pixbuf, 1, tmp, 2, "", -1); 572 gtk_list_store_set(prefs_conv_themes, &iter, 0, pixbuf, 1, tmp, 2, "", -1);
580 g_free(tmp); 573 g_free(tmp);
574
575 /* conversation theme variants */
576 gtk_list_store_clear(prefs_conv_variants);
581 577
582 /* status icon themes */ 578 /* status icon themes */
583 gtk_list_store_clear(prefs_status_icon_themes); 579 gtk_list_store_clear(prefs_status_icon_themes);
584 gtk_list_store_append(prefs_status_icon_themes, &iter); 580 gtk_list_store_append(prefs_status_icon_themes, &iter);
585 tmp = get_theme_markup(_("Default"), FALSE, _("Penguin Pimps"), 581 tmp = get_theme_markup(_("Default"), FALSE, _("Penguin Pimps"),
612 prefs_sound_themes = gtk_list_store_new(3, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING); 608 prefs_sound_themes = gtk_list_store_new(3, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING);
613 609
614 prefs_blist_themes = gtk_list_store_new(3, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING); 610 prefs_blist_themes = gtk_list_store_new(3, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING);
615 611
616 prefs_conv_themes = gtk_list_store_new(3, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING); 612 prefs_conv_themes = gtk_list_store_new(3, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING);
613
614 prefs_conv_variants = gtk_list_store_new(1, G_TYPE_STRING);
617 615
618 prefs_status_icon_themes = gtk_list_store_new(3, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING); 616 prefs_status_icon_themes = gtk_list_store_new(3, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING);
619 617
620 prefs_smiley_themes = gtk_list_store_new(3, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING); 618 prefs_smiley_themes = gtk_list_store_new(3, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING);
621 } 619 }
1063 PidginConvTheme *theme = NULL; 1061 PidginConvTheme *theme = NULL;
1064 GtkTreeIter iter; 1062 GtkTreeIter iter;
1065 gchar *name = NULL; 1063 gchar *name = NULL;
1066 1064
1067 if (gtk_combo_box_get_active_iter(combo_box, &iter)) { 1065 if (gtk_combo_box_get_active_iter(combo_box, &iter)) {
1066 const GList *variants;
1067 const char *current_variant;
1068 gboolean unset = TRUE;
1068 1069
1069 gtk_tree_model_get(GTK_TREE_MODEL(prefs_conv_themes), &iter, 2, &name, -1); 1070 gtk_tree_model_get(GTK_TREE_MODEL(prefs_conv_themes), &iter, 2, &name, -1);
1070 1071 if (!name || !*name) {
1071 if(!name || !g_str_equal(name, "")) 1072 g_free(name);
1072 theme = PIDGIN_CONV_THEME(purple_theme_manager_find_theme(name, "conversation")); 1073 return;
1074 }
1075
1076 purple_prefs_set_string(PIDGIN_PREFS_ROOT "/conversations/theme", name);
1077
1078 /* Update list of variants */
1079 gtk_list_store_clear(prefs_conv_variants);
1080
1081 theme = PIDGIN_CONV_THEME(purple_theme_manager_find_theme(name, "conversation"));
1082 current_variant = pidgin_conversation_theme_get_variant(theme);
1083
1084 variants = pidgin_conversation_theme_get_variants(theme);
1085 for (; variants && current_variant; variants = g_list_next(variants)) {
1086 gtk_list_store_append(prefs_conv_variants, &iter);
1087 gtk_list_store_set(prefs_conv_variants, &iter, 0, variants->data, -1);
1088
1089 if (g_str_equal(variants->data, current_variant)) {
1090 gtk_combo_box_set_active_iter(GTK_COMBO_BOX(prefs_conv_variants_combo_box), &iter);
1091 unset = FALSE;
1092 }
1093 }
1094
1095 if (unset)
1096 gtk_combo_box_set_active(GTK_COMBO_BOX(prefs_conv_variants_combo_box), 0);
1073 1097
1074 g_free(name); 1098 g_free(name);
1075 1099 }
1076 purple_debug_info("theme", "Setting conversation theme...\n"); 1100 }
1101
1102 /* sets the current conversation theme variant */
1103 static void
1104 prefs_set_conv_variant_cb(GtkComboBox *combo_box, gpointer user_data)
1105 {
1106 PidginConvTheme *theme = NULL;
1107 GtkTreeIter iter;
1108 gchar *name = NULL;
1109
1110 if (gtk_combo_box_get_active_iter(GTK_COMBO_BOX(prefs_conv_themes_combo_box), &iter)) {
1111 gtk_tree_model_get(GTK_TREE_MODEL(prefs_conv_themes), &iter, 2, &name, -1);
1112 theme = PIDGIN_CONV_THEME(purple_theme_manager_find_theme(name, "conversation"));
1113 g_free(name);
1114
1115 if (gtk_combo_box_get_active_iter(combo_box, &iter)) {
1116 gtk_tree_model_get(GTK_TREE_MODEL(prefs_conv_variants), &iter, 0, &name, -1);
1117 pidgin_conversation_theme_set_variant(theme, name);
1118 g_free(name);
1119 }
1077 } 1120 }
1078 } 1121 }
1079 1122
1080 /* sets the current icon theme */ 1123 /* sets the current icon theme */
1081 static void 1124 static void
1128 1171
1129 return combo_box; 1172 return combo_box;
1130 } 1173 }
1131 1174
1132 static GtkWidget * 1175 static GtkWidget *
1176 add_child_theme_prefs_combo(GtkWidget *vbox, GtkSizeGroup *combo_sg,
1177 GtkSizeGroup *label_sg, GtkListStore *theme_store,
1178 GCallback combo_box_cb, gpointer combo_box_cb_user_data,
1179 const char *label_str)
1180 {
1181 GtkWidget *label;
1182 GtkWidget *combo_box;
1183 GtkWidget *themesel_hbox;
1184 GtkCellRenderer *cell_rend;
1185
1186 themesel_hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE);
1187 gtk_box_pack_start(GTK_BOX(vbox), themesel_hbox, FALSE, FALSE, 0);
1188
1189 label = gtk_label_new(label_str);
1190 gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
1191 gtk_size_group_add_widget(label_sg, label);
1192 gtk_box_pack_start(GTK_BOX(themesel_hbox), label, FALSE, FALSE, 0);
1193
1194 combo_box = gtk_combo_box_new_with_model(GTK_TREE_MODEL(theme_store));
1195
1196 cell_rend = gtk_cell_renderer_text_new();
1197 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo_box), cell_rend, TRUE);
1198 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo_box), cell_rend, "text", 0, NULL);
1199 g_object_set(cell_rend, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
1200
1201 g_signal_connect(G_OBJECT(combo_box), "changed",
1202 (GCallback)combo_box_cb, combo_box_cb_user_data);
1203 gtk_size_group_add_widget(combo_sg, combo_box);
1204 gtk_box_pack_start(GTK_BOX(themesel_hbox), combo_box, TRUE, TRUE, 0);
1205
1206 return combo_box;
1207 }
1208
1209 static GtkWidget *
1133 theme_page(void) 1210 theme_page(void)
1134 { 1211 {
1135 GtkWidget *label; 1212 GtkWidget *label;
1136 GtkWidget *ret, *vbox; 1213 GtkWidget *ret, *vbox;
1137 GtkSizeGroup *label_sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); 1214 GtkSizeGroup *label_sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
1162 /* Conversation Themes */ 1239 /* Conversation Themes */
1163 prefs_conv_themes_combo_box = add_theme_prefs_combo( 1240 prefs_conv_themes_combo_box = add_theme_prefs_combo(
1164 vbox, combo_sg, label_sg, prefs_conv_themes, 1241 vbox, combo_sg, label_sg, prefs_conv_themes,
1165 (GCallback)prefs_set_conv_theme_cb, NULL, 1242 (GCallback)prefs_set_conv_theme_cb, NULL,
1166 _("Conversation Theme:"), PIDGIN_PREFS_ROOT "/conversations/theme", "conversation"); 1243 _("Conversation Theme:"), PIDGIN_PREFS_ROOT "/conversations/theme", "conversation");
1244
1245 /* Conversation Theme Variants */
1246 prefs_conv_variants_combo_box = add_child_theme_prefs_combo(
1247 vbox, combo_sg, label_sg, prefs_conv_variants,
1248 (GCallback)prefs_set_conv_variant_cb, NULL, _("\tVariant:"));
1167 1249
1168 /* Status Icon Themes */ 1250 /* Status Icon Themes */
1169 prefs_status_themes_combo_box = add_theme_prefs_combo( 1251 prefs_status_themes_combo_box = add_theme_prefs_combo(
1170 vbox, combo_sg, label_sg, prefs_status_icon_themes, 1252 vbox, combo_sg, label_sg, prefs_status_icon_themes,
1171 (GCallback)prefs_set_status_icon_theme_cb, NULL, 1253 (GCallback)prefs_set_status_icon_theme_cb, NULL,

mercurial