Open an explorer.exe window at the location of the file when clicking
[pidgin-git.git] / pidgin / gtkprefs.c
blobb7afd8481d0539f1fef5f4411fcbc4568a23e090
1 /**
2 * @file gtkprefs.c GTK+ Preferences
3 * @ingroup pidgin
4 */
6 /* pidgin
8 * Pidgin is the legal property of its developers, whose names are too numerous
9 * to list here. Please refer to the COPYRIGHT file distributed with this
10 * source distribution.
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
27 #include "internal.h"
28 #include "pidgin.h"
30 #include "debug.h"
31 #include "nat-pmp.h"
32 #include "notify.h"
33 #include "prefs.h"
34 #include "proxy.h"
35 #include "prpl.h"
36 #include "request.h"
37 #include "savedstatuses.h"
38 #include "sound.h"
39 #include "sound-theme.h"
40 #include "stun.h"
41 #include "theme-manager.h"
42 #include "upnp.h"
43 #include "util.h"
44 #include "network.h"
46 #include "gtkblist.h"
47 #include "gtkconv.h"
48 #include "gtkdebug.h"
49 #include "gtkdialogs.h"
50 #include "gtkimhtml.h"
51 #include "gtkimhtmltoolbar.h"
52 #include "gtkprefs.h"
53 #include "gtksavedstatuses.h"
54 #include "gtksound.h"
55 #include "gtkstatus-icon-theme.h"
56 #include "gtkthemes.h"
57 #include "gtkutils.h"
58 #include "pidginstock.h"
60 #define PROXYHOST 0
61 #define PROXYPORT 1
62 #define PROXYUSER 2
63 #define PROXYPASS 3
65 #define PREFS_OPTIMAL_ICON_SIZE 32
67 struct theme_info {
68 gchar *type;
69 gchar *extension;
70 gchar *original_name;
73 /* Main dialog */
74 static GtkWidget *prefs = NULL;
76 /* Notebook */
77 static GtkWidget *prefsnotebook = NULL;
78 static int notebook_page = 0;
80 /* Conversations page */
81 static GtkWidget *sample_imhtml = NULL;
83 /* Themes page */
84 static GtkWidget *prefs_sound_themes_combo_box;
85 static GtkWidget *prefs_blist_themes_combo_box;
86 static GtkWidget *prefs_status_themes_combo_box;
87 static GtkWidget *prefs_smiley_themes_combo_box;
89 /* Sound theme specific */
90 static GtkWidget *sound_entry = NULL;
91 static int sound_row_sel = 0;
92 static gboolean prefs_sound_themes_loading;
94 /* These exist outside the lifetime of the prefs dialog */
95 static GtkListStore *prefs_sound_themes;
96 static GtkListStore *prefs_blist_themes;
97 static GtkListStore *prefs_status_icon_themes;
98 static GtkListStore *prefs_smiley_themes;
101 * PROTOTYPES
103 static void delete_prefs(GtkWidget *, void *);
105 static void
106 update_spin_value(GtkWidget *w, GtkWidget *spin)
108 const char *key = g_object_get_data(G_OBJECT(spin), "val");
109 int value;
111 value = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spin));
113 purple_prefs_set_int(key, value);
116 GtkWidget *
117 pidgin_prefs_labeled_spin_button(GtkWidget *box, const gchar *title,
118 const char *key, int min, int max, GtkSizeGroup *sg)
120 GtkWidget *spin;
121 GtkObject *adjust;
122 int val;
124 val = purple_prefs_get_int(key);
126 adjust = gtk_adjustment_new(val, min, max, 1, 1, 0);
127 spin = gtk_spin_button_new(GTK_ADJUSTMENT(adjust), 1, 0);
128 g_object_set_data(G_OBJECT(spin), "val", (char *)key);
129 if (max < 10000)
130 gtk_widget_set_size_request(spin, 50, -1);
131 else
132 gtk_widget_set_size_request(spin, 60, -1);
133 g_signal_connect(G_OBJECT(adjust), "value-changed",
134 G_CALLBACK(update_spin_value), GTK_WIDGET(spin));
135 gtk_widget_show(spin);
137 return pidgin_add_widget_to_vbox(GTK_BOX(box), title, sg, spin, FALSE, NULL);
140 static void
141 entry_set(GtkEntry *entry, gpointer data)
143 const char *key = (const char*)data;
145 purple_prefs_set_string(key, gtk_entry_get_text(entry));
148 GtkWidget *
149 pidgin_prefs_labeled_entry(GtkWidget *page, const gchar *title,
150 const char *key, GtkSizeGroup *sg)
152 GtkWidget *entry;
153 const gchar *value;
155 value = purple_prefs_get_string(key);
157 entry = gtk_entry_new();
158 gtk_entry_set_text(GTK_ENTRY(entry), value);
159 g_signal_connect(G_OBJECT(entry), "changed",
160 G_CALLBACK(entry_set), (char*)key);
161 gtk_widget_show(entry);
163 return pidgin_add_widget_to_vbox(GTK_BOX(page), title, sg, entry, TRUE, NULL);
166 GtkWidget *
167 pidgin_prefs_labeled_password(GtkWidget *page, const gchar *title,
168 const char *key, GtkSizeGroup *sg)
170 GtkWidget *entry;
171 const gchar *value;
173 value = purple_prefs_get_string(key);
175 entry = gtk_entry_new();
176 gtk_entry_set_visibility(GTK_ENTRY(entry), FALSE);
177 gtk_entry_set_text(GTK_ENTRY(entry), value);
178 g_signal_connect(G_OBJECT(entry), "changed",
179 G_CALLBACK(entry_set), (char*)key);
180 gtk_widget_show(entry);
182 return pidgin_add_widget_to_vbox(GTK_BOX(page), title, sg, entry, TRUE, NULL);
186 static void
187 dropdown_set(GObject *w, const char *key)
189 const char *str_value;
190 int int_value;
191 PurplePrefType type;
193 type = GPOINTER_TO_INT(g_object_get_data(w, "type"));
195 if (type == PURPLE_PREF_INT) {
196 int_value = GPOINTER_TO_INT(g_object_get_data(w, "value"));
198 purple_prefs_set_int(key, int_value);
200 else if (type == PURPLE_PREF_STRING) {
201 str_value = (const char *)g_object_get_data(w, "value");
203 purple_prefs_set_string(key, str_value);
205 else if (type == PURPLE_PREF_BOOLEAN) {
206 purple_prefs_set_bool(key,
207 GPOINTER_TO_INT(g_object_get_data(w, "value")));
211 GtkWidget *
212 pidgin_prefs_dropdown_from_list(GtkWidget *box, const gchar *title,
213 PurplePrefType type, const char *key, GList *menuitems)
215 GtkWidget *dropdown, *opt, *menu;
216 GtkWidget *label = NULL;
217 gchar *text;
218 const char *stored_str = NULL;
219 int stored_int = 0;
220 int int_value = 0;
221 const char *str_value = NULL;
222 int o = 0;
224 g_return_val_if_fail(menuitems != NULL, NULL);
226 dropdown = gtk_option_menu_new();
227 menu = gtk_menu_new();
229 if (type == PURPLE_PREF_INT)
230 stored_int = purple_prefs_get_int(key);
231 else if (type == PURPLE_PREF_STRING)
232 stored_str = purple_prefs_get_string(key);
234 while (menuitems != NULL && (text = (char *) menuitems->data) != NULL) {
235 menuitems = g_list_next(menuitems);
236 g_return_val_if_fail(menuitems != NULL, NULL);
238 opt = gtk_menu_item_new_with_label(text);
240 g_object_set_data(G_OBJECT(opt), "type", GINT_TO_POINTER(type));
242 if (type == PURPLE_PREF_INT) {
243 int_value = GPOINTER_TO_INT(menuitems->data);
244 g_object_set_data(G_OBJECT(opt), "value",
245 GINT_TO_POINTER(int_value));
247 else if (type == PURPLE_PREF_STRING) {
248 str_value = (const char *)menuitems->data;
250 g_object_set_data(G_OBJECT(opt), "value", (char *)str_value);
252 else if (type == PURPLE_PREF_BOOLEAN) {
253 g_object_set_data(G_OBJECT(opt), "value",
254 menuitems->data);
257 g_signal_connect(G_OBJECT(opt), "activate",
258 G_CALLBACK(dropdown_set), (char *)key);
260 gtk_widget_show(opt);
261 gtk_menu_shell_append(GTK_MENU_SHELL(menu), opt);
263 if ((type == PURPLE_PREF_INT && stored_int == int_value) ||
264 (type == PURPLE_PREF_STRING && stored_str != NULL &&
265 !strcmp(stored_str, str_value)) ||
266 (type == PURPLE_PREF_BOOLEAN &&
267 (purple_prefs_get_bool(key) == GPOINTER_TO_INT(menuitems->data)))) {
269 gtk_menu_set_active(GTK_MENU(menu), o);
272 menuitems = g_list_next(menuitems);
274 o++;
277 gtk_option_menu_set_menu(GTK_OPTION_MENU(dropdown), menu);
279 pidgin_add_widget_to_vbox(GTK_BOX(box), title, NULL, dropdown, FALSE, &label);
281 return label;
284 GtkWidget *
285 pidgin_prefs_dropdown(GtkWidget *box, const gchar *title, PurplePrefType type,
286 const char *key, ...)
288 va_list ap;
289 GList *menuitems = NULL;
290 GtkWidget *dropdown = NULL;
291 char *name;
292 int int_value;
293 const char *str_value;
295 g_return_val_if_fail(type == PURPLE_PREF_BOOLEAN || type == PURPLE_PREF_INT ||
296 type == PURPLE_PREF_STRING, NULL);
298 va_start(ap, key);
299 while ((name = va_arg(ap, char *)) != NULL) {
301 menuitems = g_list_prepend(menuitems, name);
303 if (type == PURPLE_PREF_INT || type == PURPLE_PREF_BOOLEAN) {
304 int_value = va_arg(ap, int);
305 menuitems = g_list_prepend(menuitems, GINT_TO_POINTER(int_value));
307 else {
308 str_value = va_arg(ap, const char *);
309 menuitems = g_list_prepend(menuitems, (char *)str_value);
312 va_end(ap);
314 g_return_val_if_fail(menuitems != NULL, NULL);
316 menuitems = g_list_reverse(menuitems);
318 dropdown = pidgin_prefs_dropdown_from_list(box, title, type, key,
319 menuitems);
321 g_list_free(menuitems);
323 return dropdown;
326 static void
327 delete_prefs(GtkWidget *asdf, void *gdsa)
329 /* Close any "select sound" request dialogs */
330 purple_request_close_with_handle(prefs);
332 /* Unregister callbacks. */
333 purple_prefs_disconnect_by_handle(prefs);
335 /* NULL-ify globals */
336 sound_entry = NULL;
337 sound_row_sel = 0;
338 prefs_sound_themes_loading = FALSE;
340 prefs_sound_themes_combo_box = NULL;
341 prefs_blist_themes_combo_box = NULL;
342 prefs_status_themes_combo_box = NULL;
343 prefs_smiley_themes_combo_box = NULL;
345 sample_imhtml = NULL;
347 notebook_page = 0;
348 prefsnotebook = NULL;
349 prefs = NULL;
352 static gchar *
353 get_theme_markup(const char *name, gboolean custom, const char *author,
354 const char *description)
357 return g_strdup_printf("<b>%s</b>%s%s%s%s\n<span foreground='dim grey'>%s</span>",
358 name, custom ? " " : "", custom ? _("(Custom)") : "",
359 author != NULL ? " - " : "", author != NULL ? author : "",
360 description != NULL ? description : "");
363 static void
364 smileys_refresh_theme_list(void)
366 GdkPixbuf *pixbuf;
367 GSList *themes;
368 GtkTreeIter iter;
370 pidgin_themes_smiley_theme_probe();
372 if (!(themes = smiley_themes))
373 return;
375 while (themes) {
376 struct smiley_theme *theme = themes->data;
377 char *description = get_theme_markup(_(theme->name), FALSE,
378 _(theme->author), _(theme->desc));
379 gtk_list_store_append(prefs_smiley_themes, &iter);
382 * LEAK - Gentoo memprof thinks pixbuf is leaking here... but it
383 * looks like it should be ok to me. Anyone know what's up? --Mark
385 pixbuf = (theme->icon ? pidgin_pixbuf_new_from_file(theme->icon) : NULL);
387 gtk_list_store_set(prefs_smiley_themes, &iter,
388 0, pixbuf,
389 1, description,
390 2, theme->name,
391 -1);
393 if (pixbuf != NULL)
394 g_object_unref(G_OBJECT(pixbuf));
396 g_free(description);
397 themes = themes->next;
401 /* Rebuild the markup for the sound theme selection for "(Custom)" themes */
402 static void
403 pref_sound_generate_markup(void)
405 gboolean print_custom, customized;
406 const gchar *author, *description, *current_theme;
407 gchar *name, *markup;
408 PurpleSoundTheme *theme;
409 GtkTreeIter iter;
411 customized = pidgin_sound_is_customized();
412 current_theme = purple_prefs_get_string(PIDGIN_PREFS_ROOT "/sound/theme");
414 if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(prefs_sound_themes), &iter)) {
415 do {
416 gtk_tree_model_get(GTK_TREE_MODEL(prefs_sound_themes), &iter, 2, &name, -1);
418 print_custom = customized && name && g_str_equal(current_theme, name);
420 if (!name || *name == '\0') {
421 g_free(name);
422 name = g_strdup(_("Default"));
423 author = _("Penguin Pimps");
424 description = _("The default Pidgin sound theme");
425 } else {
426 theme = PURPLE_SOUND_THEME(purple_theme_manager_find_theme(name, "sound"));
427 author = purple_theme_get_author(PURPLE_THEME(theme));
428 description = purple_theme_get_description(PURPLE_THEME(theme));
431 markup = get_theme_markup(name, print_custom, author, description);
433 gtk_list_store_set(prefs_sound_themes, &iter, 1, markup, -1);
435 g_free(name);
436 g_free(markup);
438 } while (gtk_tree_model_iter_next(GTK_TREE_MODEL(prefs_sound_themes), &iter));
442 /* adds the themes to the theme list from the manager so they can be displayed in prefs */
443 static void
444 prefs_themes_sort(PurpleTheme *theme)
446 GdkPixbuf *pixbuf = NULL;
447 GtkTreeIter iter;
448 gchar *image_full = NULL, *markup;
449 const gchar *name, *author, *description;
451 if (PURPLE_IS_SOUND_THEME(theme)){
453 image_full = purple_theme_get_image_full(theme);
454 if (image_full != NULL){
455 pixbuf = pidgin_pixbuf_new_from_file_at_scale(image_full, PREFS_OPTIMAL_ICON_SIZE, PREFS_OPTIMAL_ICON_SIZE, TRUE);
456 g_free(image_full);
457 } else
458 pixbuf = NULL;
460 gtk_list_store_append(prefs_sound_themes, &iter);
461 gtk_list_store_set(prefs_sound_themes, &iter, 0, pixbuf, 2, purple_theme_get_name(theme), -1);
463 if (pixbuf != NULL)
464 g_object_unref(G_OBJECT(pixbuf));
466 } else if (PIDGIN_IS_BLIST_THEME(theme) || PIDGIN_IS_STATUS_ICON_THEME(theme)){
467 GtkListStore *store;
469 if (PIDGIN_IS_BLIST_THEME(theme))
470 store = prefs_blist_themes;
471 else
472 store = prefs_status_icon_themes;
474 image_full = purple_theme_get_image_full(theme);
475 if (image_full != NULL){
476 pixbuf = pidgin_pixbuf_new_from_file_at_scale(image_full, PREFS_OPTIMAL_ICON_SIZE, PREFS_OPTIMAL_ICON_SIZE, TRUE);
477 g_free(image_full);
478 } else
479 pixbuf = NULL;
481 name = purple_theme_get_name(theme);
482 author = purple_theme_get_author(theme);
483 description = purple_theme_get_description(theme);
485 markup = get_theme_markup(name, FALSE, author, description);
487 gtk_list_store_append(store, &iter);
488 gtk_list_store_set(store, &iter, 0, pixbuf, 1, markup, 2, name, -1);
490 g_free(markup);
491 if (pixbuf != NULL)
492 g_object_unref(G_OBJECT(pixbuf));
496 static void
497 prefs_set_active_theme_combo(GtkWidget *combo_box, GtkListStore *store, const gchar *current_theme)
499 GtkTreeIter iter;
500 gchar *theme = NULL;
501 gboolean unset = TRUE;
503 if (current_theme && *current_theme && gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter)) {
504 do {
505 gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, 2, &theme, -1);
507 if (g_str_equal(current_theme, theme)) {
508 gtk_combo_box_set_active_iter(GTK_COMBO_BOX(combo_box), &iter);
509 unset = FALSE;
512 g_free(theme);
513 } while (gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &iter));
516 if (unset)
517 gtk_combo_box_set_active(GTK_COMBO_BOX(combo_box), 0);
520 static void
521 prefs_themes_refresh(void)
523 GdkPixbuf *pixbuf = NULL;
524 gchar *tmp;
525 GtkTreeIter iter;
527 prefs_sound_themes_loading = TRUE;
528 /* refresh the list of themes in the manager */
529 purple_theme_manager_refresh();
531 tmp = g_build_filename(DATADIR, "icons", "hicolor", "32x32", "apps", "pidgin.png", NULL);
532 pixbuf = pidgin_pixbuf_new_from_file_at_scale(tmp, PREFS_OPTIMAL_ICON_SIZE, PREFS_OPTIMAL_ICON_SIZE, TRUE);
533 g_free(tmp);
535 /* sound themes */
536 gtk_list_store_clear(prefs_sound_themes);
537 gtk_list_store_append(prefs_sound_themes, &iter);
538 gtk_list_store_set(prefs_sound_themes, &iter, 0, pixbuf, 2, "", -1);
540 /* blist themes */
541 gtk_list_store_clear(prefs_blist_themes);
542 gtk_list_store_append(prefs_blist_themes, &iter);
543 tmp = get_theme_markup(_("Default"), FALSE, _("Penguin Pimps"),
544 _("The default Pidgin buddy list theme"));
545 gtk_list_store_set(prefs_blist_themes, &iter, 0, pixbuf, 1, tmp, 2, "", -1);
546 g_free(tmp);
548 /* status icon themes */
549 gtk_list_store_clear(prefs_status_icon_themes);
550 gtk_list_store_append(prefs_status_icon_themes, &iter);
551 tmp = get_theme_markup(_("Default"), FALSE, _("Penguin Pimps"),
552 _("The default Pidgin status icon theme"));
553 gtk_list_store_set(prefs_status_icon_themes, &iter, 0, pixbuf, 1, tmp, 2, "", -1);
554 g_free(tmp);
555 if (pixbuf)
556 g_object_unref(G_OBJECT(pixbuf));
558 /* smiley themes */
559 gtk_list_store_clear(prefs_smiley_themes);
561 purple_theme_manager_for_each_theme(prefs_themes_sort);
562 pref_sound_generate_markup();
563 smileys_refresh_theme_list();
565 /* 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"));
567 prefs_set_active_theme_combo(prefs_blist_themes_combo_box, prefs_blist_themes, purple_prefs_get_string(PIDGIN_PREFS_ROOT "/blist/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"));
569 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;
573 /* init all the theme variables so that the themes can be sorted later and used by pref pages */
574 static void
575 prefs_themes_init(void)
577 prefs_sound_themes = gtk_list_store_new(3, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING);
579 prefs_blist_themes = gtk_list_store_new(3, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING);
581 prefs_status_icon_themes = gtk_list_store_new(3, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING);
583 prefs_smiley_themes = gtk_list_store_new(3, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING);
586 static PurpleTheme *
587 prefs_theme_find_theme(const gchar *path, const gchar *type)
589 PurpleTheme *theme = purple_theme_manager_load_theme(path, type);
590 GDir *dir = g_dir_open(path, 0, NULL);
591 const gchar *next;
593 while (!PURPLE_IS_THEME(theme) && (next = g_dir_read_name(dir))) {
594 gchar *next_path = g_build_filename(path, next, NULL);
596 if (g_file_test(next_path, G_FILE_TEST_IS_DIR))
597 theme = prefs_theme_find_theme(next_path, type);
599 g_free(next_path);
602 g_dir_close(dir);
604 return theme;
607 /* Eww. Seriously ewww. But thanks, grim! This is taken from guifications2 */
608 static gboolean
609 purple_theme_file_copy(const gchar *source, const gchar *destination)
611 FILE *src, *dest;
612 gint chr = EOF;
614 if(!(src = g_fopen(source, "rb")))
615 return FALSE;
616 if(!(dest = g_fopen(destination, "wb"))) {
617 fclose(src);
618 return FALSE;
621 while((chr = fgetc(src)) != EOF) {
622 fputc(chr, dest);
625 fclose(dest);
626 fclose(src);
628 return TRUE;
631 static void
632 free_theme_info(struct theme_info *info)
634 if (info != NULL) {
635 g_free(info->type);
636 g_free(info->extension);
637 g_free(info->original_name);
638 g_free(info);
642 /* installs a theme, info is freed by function */
643 static void
644 theme_install_theme(char *path, struct theme_info *info)
646 #ifndef _WIN32
647 gchar *command;
648 #endif
649 gchar *destdir;
650 const char *tail;
651 gboolean is_smiley_theme, is_archive;
652 PurpleTheme *theme = NULL;
654 if (info == NULL)
655 return;
657 /* check the extension */
658 tail = info->extension ? info->extension : strrchr(path, '.');
660 if (!tail) {
661 free_theme_info(info);
662 return;
665 is_archive = !g_ascii_strcasecmp(tail, ".gz") || !g_ascii_strcasecmp(tail, ".tgz");
667 /* Just to be safe */
668 g_strchomp(path);
670 if ((is_smiley_theme = g_str_equal(info->type, "smiley")))
671 destdir = g_build_filename(purple_user_dir(), "smileys", NULL);
672 else
673 destdir = g_build_filename(purple_user_dir(), "themes", "temp", NULL);
675 /* We'll check this just to make sure. This also lets us do something different on
676 * other platforms, if need be */
677 if (is_archive) {
678 #ifndef _WIN32
679 gchar *path_escaped = g_shell_quote(path);
680 gchar *destdir_escaped = g_shell_quote(destdir);
682 if (!g_file_test(destdir, G_FILE_TEST_IS_DIR))
683 purple_build_dir(destdir, S_IRUSR | S_IWUSR | S_IXUSR);
685 command = g_strdup_printf("tar > /dev/null xzf %s -C %s", path_escaped, destdir_escaped);
686 g_free(path_escaped);
687 g_free(destdir_escaped);
689 /* Fire! */
690 if (system(command)) {
691 purple_notify_error(NULL, NULL, _("Theme failed to unpack."), NULL);
692 g_free(command);
693 g_free(destdir);
694 free_theme_info(info);
695 return;
697 #else
698 if (!winpidgin_gz_untar(path, destdir)) {
699 purple_notify_error(NULL, NULL, _("Theme failed to unpack."), NULL);
700 g_free(destdir);
701 free_theme_info(info);
702 return;
704 #endif
707 if (is_smiley_theme) {
708 /* just extract the folder to the smiley directory */
709 prefs_themes_refresh();
711 } else if (is_archive) {
712 theme = prefs_theme_find_theme(destdir, info->type);
714 if (PURPLE_IS_THEME(theme)) {
715 /* create the location for the theme */
716 gchar *theme_dest = g_build_filename(purple_user_dir(), "themes",
717 purple_theme_get_name(theme),
718 "purple", info->type, NULL);
720 if (!g_file_test(theme_dest, G_FILE_TEST_IS_DIR))
721 purple_build_dir(theme_dest, S_IRUSR | S_IWUSR | S_IXUSR);
723 g_free(theme_dest);
724 theme_dest = g_build_filename(purple_user_dir(), "themes",
725 purple_theme_get_name(theme),
726 "purple", info->type, NULL);
728 /* move the entire directory to new location */
729 g_rename(purple_theme_get_dir(theme), theme_dest);
731 g_free(theme_dest);
732 g_remove(destdir);
733 g_object_unref(theme);
735 prefs_themes_refresh();
737 } else {
738 /* something was wrong with the theme archive */
739 g_unlink(destdir);
740 purple_notify_error(NULL, NULL, _("Theme failed to load."), NULL);
743 } else { /* just a single file so copy it to a new temp directory and attempt to load it*/
744 gchar *temp_path, *temp_file;
746 temp_path = g_build_filename(purple_user_dir(), "themes", "temp", "sub_folder", NULL);
748 if (info->original_name != NULL) {
749 /* name was changed from the original (probably a dnd) change it back before loading */
750 temp_file = g_build_filename(temp_path, info->original_name, NULL);
752 } else {
753 gchar *source_name = g_path_get_basename(path);
754 temp_file = g_build_filename(temp_path, source_name, NULL);
755 g_free(source_name);
758 if (!g_file_test(temp_path, G_FILE_TEST_IS_DIR))
759 purple_build_dir(temp_path, S_IRUSR | S_IWUSR | S_IXUSR);
761 if (purple_theme_file_copy(path, temp_file)) {
762 /* find the theme, could be in subfolder */
763 theme = prefs_theme_find_theme(temp_path, info->type);
765 if (PURPLE_IS_THEME(theme)) {
766 gchar *theme_dest = g_build_filename(purple_user_dir(), "themes",
767 purple_theme_get_name(theme),
768 "purple", info->type, NULL);
770 if(!g_file_test(theme_dest, G_FILE_TEST_IS_DIR))
771 purple_build_dir(theme_dest, S_IRUSR | S_IWUSR | S_IXUSR);
773 g_rename(purple_theme_get_dir(theme), theme_dest);
775 g_free(theme_dest);
776 g_object_unref(theme);
778 prefs_themes_refresh();
779 } else {
780 g_remove(temp_path);
781 purple_notify_error(NULL, NULL, _("Theme failed to load."), NULL);
783 } else {
784 purple_notify_error(NULL, NULL, _("Theme failed to copy."), NULL);
787 g_free(temp_file);
788 g_free(temp_path);
791 g_free(destdir);
792 free_theme_info(info);
795 static void
796 theme_got_url(PurpleUtilFetchUrlData *url_data, gpointer user_data,
797 const gchar *themedata, size_t len, const gchar *error_message)
799 FILE *f;
800 gchar *path;
801 size_t wc;
803 if ((error_message != NULL) || (len == 0)) {
804 free_theme_info(user_data);
805 return;
808 f = purple_mkstemp(&path, TRUE);
809 wc = fwrite(themedata, len, 1, f);
810 if (wc != 1) {
811 purple_debug_warning("theme_got_url", "Unable to write theme data.\n");
812 fclose(f);
813 g_unlink(path);
814 g_free(path);
815 free_theme_info(user_data);
816 return;
818 fclose(f);
820 theme_install_theme(path, user_data);
822 g_unlink(path);
823 g_free(path);
826 static void
827 theme_dnd_recv(GtkWidget *widget, GdkDragContext *dc, guint x, guint y,
828 GtkSelectionData *sd, guint info, guint t, gpointer user_data)
830 gchar *name = g_strchomp((gchar *)sd->data);
832 if ((sd->length >= 0) && (sd->format == 8)) {
833 /* Well, it looks like the drag event was cool.
834 * Let's do something with it */
835 gchar *temp;
836 struct theme_info *info = g_new0(struct theme_info, 1);
837 info->type = g_strdup((gchar *)user_data);
838 info->extension = g_strdup(g_strrstr(name,"."));
839 temp = g_strrstr(name, "/");
840 info->original_name = temp ? g_strdup(++temp) : NULL;
842 if (!g_ascii_strncasecmp(name, "file://", 7)) {
843 GError *converr = NULL;
844 gchar *tmp;
845 /* It looks like we're dealing with a local file. Let's
846 * just untar it in the right place */
847 if(!(tmp = g_filename_from_uri(name, NULL, &converr))) {
848 purple_debug(PURPLE_DEBUG_ERROR, "theme dnd", "%s\n",
849 (converr ? converr->message :
850 "g_filename_from_uri error"));
851 free_theme_info(info);
852 return;
854 theme_install_theme(tmp, info);
855 g_free(tmp);
856 } else if (!g_ascii_strncasecmp(name, "http://", 7)) {
857 /* Oo, a web drag and drop. This is where things
858 * will start to get interesting */
859 purple_util_fetch_url(name, TRUE, NULL, FALSE, theme_got_url, info);
860 } else if (!g_ascii_strncasecmp(name, "https://", 8)) {
861 /* 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
863 * we'll try it as an HTTP URL. */
864 char *tmp = g_strdup(name + 1);
865 tmp[0] = 'h';
866 tmp[1] = 't';
867 tmp[2] = 't';
868 tmp[3] = 'p';
870 purple_util_fetch_url(tmp, TRUE, NULL, FALSE, theme_got_url, info);
871 g_free(tmp);
872 } else
873 free_theme_info(info);
875 gtk_drag_finish(dc, TRUE, FALSE, t);
878 gtk_drag_finish(dc, FALSE, FALSE, t);
881 /* builds a theme combo box from a list store with colums: icon preview, markup, theme name */
882 static GtkWidget *
883 prefs_build_theme_combo_box(GtkListStore *store, const char *current_theme, const char *type)
885 GtkCellRenderer *cell_rend;
886 GtkWidget *combo_box;
887 GtkTargetEntry te[3] = {
888 {"text/plain", 0, 0},
889 {"text/uri-list", 0, 1},
890 {"STRING", 0, 2}
893 g_return_val_if_fail(store != NULL && current_theme != NULL, NULL);
895 combo_box = gtk_combo_box_new_with_model(GTK_TREE_MODEL(store));
897 cell_rend = gtk_cell_renderer_pixbuf_new();
898 gtk_cell_renderer_set_fixed_size(cell_rend, PREFS_OPTIMAL_ICON_SIZE, PREFS_OPTIMAL_ICON_SIZE);
899 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT (combo_box), cell_rend, FALSE);
900 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo_box), cell_rend, "pixbuf", 0, NULL);
902 cell_rend = gtk_cell_renderer_text_new();
903 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT (combo_box), cell_rend, TRUE);
904 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo_box), cell_rend, "markup", 1, NULL);
905 g_object_set(cell_rend, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
907 gtk_drag_dest_set(combo_box, GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_HIGHLIGHT | GTK_DEST_DEFAULT_DROP, te,
908 sizeof(te) / sizeof(GtkTargetEntry) , GDK_ACTION_COPY | GDK_ACTION_MOVE);
910 g_signal_connect(G_OBJECT(combo_box), "drag_data_received", G_CALLBACK(theme_dnd_recv), (gpointer) type);
912 return combo_box;
915 /* sets the current sound theme */
916 static void
917 prefs_set_sound_theme_cb(GtkComboBox *combo_box, gpointer user_data)
919 gint i;
920 gchar *pref;
921 gchar *new_theme;
922 GtkTreeIter new_iter;
924 if(gtk_combo_box_get_active_iter(combo_box, &new_iter) && !prefs_sound_themes_loading) {
926 gtk_tree_model_get(GTK_TREE_MODEL(prefs_sound_themes), &new_iter, 2, &new_theme, -1);
928 purple_prefs_set_string(PIDGIN_PREFS_ROOT "/sound/theme", new_theme);
930 /* New theme removes all customization */
931 for(i = 0; i < PURPLE_NUM_SOUNDS; i++){
932 pref = g_strdup_printf(PIDGIN_PREFS_ROOT "/sound/file/%s",
933 pidgin_sound_get_event_option(i));
934 purple_prefs_set_path(pref, "");
935 g_free(pref);
938 /* gets rid of the "(Custom)" from the last selection */
939 pref_sound_generate_markup();
941 gtk_entry_set_text(GTK_ENTRY(sound_entry), _("(default)"));
943 g_free(new_theme);
947 /* sets the current smiley theme */
948 static void
949 prefs_set_smiley_theme_cb(GtkComboBox *combo_box, gpointer user_data)
951 gchar *new_theme;
952 GtkTreeIter new_iter;
954 if (gtk_combo_box_get_active_iter(combo_box, &new_iter)) {
956 gtk_tree_model_get(GTK_TREE_MODEL(prefs_smiley_themes), &new_iter, 2, &new_theme, -1);
958 purple_prefs_set_string(PIDGIN_PREFS_ROOT "/smileys/theme", new_theme);
959 pidgin_themes_smiley_themeize(sample_imhtml);
961 g_free(new_theme);
966 /* Does same as normal sort, except "none" is sorted first */
967 static gint pidgin_sort_smileys (GtkTreeModel *model,
968 GtkTreeIter *a,
969 GtkTreeIter *b,
970 gpointer userdata)
972 gint ret = 0;
973 gchar *name1 = NULL, *name2 = NULL;
975 gtk_tree_model_get(model, a, 2, &name1, -1);
976 gtk_tree_model_get(model, b, 2, &name2, -1);
978 if (name1 == NULL || name2 == NULL) {
979 if (!(name1 == NULL && name2 == NULL))
980 ret = (name1 == NULL) ? -1: 1;
981 } else if (!g_ascii_strcasecmp(name1, "none")) {
982 if (!g_utf8_collate(name1, name2))
983 ret = 0;
984 else
985 /* Sort name1 first */
986 ret = -1;
987 } else if (!g_ascii_strcasecmp(name2, "none")) {
988 /* Sort name2 first */
989 ret = 1;
990 } else {
991 /* Neither string is "none", default to normal sort */
992 ret = purple_utf8_strcasecmp(name1, name2);
995 g_free(name1);
996 g_free(name2);
998 return ret;
1001 /* sets the current buddy list theme */
1002 static void
1003 prefs_set_blist_theme_cb(GtkComboBox *combo_box, gpointer user_data)
1005 PidginBlistTheme *theme = NULL;
1006 GtkTreeIter iter;
1007 gchar *name = NULL;
1009 if(gtk_combo_box_get_active_iter(combo_box, &iter)) {
1011 gtk_tree_model_get(GTK_TREE_MODEL(prefs_blist_themes), &iter, 2, &name, -1);
1013 if(!name || !g_str_equal(name, ""))
1014 theme = PIDGIN_BLIST_THEME(purple_theme_manager_find_theme(name, "blist"));
1016 g_free(name);
1018 pidgin_blist_set_theme(theme);
1022 /* sets the current icon theme */
1023 static void
1024 prefs_set_status_icon_theme_cb(GtkComboBox *combo_box, gpointer user_data)
1026 PidginStatusIconTheme *theme = NULL;
1027 GtkTreeIter iter;
1028 gchar *name = NULL;
1030 if(gtk_combo_box_get_active_iter(combo_box, &iter)) {
1032 gtk_tree_model_get(GTK_TREE_MODEL(prefs_status_icon_themes), &iter, 2, &name, -1);
1034 if(!name || !g_str_equal(name, ""))
1035 theme = PIDGIN_STATUS_ICON_THEME(purple_theme_manager_find_theme(name, "status-icon"));
1037 g_free(name);
1039 pidgin_stock_load_status_icon_theme(theme);
1040 pidgin_blist_refresh(purple_get_blist());
1044 static GtkWidget *
1045 add_theme_prefs_combo(GtkWidget *vbox,
1046 GtkSizeGroup *combo_sg, GtkSizeGroup *label_sg,
1047 GtkListStore *theme_store,
1048 GCallback combo_box_cb, gpointer combo_box_cb_user_data,
1049 const char *label_str, const char *prefs_path,
1050 const char *theme_type)
1052 GtkWidget *label;
1053 GtkWidget *combo_box = NULL;
1054 GtkWidget *themesel_hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE);
1056 label = gtk_label_new(label_str);
1057 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
1058 gtk_size_group_add_widget(label_sg, label);
1059 gtk_box_pack_start(GTK_BOX(themesel_hbox), label, FALSE, FALSE, 0);
1061 combo_box = prefs_build_theme_combo_box(theme_store,
1062 purple_prefs_get_string(prefs_path),
1063 theme_type);
1064 g_signal_connect(G_OBJECT(combo_box), "changed",
1065 (GCallback)combo_box_cb, combo_box_cb_user_data);
1066 gtk_size_group_add_widget(combo_sg, combo_box);
1067 gtk_box_pack_start(GTK_BOX(themesel_hbox), combo_box, TRUE, TRUE, 0);
1069 gtk_box_pack_start(GTK_BOX(vbox), themesel_hbox, FALSE, FALSE, 0);
1071 return combo_box;
1074 static GtkWidget *
1075 theme_page(void)
1077 GtkWidget *label;
1078 GtkWidget *ret, *vbox;
1079 GtkSizeGroup *label_sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
1080 GtkSizeGroup *combo_sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
1082 ret = gtk_vbox_new(FALSE, PIDGIN_HIG_CAT_SPACE);
1083 gtk_container_set_border_width (GTK_CONTAINER (ret), PIDGIN_HIG_BORDER);
1085 vbox = pidgin_make_frame(ret, _("Theme Selections"));
1087 /* Instructions */
1088 label = gtk_label_new(_("Select a theme that you would like to use from "
1089 "the lists below.\nNew themes can be installed by "
1090 "dragging and dropping them onto the theme list."));
1092 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
1093 gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
1095 gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, FALSE, 0);
1096 gtk_widget_show(label);
1098 /* Buddy List Themes */
1099 prefs_blist_themes_combo_box = add_theme_prefs_combo(
1100 vbox, combo_sg, label_sg, prefs_blist_themes,
1101 (GCallback)prefs_set_blist_theme_cb, NULL,
1102 _("Buddy List Theme:"), PIDGIN_PREFS_ROOT "/blist/theme", "blist");
1104 /* Status Icon Themes */
1105 prefs_status_themes_combo_box = add_theme_prefs_combo(
1106 vbox, combo_sg, label_sg, prefs_status_icon_themes,
1107 (GCallback)prefs_set_status_icon_theme_cb, NULL,
1108 _("Status Icon Theme:"), PIDGIN_PREFS_ROOT "/status/icon-theme", "icon");
1110 /* Sound Themes */
1111 prefs_sound_themes_combo_box = add_theme_prefs_combo(
1112 vbox, combo_sg, label_sg, prefs_sound_themes,
1113 (GCallback)prefs_set_sound_theme_cb, NULL,
1114 _("Sound Theme:"), PIDGIN_PREFS_ROOT "/sound/theme", "sound");
1116 /* Smiley Themes */
1117 prefs_smiley_themes_combo_box = add_theme_prefs_combo(
1118 vbox, combo_sg, label_sg, prefs_smiley_themes,
1119 (GCallback)prefs_set_smiley_theme_cb, NULL,
1120 _("Smiley Theme:"), PIDGIN_PREFS_ROOT "/smileys/theme", "smiley");
1122 /* Custom sort so "none" theme is at top of list */
1123 gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(prefs_smiley_themes),
1124 2, pidgin_sort_smileys, NULL, NULL);
1125 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(prefs_smiley_themes),
1126 2, GTK_SORT_ASCENDING);
1128 gtk_widget_show_all(ret);
1130 return ret;
1133 static void
1134 formatting_toggle_cb(GtkIMHtml *imhtml, GtkIMHtmlButtons buttons, void *toolbar)
1136 gboolean bold, italic, uline;
1138 gtk_imhtml_get_current_format(GTK_IMHTML(imhtml),
1139 &bold, &italic, &uline);
1141 if (buttons & GTK_IMHTML_BOLD)
1142 purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/conversations/send_bold", bold);
1143 if (buttons & GTK_IMHTML_ITALIC)
1144 purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/conversations/send_italic", italic);
1145 if (buttons & GTK_IMHTML_UNDERLINE)
1146 purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/conversations/send_underline", uline);
1148 if (buttons & GTK_IMHTML_GROW || buttons & GTK_IMHTML_SHRINK)
1149 purple_prefs_set_int(PIDGIN_PREFS_ROOT "/conversations/font_size",
1150 gtk_imhtml_get_current_fontsize(GTK_IMHTML(imhtml)));
1151 if (buttons & GTK_IMHTML_FACE) {
1152 char *face = gtk_imhtml_get_current_fontface(GTK_IMHTML(imhtml));
1153 if (!face)
1154 face = g_strdup("");
1156 purple_prefs_set_string(PIDGIN_PREFS_ROOT "/conversations/font_face", face);
1157 g_free(face);
1160 if (buttons & GTK_IMHTML_FORECOLOR) {
1161 char *color = gtk_imhtml_get_current_forecolor(GTK_IMHTML(imhtml));
1162 if (!color)
1163 color = g_strdup("");
1165 purple_prefs_set_string(PIDGIN_PREFS_ROOT "/conversations/fgcolor", color);
1166 g_free(color);
1169 if (buttons & GTK_IMHTML_BACKCOLOR) {
1170 char *color;
1171 GObject *object;
1173 color = gtk_imhtml_get_current_backcolor(GTK_IMHTML(imhtml));
1174 if (!color)
1175 color = g_strdup("");
1177 /* Block the signal to prevent a loop. */
1178 object = g_object_ref(G_OBJECT(imhtml));
1179 g_signal_handlers_block_matched(object, G_SIGNAL_MATCH_DATA, 0, 0, NULL,
1180 NULL, toolbar);
1181 /* Clear the backcolor. */
1182 gtk_imhtml_toggle_backcolor(GTK_IMHTML(imhtml), "");
1183 /* Unblock the signal. */
1184 g_signal_handlers_unblock_matched(object, G_SIGNAL_MATCH_DATA, 0, 0, NULL,
1185 NULL, toolbar);
1186 g_object_unref(object);
1188 /* This will fire a toggle signal and get saved below. */
1189 gtk_imhtml_toggle_background(GTK_IMHTML(imhtml), color);
1191 g_free(color);
1194 if (buttons & GTK_IMHTML_BACKGROUND) {
1195 char *color = gtk_imhtml_get_current_background(GTK_IMHTML(imhtml));
1196 if (!color)
1197 color = g_strdup("");
1199 purple_prefs_set_string(PIDGIN_PREFS_ROOT "/conversations/bgcolor", color);
1200 g_free(color);
1204 static void
1205 formatting_clear_cb(GtkIMHtml *imhtml, void *data)
1207 purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/conversations/send_bold", FALSE);
1208 purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/conversations/send_italic", FALSE);
1209 purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/conversations/send_underline", FALSE);
1211 purple_prefs_set_int(PIDGIN_PREFS_ROOT "/conversations/font_size", 3);
1213 purple_prefs_set_string(PIDGIN_PREFS_ROOT "/conversations/font_face", "");
1214 purple_prefs_set_string(PIDGIN_PREFS_ROOT "/conversations/fgcolor", "");
1215 purple_prefs_set_string(PIDGIN_PREFS_ROOT "/conversations/bgcolor", "");
1218 static void
1219 conversation_usetabs_cb(const char *name, PurplePrefType type,
1220 gconstpointer value, gpointer data)
1222 gboolean usetabs = GPOINTER_TO_INT(value);
1224 if (usetabs)
1225 gtk_widget_set_sensitive(GTK_WIDGET(data), TRUE);
1226 else
1227 gtk_widget_set_sensitive(GTK_WIDGET(data), FALSE);
1231 #define CONVERSATION_CLOSE_ACCEL_PATH "<main>/Conversation/Close"
1233 /* Filled in in keyboard_shortcuts(). */
1234 static GtkAccelKey ctrl_w = { 0, 0, 0 };
1235 static GtkAccelKey escape = { 0, 0, 0 };
1237 static guint escape_closes_conversation_cb_id = 0;
1239 static gboolean
1240 accel_is_escape(GtkAccelKey *k)
1242 return (k->accel_key == escape.accel_key
1243 && k->accel_mods == escape.accel_mods);
1246 /* Update the tickybox in Preferences when the keybinding for Conversation ->
1247 * Close is changed via Gtk.
1249 static void
1250 conversation_close_accel_changed_cb (GtkAccelMap *object,
1251 gchar *accel_path,
1252 guint accel_key,
1253 GdkModifierType accel_mods,
1254 gpointer checkbox_)
1256 GtkToggleButton *checkbox = GTK_TOGGLE_BUTTON(checkbox_);
1257 GtkAccelKey new = { accel_key, accel_mods, 0 };
1259 g_signal_handler_block(checkbox, escape_closes_conversation_cb_id);
1260 gtk_toggle_button_set_active(checkbox, accel_is_escape(&new));
1261 g_signal_handler_unblock(checkbox, escape_closes_conversation_cb_id);
1265 static void
1266 escape_closes_conversation_cb(GtkWidget *w,
1267 gpointer unused)
1269 gboolean active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w));
1270 gboolean changed;
1271 GtkAccelKey *new_key = active ? &escape : &ctrl_w;
1273 changed = gtk_accel_map_change_entry(CONVERSATION_CLOSE_ACCEL_PATH,
1274 new_key->accel_key, new_key->accel_mods, TRUE);
1276 /* If another path is already bound to the new accelerator,
1277 * _change_entry tries to delete that binding (because it was passed
1278 * replace=TRUE). If that other path is locked, then _change_entry
1279 * will fail. We don't ever lock any accelerator paths, so this case
1280 * should never arise.
1282 if(!changed)
1283 purple_debug_warning("gtkprefs", "Escape accel failed to change\n");
1287 /* Creates preferences for keyboard shortcuts that it's hard to change with the
1288 * standard Gtk accelerator-changing mechanism.
1290 static void
1291 keyboard_shortcuts(GtkWidget *page)
1293 GtkWidget *vbox = pidgin_make_frame(page, _("Keyboard Shortcuts"));
1294 GtkWidget *checkbox;
1295 GtkAccelKey current = { 0, 0, 0 };
1296 GtkAccelMap *map = gtk_accel_map_get();
1298 /* Maybe it would be better just to hardcode the values?
1299 * -- resiak, 2007-04-30
1301 if (ctrl_w.accel_key == 0)
1303 gtk_accelerator_parse ("<Control>w", &(ctrl_w.accel_key),
1304 &(ctrl_w.accel_mods));
1305 g_assert(ctrl_w.accel_key != 0);
1307 gtk_accelerator_parse ("Escape", &(escape.accel_key),
1308 &(escape.accel_mods));
1309 g_assert(escape.accel_key != 0);
1312 checkbox = gtk_check_button_new_with_mnemonic(
1313 _("Cl_ose conversations with the Escape key"));
1314 gtk_accel_map_lookup_entry(CONVERSATION_CLOSE_ACCEL_PATH, &current);
1315 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
1316 accel_is_escape(&current));
1318 escape_closes_conversation_cb_id = g_signal_connect(checkbox,
1319 "clicked", G_CALLBACK(escape_closes_conversation_cb), NULL);
1321 g_signal_connect_object(map, "changed::" CONVERSATION_CLOSE_ACCEL_PATH,
1322 G_CALLBACK(conversation_close_accel_changed_cb), checkbox, (GConnectFlags)0);
1324 gtk_box_pack_start(GTK_BOX(vbox), checkbox, FALSE, FALSE, 0);
1327 static GtkWidget *
1328 interface_page(void)
1330 GtkWidget *ret;
1331 GtkWidget *vbox;
1332 GtkWidget *vbox2;
1333 GtkWidget *label;
1334 GtkSizeGroup *sg;
1335 GList *names = NULL;
1337 ret = gtk_vbox_new(FALSE, PIDGIN_HIG_CAT_SPACE);
1338 gtk_container_set_border_width(GTK_CONTAINER(ret), PIDGIN_HIG_BORDER);
1340 sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
1342 /* System Tray */
1343 vbox = pidgin_make_frame(ret, _("System Tray Icon"));
1344 label = pidgin_prefs_dropdown(vbox, _("_Show system tray icon:"), PURPLE_PREF_STRING,
1345 PIDGIN_PREFS_ROOT "/docklet/show",
1346 _("Always"), "always",
1347 _("On unread messages"), "pending",
1348 _("Never"), "never",
1349 NULL);
1350 gtk_size_group_add_widget(sg, label);
1351 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
1353 vbox = pidgin_make_frame(ret, _("Conversation Window"));
1354 label = pidgin_prefs_dropdown(vbox, _("_Hide new IM conversations:"),
1355 PURPLE_PREF_STRING, PIDGIN_PREFS_ROOT "/conversations/im/hide_new",
1356 _("Never"), "never",
1357 _("When away"), "away",
1358 _("Always"), "always",
1359 NULL);
1360 gtk_size_group_add_widget(sg, label);
1361 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
1363 #ifdef _WIN32
1364 pidgin_prefs_checkbox(_("Minimi_ze new conversation windows"), PIDGIN_PREFS_ROOT "/win32/minimize_new_convs", vbox);
1365 #endif
1367 /* All the tab options! */
1368 vbox = pidgin_make_frame(ret, _("Tabs"));
1370 pidgin_prefs_checkbox(_("Show IMs and chats in _tabbed windows"),
1371 PIDGIN_PREFS_ROOT "/conversations/tabs", vbox);
1374 * Connect a signal to the above preference. When conversations are not
1375 * shown in a tabbed window then all tabbing options should be disabled.
1377 vbox2 = gtk_vbox_new(FALSE, 9);
1378 gtk_box_pack_start(GTK_BOX(vbox), vbox2, FALSE, FALSE, 0);
1379 purple_prefs_connect_callback(prefs, PIDGIN_PREFS_ROOT "/conversations/tabs",
1380 conversation_usetabs_cb, vbox2);
1381 if (!purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/tabs"))
1382 gtk_widget_set_sensitive(vbox2, FALSE);
1384 pidgin_prefs_checkbox(_("Show close b_utton on tabs"),
1385 PIDGIN_PREFS_ROOT "/conversations/close_on_tabs", vbox2);
1387 label = pidgin_prefs_dropdown(vbox2, _("_Placement:"), PURPLE_PREF_INT,
1388 PIDGIN_PREFS_ROOT "/conversations/tab_side",
1389 _("Top"), GTK_POS_TOP,
1390 _("Bottom"), GTK_POS_BOTTOM,
1391 _("Left"), GTK_POS_LEFT,
1392 _("Right"), GTK_POS_RIGHT,
1393 _("Left Vertical"), GTK_POS_LEFT|8,
1394 _("Right Vertical"), GTK_POS_RIGHT|8,
1395 NULL);
1396 gtk_size_group_add_widget(sg, label);
1397 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
1399 names = pidgin_conv_placement_get_options();
1400 label = pidgin_prefs_dropdown_from_list(vbox2, _("N_ew conversations:"),
1401 PURPLE_PREF_STRING, PIDGIN_PREFS_ROOT "/conversations/placement", names);
1402 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
1404 gtk_size_group_add_widget(sg, label);
1406 g_list_free(names);
1408 keyboard_shortcuts(ret);
1410 gtk_widget_show_all(ret);
1411 g_object_unref(sg);
1412 return ret;
1415 #ifdef _WIN32
1416 static void
1417 apply_custom_font(void)
1419 PangoFontDescription *desc = NULL;
1420 if (!purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/use_theme_font")) {
1421 const char *font = purple_prefs_get_string(PIDGIN_PREFS_ROOT "/conversations/custom_font");
1422 desc = pango_font_description_from_string(font);
1425 gtk_widget_modify_font(sample_imhtml, desc);
1426 if (desc)
1427 pango_font_description_free(desc);
1430 static void
1431 pidgin_custom_font_set(GtkFontButton *font_button, gpointer nul)
1434 purple_prefs_set_string(PIDGIN_PREFS_ROOT "/conversations/custom_font",
1435 gtk_font_button_get_font_name(font_button));
1437 apply_custom_font();
1439 #endif
1441 static GtkWidget *
1442 conv_page(void)
1444 GtkWidget *ret;
1445 GtkWidget *vbox;
1446 GtkWidget *toolbar;
1447 GtkWidget *iconpref1;
1448 GtkWidget *iconpref2;
1449 GtkWidget *imhtml;
1450 GtkWidget *frame;
1451 GtkWidget *hbox;
1452 GtkWidget *checkbox;
1453 GtkWidget *spin_button;
1455 ret = gtk_vbox_new(FALSE, PIDGIN_HIG_CAT_SPACE);
1456 gtk_container_set_border_width(GTK_CONTAINER(ret), PIDGIN_HIG_BORDER);
1458 vbox = pidgin_make_frame(ret, _("Conversations"));
1460 pidgin_prefs_checkbox(_("Show _formatting on incoming messages"),
1461 PIDGIN_PREFS_ROOT "/conversations/show_incoming_formatting", vbox);
1462 pidgin_prefs_checkbox(_("Close IMs immediately when the tab is closed"),
1463 PIDGIN_PREFS_ROOT "/conversations/im/close_immediately", vbox);
1465 iconpref1 = pidgin_prefs_checkbox(_("Show _detailed information"),
1466 PIDGIN_PREFS_ROOT "/conversations/im/show_buddy_icons", vbox);
1467 iconpref2 = pidgin_prefs_checkbox(_("Enable buddy ic_on animation"),
1468 PIDGIN_PREFS_ROOT "/conversations/im/animate_buddy_icons", vbox);
1469 if (!purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/im/show_buddy_icons"))
1470 gtk_widget_set_sensitive(iconpref2, FALSE);
1471 g_signal_connect(G_OBJECT(iconpref1), "clicked",
1472 G_CALLBACK(pidgin_toggle_sensitive), iconpref2);
1474 pidgin_prefs_checkbox(_("_Notify buddies that you are typing to them"),
1475 "/purple/conversations/im/send_typing", vbox);
1476 #ifdef USE_GTKSPELL
1477 pidgin_prefs_checkbox(_("Highlight _misspelled words"),
1478 PIDGIN_PREFS_ROOT "/conversations/spellcheck", vbox);
1479 #endif
1481 pidgin_prefs_checkbox(_("Use smooth-scrolling"), PIDGIN_PREFS_ROOT "/conversations/use_smooth_scrolling", vbox);
1483 #ifdef _WIN32
1484 pidgin_prefs_checkbox(_("F_lash window when IMs are received"), PIDGIN_PREFS_ROOT "/win32/blink_im", vbox);
1485 #endif
1486 hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE);
1488 checkbox = pidgin_prefs_checkbox(_("Resize incoming custom smileys"),
1489 PIDGIN_PREFS_ROOT "/conversations/resize_custom_smileys", hbox);
1491 spin_button = pidgin_prefs_labeled_spin_button(hbox,
1492 _("Maximum size:"),
1493 PIDGIN_PREFS_ROOT "/conversations/custom_smileys_size",
1494 16, 512, NULL);
1496 if (!purple_prefs_get_bool(
1497 PIDGIN_PREFS_ROOT "/conversations/resize_custom_smileys"))
1498 gtk_widget_set_sensitive(GTK_WIDGET(spin_button), FALSE);
1500 g_signal_connect(G_OBJECT(checkbox), "clicked",
1501 G_CALLBACK(pidgin_toggle_sensitive), spin_button);
1503 pidgin_add_widget_to_vbox(GTK_BOX(vbox), NULL, NULL, hbox, TRUE, NULL);
1505 pidgin_prefs_labeled_spin_button(vbox,
1506 _("Minimum input area height in lines:"),
1507 PIDGIN_PREFS_ROOT "/conversations/minimum_entry_lines",
1508 1, 8, NULL);
1510 #ifdef _WIN32
1512 GtkWidget *fontpref, *font_button, *hbox;
1513 const char *font_name;
1514 vbox = pidgin_make_frame(ret, _("Font"));
1516 fontpref = pidgin_prefs_checkbox(_("Use font from _theme"),
1517 PIDGIN_PREFS_ROOT "/conversations/use_theme_font", vbox);
1519 font_name = purple_prefs_get_string(PIDGIN_PREFS_ROOT "/conversations/custom_font");
1520 if ((font_name == NULL) || (*font_name == '\0')) {
1521 font_button = gtk_font_button_new();
1522 } else {
1523 font_button = gtk_font_button_new_with_font(font_name);
1526 gtk_font_button_set_show_style(GTK_FONT_BUTTON(font_button), TRUE);
1527 hbox = pidgin_add_widget_to_vbox(GTK_BOX(vbox), _("Conversation _font:"), NULL, font_button, FALSE, NULL);
1528 if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/use_theme_font"))
1529 gtk_widget_set_sensitive(hbox, FALSE);
1530 g_signal_connect(G_OBJECT(fontpref), "clicked", G_CALLBACK(pidgin_toggle_sensitive), hbox);
1531 g_signal_connect(G_OBJECT(fontpref), "clicked", G_CALLBACK(apply_custom_font), hbox);
1532 g_signal_connect(G_OBJECT(font_button), "font-set", G_CALLBACK(pidgin_custom_font_set), NULL);
1535 #endif
1537 vbox = pidgin_make_frame(ret, _("Default Formatting"));
1539 frame = pidgin_create_imhtml(TRUE, &imhtml, &toolbar, NULL);
1540 gtk_widget_show(frame);
1541 gtk_widget_set_name(imhtml, "pidgin_prefs_font_imhtml");
1542 gtk_widget_set_size_request(frame, 450, -1);
1543 gtk_imhtml_set_whole_buffer_formatting_only(GTK_IMHTML(imhtml), TRUE);
1544 gtk_imhtml_set_format_functions(GTK_IMHTML(imhtml),
1545 GTK_IMHTML_BOLD |
1546 GTK_IMHTML_ITALIC |
1547 GTK_IMHTML_UNDERLINE |
1548 GTK_IMHTML_GROW |
1549 GTK_IMHTML_SHRINK |
1550 GTK_IMHTML_FACE |
1551 GTK_IMHTML_FORECOLOR |
1552 GTK_IMHTML_BACKCOLOR |
1553 GTK_IMHTML_BACKGROUND);
1555 gtk_imhtml_append_text(GTK_IMHTML(imhtml), _("This is how your outgoing message text will appear when you use protocols that support formatting."), 0);
1557 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0);
1559 gtk_imhtml_setup_entry(GTK_IMHTML(imhtml), PURPLE_CONNECTION_HTML | PURPLE_CONNECTION_FORMATTING_WBFO);
1561 g_signal_connect_after(G_OBJECT(imhtml), "format_function_toggle",
1562 G_CALLBACK(formatting_toggle_cb), toolbar);
1563 g_signal_connect_after(G_OBJECT(imhtml), "format_function_clear",
1564 G_CALLBACK(formatting_clear_cb), NULL);
1565 sample_imhtml = imhtml;
1567 gtk_widget_show(ret);
1569 return ret;
1572 static void
1573 network_ip_changed(GtkEntry *entry, gpointer data)
1575 const gchar *text = gtk_entry_get_text(entry);
1576 GdkColor color;
1578 if (text && *text) {
1579 if (purple_ip_address_is_valid(text)) {
1580 color.red = 0xAFFF;
1581 color.green = 0xFFFF;
1582 color.blue = 0xAFFF;
1584 purple_network_set_public_ip(text);
1585 } else {
1586 color.red = 0xFFFF;
1587 color.green = 0xAFFF;
1588 color.blue = 0xAFFF;
1591 gtk_widget_modify_base(GTK_WIDGET(entry), GTK_STATE_NORMAL, &color);
1593 } else {
1594 purple_network_set_public_ip("");
1595 gtk_widget_modify_base(GTK_WIDGET(entry), GTK_STATE_NORMAL, NULL);
1599 static gboolean
1600 network_stun_server_changed_cb(GtkWidget *widget,
1601 GdkEventFocus *event, gpointer data)
1603 GtkEntry *entry = GTK_ENTRY(widget);
1604 purple_prefs_set_string("/purple/network/stun_server",
1605 gtk_entry_get_text(entry));
1606 purple_network_set_stun_server(gtk_entry_get_text(entry));
1608 return FALSE;
1611 static gboolean
1612 network_turn_server_changed_cb(GtkWidget *widget,
1613 GdkEventFocus *event, gpointer data)
1615 GtkEntry *entry = GTK_ENTRY(widget);
1616 purple_prefs_set_string("/purple/network/turn_server",
1617 gtk_entry_get_text(entry));
1618 purple_network_set_turn_server(gtk_entry_get_text(entry));
1620 return FALSE;
1623 static void
1624 proxy_changed_cb(const char *name, PurplePrefType type,
1625 gconstpointer value, gpointer data)
1627 GtkWidget *frame = data;
1628 const char *proxy = value;
1630 if (strcmp(proxy, "none") && strcmp(proxy, "envvar"))
1631 gtk_widget_show_all(frame);
1632 else
1633 gtk_widget_hide(frame);
1636 static void
1637 proxy_print_option(GtkEntry *entry, int entrynum)
1639 if (entrynum == PROXYHOST)
1640 purple_prefs_set_string("/purple/proxy/host", gtk_entry_get_text(entry));
1641 else if (entrynum == PROXYPORT)
1642 purple_prefs_set_int("/purple/proxy/port", atoi(gtk_entry_get_text(entry)));
1643 else if (entrynum == PROXYUSER)
1644 purple_prefs_set_string("/purple/proxy/username", gtk_entry_get_text(entry));
1645 else if (entrynum == PROXYPASS)
1646 purple_prefs_set_string("/purple/proxy/password", gtk_entry_get_text(entry));
1649 static void
1650 proxy_button_clicked_cb(GtkWidget *button, gchar *program)
1652 GError *err = NULL;
1654 if (g_spawn_command_line_async(program, &err))
1655 return;
1657 purple_notify_error(NULL, NULL, _("Cannot start proxy configuration program."), err->message);
1658 g_error_free(err);
1661 #ifndef _WIN32
1662 static void
1663 browser_button_clicked_cb(GtkWidget *button, gpointer null)
1665 GError *err = NULL;
1667 if (g_spawn_command_line_async ("gnome-default-applications-properties", &err))
1668 return;
1670 purple_notify_error(NULL, NULL, _("Cannot start browser configuration program."), err->message);
1671 g_error_free(err);
1673 #endif
1675 static void
1676 auto_ip_button_clicked_cb(GtkWidget *button, gpointer null)
1678 const char *ip;
1679 PurpleStunNatDiscovery *stun;
1680 char *auto_ip_text;
1682 /* purple_network_get_my_ip will return the IP that was set by the user with
1683 purple_network_set_public_ip, so make a lookup for the auto-detected IP
1684 ourselves. */
1686 if (purple_prefs_get_bool("/purple/network/auto_ip")) {
1687 /* Check if STUN discovery was already done */
1688 stun = purple_stun_discover(NULL);
1689 if ((stun != NULL) && (stun->status == PURPLE_STUN_STATUS_DISCOVERED)) {
1690 ip = stun->publicip;
1691 } else {
1692 /* Attempt to get the IP from a NAT device using UPnP */
1693 ip = purple_upnp_get_public_ip();
1694 if (ip == NULL) {
1695 /* Attempt to get the IP from a NAT device using NAT-PMP */
1696 ip = purple_pmp_get_public_ip();
1697 if (ip == NULL) {
1698 /* Just fetch the IP of the local system */
1699 ip = purple_network_get_local_system_ip(-1);
1704 else
1705 ip = _("Disabled");
1707 auto_ip_text = g_strdup_printf(_("Use _automatically detected IP address: %s"), ip);
1708 gtk_button_set_label(GTK_BUTTON(button), auto_ip_text);
1709 g_free(auto_ip_text);
1712 static GtkWidget *
1713 network_page(void)
1715 GtkWidget *ret;
1716 GtkWidget *vbox, *hbox, *entry;
1717 GtkWidget *label, *auto_ip_checkbox, *ports_checkbox, *spin_button;
1718 GtkSizeGroup *sg;
1720 ret = gtk_vbox_new(FALSE, PIDGIN_HIG_CAT_SPACE);
1721 gtk_container_set_border_width (GTK_CONTAINER (ret), PIDGIN_HIG_BORDER);
1723 vbox = pidgin_make_frame (ret, _("IP Address"));
1724 sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
1726 entry = gtk_entry_new();
1727 gtk_entry_set_text(GTK_ENTRY(entry), purple_prefs_get_string(
1728 "/purple/network/stun_server"));
1729 g_signal_connect(G_OBJECT(entry), "focus-out-event",
1730 G_CALLBACK(network_stun_server_changed_cb), NULL);
1731 gtk_widget_show(entry);
1733 pidgin_add_widget_to_vbox(GTK_BOX(vbox), _("ST_UN server:"),
1734 sg, entry, TRUE, NULL);
1736 hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE);
1737 gtk_container_add(GTK_CONTAINER(vbox), hbox);
1739 label = gtk_label_new(NULL);
1740 gtk_container_add(GTK_CONTAINER(hbox), label);
1741 gtk_size_group_add_widget(sg, label);
1743 label = gtk_label_new(NULL);
1744 gtk_label_set_markup(GTK_LABEL(label),
1745 _("<span style=\"italic\">Example: stunserver.org</span>"));
1746 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
1747 gtk_container_add(GTK_CONTAINER(hbox), label);
1749 auto_ip_checkbox = pidgin_prefs_checkbox("Use _automatically detected IP address",
1750 "/purple/network/auto_ip", vbox);
1751 g_signal_connect(G_OBJECT(auto_ip_checkbox), "clicked",
1752 G_CALLBACK(auto_ip_button_clicked_cb), NULL);
1753 auto_ip_button_clicked_cb(auto_ip_checkbox, NULL); /* Update label */
1755 entry = gtk_entry_new();
1756 gtk_entry_set_text(GTK_ENTRY(entry), purple_network_get_public_ip());
1757 g_signal_connect(G_OBJECT(entry), "changed",
1758 G_CALLBACK(network_ip_changed), NULL);
1760 hbox = pidgin_add_widget_to_vbox(GTK_BOX(vbox), _("Public _IP:"),
1761 sg, entry, TRUE, NULL);
1763 if (purple_prefs_get_bool("/purple/network/auto_ip")) {
1764 gtk_widget_set_sensitive(GTK_WIDGET(hbox), FALSE);
1767 g_signal_connect(G_OBJECT(auto_ip_checkbox), "clicked",
1768 G_CALLBACK(pidgin_toggle_sensitive), hbox);
1770 g_object_unref(sg);
1772 vbox = pidgin_make_frame (ret, _("Ports"));
1773 sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
1775 pidgin_prefs_checkbox(_("_Enable automatic router port forwarding"),
1776 "/purple/network/map_ports", vbox);
1778 hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE);
1780 ports_checkbox = pidgin_prefs_checkbox(_("_Manually specify range of ports to listen on:"),
1781 "/purple/network/ports_range_use", hbox);
1783 spin_button = pidgin_prefs_labeled_spin_button(hbox, _("_Start:"),
1784 "/purple/network/ports_range_start", 0, 65535, sg);
1785 if (!purple_prefs_get_bool("/purple/network/ports_range_use"))
1786 gtk_widget_set_sensitive(GTK_WIDGET(spin_button), FALSE);
1787 g_signal_connect(G_OBJECT(ports_checkbox), "clicked",
1788 G_CALLBACK(pidgin_toggle_sensitive), spin_button);
1790 spin_button = pidgin_prefs_labeled_spin_button(hbox, _("_End:"),
1791 "/purple/network/ports_range_end", 0, 65535, sg);
1792 if (!purple_prefs_get_bool("/purple/network/ports_range_use"))
1793 gtk_widget_set_sensitive(GTK_WIDGET(spin_button), FALSE);
1794 g_signal_connect(G_OBJECT(ports_checkbox), "clicked",
1795 G_CALLBACK(pidgin_toggle_sensitive), spin_button);
1797 pidgin_add_widget_to_vbox(GTK_BOX(vbox), NULL, NULL, hbox, TRUE, NULL);
1799 g_object_unref(sg);
1801 /* TURN server */
1802 vbox = pidgin_make_frame(ret, _("Relay Server (TURN)"));
1803 sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
1805 entry = gtk_entry_new();
1806 gtk_entry_set_text(GTK_ENTRY(entry), purple_prefs_get_string(
1807 "/purple/network/turn_server"));
1808 g_signal_connect(G_OBJECT(entry), "focus-out-event",
1809 G_CALLBACK(network_turn_server_changed_cb), NULL);
1810 gtk_widget_show(entry);
1812 hbox = pidgin_add_widget_to_vbox(GTK_BOX(vbox), _("_TURN server:"),
1813 sg, entry, TRUE, NULL);
1815 pidgin_prefs_labeled_spin_button(hbox, _("_UDP Port:"),
1816 "/purple/network/turn_port", 0, 65535, NULL);
1818 pidgin_prefs_labeled_spin_button(hbox, _("T_CP Port:"),
1819 "/purple/network/turn_port_tcp", 0, 65535, NULL);
1821 hbox = pidgin_prefs_labeled_entry(vbox, _("Use_rname:"),
1822 "/purple/network/turn_username", sg);
1823 pidgin_prefs_labeled_password(hbox, _("Pass_word:"),
1824 "/purple/network/turn_password", NULL);
1826 gtk_widget_show_all(ret);
1827 g_object_unref(sg);
1829 return ret;
1832 #ifndef _WIN32
1833 static gboolean
1834 manual_browser_set(GtkWidget *entry, GdkEventFocus *event, gpointer data)
1836 const char *program = gtk_entry_get_text(GTK_ENTRY(entry));
1838 purple_prefs_set_string(PIDGIN_PREFS_ROOT "/browsers/manual_command", program);
1840 /* carry on normally */
1841 return FALSE;
1844 static GList *
1845 get_available_browsers(void)
1847 struct browser {
1848 char *name;
1849 char *command;
1852 /* Sorted reverse alphabetically */
1853 static const struct browser possible_browsers[] = {
1854 {N_("Seamonkey"), "seamonkey"},
1855 {N_("Opera"), "opera"},
1856 {N_("Netscape"), "netscape"},
1857 {N_("Mozilla"), "mozilla"},
1858 {N_("Konqueror"), "kfmclient"},
1859 {N_("Google Chrome"), "google-chrome"},
1860 /* Do not move the line below. Code below expects gnome-open to be in
1861 * this list immediately after xdg-open! */
1862 {N_("Desktop Default"), "xdg-open"},
1863 {N_("GNOME Default"), "gnome-open"},
1864 {N_("Galeon"), "galeon"},
1865 {N_("Firefox"), "firefox"},
1866 {N_("Firebird"), "mozilla-firebird"},
1867 {N_("Epiphany"), "epiphany"},
1868 /* Translators: please do not translate "chromium-browser" here! */
1869 {N_("Chromium (chromium-browser)"), "chromium-browser"},
1870 /* Translators: please do not translate "chrome" here! */
1871 {N_("Chromium (chrome)"), "chrome"}
1873 static const int num_possible_browsers = G_N_ELEMENTS(possible_browsers);
1875 GList *browsers = NULL;
1876 int i = 0;
1877 char *browser_setting = (char *)purple_prefs_get_string(PIDGIN_PREFS_ROOT "/browsers/browser");
1879 browsers = g_list_prepend(browsers, (gpointer)"custom");
1880 browsers = g_list_prepend(browsers, (gpointer)_("Manual"));
1882 for (i = 0; i < num_possible_browsers; i++) {
1883 if (purple_program_is_valid(possible_browsers[i].command)) {
1884 browsers = g_list_prepend(browsers,
1885 possible_browsers[i].command);
1886 browsers = g_list_prepend(browsers, (gpointer)_(possible_browsers[i].name));
1887 if(browser_setting && !strcmp(possible_browsers[i].command, browser_setting))
1888 browser_setting = NULL;
1889 /* If xdg-open is valid, prefer it over gnome-open and skip forward */
1890 if(!strcmp(possible_browsers[i].command, "xdg-open")) {
1891 if (browser_setting && !strcmp("gnome-open", browser_setting)) {
1892 purple_prefs_set_string(PIDGIN_PREFS_ROOT "/browsers/browser", possible_browsers[i].command);
1893 browser_setting = NULL;
1895 i++;
1900 if(browser_setting)
1901 purple_prefs_set_string(PIDGIN_PREFS_ROOT "/browsers/browser", "custom");
1903 return browsers;
1906 static void
1907 browser_changed1_cb(const char *name, PurplePrefType type,
1908 gconstpointer value, gpointer data)
1910 GtkWidget *hbox = data;
1911 const char *browser = value;
1913 gtk_widget_set_sensitive(hbox, strcmp(browser, "custom"));
1916 static void
1917 browser_changed2_cb(const char *name, PurplePrefType type,
1918 gconstpointer value, gpointer data)
1920 GtkWidget *hbox = data;
1921 const char *browser = value;
1923 gtk_widget_set_sensitive(hbox, !strcmp(browser, "custom"));
1926 static GtkWidget *
1927 browser_page(void)
1929 GtkWidget *ret, *vbox, *hbox, *label, *entry, *browser_button;
1930 GtkSizeGroup *sg;
1931 GList *browsers = NULL;
1933 ret = gtk_vbox_new(FALSE, PIDGIN_HIG_CAT_SPACE);
1934 gtk_container_set_border_width (GTK_CONTAINER (ret), PIDGIN_HIG_BORDER);
1936 vbox = pidgin_make_frame (ret, _("Browser Selection"));
1938 if(purple_running_gnome()) {
1939 gchar *path = g_find_program_in_path("gnome-default-applications-properties");
1941 hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE);
1942 label = gtk_label_new(_("Browser preferences are configured in GNOME preferences"));
1943 gtk_container_add(GTK_CONTAINER(vbox), hbox);
1944 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1946 hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE);
1947 gtk_container_add(GTK_CONTAINER(vbox), hbox);
1949 if(path == NULL) {
1950 label = gtk_label_new(NULL);
1951 gtk_label_set_markup(GTK_LABEL(label),
1952 _("<b>Browser configuration program was not found.</b>"));
1953 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1954 } else {
1955 browser_button = gtk_button_new_with_mnemonic(_("Configure _Browser"));
1956 g_signal_connect(G_OBJECT(browser_button), "clicked",
1957 G_CALLBACK(browser_button_clicked_cb), NULL);
1958 gtk_box_pack_start(GTK_BOX(hbox), browser_button, FALSE, FALSE, 0);
1961 g_free(path);
1962 gtk_widget_show_all(ret);
1963 } else {
1964 sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
1966 browsers = get_available_browsers();
1967 if (browsers != NULL) {
1968 label = pidgin_prefs_dropdown_from_list(vbox,_("_Browser:"), PURPLE_PREF_STRING,
1969 PIDGIN_PREFS_ROOT "/browsers/browser",
1970 browsers);
1971 g_list_free(browsers);
1972 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
1973 gtk_size_group_add_widget(sg, label);
1975 hbox = gtk_hbox_new(FALSE, 0);
1976 label = pidgin_prefs_dropdown(hbox, _("_Open link in:"), PURPLE_PREF_INT,
1977 PIDGIN_PREFS_ROOT "/browsers/place",
1978 _("Browser default"), PIDGIN_BROWSER_DEFAULT,
1979 _("Existing window"), PIDGIN_BROWSER_CURRENT,
1980 _("New window"), PIDGIN_BROWSER_NEW_WINDOW,
1981 _("New tab"), PIDGIN_BROWSER_NEW_TAB,
1982 NULL);
1983 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
1984 gtk_size_group_add_widget(sg, label);
1985 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1987 if (!strcmp(purple_prefs_get_string(PIDGIN_PREFS_ROOT "/browsers/browser"), "custom"))
1988 gtk_widget_set_sensitive(hbox, FALSE);
1989 purple_prefs_connect_callback(prefs, PIDGIN_PREFS_ROOT "/browsers/browser",
1990 browser_changed1_cb, hbox);
1993 entry = gtk_entry_new();
1994 gtk_entry_set_text(GTK_ENTRY(entry),
1995 purple_prefs_get_string(PIDGIN_PREFS_ROOT "/browsers/manual_command"));
1996 g_signal_connect(G_OBJECT(entry), "focus-out-event",
1997 G_CALLBACK(manual_browser_set), NULL);
1998 hbox = pidgin_add_widget_to_vbox(GTK_BOX(vbox), _("_Manual:\n(%s for URL)"), sg, entry, TRUE, NULL);
1999 if (strcmp(purple_prefs_get_string(PIDGIN_PREFS_ROOT "/browsers/browser"), "custom"))
2000 gtk_widget_set_sensitive(hbox, FALSE);
2001 purple_prefs_connect_callback(prefs, PIDGIN_PREFS_ROOT "/browsers/browser",
2002 browser_changed2_cb, hbox);
2004 gtk_widget_show_all(ret);
2005 g_object_unref(sg);
2008 return ret;
2010 #endif /*_WIN32*/
2012 static GtkWidget *
2013 proxy_page(void)
2015 GtkWidget *ret = NULL, *vbox = NULL, *hbox = NULL;
2016 GtkWidget *table = NULL, *entry = NULL, *label = NULL, *proxy_button = NULL;
2017 GtkWidget *prefs_proxy_frame = NULL;
2018 PurpleProxyInfo *proxy_info;
2020 ret = gtk_vbox_new(FALSE, PIDGIN_HIG_CAT_SPACE);
2021 gtk_container_set_border_width(GTK_CONTAINER(ret), PIDGIN_HIG_BORDER);
2022 vbox = pidgin_make_frame(ret, _("Proxy Server"));
2023 prefs_proxy_frame = gtk_vbox_new(FALSE, PIDGIN_HIG_BOX_SPACE);
2025 if(purple_running_gnome()) {
2026 gchar *path = NULL;
2028 hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE);
2029 label = gtk_label_new(_("Proxy preferences are configured in GNOME preferences"));
2030 gtk_container_add(GTK_CONTAINER(vbox), hbox);
2031 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
2033 hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE);
2034 gtk_container_add(GTK_CONTAINER(vbox), hbox);
2036 path = g_find_program_in_path("gnome-network-properties");
2037 if (path == NULL)
2038 path = g_find_program_in_path("gnome-network-preferences");
2040 if (path == NULL) {
2041 label = gtk_label_new(NULL);
2042 gtk_label_set_markup(GTK_LABEL(label),
2043 _("<b>Proxy configuration program was not found.</b>"));
2044 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
2045 } else {
2046 proxy_button = gtk_button_new_with_mnemonic(_("Configure _Proxy"));
2047 g_signal_connect(G_OBJECT(proxy_button), "clicked",
2048 G_CALLBACK(proxy_button_clicked_cb),
2049 path);
2050 gtk_box_pack_start(GTK_BOX(hbox), proxy_button, FALSE, FALSE, 0);
2053 /* NOTE: path leaks, but only when the prefs window is destroyed,
2054 which is never */
2055 gtk_widget_show_all(ret);
2056 } else {
2057 GtkWidget *prefs_proxy_subframe = gtk_vbox_new(FALSE, 0);
2059 /* This is a global option that affects SOCKS4 usage even with
2060 * account-specific proxy settings */
2061 pidgin_prefs_checkbox(_("Use remote _DNS with SOCKS4 proxies"),
2062 "/purple/proxy/socks4_remotedns", prefs_proxy_frame);
2063 gtk_box_pack_start(GTK_BOX(vbox), prefs_proxy_frame, 0, 0, 0);
2065 pidgin_prefs_dropdown(prefs_proxy_frame, _("Proxy t_ype:"), PURPLE_PREF_STRING,
2066 "/purple/proxy/type",
2067 _("No proxy"), "none",
2068 _("SOCKS 4"), "socks4",
2069 _("SOCKS 5"), "socks5",
2070 _("Tor/Privacy (SOCKS5)"), "tor",
2071 _("HTTP"), "http",
2072 _("Use Environmental Settings"), "envvar",
2073 NULL);
2074 gtk_box_pack_start(GTK_BOX(prefs_proxy_frame), prefs_proxy_subframe, 0, 0, 0);
2075 proxy_info = purple_global_proxy_get_info();
2077 gtk_widget_show_all(ret);
2079 purple_prefs_connect_callback(prefs, "/purple/proxy/type",
2080 proxy_changed_cb, prefs_proxy_subframe);
2082 table = gtk_table_new(4, 2, FALSE);
2083 gtk_container_set_border_width(GTK_CONTAINER(table), 0);
2084 gtk_table_set_col_spacings(GTK_TABLE(table), 5);
2085 gtk_table_set_row_spacings(GTK_TABLE(table), 10);
2086 gtk_container_add(GTK_CONTAINER(prefs_proxy_subframe), table);
2088 label = gtk_label_new_with_mnemonic(_("_Host:"));
2089 gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5);
2090 gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1, GTK_FILL, 0, 0, 0);
2092 entry = gtk_entry_new();
2093 gtk_label_set_mnemonic_widget(GTK_LABEL(label), entry);
2094 gtk_table_attach(GTK_TABLE(table), entry, 1, 2, 0, 1, GTK_FILL, 0, 0, 0);
2095 g_signal_connect(G_OBJECT(entry), "changed",
2096 G_CALLBACK(proxy_print_option), (void *)PROXYHOST);
2098 if (proxy_info != NULL && purple_proxy_info_get_host(proxy_info))
2099 gtk_entry_set_text(GTK_ENTRY(entry),
2100 purple_proxy_info_get_host(proxy_info));
2102 hbox = gtk_hbox_new(TRUE, 5);
2103 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
2104 pidgin_set_accessible_label (entry, label);
2106 label = gtk_label_new_with_mnemonic(_("P_ort:"));
2107 gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5);
2108 gtk_table_attach(GTK_TABLE(table), label, 2, 3, 0, 1, GTK_FILL, 0, 0, 0);
2110 entry = gtk_spin_button_new_with_range(0, 65535, 1);
2111 gtk_label_set_mnemonic_widget(GTK_LABEL(label), entry);
2112 gtk_table_attach(GTK_TABLE(table), entry, 3, 4, 0, 1, GTK_FILL, 0, 0, 0);
2113 g_signal_connect(G_OBJECT(entry), "changed",
2114 G_CALLBACK(proxy_print_option), (void *)PROXYPORT);
2116 if (proxy_info != NULL && purple_proxy_info_get_port(proxy_info) != 0) {
2117 gtk_spin_button_set_value(GTK_SPIN_BUTTON(entry),
2118 purple_proxy_info_get_port(proxy_info));
2120 pidgin_set_accessible_label (entry, label);
2122 label = gtk_label_new_with_mnemonic(_("User_name:"));
2123 gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5);
2124 gtk_table_attach(GTK_TABLE(table), label, 0, 1, 1, 2, GTK_FILL, 0, 0, 0);
2126 entry = gtk_entry_new();
2127 gtk_label_set_mnemonic_widget(GTK_LABEL(label), entry);
2128 gtk_table_attach(GTK_TABLE(table), entry, 1, 2, 1, 2, GTK_FILL, 0, 0, 0);
2129 g_signal_connect(G_OBJECT(entry), "changed",
2130 G_CALLBACK(proxy_print_option), (void *)PROXYUSER);
2132 if (proxy_info != NULL && purple_proxy_info_get_username(proxy_info) != NULL)
2133 gtk_entry_set_text(GTK_ENTRY(entry),
2134 purple_proxy_info_get_username(proxy_info));
2136 hbox = gtk_hbox_new(TRUE, 5);
2137 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
2138 pidgin_set_accessible_label (entry, label);
2140 label = gtk_label_new_with_mnemonic(_("Pa_ssword:"));
2141 gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5);
2142 gtk_table_attach(GTK_TABLE(table), label, 2, 3, 1, 2, GTK_FILL, 0, 0, 0);
2144 entry = gtk_entry_new();
2145 gtk_label_set_mnemonic_widget(GTK_LABEL(label), entry);
2146 gtk_table_attach(GTK_TABLE(table), entry, 3, 4, 1, 2, GTK_FILL , 0, 0, 0);
2147 gtk_entry_set_visibility(GTK_ENTRY(entry), FALSE);
2148 #if !GTK_CHECK_VERSION(2,16,0)
2149 if (gtk_entry_get_invisible_char(GTK_ENTRY(entry)) == '*')
2150 gtk_entry_set_invisible_char(GTK_ENTRY(entry), PIDGIN_INVISIBLE_CHAR);
2151 #endif /* Less than GTK+ 2.16 */
2152 g_signal_connect(G_OBJECT(entry), "changed",
2153 G_CALLBACK(proxy_print_option), (void *)PROXYPASS);
2155 if (proxy_info != NULL && purple_proxy_info_get_password(proxy_info) != NULL)
2156 gtk_entry_set_text(GTK_ENTRY(entry),
2157 purple_proxy_info_get_password(proxy_info));
2158 pidgin_set_accessible_label (entry, label);
2160 proxy_changed_cb("/purple/proxy/type", PURPLE_PREF_STRING,
2161 purple_prefs_get_string("/purple/proxy/type"),
2162 prefs_proxy_subframe);
2166 return ret;
2169 static GtkWidget *
2170 logging_page(void)
2172 GtkWidget *ret;
2173 GtkWidget *vbox;
2174 GList *names;
2176 ret = gtk_vbox_new(FALSE, PIDGIN_HIG_CAT_SPACE);
2177 gtk_container_set_border_width (GTK_CONTAINER (ret), PIDGIN_HIG_BORDER);
2180 vbox = pidgin_make_frame (ret, _("Logging"));
2181 names = purple_log_logger_get_options();
2183 pidgin_prefs_dropdown_from_list(vbox, _("Log _format:"), PURPLE_PREF_STRING,
2184 "/purple/logging/format", names);
2186 g_list_free(names);
2188 pidgin_prefs_checkbox(_("Log all _instant messages"),
2189 "/purple/logging/log_ims", vbox);
2190 pidgin_prefs_checkbox(_("Log all c_hats"),
2191 "/purple/logging/log_chats", vbox);
2192 pidgin_prefs_checkbox(_("Log all _status changes to system log"),
2193 "/purple/logging/log_system", vbox);
2195 gtk_widget_show_all(ret);
2197 return ret;
2200 #ifndef _WIN32
2201 static gint
2202 sound_cmd_yeah(GtkEntry *entry, gpointer d)
2204 purple_prefs_set_path(PIDGIN_PREFS_ROOT "/sound/command",
2205 gtk_entry_get_text(GTK_ENTRY(entry)));
2206 return TRUE;
2209 static void
2210 sound_changed1_cb(const char *name, PurplePrefType type,
2211 gconstpointer value, gpointer data)
2213 GtkWidget *hbox = data;
2214 const char *method = value;
2216 gtk_widget_set_sensitive(hbox, !strcmp(method, "custom"));
2219 static void
2220 sound_changed2_cb(const char *name, PurplePrefType type,
2221 gconstpointer value, gpointer data)
2223 GtkWidget *vbox = data;
2224 const char *method = value;
2226 gtk_widget_set_sensitive(vbox, strcmp(method, "none"));
2228 #endif /* !_WIN32 */
2230 #ifdef USE_GSTREAMER
2231 static void
2232 sound_changed3_cb(const char *name, PurplePrefType type,
2233 gconstpointer value, gpointer data)
2235 GtkWidget *hbox = data;
2236 const char *method = value;
2238 gtk_widget_set_sensitive(hbox,
2239 !strcmp(method, "automatic") ||
2240 !strcmp(method, "alsa") ||
2241 !strcmp(method, "esd"));
2243 #endif /* USE_GSTREAMER */
2246 static void
2247 event_toggled(GtkCellRendererToggle *cell, gchar *pth, gpointer data)
2249 GtkTreeModel *model = (GtkTreeModel *)data;
2250 GtkTreeIter iter;
2251 GtkTreePath *path = gtk_tree_path_new_from_string(pth);
2252 char *pref;
2254 gtk_tree_model_get_iter (model, &iter, path);
2255 gtk_tree_model_get (model, &iter,
2256 2, &pref,
2257 -1);
2259 purple_prefs_set_bool(pref, !gtk_cell_renderer_toggle_get_active(cell));
2260 g_free(pref);
2262 gtk_list_store_set(GTK_LIST_STORE (model), &iter,
2263 0, !gtk_cell_renderer_toggle_get_active(cell),
2264 -1);
2266 gtk_tree_path_free(path);
2269 static void
2270 test_sound(GtkWidget *button, gpointer i_am_NULL)
2272 char *pref;
2273 gboolean temp_enabled;
2274 gboolean temp_mute;
2276 pref = g_strdup_printf(PIDGIN_PREFS_ROOT "/sound/enabled/%s",
2277 pidgin_sound_get_event_option(sound_row_sel));
2279 temp_enabled = purple_prefs_get_bool(pref);
2280 temp_mute = purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/sound/mute");
2282 if (!temp_enabled) purple_prefs_set_bool(pref, TRUE);
2283 if (temp_mute) purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/sound/mute", FALSE);
2285 purple_sound_play_event(sound_row_sel, NULL);
2287 if (!temp_enabled) purple_prefs_set_bool(pref, FALSE);
2288 if (temp_mute) purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/sound/mute", TRUE);
2290 g_free(pref);
2294 * Resets a sound file back to default.
2296 static void
2297 reset_sound(GtkWidget *button, gpointer i_am_also_NULL)
2299 gchar *pref;
2301 pref = g_strdup_printf(PIDGIN_PREFS_ROOT "/sound/file/%s",
2302 pidgin_sound_get_event_option(sound_row_sel));
2303 purple_prefs_set_path(pref, "");
2304 g_free(pref);
2306 gtk_entry_set_text(GTK_ENTRY(sound_entry), _("(default)"));
2308 pref_sound_generate_markup();
2311 static void
2312 sound_chosen_cb(void *user_data, const char *filename)
2314 gchar *pref;
2315 int sound;
2317 sound = GPOINTER_TO_INT(user_data);
2319 /* Set it -- and forget it */
2320 pref = g_strdup_printf(PIDGIN_PREFS_ROOT "/sound/file/%s",
2321 pidgin_sound_get_event_option(sound));
2322 purple_prefs_set_path(pref, filename);
2323 g_free(pref);
2326 * If the sound we just changed is still the currently selected
2327 * sound, then update the box showing the file name.
2329 if (sound == sound_row_sel)
2330 gtk_entry_set_text(GTK_ENTRY(sound_entry), filename);
2332 pref_sound_generate_markup();
2335 static void
2336 select_sound(GtkWidget *button, gpointer being_NULL_is_fun)
2338 gchar *pref;
2339 const char *filename;
2341 pref = g_strdup_printf(PIDGIN_PREFS_ROOT "/sound/file/%s",
2342 pidgin_sound_get_event_option(sound_row_sel));
2343 filename = purple_prefs_get_path(pref);
2344 g_free(pref);
2346 if (*filename == '\0')
2347 filename = NULL;
2349 purple_request_file(prefs, _("Sound Selection"), filename, FALSE,
2350 G_CALLBACK(sound_chosen_cb), NULL,
2351 NULL, NULL, NULL,
2352 GINT_TO_POINTER(sound_row_sel));
2355 #ifdef USE_GSTREAMER
2356 static gchar *
2357 prefs_sound_volume_format(GtkScale *scale, gdouble val)
2359 if(val < 15) {
2360 return g_strdup_printf(_("Quietest"));
2361 } else if(val < 30) {
2362 return g_strdup_printf(_("Quieter"));
2363 } else if(val < 45) {
2364 return g_strdup_printf(_("Quiet"));
2365 } else if(val < 55) {
2366 return g_strdup_printf(_("Normal"));
2367 } else if(val < 70) {
2368 return g_strdup_printf(_("Loud"));
2369 } else if(val < 85) {
2370 return g_strdup_printf(_("Louder"));
2371 } else {
2372 return g_strdup_printf(_("Loudest"));
2376 static void
2377 prefs_sound_volume_changed(GtkRange *range)
2379 int val = (int)gtk_range_get_value(GTK_RANGE(range));
2380 purple_prefs_set_int(PIDGIN_PREFS_ROOT "/sound/volume", val);
2382 #endif
2384 static void
2385 prefs_sound_sel(GtkTreeSelection *sel, GtkTreeModel *model)
2387 GtkTreeIter iter;
2388 GValue val;
2389 const char *file;
2390 char *pref;
2392 if (! gtk_tree_selection_get_selected (sel, &model, &iter))
2393 return;
2395 val.g_type = 0;
2396 gtk_tree_model_get_value (model, &iter, 3, &val);
2397 sound_row_sel = g_value_get_uint(&val);
2399 pref = g_strdup_printf(PIDGIN_PREFS_ROOT "/sound/file/%s",
2400 pidgin_sound_get_event_option(sound_row_sel));
2401 file = purple_prefs_get_path(pref);
2402 g_free(pref);
2403 if (sound_entry)
2404 gtk_entry_set_text(GTK_ENTRY(sound_entry), (file && *file != '\0') ? file : _("(default)"));
2405 g_value_unset (&val);
2407 pref_sound_generate_markup();
2411 static void
2412 mute_changed_cb(const char *pref_name,
2413 PurplePrefType pref_type,
2414 gconstpointer val,
2415 gpointer data)
2417 GtkToggleButton *button = data;
2418 gboolean muted = GPOINTER_TO_INT(val);
2420 g_return_if_fail(!strcmp (pref_name, PIDGIN_PREFS_ROOT "/sound/mute"));
2422 /* Block the handler that re-sets the preference. */
2423 g_signal_handlers_block_matched(button, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, (gpointer)pref_name);
2424 gtk_toggle_button_set_active (button, muted);
2425 g_signal_handlers_unblock_matched(button, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, (gpointer)pref_name);
2429 static GtkWidget *
2430 sound_page(void)
2432 GtkWidget *ret;
2433 GtkWidget *vbox, *vbox2, *sw, *button;
2434 GtkSizeGroup *sg;
2435 GtkTreeIter iter;
2436 GtkWidget *event_view;
2437 GtkListStore *event_store;
2438 GtkCellRenderer *rend;
2439 GtkTreeViewColumn *col;
2440 GtkTreeSelection *sel;
2441 GtkTreePath *path;
2442 GtkWidget *hbox;
2443 int j;
2444 const char *file;
2445 char *pref;
2446 #ifndef _WIN32
2447 GtkWidget *dd;
2448 GtkWidget *entry;
2449 const char *cmd;
2450 #endif
2452 ret = gtk_vbox_new(FALSE, PIDGIN_HIG_CAT_SPACE);
2453 gtk_container_set_border_width (GTK_CONTAINER (ret), PIDGIN_HIG_BORDER);
2455 sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
2457 vbox2 = pidgin_make_frame(ret, _("Sound Options"));
2459 vbox = gtk_vbox_new(FALSE, PIDGIN_HIG_BOX_SPACE);
2460 gtk_box_pack_start(GTK_BOX(vbox2), vbox, FALSE, FALSE, 0);
2462 #ifndef _WIN32
2463 dd = pidgin_prefs_dropdown(vbox2, _("_Method:"), PURPLE_PREF_STRING,
2464 PIDGIN_PREFS_ROOT "/sound/method",
2465 _("Console beep"), "beep",
2466 #ifdef USE_GSTREAMER
2467 _("Automatic"), "automatic",
2468 "ESD", "esd",
2469 "ALSA", "alsa",
2470 #endif
2471 _("Command"), "custom",
2472 _("No sounds"), "none",
2473 NULL);
2474 gtk_size_group_add_widget(sg, dd);
2475 gtk_misc_set_alignment(GTK_MISC(dd), 0, 0.5);
2477 entry = gtk_entry_new();
2478 gtk_editable_set_editable(GTK_EDITABLE(entry), TRUE);
2479 cmd = purple_prefs_get_path(PIDGIN_PREFS_ROOT "/sound/command");
2480 if(cmd)
2481 gtk_entry_set_text(GTK_ENTRY(entry), cmd);
2482 g_signal_connect(G_OBJECT(entry), "changed",
2483 G_CALLBACK(sound_cmd_yeah), NULL);
2485 hbox = pidgin_add_widget_to_vbox(GTK_BOX(vbox), _("Sound c_ommand:\n(%s for filename)"), sg, entry, TRUE, NULL);
2486 purple_prefs_connect_callback(prefs, PIDGIN_PREFS_ROOT "/sound/method",
2487 sound_changed1_cb, hbox);
2488 gtk_widget_set_sensitive(hbox,
2489 !strcmp(purple_prefs_get_string(PIDGIN_PREFS_ROOT "/sound/method"),
2490 "custom"));
2491 #endif /* _WIN32 */
2493 button = pidgin_prefs_checkbox(_("M_ute sounds"), PIDGIN_PREFS_ROOT "/sound/mute", vbox);
2494 purple_prefs_connect_callback(prefs, PIDGIN_PREFS_ROOT "/sound/mute", mute_changed_cb, button);
2496 pidgin_prefs_checkbox(_("Sounds when conversation has _focus"),
2497 PIDGIN_PREFS_ROOT "/sound/conv_focus", vbox);
2498 pidgin_prefs_dropdown(vbox, _("_Enable sounds:"),
2499 PURPLE_PREF_INT, "/purple/sound/while_status",
2500 _("Only when available"), 1,
2501 _("Only when not available"), 2,
2502 _("Always"), 3,
2503 NULL);
2505 #ifdef USE_GSTREAMER
2506 sw = gtk_hscale_new_with_range(0.0, 100.0, 5.0);
2507 gtk_range_set_increments(GTK_RANGE(sw), 5.0, 25.0);
2508 gtk_range_set_value(GTK_RANGE(sw), purple_prefs_get_int(PIDGIN_PREFS_ROOT "/sound/volume"));
2509 g_signal_connect (G_OBJECT (sw), "format-value",
2510 G_CALLBACK (prefs_sound_volume_format),
2511 NULL);
2512 g_signal_connect (G_OBJECT (sw), "value-changed",
2513 G_CALLBACK (prefs_sound_volume_changed),
2514 NULL);
2515 hbox = pidgin_add_widget_to_vbox(GTK_BOX(vbox), _("V_olume:"), NULL, sw, TRUE, NULL);
2517 purple_prefs_connect_callback(prefs, PIDGIN_PREFS_ROOT "/sound/method",
2518 sound_changed3_cb, hbox);
2519 sound_changed3_cb(PIDGIN_PREFS_ROOT "/sound/method", PURPLE_PREF_STRING,
2520 purple_prefs_get_string(PIDGIN_PREFS_ROOT "/sound/method"), hbox);
2521 #endif
2523 #ifndef _WIN32
2524 gtk_widget_set_sensitive(vbox,
2525 strcmp(purple_prefs_get_string(PIDGIN_PREFS_ROOT "/sound/method"), "none"));
2526 purple_prefs_connect_callback(prefs, PIDGIN_PREFS_ROOT "/sound/method",
2527 sound_changed2_cb, vbox);
2528 #endif
2529 vbox = pidgin_make_frame(ret, _("Sound Events"));
2531 /* The following is an ugly hack to make the frame expand so the
2532 * sound events list is big enough to be usable */
2533 gtk_box_set_child_packing(GTK_BOX(vbox->parent), vbox, TRUE, TRUE, 0,
2534 GTK_PACK_START);
2535 gtk_box_set_child_packing(GTK_BOX(vbox->parent->parent), vbox->parent, TRUE,
2536 TRUE, 0, GTK_PACK_START);
2537 gtk_box_set_child_packing(GTK_BOX(vbox->parent->parent->parent),
2538 vbox->parent->parent, TRUE, TRUE, 0, GTK_PACK_START);
2540 /* SOUND SELECTION */
2541 event_store = gtk_list_store_new (4, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_UINT);
2543 for (j=0; j < PURPLE_NUM_SOUNDS; j++) {
2544 char *pref = g_strdup_printf(PIDGIN_PREFS_ROOT "/sound/enabled/%s",
2545 pidgin_sound_get_event_option(j));
2546 const char *label = pidgin_sound_get_event_label(j);
2548 if (label == NULL) {
2549 g_free(pref);
2550 continue;
2553 gtk_list_store_append (event_store, &iter);
2554 gtk_list_store_set(event_store, &iter,
2555 0, purple_prefs_get_bool(pref),
2556 1, _(label),
2557 2, pref,
2558 3, j,
2559 -1);
2560 g_free(pref);
2563 event_view = gtk_tree_view_new_with_model (GTK_TREE_MODEL(event_store));
2565 rend = gtk_cell_renderer_toggle_new();
2566 sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (event_view));
2567 g_signal_connect (G_OBJECT (sel), "changed",
2568 G_CALLBACK (prefs_sound_sel),
2569 NULL);
2570 g_signal_connect (G_OBJECT(rend), "toggled",
2571 G_CALLBACK(event_toggled), event_store);
2572 path = gtk_tree_path_new_first();
2573 gtk_tree_selection_select_path(sel, path);
2574 gtk_tree_path_free(path);
2576 col = gtk_tree_view_column_new_with_attributes (_("Play"),
2577 rend,
2578 "active", 0,
2579 NULL);
2580 gtk_tree_view_append_column (GTK_TREE_VIEW(event_view), col);
2582 rend = gtk_cell_renderer_text_new();
2583 col = gtk_tree_view_column_new_with_attributes (_("Event"),
2584 rend,
2585 "text", 1,
2586 NULL);
2587 gtk_tree_view_append_column (GTK_TREE_VIEW(event_view), col);
2588 g_object_unref(G_OBJECT(event_store));
2589 gtk_box_pack_start(GTK_BOX(vbox),
2590 pidgin_make_scrollable(event_view, GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC, GTK_SHADOW_IN, -1, 100),
2591 TRUE, TRUE, 0);
2593 hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE);
2594 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
2595 sound_entry = gtk_entry_new();
2596 pref = g_strdup_printf(PIDGIN_PREFS_ROOT "/sound/file/%s",
2597 pidgin_sound_get_event_option(0));
2598 file = purple_prefs_get_path(pref);
2599 g_free(pref);
2600 gtk_entry_set_text(GTK_ENTRY(sound_entry), (file && *file != '\0') ? file : _("(default)"));
2601 gtk_editable_set_editable(GTK_EDITABLE(sound_entry), FALSE);
2602 gtk_box_pack_start(GTK_BOX(hbox), sound_entry, FALSE, FALSE, PIDGIN_HIG_BOX_SPACE);
2604 button = gtk_button_new_with_mnemonic(_("_Browse..."));
2605 g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(select_sound), NULL);
2606 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 1);
2608 button = gtk_button_new_with_mnemonic(_("Pre_view"));
2609 g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(test_sound), NULL);
2610 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 1);
2612 button = gtk_button_new_with_mnemonic(_("_Reset"));
2613 g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(reset_sound), NULL);
2614 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 1);
2616 gtk_widget_show_all(ret);
2617 g_object_unref(sg);
2619 return ret;
2623 static void
2624 set_idle_away(PurpleSavedStatus *status)
2626 purple_prefs_set_int("/purple/savedstatus/idleaway", purple_savedstatus_get_creation_time(status));
2629 static void
2630 set_startupstatus(PurpleSavedStatus *status)
2632 purple_prefs_set_int("/purple/savedstatus/startup", purple_savedstatus_get_creation_time(status));
2635 static GtkWidget *
2636 away_page(void)
2638 GtkWidget *ret;
2639 GtkWidget *vbox;
2640 GtkWidget *hbox;
2641 GtkWidget *dd;
2642 GtkWidget *label;
2643 GtkWidget *button;
2644 GtkWidget *select;
2645 GtkWidget *menu;
2646 GtkSizeGroup *sg;
2648 ret = gtk_vbox_new(FALSE, PIDGIN_HIG_CAT_SPACE);
2649 gtk_container_set_border_width (GTK_CONTAINER (ret), PIDGIN_HIG_BORDER);
2651 sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
2653 /* Idle stuff */
2654 vbox = pidgin_make_frame(ret, _("Idle"));
2656 dd = pidgin_prefs_dropdown(vbox, _("_Report idle time:"),
2657 PURPLE_PREF_STRING, "/purple/away/idle_reporting",
2658 _("Never"), "none",
2659 _("From last sent message"), "purple",
2660 #if defined(USE_SCREENSAVER) || defined(HAVE_IOKIT)
2661 _("Based on keyboard or mouse use"), "system",
2662 #endif
2663 NULL);
2664 gtk_size_group_add_widget(sg, dd);
2665 gtk_misc_set_alignment(GTK_MISC(dd), 0, 0.5);
2667 select = pidgin_prefs_labeled_spin_button(vbox,
2668 _("_Minutes before becoming idle:"), "/purple/away/mins_before_away",
2669 1, 24 * 60, sg);
2671 hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE);
2672 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
2674 button = pidgin_prefs_checkbox(_("Change to this status when _idle:"),
2675 "/purple/away/away_when_idle", hbox);
2676 gtk_size_group_add_widget(sg, button);
2678 /* TODO: Show something useful if we don't have any saved statuses. */
2679 menu = pidgin_status_menu(purple_savedstatus_get_idleaway(), G_CALLBACK(set_idle_away));
2680 gtk_size_group_add_widget(sg, menu);
2681 gtk_box_pack_start(GTK_BOX(hbox), menu, FALSE, FALSE, 0);
2683 g_signal_connect(G_OBJECT(button), "clicked",
2684 G_CALLBACK(pidgin_toggle_sensitive), menu);
2686 if(!purple_prefs_get_bool("/purple/away/away_when_idle"))
2687 gtk_widget_set_sensitive(GTK_WIDGET(menu), FALSE);
2689 /* Away stuff */
2690 vbox = pidgin_make_frame(ret, _("Away"));
2692 dd = pidgin_prefs_dropdown(vbox, _("_Auto-reply:"),
2693 PURPLE_PREF_STRING, "/purple/away/auto_reply",
2694 _("Never"), "never",
2695 _("When away"), "away",
2696 _("When both away and idle"), "awayidle",
2697 NULL);
2698 gtk_size_group_add_widget(sg, dd);
2699 gtk_misc_set_alignment(GTK_MISC(dd), 0, 0.5);
2701 /* Signon status stuff */
2702 vbox = pidgin_make_frame(ret, _("Status at Startup"));
2704 button = pidgin_prefs_checkbox(_("Use status from last _exit at startup"),
2705 "/purple/savedstatus/startup_current_status", vbox);
2706 gtk_size_group_add_widget(sg, button);
2708 /* TODO: Show something useful if we don't have any saved statuses. */
2709 menu = pidgin_status_menu(purple_savedstatus_get_startup(), G_CALLBACK(set_startupstatus));
2710 gtk_size_group_add_widget(sg, menu);
2711 g_signal_connect(G_OBJECT(button), "clicked",
2712 G_CALLBACK(pidgin_toggle_sensitive), menu);
2713 pidgin_add_widget_to_vbox(GTK_BOX(vbox), _("Status to a_pply at startup:"), sg, menu, TRUE, &label);
2714 g_signal_connect(G_OBJECT(button), "clicked",
2715 G_CALLBACK(pidgin_toggle_sensitive), label);
2717 if(purple_prefs_get_bool("/purple/savedstatus/startup_current_status")) {
2718 gtk_widget_set_sensitive(GTK_WIDGET(menu), FALSE);
2719 gtk_widget_set_sensitive(GTK_WIDGET(label), FALSE);
2722 gtk_widget_show_all(ret);
2723 g_object_unref(sg);
2725 return ret;
2728 static int
2729 prefs_notebook_add_page(const char *text, GtkWidget *page, int ind)
2731 return gtk_notebook_append_page(GTK_NOTEBOOK(prefsnotebook), page, gtk_label_new(text));
2734 static void
2735 prefs_notebook_init(void)
2737 prefs_notebook_add_page(_("Interface"), interface_page(), notebook_page++);
2739 #ifndef _WIN32
2740 /* We use the registered default browser in windows */
2741 /* if the user is running Mac OS X, hide the browsers tab */
2742 if(purple_running_osx() == FALSE)
2743 prefs_notebook_add_page(_("Browser"), browser_page(), notebook_page++);
2744 #endif
2746 prefs_notebook_add_page(_("Conversations"), conv_page(), notebook_page++);
2747 prefs_notebook_add_page(_("Logging"), logging_page(), notebook_page++);
2748 prefs_notebook_add_page(_("Network"), network_page(), notebook_page++);
2749 prefs_notebook_add_page(_("Proxy"), proxy_page(), notebook_page++);
2751 prefs_notebook_add_page(_("Sounds"), sound_page(), notebook_page++);
2752 prefs_notebook_add_page(_("Status / Idle"), away_page(), notebook_page++);
2753 prefs_notebook_add_page(_("Themes"), theme_page(), notebook_page++);
2756 void
2757 pidgin_prefs_show(void)
2759 GtkWidget *vbox;
2760 GtkWidget *notebook;
2761 GtkWidget *button;
2763 if (prefs) {
2764 gtk_window_present(GTK_WINDOW(prefs));
2765 return;
2768 /* copy the preferences to tmp values...
2769 * I liked "take affect immediately" Oh well :-( */
2770 /* (that should have been "effect," right?) */
2772 /* Back to instant-apply! I win! BU-HAHAHA! */
2774 /* Create the window */
2775 prefs = pidgin_create_dialog(_("Preferences"), PIDGIN_HIG_BORDER, "preferences", FALSE);
2776 g_signal_connect(G_OBJECT(prefs), "destroy",
2777 G_CALLBACK(delete_prefs), NULL);
2779 vbox = pidgin_dialog_get_vbox_with_properties(GTK_DIALOG(prefs), FALSE, PIDGIN_HIG_BORDER);
2781 /* The notebook */
2782 prefsnotebook = notebook = gtk_notebook_new ();
2783 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(notebook), GTK_POS_LEFT);
2784 gtk_box_pack_start(GTK_BOX (vbox), notebook, FALSE, FALSE, 0);
2785 gtk_widget_show(prefsnotebook);
2787 button = pidgin_dialog_add_button(GTK_DIALOG(prefs), GTK_STOCK_CLOSE, NULL, NULL);
2788 g_signal_connect_swapped(G_OBJECT(button), "clicked",
2789 G_CALLBACK(gtk_widget_destroy), prefs);
2791 prefs_notebook_init();
2793 /* Refresh the list of themes before showing the preferences window */
2794 prefs_themes_refresh();
2796 /* Show everything. */
2797 gtk_widget_show(prefs);
2800 static void
2801 set_bool_pref(GtkWidget *w, const char *key)
2803 purple_prefs_set_bool(key,
2804 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w)));
2807 GtkWidget *
2808 pidgin_prefs_checkbox(const char *text, const char *key, GtkWidget *page)
2810 GtkWidget *button;
2812 button = gtk_check_button_new_with_mnemonic(text);
2813 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button),
2814 purple_prefs_get_bool(key));
2816 gtk_box_pack_start(GTK_BOX(page), button, FALSE, FALSE, 0);
2818 g_signal_connect(G_OBJECT(button), "clicked",
2819 G_CALLBACK(set_bool_pref), (char *)key);
2821 gtk_widget_show(button);
2823 return button;
2826 static void
2827 smiley_theme_pref_cb(const char *name, PurplePrefType type,
2828 gconstpointer value, gpointer data)
2830 const char *themename = value;
2831 GSList *themes;
2833 for (themes = smiley_themes; themes; themes = themes->next) {
2834 struct smiley_theme *smile = themes->data;
2835 if (smile->name && strcmp(themename, smile->name) == 0) {
2836 pidgin_themes_load_smiley_theme(smile->path, TRUE);
2837 break;
2842 void
2843 pidgin_prefs_init(void)
2845 purple_prefs_add_none(PIDGIN_PREFS_ROOT "");
2846 purple_prefs_add_none("/plugins/gtk");
2848 #ifndef _WIN32
2849 /* Browsers */
2850 purple_prefs_add_none(PIDGIN_PREFS_ROOT "/browsers");
2851 purple_prefs_add_int(PIDGIN_PREFS_ROOT "/browsers/place", PIDGIN_BROWSER_DEFAULT);
2852 purple_prefs_add_string(PIDGIN_PREFS_ROOT "/browsers/manual_command", "");
2853 purple_prefs_add_string(PIDGIN_PREFS_ROOT "/browsers/browser", "xdg-open");
2854 #endif
2856 /* Plugins */
2857 purple_prefs_add_none(PIDGIN_PREFS_ROOT "/plugins");
2858 purple_prefs_add_path_list(PIDGIN_PREFS_ROOT "/plugins/loaded", NULL);
2860 /* File locations */
2861 purple_prefs_add_none(PIDGIN_PREFS_ROOT "/filelocations");
2862 purple_prefs_add_path(PIDGIN_PREFS_ROOT "/filelocations/last_save_folder", "");
2863 purple_prefs_add_path(PIDGIN_PREFS_ROOT "/filelocations/last_open_folder", "");
2864 purple_prefs_add_path(PIDGIN_PREFS_ROOT "/filelocations/last_icon_folder", "");
2866 /* Themes */
2867 prefs_themes_init();
2869 /* Smiley Themes */
2870 purple_prefs_add_none(PIDGIN_PREFS_ROOT "/smileys");
2871 purple_prefs_add_string(PIDGIN_PREFS_ROOT "/smileys/theme", "Default");
2873 /* Smiley Callbacks */
2874 purple_prefs_connect_callback(&prefs, PIDGIN_PREFS_ROOT "/smileys/theme",
2875 smiley_theme_pref_cb, NULL);
2877 pidgin_prefs_update_old();
2880 void
2881 pidgin_prefs_update_old(void)
2883 const char *str = NULL;
2885 purple_prefs_rename("/gaim/gtk", PIDGIN_PREFS_ROOT);
2887 /* Rename some old prefs */
2888 purple_prefs_rename(PIDGIN_PREFS_ROOT "/logging/log_ims", "/purple/logging/log_ims");
2889 purple_prefs_rename(PIDGIN_PREFS_ROOT "/logging/log_chats", "/purple/logging/log_chats");
2890 purple_prefs_rename("/purple/conversations/placement",
2891 PIDGIN_PREFS_ROOT "/conversations/placement");
2893 purple_prefs_rename(PIDGIN_PREFS_ROOT "/debug/timestamps", "/purple/debug/timestamps");
2894 purple_prefs_rename(PIDGIN_PREFS_ROOT "/conversations/im/raise_on_events", "/plugins/gtk/X11/notify/method_raise");
2896 purple_prefs_rename_boolean_toggle(PIDGIN_PREFS_ROOT "/conversations/ignore_colors",
2897 PIDGIN_PREFS_ROOT "/conversations/show_incoming_formatting");
2900 * this path pref changed to a string, so migrate. I know this will break
2901 * things for and confuse users that use multiple versions with the same
2902 * config directory, but I'm not inclined to want to deal with that at the
2903 * moment. -- rekkanoryo
2905 if((str = purple_prefs_get_path(PIDGIN_PREFS_ROOT "/browsers/command")) != NULL) {
2906 purple_prefs_set_string(PIDGIN_PREFS_ROOT "/browsers/manual_command", str);
2907 purple_prefs_remove(PIDGIN_PREFS_ROOT "/browsers/command");
2910 /* this string pref moved into the core, try to be friendly */
2911 purple_prefs_rename(PIDGIN_PREFS_ROOT "/idle/reporting_method", "/purple/away/idle_reporting");
2912 if ((str = purple_prefs_get_string("/purple/away/idle_reporting")) &&
2913 strcmp(str, "gaim") == 0)
2914 purple_prefs_set_string("/purple/away/idle_reporting", "purple");
2916 /* Remove some no-longer-used prefs */
2917 purple_prefs_remove(PIDGIN_PREFS_ROOT "/blist/auto_expand_contacts");
2918 purple_prefs_remove(PIDGIN_PREFS_ROOT "/blist/button_style");
2919 purple_prefs_remove(PIDGIN_PREFS_ROOT "/blist/grey_idle_buddies");
2920 purple_prefs_remove(PIDGIN_PREFS_ROOT "/blist/raise_on_events");
2921 purple_prefs_remove(PIDGIN_PREFS_ROOT "/blist/show_group_count");
2922 purple_prefs_remove(PIDGIN_PREFS_ROOT "/blist/show_warning_level");
2923 purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/button_type");
2924 purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/ctrl_enter_sends");
2925 purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/enter_sends");
2926 purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/escape_closes");
2927 purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/html_shortcuts");
2928 purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/icons_on_tabs");
2929 purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/send_formatting");
2930 purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/show_smileys");
2931 purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/show_urls_as_links");
2932 purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/smiley_shortcuts");
2933 purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/use_custom_bgcolor");
2934 purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/use_custom_fgcolor");
2935 purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/use_custom_font");
2936 purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/use_custom_size");
2937 purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/chat/old_tab_complete");
2938 purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/chat/tab_completion");
2939 purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/im/hide_on_send");
2940 purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/chat/color_nicks");
2941 purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/chat/raise_on_events");
2942 purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/ignore_fonts");
2943 purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/ignore_font_sizes");
2944 purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/passthrough_unknown_commands");
2945 purple_prefs_remove(PIDGIN_PREFS_ROOT "/idle");
2946 purple_prefs_remove(PIDGIN_PREFS_ROOT "/logging/individual_logs");
2947 purple_prefs_remove(PIDGIN_PREFS_ROOT "/sound/signon");
2948 purple_prefs_remove(PIDGIN_PREFS_ROOT "/sound/silent_signon");
2950 /* Convert old queuing prefs to hide_new 3-way pref. */
2951 if (purple_prefs_exists("/plugins/gtk/docklet/queue_messages") &&
2952 purple_prefs_get_bool("/plugins/gtk/docklet/queue_messages"))
2954 purple_prefs_set_string(PIDGIN_PREFS_ROOT "/conversations/im/hide_new", "always");
2956 else if (purple_prefs_exists(PIDGIN_PREFS_ROOT "/away/queue_messages") &&
2957 purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/away/queue_messages"))
2959 purple_prefs_set_string(PIDGIN_PREFS_ROOT "/conversations/im/hide_new", "away");
2961 purple_prefs_remove(PIDGIN_PREFS_ROOT "/away/queue_messages");
2962 purple_prefs_remove(PIDGIN_PREFS_ROOT "/away");
2963 purple_prefs_remove("/plugins/gtk/docklet/queue_messages");
2965 purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/chat/default_width");
2966 purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/chat/default_height");
2967 purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/im/default_width");
2968 purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/im/default_height");
2969 purple_prefs_rename(PIDGIN_PREFS_ROOT "/conversations/x",
2970 PIDGIN_PREFS_ROOT "/conversations/im/x");
2971 purple_prefs_rename(PIDGIN_PREFS_ROOT "/conversations/y",
2972 PIDGIN_PREFS_ROOT "/conversations/im/y");