Mercurial > pidgin.yaz
comparison pidgin/gtkprefs.c @ 32692:0f94ec89f0bc
merged from im.pidgin.pidgin
author | Yoshiki Yazawa <yaz@honeyplanet.jp> |
---|---|
date | Mon, 26 Sep 2011 14:57:21 +0900 |
parents | 9aee8493db7f 904686722499 |
children |
comparison
equal
deleted
inserted
replaced
32438:55e678325bda | 32692:0f94ec89f0bc |
---|---|
43 #include "util.h" | 43 #include "util.h" |
44 #include "network.h" | 44 #include "network.h" |
45 | 45 |
46 #include "gtkblist.h" | 46 #include "gtkblist.h" |
47 #include "gtkconv.h" | 47 #include "gtkconv.h" |
48 #include "gtkconv-theme.h" | |
48 #include "gtkdebug.h" | 49 #include "gtkdebug.h" |
49 #include "gtkdialogs.h" | 50 #include "gtkdialogs.h" |
50 #include "gtkimhtml.h" | 51 #include "gtkimhtml.h" |
51 #include "gtkimhtmltoolbar.h" | 52 #include "gtkimhtmltoolbar.h" |
52 #include "gtkprefs.h" | 53 #include "gtkprefs.h" |
81 static GtkWidget *sample_imhtml = NULL; | 82 static GtkWidget *sample_imhtml = NULL; |
82 | 83 |
83 /* Themes page */ | 84 /* Themes page */ |
84 static GtkWidget *prefs_sound_themes_combo_box; | 85 static GtkWidget *prefs_sound_themes_combo_box; |
85 static GtkWidget *prefs_blist_themes_combo_box; | 86 static GtkWidget *prefs_blist_themes_combo_box; |
87 static GtkWidget *prefs_conv_themes_combo_box; | |
88 static GtkWidget *prefs_conv_variants_combo_box; | |
86 static GtkWidget *prefs_status_themes_combo_box; | 89 static GtkWidget *prefs_status_themes_combo_box; |
87 static GtkWidget *prefs_smiley_themes_combo_box; | 90 static GtkWidget *prefs_smiley_themes_combo_box; |
88 | 91 |
89 /* Sound theme specific */ | 92 /* Sound theme specific */ |
90 static GtkWidget *sound_entry = NULL; | 93 static GtkWidget *sound_entry = NULL; |
92 static gboolean prefs_sound_themes_loading; | 95 static gboolean prefs_sound_themes_loading; |
93 | 96 |
94 /* These exist outside the lifetime of the prefs dialog */ | 97 /* These exist outside the lifetime of the prefs dialog */ |
95 static GtkListStore *prefs_sound_themes; | 98 static GtkListStore *prefs_sound_themes; |
96 static GtkListStore *prefs_blist_themes; | 99 static GtkListStore *prefs_blist_themes; |
100 static GtkListStore *prefs_conv_themes; | |
101 static GtkListStore *prefs_conv_variants; | |
97 static GtkListStore *prefs_status_icon_themes; | 102 static GtkListStore *prefs_status_icon_themes; |
98 static GtkListStore *prefs_smiley_themes; | 103 static GtkListStore *prefs_smiley_themes; |
99 | 104 |
100 /* | 105 /* |
101 * PROTOTYPES | 106 * PROTOTYPES |
337 sound_row_sel = 0; | 342 sound_row_sel = 0; |
338 prefs_sound_themes_loading = FALSE; | 343 prefs_sound_themes_loading = FALSE; |
339 | 344 |
340 prefs_sound_themes_combo_box = NULL; | 345 prefs_sound_themes_combo_box = NULL; |
341 prefs_blist_themes_combo_box = NULL; | 346 prefs_blist_themes_combo_box = NULL; |
347 prefs_conv_themes_combo_box = NULL; | |
348 prefs_conv_variants_combo_box = NULL; | |
342 prefs_status_themes_combo_box = NULL; | 349 prefs_status_themes_combo_box = NULL; |
343 prefs_smiley_themes_combo_box = NULL; | 350 prefs_smiley_themes_combo_box = NULL; |
344 | 351 |
345 sample_imhtml = NULL; | 352 sample_imhtml = NULL; |
346 | 353 |
488 gtk_list_store_set(store, &iter, 0, pixbuf, 1, markup, 2, name, -1); | 495 gtk_list_store_set(store, &iter, 0, pixbuf, 1, markup, 2, name, -1); |
489 | 496 |
490 g_free(markup); | 497 g_free(markup); |
491 if (pixbuf != NULL) | 498 if (pixbuf != NULL) |
492 g_object_unref(G_OBJECT(pixbuf)); | 499 g_object_unref(G_OBJECT(pixbuf)); |
500 | |
501 } else if (PIDGIN_IS_CONV_THEME(theme)) { | |
502 /* No image available? */ | |
503 | |
504 name = purple_theme_get_name(theme); | |
505 /* No author available */ | |
506 /* No description available */ | |
507 | |
508 markup = get_theme_markup(name, FALSE, NULL, NULL); | |
509 | |
510 gtk_list_store_append(prefs_conv_themes, &iter); | |
511 gtk_list_store_set(prefs_conv_themes, &iter, 1, markup, 2, name, -1); | |
493 } | 512 } |
494 } | 513 } |
495 | 514 |
496 static void | 515 static void |
497 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) |
542 gtk_list_store_append(prefs_blist_themes, &iter); | 561 gtk_list_store_append(prefs_blist_themes, &iter); |
543 tmp = get_theme_markup(_("Default"), FALSE, _("Penguin Pimps"), | 562 tmp = get_theme_markup(_("Default"), FALSE, _("Penguin Pimps"), |
544 _("The default Pidgin buddy list theme")); | 563 _("The default Pidgin buddy list theme")); |
545 gtk_list_store_set(prefs_blist_themes, &iter, 0, pixbuf, 1, tmp, 2, "", -1); | 564 gtk_list_store_set(prefs_blist_themes, &iter, 0, pixbuf, 1, tmp, 2, "", -1); |
546 g_free(tmp); | 565 g_free(tmp); |
566 | |
567 /* conversation themes */ | |
568 gtk_list_store_clear(prefs_conv_themes); | |
569 gtk_list_store_append(prefs_conv_themes, &iter); | |
570 tmp = get_theme_markup(_("Default"), FALSE, _("Penguin Pimps"), | |
571 _("The default Pidgin conversation theme")); | |
572 gtk_list_store_set(prefs_conv_themes, &iter, 0, pixbuf, 1, tmp, 2, "", -1); | |
573 g_free(tmp); | |
574 | |
575 /* conversation theme variants */ | |
576 gtk_list_store_clear(prefs_conv_variants); | |
547 | 577 |
548 /* status icon themes */ | 578 /* status icon themes */ |
549 gtk_list_store_clear(prefs_status_icon_themes); | 579 gtk_list_store_clear(prefs_status_icon_themes); |
550 gtk_list_store_append(prefs_status_icon_themes, &iter); | 580 gtk_list_store_append(prefs_status_icon_themes, &iter); |
551 tmp = get_theme_markup(_("Default"), FALSE, _("Penguin Pimps"), | 581 tmp = get_theme_markup(_("Default"), FALSE, _("Penguin Pimps"), |
563 smileys_refresh_theme_list(); | 593 smileys_refresh_theme_list(); |
564 | 594 |
565 /* set active */ | 595 /* set active */ |
566 prefs_set_active_theme_combo(prefs_sound_themes_combo_box, prefs_sound_themes, purple_prefs_get_string(PIDGIN_PREFS_ROOT "/sound/theme")); | 596 prefs_set_active_theme_combo(prefs_sound_themes_combo_box, prefs_sound_themes, purple_prefs_get_string(PIDGIN_PREFS_ROOT "/sound/theme")); |
567 prefs_set_active_theme_combo(prefs_blist_themes_combo_box, prefs_blist_themes, purple_prefs_get_string(PIDGIN_PREFS_ROOT "/blist/theme")); | 597 prefs_set_active_theme_combo(prefs_blist_themes_combo_box, prefs_blist_themes, purple_prefs_get_string(PIDGIN_PREFS_ROOT "/blist/theme")); |
598 prefs_set_active_theme_combo(prefs_conv_themes_combo_box, prefs_conv_themes, purple_prefs_get_string(PIDGIN_PREFS_ROOT "/conversations/theme")); | |
568 prefs_set_active_theme_combo(prefs_status_themes_combo_box, prefs_status_icon_themes, purple_prefs_get_string(PIDGIN_PREFS_ROOT "/status/icon-theme")); | 599 prefs_set_active_theme_combo(prefs_status_themes_combo_box, prefs_status_icon_themes, purple_prefs_get_string(PIDGIN_PREFS_ROOT "/status/icon-theme")); |
569 prefs_set_active_theme_combo(prefs_smiley_themes_combo_box, prefs_smiley_themes, purple_prefs_get_string(PIDGIN_PREFS_ROOT "/smileys/theme")); | 600 prefs_set_active_theme_combo(prefs_smiley_themes_combo_box, prefs_smiley_themes, purple_prefs_get_string(PIDGIN_PREFS_ROOT "/smileys/theme")); |
570 prefs_sound_themes_loading = FALSE; | 601 prefs_sound_themes_loading = FALSE; |
571 } | 602 } |
572 | 603 |
575 prefs_themes_init(void) | 606 prefs_themes_init(void) |
576 { | 607 { |
577 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); |
578 | 609 |
579 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); |
611 | |
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); | |
580 | 615 |
581 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); |
582 | 617 |
583 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); |
584 } | 619 } |
854 theme_install_theme(tmp, info); | 889 theme_install_theme(tmp, info); |
855 g_free(tmp); | 890 g_free(tmp); |
856 } else if (!g_ascii_strncasecmp(name, "http://", 7)) { | 891 } else if (!g_ascii_strncasecmp(name, "http://", 7)) { |
857 /* Oo, a web drag and drop. This is where things | 892 /* Oo, a web drag and drop. This is where things |
858 * will start to get interesting */ | 893 * will start to get interesting */ |
859 purple_util_fetch_url(name, TRUE, NULL, FALSE, theme_got_url, info); | 894 purple_util_fetch_url(name, TRUE, NULL, FALSE, -1, theme_got_url, info); |
860 } else if (!g_ascii_strncasecmp(name, "https://", 8)) { | 895 } else if (!g_ascii_strncasecmp(name, "https://", 8)) { |
861 /* purple_util_fetch_url() doesn't support HTTPS, but we want users | 896 /* purple_util_fetch_url() doesn't support HTTPS, but we want users |
862 * to be able to drag and drop links from the SF trackers, so | 897 * to be able to drag and drop links from the SF trackers, so |
863 * we'll try it as an HTTP URL. */ | 898 * we'll try it as an HTTP URL. */ |
864 char *tmp = g_strdup(name + 1); | 899 char *tmp = g_strdup(name + 1); |
865 tmp[0] = 'h'; | 900 tmp[0] = 'h'; |
866 tmp[1] = 't'; | 901 tmp[1] = 't'; |
867 tmp[2] = 't'; | 902 tmp[2] = 't'; |
868 tmp[3] = 'p'; | 903 tmp[3] = 'p'; |
869 | 904 |
870 purple_util_fetch_url(tmp, TRUE, NULL, FALSE, theme_got_url, info); | 905 purple_util_fetch_url(tmp, TRUE, NULL, FALSE, -1, theme_got_url, info); |
871 g_free(tmp); | 906 g_free(tmp); |
872 } else | 907 } else |
873 free_theme_info(info); | 908 free_theme_info(info); |
874 | 909 |
875 gtk_drag_finish(dc, TRUE, FALSE, t); | 910 gtk_drag_finish(dc, TRUE, FALSE, t); |
1017 | 1052 |
1018 pidgin_blist_set_theme(theme); | 1053 pidgin_blist_set_theme(theme); |
1019 } | 1054 } |
1020 } | 1055 } |
1021 | 1056 |
1057 /* sets the current conversation theme */ | |
1058 static void | |
1059 prefs_set_conv_theme_cb(GtkComboBox *combo_box, gpointer user_data) | |
1060 { | |
1061 PidginConvTheme *theme = NULL; | |
1062 GtkTreeIter iter; | |
1063 gchar *name = NULL; | |
1064 | |
1065 if (gtk_combo_box_get_active_iter(combo_box, &iter)) { | |
1066 const GList *variants; | |
1067 const char *current_variant; | |
1068 gboolean unset = TRUE; | |
1069 | |
1070 gtk_tree_model_get(GTK_TREE_MODEL(prefs_conv_themes), &iter, 2, &name, -1); | |
1071 if (!name || !*name) { | |
1072 g_free(name); | |
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); | |
1097 | |
1098 g_free(name); | |
1099 } | |
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 } | |
1120 } | |
1121 } | |
1122 | |
1022 /* sets the current icon theme */ | 1123 /* sets the current icon theme */ |
1023 static void | 1124 static void |
1024 prefs_set_status_icon_theme_cb(GtkComboBox *combo_box, gpointer user_data) | 1125 prefs_set_status_icon_theme_cb(GtkComboBox *combo_box, gpointer user_data) |
1025 { | 1126 { |
1026 PidginStatusIconTheme *theme = NULL; | 1127 PidginStatusIconTheme *theme = NULL; |
1070 | 1171 |
1071 return combo_box; | 1172 return combo_box; |
1072 } | 1173 } |
1073 | 1174 |
1074 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 * | |
1075 theme_page(void) | 1210 theme_page(void) |
1076 { | 1211 { |
1077 GtkWidget *label; | 1212 GtkWidget *label; |
1078 GtkWidget *ret, *vbox; | 1213 GtkWidget *ret, *vbox; |
1079 GtkSizeGroup *label_sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); | 1214 GtkSizeGroup *label_sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); |
1098 /* Buddy List Themes */ | 1233 /* Buddy List Themes */ |
1099 prefs_blist_themes_combo_box = add_theme_prefs_combo( | 1234 prefs_blist_themes_combo_box = add_theme_prefs_combo( |
1100 vbox, combo_sg, label_sg, prefs_blist_themes, | 1235 vbox, combo_sg, label_sg, prefs_blist_themes, |
1101 (GCallback)prefs_set_blist_theme_cb, NULL, | 1236 (GCallback)prefs_set_blist_theme_cb, NULL, |
1102 _("Buddy List Theme:"), PIDGIN_PREFS_ROOT "/blist/theme", "blist"); | 1237 _("Buddy List Theme:"), PIDGIN_PREFS_ROOT "/blist/theme", "blist"); |
1238 | |
1239 /* Conversation Themes */ | |
1240 prefs_conv_themes_combo_box = add_theme_prefs_combo( | |
1241 vbox, combo_sg, label_sg, prefs_conv_themes, | |
1242 (GCallback)prefs_set_conv_theme_cb, NULL, | |
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:")); | |
1249 | |
1250 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(prefs_conv_variants), | |
1251 0, GTK_SORT_ASCENDING); | |
1103 | 1252 |
1104 /* Status Icon Themes */ | 1253 /* Status Icon Themes */ |
1105 prefs_status_themes_combo_box = add_theme_prefs_combo( | 1254 prefs_status_themes_combo_box = add_theme_prefs_combo( |
1106 vbox, combo_sg, label_sg, prefs_status_icon_themes, | 1255 vbox, combo_sg, label_sg, prefs_status_icon_themes, |
1107 (GCallback)prefs_set_status_icon_theme_cb, NULL, | 1256 (GCallback)prefs_set_status_icon_theme_cb, NULL, |
2866 purple_prefs_add_path(PIDGIN_PREFS_ROOT "/filelocations/last_open_folder", ""); | 3015 purple_prefs_add_path(PIDGIN_PREFS_ROOT "/filelocations/last_open_folder", ""); |
2867 purple_prefs_add_path(PIDGIN_PREFS_ROOT "/filelocations/last_icon_folder", ""); | 3016 purple_prefs_add_path(PIDGIN_PREFS_ROOT "/filelocations/last_icon_folder", ""); |
2868 | 3017 |
2869 /* Themes */ | 3018 /* Themes */ |
2870 prefs_themes_init(); | 3019 prefs_themes_init(); |
3020 | |
3021 /* Conversation Themes */ | |
3022 purple_prefs_add_none(PIDGIN_PREFS_ROOT "/conversations"); | |
3023 purple_prefs_add_string(PIDGIN_PREFS_ROOT "/conversations/theme", "Default"); | |
2871 | 3024 |
2872 /* Smiley Themes */ | 3025 /* Smiley Themes */ |
2873 purple_prefs_add_none(PIDGIN_PREFS_ROOT "/smileys"); | 3026 purple_prefs_add_none(PIDGIN_PREFS_ROOT "/smileys"); |
2874 purple_prefs_add_string(PIDGIN_PREFS_ROOT "/smileys/theme", "Default"); | 3027 purple_prefs_add_string(PIDGIN_PREFS_ROOT "/smileys/theme", "Default"); |
2875 | 3028 |