Replace strcmp() with purple_strequal()
[pidgin-git.git] / pidgin / gtkprefs.c
blobd5368e70f796b86e945bd6eb15df6e444577ea38
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 purple_strequal(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 && purple_strequal(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 (purple_strequal(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 = purple_strequal(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 if (g_remove(destdir) != 0) {
733 purple_debug_error("gtkprefs",
734 "couldn't remove temp (dest) path\n");
736 g_object_unref(theme);
738 prefs_themes_refresh();
740 } else {
741 /* something was wrong with the theme archive */
742 g_unlink(destdir);
743 purple_notify_error(NULL, NULL, _("Theme failed to load."), NULL);
746 } else { /* just a single file so copy it to a new temp directory and attempt to load it*/
747 gchar *temp_path, *temp_file;
749 temp_path = g_build_filename(purple_user_dir(), "themes", "temp", "sub_folder", NULL);
751 if (info->original_name != NULL) {
752 /* name was changed from the original (probably a dnd) change it back before loading */
753 temp_file = g_build_filename(temp_path, info->original_name, NULL);
755 } else {
756 gchar *source_name = g_path_get_basename(path);
757 temp_file = g_build_filename(temp_path, source_name, NULL);
758 g_free(source_name);
761 if (!g_file_test(temp_path, G_FILE_TEST_IS_DIR))
762 purple_build_dir(temp_path, S_IRUSR | S_IWUSR | S_IXUSR);
764 if (purple_theme_file_copy(path, temp_file)) {
765 /* find the theme, could be in subfolder */
766 theme = prefs_theme_find_theme(temp_path, info->type);
768 if (PURPLE_IS_THEME(theme)) {
769 gchar *theme_dest = g_build_filename(purple_user_dir(), "themes",
770 purple_theme_get_name(theme),
771 "purple", info->type, NULL);
773 if(!g_file_test(theme_dest, G_FILE_TEST_IS_DIR))
774 purple_build_dir(theme_dest, S_IRUSR | S_IWUSR | S_IXUSR);
776 g_rename(purple_theme_get_dir(theme), theme_dest);
778 g_free(theme_dest);
779 g_object_unref(theme);
781 prefs_themes_refresh();
782 } else {
783 if (g_remove(temp_path) != 0) {
784 purple_debug_error("gtkprefs",
785 "couldn't remove temp path\n");
787 purple_notify_error(NULL, NULL, _("Theme failed to load."), NULL);
789 } else {
790 purple_notify_error(NULL, NULL, _("Theme failed to copy."), NULL);
793 g_free(temp_file);
794 g_free(temp_path);
797 g_free(destdir);
798 free_theme_info(info);
801 static void
802 theme_got_url(PurpleUtilFetchUrlData *url_data, gpointer user_data,
803 const gchar *themedata, size_t len, const gchar *error_message)
805 FILE *f;
806 gchar *path;
807 size_t wc;
809 if ((error_message != NULL) || (len == 0)) {
810 free_theme_info(user_data);
811 return;
814 f = purple_mkstemp(&path, TRUE);
815 wc = fwrite(themedata, len, 1, f);
816 if (wc != 1) {
817 purple_debug_warning("theme_got_url", "Unable to write theme data.\n");
818 fclose(f);
819 g_unlink(path);
820 g_free(path);
821 free_theme_info(user_data);
822 return;
824 fclose(f);
826 theme_install_theme(path, user_data);
828 g_unlink(path);
829 g_free(path);
832 static void
833 theme_dnd_recv(GtkWidget *widget, GdkDragContext *dc, guint x, guint y,
834 GtkSelectionData *sd, guint info, guint t, gpointer user_data)
836 gchar *name = g_strchomp((gchar *)sd->data);
838 if ((sd->length >= 0) && (sd->format == 8)) {
839 /* Well, it looks like the drag event was cool.
840 * Let's do something with it */
841 gchar *temp;
842 struct theme_info *info = g_new0(struct theme_info, 1);
843 info->type = g_strdup((gchar *)user_data);
844 info->extension = g_strdup(g_strrstr(name,"."));
845 temp = g_strrstr(name, "/");
846 info->original_name = temp ? g_strdup(++temp) : NULL;
848 if (!g_ascii_strncasecmp(name, "file://", 7)) {
849 GError *converr = NULL;
850 gchar *tmp;
851 /* It looks like we're dealing with a local file. Let's
852 * just untar it in the right place */
853 if(!(tmp = g_filename_from_uri(name, NULL, &converr))) {
854 purple_debug(PURPLE_DEBUG_ERROR, "theme dnd", "%s\n",
855 (converr ? converr->message :
856 "g_filename_from_uri error"));
857 free_theme_info(info);
858 return;
860 theme_install_theme(tmp, info);
861 g_free(tmp);
862 } else if (!g_ascii_strncasecmp(name, "http://", 7)) {
863 /* Oo, a web drag and drop. This is where things
864 * will start to get interesting */
865 purple_util_fetch_url(name, TRUE, NULL, FALSE, theme_got_url, info);
866 } else if (!g_ascii_strncasecmp(name, "https://", 8)) {
867 /* purple_util_fetch_url() doesn't support HTTPS, but we want users
868 * to be able to drag and drop links from the SF trackers, so
869 * we'll try it as an HTTP URL. */
870 char *tmp = g_strdup(name + 1);
871 tmp[0] = 'h';
872 tmp[1] = 't';
873 tmp[2] = 't';
874 tmp[3] = 'p';
876 purple_util_fetch_url(tmp, TRUE, NULL, FALSE, theme_got_url, info);
877 g_free(tmp);
878 } else
879 free_theme_info(info);
881 gtk_drag_finish(dc, TRUE, FALSE, t);
884 gtk_drag_finish(dc, FALSE, FALSE, t);
887 /* builds a theme combo box from a list store with colums: icon preview, markup, theme name */
888 static GtkWidget *
889 prefs_build_theme_combo_box(GtkListStore *store, const char *current_theme, const char *type)
891 GtkCellRenderer *cell_rend;
892 GtkWidget *combo_box;
893 GtkTargetEntry te[3] = {
894 {"text/plain", 0, 0},
895 {"text/uri-list", 0, 1},
896 {"STRING", 0, 2}
899 g_return_val_if_fail(store != NULL && current_theme != NULL, NULL);
901 combo_box = gtk_combo_box_new_with_model(GTK_TREE_MODEL(store));
903 cell_rend = gtk_cell_renderer_pixbuf_new();
904 gtk_cell_renderer_set_fixed_size(cell_rend, PREFS_OPTIMAL_ICON_SIZE, PREFS_OPTIMAL_ICON_SIZE);
905 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT (combo_box), cell_rend, FALSE);
906 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo_box), cell_rend, "pixbuf", 0, NULL);
908 cell_rend = gtk_cell_renderer_text_new();
909 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT (combo_box), cell_rend, TRUE);
910 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo_box), cell_rend, "markup", 1, NULL);
911 g_object_set(cell_rend, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
913 gtk_drag_dest_set(combo_box, GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_HIGHLIGHT | GTK_DEST_DEFAULT_DROP, te,
914 sizeof(te) / sizeof(GtkTargetEntry) , GDK_ACTION_COPY | GDK_ACTION_MOVE);
916 g_signal_connect(G_OBJECT(combo_box), "drag_data_received", G_CALLBACK(theme_dnd_recv), (gpointer) type);
918 return combo_box;
921 /* sets the current sound theme */
922 static void
923 prefs_set_sound_theme_cb(GtkComboBox *combo_box, gpointer user_data)
925 gint i;
926 gchar *pref;
927 gchar *new_theme;
928 GtkTreeIter new_iter;
930 if(gtk_combo_box_get_active_iter(combo_box, &new_iter) && !prefs_sound_themes_loading) {
932 gtk_tree_model_get(GTK_TREE_MODEL(prefs_sound_themes), &new_iter, 2, &new_theme, -1);
934 purple_prefs_set_string(PIDGIN_PREFS_ROOT "/sound/theme", new_theme);
936 /* New theme removes all customization */
937 for(i = 0; i < PURPLE_NUM_SOUNDS; i++){
938 pref = g_strdup_printf(PIDGIN_PREFS_ROOT "/sound/file/%s",
939 pidgin_sound_get_event_option(i));
940 purple_prefs_set_path(pref, "");
941 g_free(pref);
944 /* gets rid of the "(Custom)" from the last selection */
945 pref_sound_generate_markup();
947 gtk_entry_set_text(GTK_ENTRY(sound_entry), _("(default)"));
949 g_free(new_theme);
953 /* sets the current smiley theme */
954 static void
955 prefs_set_smiley_theme_cb(GtkComboBox *combo_box, gpointer user_data)
957 gchar *new_theme;
958 GtkTreeIter new_iter;
960 if (gtk_combo_box_get_active_iter(combo_box, &new_iter)) {
962 gtk_tree_model_get(GTK_TREE_MODEL(prefs_smiley_themes), &new_iter, 2, &new_theme, -1);
964 purple_prefs_set_string(PIDGIN_PREFS_ROOT "/smileys/theme", new_theme);
965 pidgin_themes_smiley_themeize(sample_imhtml);
967 g_free(new_theme);
972 /* Does same as normal sort, except "none" is sorted first */
973 static gint pidgin_sort_smileys (GtkTreeModel *model,
974 GtkTreeIter *a,
975 GtkTreeIter *b,
976 gpointer userdata)
978 gint ret = 0;
979 gchar *name1 = NULL, *name2 = NULL;
981 gtk_tree_model_get(model, a, 2, &name1, -1);
982 gtk_tree_model_get(model, b, 2, &name2, -1);
984 if (name1 == NULL || name2 == NULL) {
985 if (!(name1 == NULL && name2 == NULL))
986 ret = (name1 == NULL) ? -1: 1;
987 } else if (!g_ascii_strcasecmp(name1, "none")) {
988 if (!g_utf8_collate(name1, name2))
989 ret = 0;
990 else
991 /* Sort name1 first */
992 ret = -1;
993 } else if (!g_ascii_strcasecmp(name2, "none")) {
994 /* Sort name2 first */
995 ret = 1;
996 } else {
997 /* Neither string is "none", default to normal sort */
998 ret = purple_utf8_strcasecmp(name1, name2);
1001 g_free(name1);
1002 g_free(name2);
1004 return ret;
1007 /* sets the current buddy list theme */
1008 static void
1009 prefs_set_blist_theme_cb(GtkComboBox *combo_box, gpointer user_data)
1011 PidginBlistTheme *theme = NULL;
1012 GtkTreeIter iter;
1013 gchar *name = NULL;
1015 if(gtk_combo_box_get_active_iter(combo_box, &iter)) {
1017 gtk_tree_model_get(GTK_TREE_MODEL(prefs_blist_themes), &iter, 2, &name, -1);
1019 if(!name || !purple_strequal(name, ""))
1020 theme = PIDGIN_BLIST_THEME(purple_theme_manager_find_theme(name, "blist"));
1022 g_free(name);
1024 pidgin_blist_set_theme(theme);
1028 /* sets the current icon theme */
1029 static void
1030 prefs_set_status_icon_theme_cb(GtkComboBox *combo_box, gpointer user_data)
1032 PidginStatusIconTheme *theme = NULL;
1033 GtkTreeIter iter;
1034 gchar *name = NULL;
1036 if(gtk_combo_box_get_active_iter(combo_box, &iter)) {
1038 gtk_tree_model_get(GTK_TREE_MODEL(prefs_status_icon_themes), &iter, 2, &name, -1);
1040 if(!name || !purple_strequal(name, ""))
1041 theme = PIDGIN_STATUS_ICON_THEME(purple_theme_manager_find_theme(name, "status-icon"));
1043 g_free(name);
1045 pidgin_stock_load_status_icon_theme(theme);
1046 pidgin_blist_refresh(purple_get_blist());
1050 static GtkWidget *
1051 add_theme_prefs_combo(GtkWidget *vbox,
1052 GtkSizeGroup *combo_sg, GtkSizeGroup *label_sg,
1053 GtkListStore *theme_store,
1054 GCallback combo_box_cb, gpointer combo_box_cb_user_data,
1055 const char *label_str, const char *prefs_path,
1056 const char *theme_type)
1058 GtkWidget *label;
1059 GtkWidget *combo_box = NULL;
1060 GtkWidget *themesel_hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE);
1062 label = gtk_label_new(label_str);
1063 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
1064 gtk_size_group_add_widget(label_sg, label);
1065 gtk_box_pack_start(GTK_BOX(themesel_hbox), label, FALSE, FALSE, 0);
1067 combo_box = prefs_build_theme_combo_box(theme_store,
1068 purple_prefs_get_string(prefs_path),
1069 theme_type);
1070 g_signal_connect(G_OBJECT(combo_box), "changed",
1071 (GCallback)combo_box_cb, combo_box_cb_user_data);
1072 gtk_size_group_add_widget(combo_sg, combo_box);
1073 gtk_box_pack_start(GTK_BOX(themesel_hbox), combo_box, TRUE, TRUE, 0);
1075 gtk_box_pack_start(GTK_BOX(vbox), themesel_hbox, FALSE, FALSE, 0);
1077 return combo_box;
1080 static GtkWidget *
1081 theme_page(void)
1083 GtkWidget *label;
1084 GtkWidget *ret, *vbox;
1085 GtkSizeGroup *label_sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
1086 GtkSizeGroup *combo_sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
1088 ret = gtk_vbox_new(FALSE, PIDGIN_HIG_CAT_SPACE);
1089 gtk_container_set_border_width (GTK_CONTAINER (ret), PIDGIN_HIG_BORDER);
1091 vbox = pidgin_make_frame(ret, _("Theme Selections"));
1093 /* Instructions */
1094 label = gtk_label_new(_("Select a theme that you would like to use from "
1095 "the lists below.\nNew themes can be installed by "
1096 "dragging and dropping them onto the theme list."));
1098 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
1099 gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
1101 gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, FALSE, 0);
1102 gtk_widget_show(label);
1104 /* Buddy List Themes */
1105 prefs_blist_themes_combo_box = add_theme_prefs_combo(
1106 vbox, combo_sg, label_sg, prefs_blist_themes,
1107 (GCallback)prefs_set_blist_theme_cb, NULL,
1108 _("Buddy List Theme:"), PIDGIN_PREFS_ROOT "/blist/theme", "blist");
1110 /* Status Icon Themes */
1111 prefs_status_themes_combo_box = add_theme_prefs_combo(
1112 vbox, combo_sg, label_sg, prefs_status_icon_themes,
1113 (GCallback)prefs_set_status_icon_theme_cb, NULL,
1114 _("Status Icon Theme:"), PIDGIN_PREFS_ROOT "/status/icon-theme", "icon");
1116 /* Sound Themes */
1117 prefs_sound_themes_combo_box = add_theme_prefs_combo(
1118 vbox, combo_sg, label_sg, prefs_sound_themes,
1119 (GCallback)prefs_set_sound_theme_cb, NULL,
1120 _("Sound Theme:"), PIDGIN_PREFS_ROOT "/sound/theme", "sound");
1122 /* Smiley Themes */
1123 prefs_smiley_themes_combo_box = add_theme_prefs_combo(
1124 vbox, combo_sg, label_sg, prefs_smiley_themes,
1125 (GCallback)prefs_set_smiley_theme_cb, NULL,
1126 _("Smiley Theme:"), PIDGIN_PREFS_ROOT "/smileys/theme", "smiley");
1128 /* Custom sort so "none" theme is at top of list */
1129 gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(prefs_smiley_themes),
1130 2, pidgin_sort_smileys, NULL, NULL);
1131 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(prefs_smiley_themes),
1132 2, GTK_SORT_ASCENDING);
1134 gtk_widget_show_all(ret);
1136 return ret;
1139 static void
1140 formatting_toggle_cb(GtkIMHtml *imhtml, GtkIMHtmlButtons buttons, void *toolbar)
1142 gboolean bold, italic, uline;
1144 gtk_imhtml_get_current_format(GTK_IMHTML(imhtml),
1145 &bold, &italic, &uline);
1147 if (buttons & GTK_IMHTML_BOLD)
1148 purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/conversations/send_bold", bold);
1149 if (buttons & GTK_IMHTML_ITALIC)
1150 purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/conversations/send_italic", italic);
1151 if (buttons & GTK_IMHTML_UNDERLINE)
1152 purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/conversations/send_underline", uline);
1154 if (buttons & GTK_IMHTML_GROW || buttons & GTK_IMHTML_SHRINK)
1155 purple_prefs_set_int(PIDGIN_PREFS_ROOT "/conversations/font_size",
1156 gtk_imhtml_get_current_fontsize(GTK_IMHTML(imhtml)));
1157 if (buttons & GTK_IMHTML_FACE) {
1158 char *face = gtk_imhtml_get_current_fontface(GTK_IMHTML(imhtml));
1159 if (!face)
1160 face = g_strdup("");
1162 purple_prefs_set_string(PIDGIN_PREFS_ROOT "/conversations/font_face", face);
1163 g_free(face);
1166 if (buttons & GTK_IMHTML_FORECOLOR) {
1167 char *color = gtk_imhtml_get_current_forecolor(GTK_IMHTML(imhtml));
1168 if (!color)
1169 color = g_strdup("");
1171 purple_prefs_set_string(PIDGIN_PREFS_ROOT "/conversations/fgcolor", color);
1172 g_free(color);
1175 if (buttons & GTK_IMHTML_BACKCOLOR) {
1176 char *color;
1177 GObject *object;
1179 color = gtk_imhtml_get_current_backcolor(GTK_IMHTML(imhtml));
1180 if (!color)
1181 color = g_strdup("");
1183 /* Block the signal to prevent a loop. */
1184 object = g_object_ref(G_OBJECT(imhtml));
1185 g_signal_handlers_block_matched(object, G_SIGNAL_MATCH_DATA, 0, 0, NULL,
1186 NULL, toolbar);
1187 /* Clear the backcolor. */
1188 gtk_imhtml_toggle_backcolor(GTK_IMHTML(imhtml), "");
1189 /* Unblock the signal. */
1190 g_signal_handlers_unblock_matched(object, G_SIGNAL_MATCH_DATA, 0, 0, NULL,
1191 NULL, toolbar);
1192 g_object_unref(object);
1194 /* This will fire a toggle signal and get saved below. */
1195 gtk_imhtml_toggle_background(GTK_IMHTML(imhtml), color);
1197 g_free(color);
1200 if (buttons & GTK_IMHTML_BACKGROUND) {
1201 char *color = gtk_imhtml_get_current_background(GTK_IMHTML(imhtml));
1202 if (!color)
1203 color = g_strdup("");
1205 purple_prefs_set_string(PIDGIN_PREFS_ROOT "/conversations/bgcolor", color);
1206 g_free(color);
1210 static void
1211 formatting_clear_cb(GtkIMHtml *imhtml, void *data)
1213 purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/conversations/send_bold", FALSE);
1214 purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/conversations/send_italic", FALSE);
1215 purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/conversations/send_underline", FALSE);
1217 purple_prefs_set_int(PIDGIN_PREFS_ROOT "/conversations/font_size", 3);
1219 purple_prefs_set_string(PIDGIN_PREFS_ROOT "/conversations/font_face", "");
1220 purple_prefs_set_string(PIDGIN_PREFS_ROOT "/conversations/fgcolor", "");
1221 purple_prefs_set_string(PIDGIN_PREFS_ROOT "/conversations/bgcolor", "");
1224 static void
1225 conversation_usetabs_cb(const char *name, PurplePrefType type,
1226 gconstpointer value, gpointer data)
1228 gboolean usetabs = GPOINTER_TO_INT(value);
1230 if (usetabs)
1231 gtk_widget_set_sensitive(GTK_WIDGET(data), TRUE);
1232 else
1233 gtk_widget_set_sensitive(GTK_WIDGET(data), FALSE);
1237 #define CONVERSATION_CLOSE_ACCEL_PATH "<main>/Conversation/Close"
1239 /* Filled in in keyboard_shortcuts(). */
1240 static GtkAccelKey ctrl_w = { 0, 0, 0 };
1241 static GtkAccelKey escape = { 0, 0, 0 };
1243 static guint escape_closes_conversation_cb_id = 0;
1245 static gboolean
1246 accel_is_escape(GtkAccelKey *k)
1248 return (k->accel_key == escape.accel_key
1249 && k->accel_mods == escape.accel_mods);
1252 /* Update the tickybox in Preferences when the keybinding for Conversation ->
1253 * Close is changed via Gtk.
1255 static void
1256 conversation_close_accel_changed_cb (GtkAccelMap *object,
1257 gchar *accel_path,
1258 guint accel_key,
1259 GdkModifierType accel_mods,
1260 gpointer checkbox_)
1262 GtkToggleButton *checkbox = GTK_TOGGLE_BUTTON(checkbox_);
1263 GtkAccelKey new = { accel_key, accel_mods, 0 };
1265 g_signal_handler_block(checkbox, escape_closes_conversation_cb_id);
1266 gtk_toggle_button_set_active(checkbox, accel_is_escape(&new));
1267 g_signal_handler_unblock(checkbox, escape_closes_conversation_cb_id);
1271 static void
1272 escape_closes_conversation_cb(GtkWidget *w,
1273 gpointer unused)
1275 gboolean active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w));
1276 gboolean changed;
1277 GtkAccelKey *new_key = active ? &escape : &ctrl_w;
1279 changed = gtk_accel_map_change_entry(CONVERSATION_CLOSE_ACCEL_PATH,
1280 new_key->accel_key, new_key->accel_mods, TRUE);
1282 /* If another path is already bound to the new accelerator,
1283 * _change_entry tries to delete that binding (because it was passed
1284 * replace=TRUE). If that other path is locked, then _change_entry
1285 * will fail. We don't ever lock any accelerator paths, so this case
1286 * should never arise.
1288 if(!changed)
1289 purple_debug_warning("gtkprefs", "Escape accel failed to change\n");
1293 /* Creates preferences for keyboard shortcuts that it's hard to change with the
1294 * standard Gtk accelerator-changing mechanism.
1296 static void
1297 keyboard_shortcuts(GtkWidget *page)
1299 GtkWidget *vbox = pidgin_make_frame(page, _("Keyboard Shortcuts"));
1300 GtkWidget *checkbox;
1301 GtkAccelKey current = { 0, 0, 0 };
1302 GtkAccelMap *map = gtk_accel_map_get();
1304 /* Maybe it would be better just to hardcode the values?
1305 * -- resiak, 2007-04-30
1307 if (ctrl_w.accel_key == 0)
1309 gtk_accelerator_parse ("<Control>w", &(ctrl_w.accel_key),
1310 &(ctrl_w.accel_mods));
1311 g_assert(ctrl_w.accel_key != 0);
1313 gtk_accelerator_parse ("Escape", &(escape.accel_key),
1314 &(escape.accel_mods));
1315 g_assert(escape.accel_key != 0);
1318 checkbox = gtk_check_button_new_with_mnemonic(
1319 _("Cl_ose conversations with the Escape key"));
1320 gtk_accel_map_lookup_entry(CONVERSATION_CLOSE_ACCEL_PATH, &current);
1321 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
1322 accel_is_escape(&current));
1324 escape_closes_conversation_cb_id = g_signal_connect(checkbox,
1325 "clicked", G_CALLBACK(escape_closes_conversation_cb), NULL);
1327 g_signal_connect_object(map, "changed::" CONVERSATION_CLOSE_ACCEL_PATH,
1328 G_CALLBACK(conversation_close_accel_changed_cb), checkbox, (GConnectFlags)0);
1330 gtk_box_pack_start(GTK_BOX(vbox), checkbox, FALSE, FALSE, 0);
1333 static GtkWidget *
1334 interface_page(void)
1336 GtkWidget *ret;
1337 GtkWidget *vbox;
1338 GtkWidget *vbox2;
1339 GtkWidget *label;
1340 GtkSizeGroup *sg;
1341 GList *names = NULL;
1343 ret = gtk_vbox_new(FALSE, PIDGIN_HIG_CAT_SPACE);
1344 gtk_container_set_border_width(GTK_CONTAINER(ret), PIDGIN_HIG_BORDER);
1346 sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
1348 /* System Tray */
1349 vbox = pidgin_make_frame(ret, _("System Tray Icon"));
1350 label = pidgin_prefs_dropdown(vbox, _("_Show system tray icon:"), PURPLE_PREF_STRING,
1351 PIDGIN_PREFS_ROOT "/docklet/show",
1352 _("Always"), "always",
1353 _("On unread messages"), "pending",
1354 _("Never"), "never",
1355 NULL);
1356 gtk_size_group_add_widget(sg, label);
1357 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
1359 vbox = pidgin_make_frame(ret, _("Conversation Window"));
1360 label = pidgin_prefs_dropdown(vbox, _("_Hide new IM conversations:"),
1361 PURPLE_PREF_STRING, PIDGIN_PREFS_ROOT "/conversations/im/hide_new",
1362 _("Never"), "never",
1363 _("When away"), "away",
1364 _("Always"), "always",
1365 NULL);
1366 gtk_size_group_add_widget(sg, label);
1367 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
1369 #ifdef _WIN32
1370 pidgin_prefs_checkbox(_("Minimi_ze new conversation windows"), PIDGIN_PREFS_ROOT "/win32/minimize_new_convs", vbox);
1371 #endif
1373 /* All the tab options! */
1374 vbox = pidgin_make_frame(ret, _("Tabs"));
1376 pidgin_prefs_checkbox(_("Show IMs and chats in _tabbed windows"),
1377 PIDGIN_PREFS_ROOT "/conversations/tabs", vbox);
1380 * Connect a signal to the above preference. When conversations are not
1381 * shown in a tabbed window then all tabbing options should be disabled.
1383 vbox2 = gtk_vbox_new(FALSE, 9);
1384 gtk_box_pack_start(GTK_BOX(vbox), vbox2, FALSE, FALSE, 0);
1385 purple_prefs_connect_callback(prefs, PIDGIN_PREFS_ROOT "/conversations/tabs",
1386 conversation_usetabs_cb, vbox2);
1387 if (!purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/tabs"))
1388 gtk_widget_set_sensitive(vbox2, FALSE);
1390 pidgin_prefs_checkbox(_("Show close b_utton on tabs"),
1391 PIDGIN_PREFS_ROOT "/conversations/close_on_tabs", vbox2);
1393 label = pidgin_prefs_dropdown(vbox2, _("_Placement:"), PURPLE_PREF_INT,
1394 PIDGIN_PREFS_ROOT "/conversations/tab_side",
1395 _("Top"), GTK_POS_TOP,
1396 _("Bottom"), GTK_POS_BOTTOM,
1397 _("Left"), GTK_POS_LEFT,
1398 _("Right"), GTK_POS_RIGHT,
1399 _("Left Vertical"), GTK_POS_LEFT|8,
1400 _("Right Vertical"), GTK_POS_RIGHT|8,
1401 NULL);
1402 gtk_size_group_add_widget(sg, label);
1403 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
1405 names = pidgin_conv_placement_get_options();
1406 label = pidgin_prefs_dropdown_from_list(vbox2, _("N_ew conversations:"),
1407 PURPLE_PREF_STRING, PIDGIN_PREFS_ROOT "/conversations/placement", names);
1408 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
1410 gtk_size_group_add_widget(sg, label);
1412 g_list_free(names);
1414 keyboard_shortcuts(ret);
1416 gtk_widget_show_all(ret);
1417 g_object_unref(sg);
1418 return ret;
1421 #ifdef _WIN32
1422 static void
1423 apply_custom_font(void)
1425 PangoFontDescription *desc = NULL;
1426 if (!purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/use_theme_font")) {
1427 const char *font = purple_prefs_get_string(PIDGIN_PREFS_ROOT "/conversations/custom_font");
1428 desc = pango_font_description_from_string(font);
1431 gtk_widget_modify_font(sample_imhtml, desc);
1432 if (desc)
1433 pango_font_description_free(desc);
1436 static void
1437 pidgin_custom_font_set(GtkFontButton *font_button, gpointer nul)
1440 purple_prefs_set_string(PIDGIN_PREFS_ROOT "/conversations/custom_font",
1441 gtk_font_button_get_font_name(font_button));
1443 apply_custom_font();
1445 #endif
1447 static GtkWidget *
1448 conv_page(void)
1450 GtkWidget *ret;
1451 GtkWidget *vbox;
1452 GtkWidget *toolbar;
1453 GtkWidget *iconpref1;
1454 GtkWidget *iconpref2;
1455 GtkWidget *imhtml;
1456 GtkWidget *frame;
1457 GtkWidget *hbox;
1458 GtkWidget *checkbox;
1459 GtkWidget *spin_button;
1461 ret = gtk_vbox_new(FALSE, PIDGIN_HIG_CAT_SPACE);
1462 gtk_container_set_border_width(GTK_CONTAINER(ret), PIDGIN_HIG_BORDER);
1464 vbox = pidgin_make_frame(ret, _("Conversations"));
1466 pidgin_prefs_checkbox(_("Show _formatting on incoming messages"),
1467 PIDGIN_PREFS_ROOT "/conversations/show_incoming_formatting", vbox);
1468 pidgin_prefs_checkbox(_("Close IMs immediately when the tab is closed"),
1469 PIDGIN_PREFS_ROOT "/conversations/im/close_immediately", vbox);
1471 iconpref1 = pidgin_prefs_checkbox(_("Show _detailed information"),
1472 PIDGIN_PREFS_ROOT "/conversations/im/show_buddy_icons", vbox);
1473 iconpref2 = pidgin_prefs_checkbox(_("Enable buddy ic_on animation"),
1474 PIDGIN_PREFS_ROOT "/conversations/im/animate_buddy_icons", vbox);
1475 if (!purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/im/show_buddy_icons"))
1476 gtk_widget_set_sensitive(iconpref2, FALSE);
1477 g_signal_connect(G_OBJECT(iconpref1), "clicked",
1478 G_CALLBACK(pidgin_toggle_sensitive), iconpref2);
1480 pidgin_prefs_checkbox(_("_Notify buddies that you are typing to them"),
1481 "/purple/conversations/im/send_typing", vbox);
1482 #ifdef USE_GTKSPELL
1483 pidgin_prefs_checkbox(_("Highlight _misspelled words"),
1484 PIDGIN_PREFS_ROOT "/conversations/spellcheck", vbox);
1485 #endif
1487 pidgin_prefs_checkbox(_("Use smooth-scrolling"), PIDGIN_PREFS_ROOT "/conversations/use_smooth_scrolling", vbox);
1489 #ifdef _WIN32
1490 pidgin_prefs_checkbox(_("F_lash window when IMs are received"), PIDGIN_PREFS_ROOT "/win32/blink_im", vbox);
1491 #endif
1492 hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE);
1494 checkbox = pidgin_prefs_checkbox(_("Resize incoming custom smileys"),
1495 PIDGIN_PREFS_ROOT "/conversations/resize_custom_smileys", hbox);
1497 spin_button = pidgin_prefs_labeled_spin_button(hbox,
1498 _("Maximum size:"),
1499 PIDGIN_PREFS_ROOT "/conversations/custom_smileys_size",
1500 16, 512, NULL);
1502 if (!purple_prefs_get_bool(
1503 PIDGIN_PREFS_ROOT "/conversations/resize_custom_smileys"))
1504 gtk_widget_set_sensitive(GTK_WIDGET(spin_button), FALSE);
1506 g_signal_connect(G_OBJECT(checkbox), "clicked",
1507 G_CALLBACK(pidgin_toggle_sensitive), spin_button);
1509 pidgin_add_widget_to_vbox(GTK_BOX(vbox), NULL, NULL, hbox, TRUE, NULL);
1511 pidgin_prefs_labeled_spin_button(vbox,
1512 _("Minimum input area height in lines:"),
1513 PIDGIN_PREFS_ROOT "/conversations/minimum_entry_lines",
1514 1, 8, NULL);
1516 #ifdef _WIN32
1518 GtkWidget *fontpref, *font_button, *hbox;
1519 const char *font_name;
1520 vbox = pidgin_make_frame(ret, _("Font"));
1522 fontpref = pidgin_prefs_checkbox(_("Use font from _theme"),
1523 PIDGIN_PREFS_ROOT "/conversations/use_theme_font", vbox);
1525 font_name = purple_prefs_get_string(PIDGIN_PREFS_ROOT "/conversations/custom_font");
1526 if ((font_name == NULL) || (*font_name == '\0')) {
1527 font_button = gtk_font_button_new();
1528 } else {
1529 font_button = gtk_font_button_new_with_font(font_name);
1532 gtk_font_button_set_show_style(GTK_FONT_BUTTON(font_button), TRUE);
1533 hbox = pidgin_add_widget_to_vbox(GTK_BOX(vbox), _("Conversation _font:"), NULL, font_button, FALSE, NULL);
1534 if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/use_theme_font"))
1535 gtk_widget_set_sensitive(hbox, FALSE);
1536 g_signal_connect(G_OBJECT(fontpref), "clicked", G_CALLBACK(pidgin_toggle_sensitive), hbox);
1537 g_signal_connect(G_OBJECT(fontpref), "clicked", G_CALLBACK(apply_custom_font), hbox);
1538 g_signal_connect(G_OBJECT(font_button), "font-set", G_CALLBACK(pidgin_custom_font_set), NULL);
1541 #endif
1543 vbox = pidgin_make_frame(ret, _("Default Formatting"));
1545 frame = pidgin_create_imhtml(TRUE, &imhtml, &toolbar, NULL);
1546 gtk_widget_show(frame);
1547 gtk_widget_set_name(imhtml, "pidgin_prefs_font_imhtml");
1548 gtk_widget_set_size_request(frame, 450, -1);
1549 gtk_imhtml_set_whole_buffer_formatting_only(GTK_IMHTML(imhtml), TRUE);
1550 gtk_imhtml_set_format_functions(GTK_IMHTML(imhtml),
1551 GTK_IMHTML_BOLD |
1552 GTK_IMHTML_ITALIC |
1553 GTK_IMHTML_UNDERLINE |
1554 GTK_IMHTML_GROW |
1555 GTK_IMHTML_SHRINK |
1556 GTK_IMHTML_FACE |
1557 GTK_IMHTML_FORECOLOR |
1558 GTK_IMHTML_BACKCOLOR |
1559 GTK_IMHTML_BACKGROUND);
1561 gtk_imhtml_append_text(GTK_IMHTML(imhtml), _("This is how your outgoing message text will appear when you use protocols that support formatting."), 0);
1563 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0);
1565 gtk_imhtml_setup_entry(GTK_IMHTML(imhtml), PURPLE_CONNECTION_HTML | PURPLE_CONNECTION_FORMATTING_WBFO);
1567 g_signal_connect_after(G_OBJECT(imhtml), "format_function_toggle",
1568 G_CALLBACK(formatting_toggle_cb), toolbar);
1569 g_signal_connect_after(G_OBJECT(imhtml), "format_function_clear",
1570 G_CALLBACK(formatting_clear_cb), NULL);
1571 sample_imhtml = imhtml;
1573 gtk_widget_show(ret);
1575 return ret;
1578 static void
1579 network_ip_changed(GtkEntry *entry, gpointer data)
1581 const gchar *text = gtk_entry_get_text(entry);
1582 GdkColor color;
1584 if (text && *text) {
1585 if (purple_ip_address_is_valid(text)) {
1586 color.red = 0xAFFF;
1587 color.green = 0xFFFF;
1588 color.blue = 0xAFFF;
1590 purple_network_set_public_ip(text);
1591 } else {
1592 color.red = 0xFFFF;
1593 color.green = 0xAFFF;
1594 color.blue = 0xAFFF;
1597 gtk_widget_modify_base(GTK_WIDGET(entry), GTK_STATE_NORMAL, &color);
1599 } else {
1600 purple_network_set_public_ip("");
1601 gtk_widget_modify_base(GTK_WIDGET(entry), GTK_STATE_NORMAL, NULL);
1605 static gboolean
1606 network_stun_server_changed_cb(GtkWidget *widget,
1607 GdkEventFocus *event, gpointer data)
1609 GtkEntry *entry = GTK_ENTRY(widget);
1610 purple_prefs_set_string("/purple/network/stun_server",
1611 gtk_entry_get_text(entry));
1612 purple_network_set_stun_server(gtk_entry_get_text(entry));
1614 return FALSE;
1617 static gboolean
1618 network_turn_server_changed_cb(GtkWidget *widget,
1619 GdkEventFocus *event, gpointer data)
1621 GtkEntry *entry = GTK_ENTRY(widget);
1622 purple_prefs_set_string("/purple/network/turn_server",
1623 gtk_entry_get_text(entry));
1624 purple_network_set_turn_server(gtk_entry_get_text(entry));
1626 return FALSE;
1629 static void
1630 proxy_changed_cb(const char *name, PurplePrefType type,
1631 gconstpointer value, gpointer data)
1633 GtkWidget *frame = data;
1634 const char *proxy = value;
1636 if (!purple_strequal(proxy, "none") && !purple_strequal(proxy, "envvar"))
1637 gtk_widget_show_all(frame);
1638 else
1639 gtk_widget_hide(frame);
1642 static void
1643 proxy_print_option(GtkEntry *entry, int entrynum)
1645 if (entrynum == PROXYHOST)
1646 purple_prefs_set_string("/purple/proxy/host", gtk_entry_get_text(entry));
1647 else if (entrynum == PROXYPORT)
1648 purple_prefs_set_int("/purple/proxy/port", atoi(gtk_entry_get_text(entry)));
1649 else if (entrynum == PROXYUSER)
1650 purple_prefs_set_string("/purple/proxy/username", gtk_entry_get_text(entry));
1651 else if (entrynum == PROXYPASS)
1652 purple_prefs_set_string("/purple/proxy/password", gtk_entry_get_text(entry));
1655 static void
1656 proxy_button_clicked_cb(GtkWidget *button, gchar *program)
1658 GError *err = NULL;
1660 if (g_spawn_command_line_async(program, &err))
1661 return;
1663 purple_notify_error(NULL, NULL, _("Cannot start proxy configuration program."), err->message);
1664 g_error_free(err);
1667 #ifndef _WIN32
1668 static void
1669 browser_button_clicked_cb(GtkWidget *button, gchar *path)
1671 GError *err = NULL;
1673 if (g_spawn_command_line_async(path, &err))
1674 return;
1676 purple_notify_error(NULL, NULL, _("Cannot start browser configuration program."), err->message);
1677 g_error_free(err);
1679 #endif
1681 static void
1682 auto_ip_button_clicked_cb(GtkWidget *button, gpointer null)
1684 const char *ip;
1685 PurpleStunNatDiscovery *stun;
1686 char *auto_ip_text;
1688 /* purple_network_get_my_ip will return the IP that was set by the user with
1689 purple_network_set_public_ip, so make a lookup for the auto-detected IP
1690 ourselves. */
1692 if (purple_prefs_get_bool("/purple/network/auto_ip")) {
1693 /* Check if STUN discovery was already done */
1694 stun = purple_stun_discover(NULL);
1695 if ((stun != NULL) && (stun->status == PURPLE_STUN_STATUS_DISCOVERED)) {
1696 ip = stun->publicip;
1697 } else {
1698 /* Attempt to get the IP from a NAT device using UPnP */
1699 ip = purple_upnp_get_public_ip();
1700 if (ip == NULL) {
1701 /* Attempt to get the IP from a NAT device using NAT-PMP */
1702 ip = purple_pmp_get_public_ip();
1703 if (ip == NULL) {
1704 /* Just fetch the IP of the local system */
1705 ip = purple_network_get_local_system_ip(-1);
1710 else
1711 ip = _("Disabled");
1713 auto_ip_text = g_strdup_printf(_("Use _automatically detected IP address: %s"), ip);
1714 gtk_button_set_label(GTK_BUTTON(button), auto_ip_text);
1715 g_free(auto_ip_text);
1718 static GtkWidget *
1719 network_page(void)
1721 GtkWidget *ret;
1722 GtkWidget *vbox, *hbox, *entry;
1723 GtkWidget *label, *auto_ip_checkbox, *ports_checkbox, *spin_button;
1724 GtkSizeGroup *sg;
1726 ret = gtk_vbox_new(FALSE, PIDGIN_HIG_CAT_SPACE);
1727 gtk_container_set_border_width (GTK_CONTAINER (ret), PIDGIN_HIG_BORDER);
1729 vbox = pidgin_make_frame (ret, _("IP Address"));
1730 sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
1732 entry = gtk_entry_new();
1733 gtk_entry_set_text(GTK_ENTRY(entry), purple_prefs_get_string(
1734 "/purple/network/stun_server"));
1735 g_signal_connect(G_OBJECT(entry), "focus-out-event",
1736 G_CALLBACK(network_stun_server_changed_cb), NULL);
1737 gtk_widget_show(entry);
1739 pidgin_add_widget_to_vbox(GTK_BOX(vbox), _("ST_UN server:"),
1740 sg, entry, TRUE, NULL);
1742 hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE);
1743 gtk_container_add(GTK_CONTAINER(vbox), hbox);
1745 label = gtk_label_new(NULL);
1746 gtk_container_add(GTK_CONTAINER(hbox), label);
1747 gtk_size_group_add_widget(sg, label);
1749 label = gtk_label_new(NULL);
1750 gtk_label_set_markup(GTK_LABEL(label),
1751 _("<span style=\"italic\">Example: stunserver.org</span>"));
1752 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
1753 gtk_container_add(GTK_CONTAINER(hbox), label);
1755 auto_ip_checkbox = pidgin_prefs_checkbox("Use _automatically detected IP address",
1756 "/purple/network/auto_ip", vbox);
1757 g_signal_connect(G_OBJECT(auto_ip_checkbox), "clicked",
1758 G_CALLBACK(auto_ip_button_clicked_cb), NULL);
1759 auto_ip_button_clicked_cb(auto_ip_checkbox, NULL); /* Update label */
1761 entry = gtk_entry_new();
1762 gtk_entry_set_text(GTK_ENTRY(entry), purple_network_get_public_ip());
1763 g_signal_connect(G_OBJECT(entry), "changed",
1764 G_CALLBACK(network_ip_changed), NULL);
1766 hbox = pidgin_add_widget_to_vbox(GTK_BOX(vbox), _("Public _IP:"),
1767 sg, entry, TRUE, NULL);
1769 if (purple_prefs_get_bool("/purple/network/auto_ip")) {
1770 gtk_widget_set_sensitive(GTK_WIDGET(hbox), FALSE);
1773 g_signal_connect(G_OBJECT(auto_ip_checkbox), "clicked",
1774 G_CALLBACK(pidgin_toggle_sensitive), hbox);
1776 g_object_unref(sg);
1778 vbox = pidgin_make_frame (ret, _("Ports"));
1779 sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
1781 pidgin_prefs_checkbox(_("_Enable automatic router port forwarding"),
1782 "/purple/network/map_ports", vbox);
1784 hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE);
1786 ports_checkbox = pidgin_prefs_checkbox(_("_Manually specify range of ports to listen on:"),
1787 "/purple/network/ports_range_use", hbox);
1789 spin_button = pidgin_prefs_labeled_spin_button(hbox, _("_Start:"),
1790 "/purple/network/ports_range_start", 0, 65535, sg);
1791 if (!purple_prefs_get_bool("/purple/network/ports_range_use"))
1792 gtk_widget_set_sensitive(GTK_WIDGET(spin_button), FALSE);
1793 g_signal_connect(G_OBJECT(ports_checkbox), "clicked",
1794 G_CALLBACK(pidgin_toggle_sensitive), spin_button);
1796 spin_button = pidgin_prefs_labeled_spin_button(hbox, _("_End:"),
1797 "/purple/network/ports_range_end", 0, 65535, sg);
1798 if (!purple_prefs_get_bool("/purple/network/ports_range_use"))
1799 gtk_widget_set_sensitive(GTK_WIDGET(spin_button), FALSE);
1800 g_signal_connect(G_OBJECT(ports_checkbox), "clicked",
1801 G_CALLBACK(pidgin_toggle_sensitive), spin_button);
1803 pidgin_add_widget_to_vbox(GTK_BOX(vbox), NULL, NULL, hbox, TRUE, NULL);
1805 g_object_unref(sg);
1807 /* TURN server */
1808 vbox = pidgin_make_frame(ret, _("Relay Server (TURN)"));
1809 sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
1811 entry = gtk_entry_new();
1812 gtk_entry_set_text(GTK_ENTRY(entry), purple_prefs_get_string(
1813 "/purple/network/turn_server"));
1814 g_signal_connect(G_OBJECT(entry), "focus-out-event",
1815 G_CALLBACK(network_turn_server_changed_cb), NULL);
1816 gtk_widget_show(entry);
1818 hbox = pidgin_add_widget_to_vbox(GTK_BOX(vbox), _("_TURN server:"),
1819 sg, entry, TRUE, NULL);
1821 pidgin_prefs_labeled_spin_button(hbox, _("_UDP Port:"),
1822 "/purple/network/turn_port", 0, 65535, NULL);
1824 pidgin_prefs_labeled_spin_button(hbox, _("T_CP Port:"),
1825 "/purple/network/turn_port_tcp", 0, 65535, NULL);
1827 hbox = pidgin_prefs_labeled_entry(vbox, _("Use_rname:"),
1828 "/purple/network/turn_username", sg);
1829 pidgin_prefs_labeled_password(hbox, _("Pass_word:"),
1830 "/purple/network/turn_password", NULL);
1832 gtk_widget_show_all(ret);
1833 g_object_unref(sg);
1835 return ret;
1838 #ifndef _WIN32
1839 static gboolean
1840 manual_browser_set(GtkWidget *entry, GdkEventFocus *event, gpointer data)
1842 const char *program = gtk_entry_get_text(GTK_ENTRY(entry));
1844 purple_prefs_set_string(PIDGIN_PREFS_ROOT "/browsers/manual_command", program);
1846 /* carry on normally */
1847 return FALSE;
1850 static GList *
1851 get_available_browsers(void)
1853 struct browser {
1854 char *name;
1855 char *command;
1858 /* Sorted reverse alphabetically */
1859 static const struct browser possible_browsers[] = {
1860 {N_("Seamonkey"), "seamonkey"},
1861 {N_("Opera"), "opera"},
1862 {N_("Netscape"), "netscape"},
1863 {N_("Mozilla"), "mozilla"},
1864 {N_("Konqueror"), "kfmclient"},
1865 {N_("Google Chrome"), "google-chrome"},
1866 /* Do not move the line below. Code below expects gnome-open to be in
1867 * this list immediately after xdg-open! */
1868 {N_("Desktop Default"), "xdg-open"},
1869 {N_("GNOME Default"), "gnome-open"},
1870 {N_("Galeon"), "galeon"},
1871 {N_("Firefox"), "firefox"},
1872 {N_("Firebird"), "mozilla-firebird"},
1873 {N_("Epiphany"), "epiphany"},
1874 /* Translators: please do not translate "chromium-browser" here! */
1875 {N_("Chromium (chromium-browser)"), "chromium-browser"},
1876 /* Translators: please do not translate "chrome" here! */
1877 {N_("Chromium (chrome)"), "chrome"}
1879 static const int num_possible_browsers = G_N_ELEMENTS(possible_browsers);
1881 GList *browsers = NULL;
1882 int i = 0;
1883 char *browser_setting = (char *)purple_prefs_get_string(PIDGIN_PREFS_ROOT "/browsers/browser");
1885 browsers = g_list_prepend(browsers, (gpointer)"custom");
1886 browsers = g_list_prepend(browsers, (gpointer)_("Manual"));
1888 for (i = 0; i < num_possible_browsers; i++) {
1889 if (purple_program_is_valid(possible_browsers[i].command)) {
1890 browsers = g_list_prepend(browsers,
1891 possible_browsers[i].command);
1892 browsers = g_list_prepend(browsers, (gpointer)_(possible_browsers[i].name));
1893 if(browser_setting && purple_strequal(possible_browsers[i].command, browser_setting))
1894 browser_setting = NULL;
1895 /* If xdg-open is valid, prefer it over gnome-open and skip forward */
1896 if(purple_strequal(possible_browsers[i].command, "xdg-open")) {
1897 if (browser_setting && purple_strequal("gnome-open", browser_setting)) {
1898 purple_prefs_set_string(PIDGIN_PREFS_ROOT "/browsers/browser", possible_browsers[i].command);
1899 browser_setting = NULL;
1901 i++;
1906 if(browser_setting)
1907 purple_prefs_set_string(PIDGIN_PREFS_ROOT "/browsers/browser", "custom");
1909 return browsers;
1912 static void
1913 browser_changed1_cb(const char *name, PurplePrefType type,
1914 gconstpointer value, gpointer data)
1916 GtkWidget *hbox = data;
1917 const char *browser = value;
1919 gtk_widget_set_sensitive(hbox, !purple_strequal(browser, "custom"));
1922 static void
1923 browser_changed2_cb(const char *name, PurplePrefType type,
1924 gconstpointer value, gpointer data)
1926 GtkWidget *hbox = data;
1927 const char *browser = value;
1929 gtk_widget_set_sensitive(hbox, purple_strequal(browser, "custom"));
1932 static GtkWidget *
1933 browser_page(void)
1935 GtkWidget *ret, *vbox, *hbox, *label, *entry, *browser_button;
1936 GtkSizeGroup *sg;
1937 GList *browsers = NULL;
1939 ret = gtk_vbox_new(FALSE, PIDGIN_HIG_CAT_SPACE);
1940 gtk_container_set_border_width (GTK_CONTAINER (ret), PIDGIN_HIG_BORDER);
1942 vbox = pidgin_make_frame (ret, _("Browser Selection"));
1944 if (purple_running_gnome()) {
1945 gchar *path;
1947 hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE);
1948 label = gtk_label_new(_("Browser preferences are configured in GNOME preferences"));
1949 gtk_container_add(GTK_CONTAINER(vbox), hbox);
1950 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1952 hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE);
1953 gtk_container_add(GTK_CONTAINER(vbox), hbox);
1955 path = g_find_program_in_path("gnome-control-center");
1956 if (path != NULL) {
1957 gchar *tmp = g_strdup_printf("%s info", path);
1958 g_free(path);
1959 path = tmp;
1960 } else {
1961 path = g_find_program_in_path("gnome-default-applications-properties");
1964 if (path == NULL) {
1965 label = gtk_label_new(NULL);
1966 gtk_label_set_markup(GTK_LABEL(label),
1967 _("<b>Browser configuration program was not found.</b>"));
1968 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1969 } else {
1970 browser_button = gtk_button_new_with_mnemonic(_("Configure _Browser"));
1971 g_signal_connect_data(G_OBJECT(browser_button), "clicked",
1972 G_CALLBACK(browser_button_clicked_cb), path,
1973 (GClosureNotify)g_free, 0);
1974 gtk_box_pack_start(GTK_BOX(hbox), browser_button, FALSE, FALSE, 0);
1977 gtk_widget_show_all(ret);
1978 } else {
1979 sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
1981 browsers = get_available_browsers();
1982 if (browsers != NULL) {
1983 label = pidgin_prefs_dropdown_from_list(vbox,_("_Browser:"), PURPLE_PREF_STRING,
1984 PIDGIN_PREFS_ROOT "/browsers/browser",
1985 browsers);
1986 g_list_free(browsers);
1987 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
1988 gtk_size_group_add_widget(sg, label);
1990 hbox = gtk_hbox_new(FALSE, 0);
1991 label = pidgin_prefs_dropdown(hbox, _("_Open link in:"), PURPLE_PREF_INT,
1992 PIDGIN_PREFS_ROOT "/browsers/place",
1993 _("Browser default"), PIDGIN_BROWSER_DEFAULT,
1994 _("Existing window"), PIDGIN_BROWSER_CURRENT,
1995 _("New window"), PIDGIN_BROWSER_NEW_WINDOW,
1996 _("New tab"), PIDGIN_BROWSER_NEW_TAB,
1997 NULL);
1998 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
1999 gtk_size_group_add_widget(sg, label);
2000 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
2002 if (purple_strequal(purple_prefs_get_string(PIDGIN_PREFS_ROOT "/browsers/browser"), "custom"))
2003 gtk_widget_set_sensitive(hbox, FALSE);
2004 purple_prefs_connect_callback(prefs, PIDGIN_PREFS_ROOT "/browsers/browser",
2005 browser_changed1_cb, hbox);
2008 entry = gtk_entry_new();
2009 gtk_entry_set_text(GTK_ENTRY(entry),
2010 purple_prefs_get_string(PIDGIN_PREFS_ROOT "/browsers/manual_command"));
2011 g_signal_connect(G_OBJECT(entry), "focus-out-event",
2012 G_CALLBACK(manual_browser_set), NULL);
2013 hbox = pidgin_add_widget_to_vbox(GTK_BOX(vbox), _("_Manual:\n(%s for URL)"), sg, entry, TRUE, NULL);
2014 if (!purple_strequal(purple_prefs_get_string(PIDGIN_PREFS_ROOT "/browsers/browser"), "custom"))
2015 gtk_widget_set_sensitive(hbox, FALSE);
2016 purple_prefs_connect_callback(prefs, PIDGIN_PREFS_ROOT "/browsers/browser",
2017 browser_changed2_cb, hbox);
2019 gtk_widget_show_all(ret);
2020 g_object_unref(sg);
2023 return ret;
2025 #endif /*_WIN32*/
2027 static GtkWidget *
2028 proxy_page(void)
2030 GtkWidget *ret = NULL, *vbox = NULL, *hbox = NULL;
2031 GtkWidget *table = NULL, *entry = NULL, *label = NULL, *proxy_button = NULL;
2032 GtkWidget *prefs_proxy_frame = NULL;
2033 PurpleProxyInfo *proxy_info;
2035 ret = gtk_vbox_new(FALSE, PIDGIN_HIG_CAT_SPACE);
2036 gtk_container_set_border_width(GTK_CONTAINER(ret), PIDGIN_HIG_BORDER);
2037 vbox = pidgin_make_frame(ret, _("Proxy Server"));
2038 prefs_proxy_frame = gtk_vbox_new(FALSE, PIDGIN_HIG_BOX_SPACE);
2040 if(purple_running_gnome()) {
2041 gchar *path = NULL;
2043 hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE);
2044 label = gtk_label_new(_("Proxy preferences are configured in GNOME preferences"));
2045 gtk_container_add(GTK_CONTAINER(vbox), hbox);
2046 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
2048 hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE);
2049 gtk_container_add(GTK_CONTAINER(vbox), hbox);
2051 path = g_find_program_in_path("gnome-network-properties");
2052 if (path == NULL)
2053 path = g_find_program_in_path("gnome-network-preferences");
2054 if (path == NULL) {
2055 path = g_find_program_in_path("gnome-control-center");
2056 if (path != NULL) {
2057 char *tmp = g_strdup_printf("%s network", path);
2058 g_free(path);
2059 path = tmp;
2063 if (path == NULL) {
2064 label = gtk_label_new(NULL);
2065 gtk_label_set_markup(GTK_LABEL(label),
2066 _("<b>Proxy configuration program was not found.</b>"));
2067 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
2068 } else {
2069 proxy_button = gtk_button_new_with_mnemonic(_("Configure _Proxy"));
2070 g_signal_connect(G_OBJECT(proxy_button), "clicked",
2071 G_CALLBACK(proxy_button_clicked_cb),
2072 path);
2073 gtk_box_pack_start(GTK_BOX(hbox), proxy_button, FALSE, FALSE, 0);
2076 /* NOTE: path leaks, but only when the prefs window is destroyed,
2077 which is never */
2078 gtk_widget_show_all(ret);
2079 } else {
2080 GtkWidget *prefs_proxy_subframe = gtk_vbox_new(FALSE, 0);
2082 /* This is a global option that affects SOCKS4 usage even with
2083 * account-specific proxy settings */
2084 pidgin_prefs_checkbox(_("Use remote _DNS with SOCKS4 proxies"),
2085 "/purple/proxy/socks4_remotedns", prefs_proxy_frame);
2086 gtk_box_pack_start(GTK_BOX(vbox), prefs_proxy_frame, 0, 0, 0);
2088 pidgin_prefs_dropdown(prefs_proxy_frame, _("Proxy t_ype:"), PURPLE_PREF_STRING,
2089 "/purple/proxy/type",
2090 _("No proxy"), "none",
2091 _("SOCKS 4"), "socks4",
2092 _("SOCKS 5"), "socks5",
2093 _("Tor/Privacy (SOCKS5)"), "tor",
2094 _("HTTP"), "http",
2095 _("Use Environmental Settings"), "envvar",
2096 NULL);
2097 gtk_box_pack_start(GTK_BOX(prefs_proxy_frame), prefs_proxy_subframe, 0, 0, 0);
2098 proxy_info = purple_global_proxy_get_info();
2100 gtk_widget_show_all(ret);
2102 purple_prefs_connect_callback(prefs, "/purple/proxy/type",
2103 proxy_changed_cb, prefs_proxy_subframe);
2105 table = gtk_table_new(4, 2, FALSE);
2106 gtk_container_set_border_width(GTK_CONTAINER(table), 0);
2107 gtk_table_set_col_spacings(GTK_TABLE(table), 5);
2108 gtk_table_set_row_spacings(GTK_TABLE(table), 10);
2109 gtk_container_add(GTK_CONTAINER(prefs_proxy_subframe), table);
2111 label = gtk_label_new_with_mnemonic(_("_Host:"));
2112 gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5);
2113 gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1, GTK_FILL, 0, 0, 0);
2115 entry = gtk_entry_new();
2116 gtk_label_set_mnemonic_widget(GTK_LABEL(label), entry);
2117 gtk_table_attach(GTK_TABLE(table), entry, 1, 2, 0, 1, GTK_FILL, 0, 0, 0);
2118 g_signal_connect(G_OBJECT(entry), "changed",
2119 G_CALLBACK(proxy_print_option), (void *)PROXYHOST);
2121 if (proxy_info != NULL && purple_proxy_info_get_host(proxy_info))
2122 gtk_entry_set_text(GTK_ENTRY(entry),
2123 purple_proxy_info_get_host(proxy_info));
2125 hbox = gtk_hbox_new(TRUE, 5);
2126 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
2127 pidgin_set_accessible_label (entry, label);
2129 label = gtk_label_new_with_mnemonic(_("P_ort:"));
2130 gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5);
2131 gtk_table_attach(GTK_TABLE(table), label, 2, 3, 0, 1, GTK_FILL, 0, 0, 0);
2133 entry = gtk_spin_button_new_with_range(0, 65535, 1);
2134 gtk_label_set_mnemonic_widget(GTK_LABEL(label), entry);
2135 gtk_table_attach(GTK_TABLE(table), entry, 3, 4, 0, 1, GTK_FILL, 0, 0, 0);
2136 g_signal_connect(G_OBJECT(entry), "changed",
2137 G_CALLBACK(proxy_print_option), (void *)PROXYPORT);
2139 if (proxy_info != NULL && purple_proxy_info_get_port(proxy_info) != 0) {
2140 gtk_spin_button_set_value(GTK_SPIN_BUTTON(entry),
2141 purple_proxy_info_get_port(proxy_info));
2143 pidgin_set_accessible_label (entry, label);
2145 label = gtk_label_new_with_mnemonic(_("User_name:"));
2146 gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5);
2147 gtk_table_attach(GTK_TABLE(table), label, 0, 1, 1, 2, GTK_FILL, 0, 0, 0);
2149 entry = gtk_entry_new();
2150 gtk_label_set_mnemonic_widget(GTK_LABEL(label), entry);
2151 gtk_table_attach(GTK_TABLE(table), entry, 1, 2, 1, 2, GTK_FILL, 0, 0, 0);
2152 g_signal_connect(G_OBJECT(entry), "changed",
2153 G_CALLBACK(proxy_print_option), (void *)PROXYUSER);
2155 if (proxy_info != NULL && purple_proxy_info_get_username(proxy_info) != NULL)
2156 gtk_entry_set_text(GTK_ENTRY(entry),
2157 purple_proxy_info_get_username(proxy_info));
2159 hbox = gtk_hbox_new(TRUE, 5);
2160 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
2161 pidgin_set_accessible_label (entry, label);
2163 label = gtk_label_new_with_mnemonic(_("Pa_ssword:"));
2164 gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5);
2165 gtk_table_attach(GTK_TABLE(table), label, 2, 3, 1, 2, GTK_FILL, 0, 0, 0);
2167 entry = gtk_entry_new();
2168 gtk_label_set_mnemonic_widget(GTK_LABEL(label), entry);
2169 gtk_table_attach(GTK_TABLE(table), entry, 3, 4, 1, 2, GTK_FILL , 0, 0, 0);
2170 gtk_entry_set_visibility(GTK_ENTRY(entry), FALSE);
2171 #if !GTK_CHECK_VERSION(2,16,0)
2172 if (gtk_entry_get_invisible_char(GTK_ENTRY(entry)) == '*')
2173 gtk_entry_set_invisible_char(GTK_ENTRY(entry), PIDGIN_INVISIBLE_CHAR);
2174 #endif /* Less than GTK+ 2.16 */
2175 g_signal_connect(G_OBJECT(entry), "changed",
2176 G_CALLBACK(proxy_print_option), (void *)PROXYPASS);
2178 if (proxy_info != NULL && purple_proxy_info_get_password(proxy_info) != NULL)
2179 gtk_entry_set_text(GTK_ENTRY(entry),
2180 purple_proxy_info_get_password(proxy_info));
2181 pidgin_set_accessible_label (entry, label);
2183 proxy_changed_cb("/purple/proxy/type", PURPLE_PREF_STRING,
2184 purple_prefs_get_string("/purple/proxy/type"),
2185 prefs_proxy_subframe);
2189 return ret;
2192 static GtkWidget *
2193 logging_page(void)
2195 GtkWidget *ret;
2196 GtkWidget *vbox;
2197 GList *names;
2199 ret = gtk_vbox_new(FALSE, PIDGIN_HIG_CAT_SPACE);
2200 gtk_container_set_border_width (GTK_CONTAINER (ret), PIDGIN_HIG_BORDER);
2203 vbox = pidgin_make_frame (ret, _("Logging"));
2204 names = purple_log_logger_get_options();
2206 pidgin_prefs_dropdown_from_list(vbox, _("Log _format:"), PURPLE_PREF_STRING,
2207 "/purple/logging/format", names);
2209 g_list_free(names);
2211 pidgin_prefs_checkbox(_("Log all _instant messages"),
2212 "/purple/logging/log_ims", vbox);
2213 pidgin_prefs_checkbox(_("Log all c_hats"),
2214 "/purple/logging/log_chats", vbox);
2215 pidgin_prefs_checkbox(_("Log all _status changes to system log"),
2216 "/purple/logging/log_system", vbox);
2218 gtk_widget_show_all(ret);
2220 return ret;
2223 #ifndef _WIN32
2224 static gint
2225 sound_cmd_yeah(GtkEntry *entry, gpointer d)
2227 purple_prefs_set_path(PIDGIN_PREFS_ROOT "/sound/command",
2228 gtk_entry_get_text(GTK_ENTRY(entry)));
2229 return TRUE;
2232 static void
2233 sound_changed1_cb(const char *name, PurplePrefType type,
2234 gconstpointer value, gpointer data)
2236 GtkWidget *hbox = data;
2237 const char *method = value;
2239 gtk_widget_set_sensitive(hbox, purple_strequal(method, "custom"));
2242 static void
2243 sound_changed2_cb(const char *name, PurplePrefType type,
2244 gconstpointer value, gpointer data)
2246 GtkWidget *vbox = data;
2247 const char *method = value;
2249 gtk_widget_set_sensitive(vbox, !purple_strequal(method, "none"));
2251 #endif /* !_WIN32 */
2253 #ifdef USE_GSTREAMER
2254 static void
2255 sound_changed3_cb(const char *name, PurplePrefType type,
2256 gconstpointer value, gpointer data)
2258 GtkWidget *hbox = data;
2259 const char *method = value;
2261 gtk_widget_set_sensitive(hbox,
2262 purple_strequal(method, "automatic") ||
2263 purple_strequal(method, "alsa") ||
2264 purple_strequal(method, "esd"));
2266 #endif /* USE_GSTREAMER */
2269 static void
2270 event_toggled(GtkCellRendererToggle *cell, gchar *pth, gpointer data)
2272 GtkTreeModel *model = (GtkTreeModel *)data;
2273 GtkTreeIter iter;
2274 GtkTreePath *path = gtk_tree_path_new_from_string(pth);
2275 char *pref;
2277 gtk_tree_model_get_iter (model, &iter, path);
2278 gtk_tree_model_get (model, &iter,
2279 2, &pref,
2280 -1);
2282 purple_prefs_set_bool(pref, !gtk_cell_renderer_toggle_get_active(cell));
2283 g_free(pref);
2285 gtk_list_store_set(GTK_LIST_STORE (model), &iter,
2286 0, !gtk_cell_renderer_toggle_get_active(cell),
2287 -1);
2289 gtk_tree_path_free(path);
2292 static void
2293 test_sound(GtkWidget *button, gpointer i_am_NULL)
2295 char *pref;
2296 gboolean temp_enabled;
2297 gboolean temp_mute;
2299 pref = g_strdup_printf(PIDGIN_PREFS_ROOT "/sound/enabled/%s",
2300 pidgin_sound_get_event_option(sound_row_sel));
2302 temp_enabled = purple_prefs_get_bool(pref);
2303 temp_mute = purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/sound/mute");
2305 if (!temp_enabled) purple_prefs_set_bool(pref, TRUE);
2306 if (temp_mute) purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/sound/mute", FALSE);
2308 purple_sound_play_event(sound_row_sel, NULL);
2310 if (!temp_enabled) purple_prefs_set_bool(pref, FALSE);
2311 if (temp_mute) purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/sound/mute", TRUE);
2313 g_free(pref);
2317 * Resets a sound file back to default.
2319 static void
2320 reset_sound(GtkWidget *button, gpointer i_am_also_NULL)
2322 gchar *pref;
2324 pref = g_strdup_printf(PIDGIN_PREFS_ROOT "/sound/file/%s",
2325 pidgin_sound_get_event_option(sound_row_sel));
2326 purple_prefs_set_path(pref, "");
2327 g_free(pref);
2329 gtk_entry_set_text(GTK_ENTRY(sound_entry), _("(default)"));
2331 pref_sound_generate_markup();
2334 static void
2335 sound_chosen_cb(void *user_data, const char *filename)
2337 gchar *pref;
2338 int sound;
2340 sound = GPOINTER_TO_INT(user_data);
2342 /* Set it -- and forget it */
2343 pref = g_strdup_printf(PIDGIN_PREFS_ROOT "/sound/file/%s",
2344 pidgin_sound_get_event_option(sound));
2345 purple_prefs_set_path(pref, filename);
2346 g_free(pref);
2349 * If the sound we just changed is still the currently selected
2350 * sound, then update the box showing the file name.
2352 if (sound == sound_row_sel)
2353 gtk_entry_set_text(GTK_ENTRY(sound_entry), filename);
2355 pref_sound_generate_markup();
2358 static void
2359 select_sound(GtkWidget *button, gpointer being_NULL_is_fun)
2361 gchar *pref;
2362 const char *filename;
2364 pref = g_strdup_printf(PIDGIN_PREFS_ROOT "/sound/file/%s",
2365 pidgin_sound_get_event_option(sound_row_sel));
2366 filename = purple_prefs_get_path(pref);
2367 g_free(pref);
2369 if (*filename == '\0')
2370 filename = NULL;
2372 purple_request_file(prefs, _("Sound Selection"), filename, FALSE,
2373 G_CALLBACK(sound_chosen_cb), NULL,
2374 NULL, NULL, NULL,
2375 GINT_TO_POINTER(sound_row_sel));
2378 #ifdef USE_GSTREAMER
2379 static gchar *
2380 prefs_sound_volume_format(GtkScale *scale, gdouble val)
2382 if(val < 15) {
2383 return g_strdup_printf(_("Quietest"));
2384 } else if(val < 30) {
2385 return g_strdup_printf(_("Quieter"));
2386 } else if(val < 45) {
2387 return g_strdup_printf(_("Quiet"));
2388 } else if(val < 55) {
2389 return g_strdup_printf(_("Normal"));
2390 } else if(val < 70) {
2391 return g_strdup_printf(_("Loud"));
2392 } else if(val < 85) {
2393 return g_strdup_printf(_("Louder"));
2394 } else {
2395 return g_strdup_printf(_("Loudest"));
2399 static void
2400 prefs_sound_volume_changed(GtkRange *range)
2402 int val = (int)gtk_range_get_value(GTK_RANGE(range));
2403 purple_prefs_set_int(PIDGIN_PREFS_ROOT "/sound/volume", val);
2405 #endif
2407 static void
2408 prefs_sound_sel(GtkTreeSelection *sel, GtkTreeModel *model)
2410 GtkTreeIter iter;
2411 GValue val;
2412 const char *file;
2413 char *pref;
2415 if (! gtk_tree_selection_get_selected (sel, &model, &iter))
2416 return;
2418 val.g_type = 0;
2419 gtk_tree_model_get_value (model, &iter, 3, &val);
2420 sound_row_sel = g_value_get_uint(&val);
2422 pref = g_strdup_printf(PIDGIN_PREFS_ROOT "/sound/file/%s",
2423 pidgin_sound_get_event_option(sound_row_sel));
2424 file = purple_prefs_get_path(pref);
2425 g_free(pref);
2426 if (sound_entry)
2427 gtk_entry_set_text(GTK_ENTRY(sound_entry), (file && *file != '\0') ? file : _("(default)"));
2428 g_value_unset (&val);
2430 pref_sound_generate_markup();
2434 static void
2435 mute_changed_cb(const char *pref_name,
2436 PurplePrefType pref_type,
2437 gconstpointer val,
2438 gpointer data)
2440 GtkToggleButton *button = data;
2441 gboolean muted = GPOINTER_TO_INT(val);
2443 g_return_if_fail(purple_strequal (pref_name, PIDGIN_PREFS_ROOT "/sound/mute"));
2445 /* Block the handler that re-sets the preference. */
2446 g_signal_handlers_block_matched(button, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, (gpointer)pref_name);
2447 gtk_toggle_button_set_active (button, muted);
2448 g_signal_handlers_unblock_matched(button, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, (gpointer)pref_name);
2452 static GtkWidget *
2453 sound_page(void)
2455 GtkWidget *ret;
2456 GtkWidget *vbox, *vbox2, *sw, *button;
2457 GtkSizeGroup *sg;
2458 GtkTreeIter iter;
2459 GtkWidget *event_view;
2460 GtkListStore *event_store;
2461 GtkCellRenderer *rend;
2462 GtkTreeViewColumn *col;
2463 GtkTreeSelection *sel;
2464 GtkTreePath *path;
2465 GtkWidget *hbox;
2466 int j;
2467 const char *file;
2468 char *pref;
2469 #ifndef _WIN32
2470 GtkWidget *dd;
2471 GtkWidget *entry;
2472 const char *cmd;
2473 #endif
2475 ret = gtk_vbox_new(FALSE, PIDGIN_HIG_CAT_SPACE);
2476 gtk_container_set_border_width (GTK_CONTAINER (ret), PIDGIN_HIG_BORDER);
2478 sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
2480 vbox2 = pidgin_make_frame(ret, _("Sound Options"));
2482 vbox = gtk_vbox_new(FALSE, PIDGIN_HIG_BOX_SPACE);
2483 gtk_box_pack_start(GTK_BOX(vbox2), vbox, FALSE, FALSE, 0);
2485 #ifndef _WIN32
2486 dd = pidgin_prefs_dropdown(vbox2, _("_Method:"), PURPLE_PREF_STRING,
2487 PIDGIN_PREFS_ROOT "/sound/method",
2488 _("Console beep"), "beep",
2489 #ifdef USE_GSTREAMER
2490 _("Automatic"), "automatic",
2491 "ESD", "esd",
2492 "ALSA", "alsa",
2493 #endif
2494 _("Command"), "custom",
2495 _("No sounds"), "none",
2496 NULL);
2497 gtk_size_group_add_widget(sg, dd);
2498 gtk_misc_set_alignment(GTK_MISC(dd), 0, 0.5);
2500 entry = gtk_entry_new();
2501 gtk_editable_set_editable(GTK_EDITABLE(entry), TRUE);
2502 cmd = purple_prefs_get_path(PIDGIN_PREFS_ROOT "/sound/command");
2503 if(cmd)
2504 gtk_entry_set_text(GTK_ENTRY(entry), cmd);
2505 g_signal_connect(G_OBJECT(entry), "changed",
2506 G_CALLBACK(sound_cmd_yeah), NULL);
2508 hbox = pidgin_add_widget_to_vbox(GTK_BOX(vbox), _("Sound c_ommand:\n(%s for filename)"), sg, entry, TRUE, NULL);
2509 purple_prefs_connect_callback(prefs, PIDGIN_PREFS_ROOT "/sound/method",
2510 sound_changed1_cb, hbox);
2511 gtk_widget_set_sensitive(hbox,
2512 purple_strequal(purple_prefs_get_string(PIDGIN_PREFS_ROOT "/sound/method"),
2513 "custom"));
2514 #endif /* _WIN32 */
2516 button = pidgin_prefs_checkbox(_("M_ute sounds"), PIDGIN_PREFS_ROOT "/sound/mute", vbox);
2517 purple_prefs_connect_callback(prefs, PIDGIN_PREFS_ROOT "/sound/mute", mute_changed_cb, button);
2519 pidgin_prefs_checkbox(_("Sounds when conversation has _focus"),
2520 PIDGIN_PREFS_ROOT "/sound/conv_focus", vbox);
2521 pidgin_prefs_dropdown(vbox, _("_Enable sounds:"),
2522 PURPLE_PREF_INT, "/purple/sound/while_status",
2523 _("Only when available"), 1,
2524 _("Only when not available"), 2,
2525 _("Always"), 3,
2526 NULL);
2528 #ifdef USE_GSTREAMER
2529 sw = gtk_hscale_new_with_range(0.0, 100.0, 5.0);
2530 gtk_range_set_increments(GTK_RANGE(sw), 5.0, 25.0);
2531 gtk_range_set_value(GTK_RANGE(sw), purple_prefs_get_int(PIDGIN_PREFS_ROOT "/sound/volume"));
2532 g_signal_connect (G_OBJECT (sw), "format-value",
2533 G_CALLBACK (prefs_sound_volume_format),
2534 NULL);
2535 g_signal_connect (G_OBJECT (sw), "value-changed",
2536 G_CALLBACK (prefs_sound_volume_changed),
2537 NULL);
2538 hbox = pidgin_add_widget_to_vbox(GTK_BOX(vbox), _("V_olume:"), NULL, sw, TRUE, NULL);
2540 purple_prefs_connect_callback(prefs, PIDGIN_PREFS_ROOT "/sound/method",
2541 sound_changed3_cb, hbox);
2542 sound_changed3_cb(PIDGIN_PREFS_ROOT "/sound/method", PURPLE_PREF_STRING,
2543 purple_prefs_get_string(PIDGIN_PREFS_ROOT "/sound/method"), hbox);
2544 #endif
2546 #ifndef _WIN32
2547 gtk_widget_set_sensitive(vbox,
2548 !purple_strequal(purple_prefs_get_string(PIDGIN_PREFS_ROOT "/sound/method"), "none"));
2549 purple_prefs_connect_callback(prefs, PIDGIN_PREFS_ROOT "/sound/method",
2550 sound_changed2_cb, vbox);
2551 #endif
2552 vbox = pidgin_make_frame(ret, _("Sound Events"));
2554 /* The following is an ugly hack to make the frame expand so the
2555 * sound events list is big enough to be usable */
2556 gtk_box_set_child_packing(GTK_BOX(vbox->parent), vbox, TRUE, TRUE, 0,
2557 GTK_PACK_START);
2558 gtk_box_set_child_packing(GTK_BOX(vbox->parent->parent), vbox->parent, TRUE,
2559 TRUE, 0, GTK_PACK_START);
2560 gtk_box_set_child_packing(GTK_BOX(vbox->parent->parent->parent),
2561 vbox->parent->parent, TRUE, TRUE, 0, GTK_PACK_START);
2563 /* SOUND SELECTION */
2564 event_store = gtk_list_store_new (4, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_UINT);
2566 for (j=0; j < PURPLE_NUM_SOUNDS; j++) {
2567 char *pref = g_strdup_printf(PIDGIN_PREFS_ROOT "/sound/enabled/%s",
2568 pidgin_sound_get_event_option(j));
2569 const char *label = pidgin_sound_get_event_label(j);
2571 if (label == NULL) {
2572 g_free(pref);
2573 continue;
2576 gtk_list_store_append (event_store, &iter);
2577 gtk_list_store_set(event_store, &iter,
2578 0, purple_prefs_get_bool(pref),
2579 1, _(label),
2580 2, pref,
2581 3, j,
2582 -1);
2583 g_free(pref);
2586 event_view = gtk_tree_view_new_with_model (GTK_TREE_MODEL(event_store));
2588 rend = gtk_cell_renderer_toggle_new();
2589 sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (event_view));
2590 g_signal_connect (G_OBJECT (sel), "changed",
2591 G_CALLBACK (prefs_sound_sel),
2592 NULL);
2593 g_signal_connect (G_OBJECT(rend), "toggled",
2594 G_CALLBACK(event_toggled), event_store);
2595 path = gtk_tree_path_new_first();
2596 gtk_tree_selection_select_path(sel, path);
2597 gtk_tree_path_free(path);
2599 col = gtk_tree_view_column_new_with_attributes (_("Play"),
2600 rend,
2601 "active", 0,
2602 NULL);
2603 gtk_tree_view_append_column (GTK_TREE_VIEW(event_view), col);
2605 rend = gtk_cell_renderer_text_new();
2606 col = gtk_tree_view_column_new_with_attributes (_("Event"),
2607 rend,
2608 "text", 1,
2609 NULL);
2610 gtk_tree_view_append_column (GTK_TREE_VIEW(event_view), col);
2611 g_object_unref(G_OBJECT(event_store));
2612 gtk_box_pack_start(GTK_BOX(vbox),
2613 pidgin_make_scrollable(event_view, GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC, GTK_SHADOW_IN, -1, 100),
2614 TRUE, TRUE, 0);
2616 hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE);
2617 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
2618 sound_entry = gtk_entry_new();
2619 pref = g_strdup_printf(PIDGIN_PREFS_ROOT "/sound/file/%s",
2620 pidgin_sound_get_event_option(0));
2621 file = purple_prefs_get_path(pref);
2622 g_free(pref);
2623 gtk_entry_set_text(GTK_ENTRY(sound_entry), (file && *file != '\0') ? file : _("(default)"));
2624 gtk_editable_set_editable(GTK_EDITABLE(sound_entry), FALSE);
2625 gtk_box_pack_start(GTK_BOX(hbox), sound_entry, FALSE, FALSE, PIDGIN_HIG_BOX_SPACE);
2627 button = gtk_button_new_with_mnemonic(_("_Browse..."));
2628 g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(select_sound), NULL);
2629 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 1);
2631 button = gtk_button_new_with_mnemonic(_("Pre_view"));
2632 g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(test_sound), NULL);
2633 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 1);
2635 button = gtk_button_new_with_mnemonic(_("_Reset"));
2636 g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(reset_sound), NULL);
2637 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 1);
2639 gtk_widget_show_all(ret);
2640 g_object_unref(sg);
2642 return ret;
2646 static void
2647 set_idle_away(PurpleSavedStatus *status)
2649 purple_prefs_set_int("/purple/savedstatus/idleaway", purple_savedstatus_get_creation_time(status));
2652 static void
2653 set_startupstatus(PurpleSavedStatus *status)
2655 purple_prefs_set_int("/purple/savedstatus/startup", purple_savedstatus_get_creation_time(status));
2658 static GtkWidget *
2659 away_page(void)
2661 GtkWidget *ret;
2662 GtkWidget *vbox;
2663 GtkWidget *hbox;
2664 GtkWidget *dd;
2665 GtkWidget *label;
2666 GtkWidget *button;
2667 GtkWidget *menu;
2668 GtkSizeGroup *sg;
2670 ret = gtk_vbox_new(FALSE, PIDGIN_HIG_CAT_SPACE);
2671 gtk_container_set_border_width (GTK_CONTAINER (ret), PIDGIN_HIG_BORDER);
2673 sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
2675 /* Idle stuff */
2676 vbox = pidgin_make_frame(ret, _("Idle"));
2678 dd = pidgin_prefs_dropdown(vbox, _("_Report idle time:"),
2679 PURPLE_PREF_STRING, "/purple/away/idle_reporting",
2680 _("Never"), "none",
2681 _("From last sent message"), "purple",
2682 #if defined(USE_SCREENSAVER) || defined(HAVE_IOKIT)
2683 _("Based on keyboard or mouse use"), "system",
2684 #endif
2685 NULL);
2686 gtk_size_group_add_widget(sg, dd);
2687 gtk_misc_set_alignment(GTK_MISC(dd), 0, 0.5);
2689 pidgin_prefs_labeled_spin_button(vbox,
2690 _("_Minutes before becoming idle:"), "/purple/away/mins_before_away",
2691 1, 24 * 60, sg);
2693 hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE);
2694 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
2696 button = pidgin_prefs_checkbox(_("Change to this status when _idle:"),
2697 "/purple/away/away_when_idle", hbox);
2698 gtk_size_group_add_widget(sg, button);
2700 /* TODO: Show something useful if we don't have any saved statuses. */
2701 menu = pidgin_status_menu(purple_savedstatus_get_idleaway(), G_CALLBACK(set_idle_away));
2702 gtk_size_group_add_widget(sg, menu);
2703 gtk_box_pack_start(GTK_BOX(hbox), menu, FALSE, FALSE, 0);
2705 g_signal_connect(G_OBJECT(button), "clicked",
2706 G_CALLBACK(pidgin_toggle_sensitive), menu);
2708 if(!purple_prefs_get_bool("/purple/away/away_when_idle"))
2709 gtk_widget_set_sensitive(GTK_WIDGET(menu), FALSE);
2711 /* Away stuff */
2712 vbox = pidgin_make_frame(ret, _("Away"));
2714 dd = pidgin_prefs_dropdown(vbox, _("_Auto-reply:"),
2715 PURPLE_PREF_STRING, "/purple/away/auto_reply",
2716 _("Never"), "never",
2717 _("When away"), "away",
2718 _("When both away and idle"), "awayidle",
2719 NULL);
2720 gtk_size_group_add_widget(sg, dd);
2721 gtk_misc_set_alignment(GTK_MISC(dd), 0, 0.5);
2723 /* Signon status stuff */
2724 vbox = pidgin_make_frame(ret, _("Status at Startup"));
2726 button = pidgin_prefs_checkbox(_("Use status from last _exit at startup"),
2727 "/purple/savedstatus/startup_current_status", vbox);
2728 gtk_size_group_add_widget(sg, button);
2730 /* TODO: Show something useful if we don't have any saved statuses. */
2731 menu = pidgin_status_menu(purple_savedstatus_get_startup(), G_CALLBACK(set_startupstatus));
2732 gtk_size_group_add_widget(sg, menu);
2733 g_signal_connect(G_OBJECT(button), "clicked",
2734 G_CALLBACK(pidgin_toggle_sensitive), menu);
2735 pidgin_add_widget_to_vbox(GTK_BOX(vbox), _("Status to a_pply at startup:"), sg, menu, TRUE, &label);
2736 g_signal_connect(G_OBJECT(button), "clicked",
2737 G_CALLBACK(pidgin_toggle_sensitive), label);
2739 if(purple_prefs_get_bool("/purple/savedstatus/startup_current_status")) {
2740 gtk_widget_set_sensitive(GTK_WIDGET(menu), FALSE);
2741 gtk_widget_set_sensitive(GTK_WIDGET(label), FALSE);
2744 gtk_widget_show_all(ret);
2745 g_object_unref(sg);
2747 return ret;
2750 static int
2751 prefs_notebook_add_page(const char *text, GtkWidget *page, int ind)
2753 return gtk_notebook_append_page(GTK_NOTEBOOK(prefsnotebook), page, gtk_label_new(text));
2756 static void
2757 prefs_notebook_init(void)
2759 prefs_notebook_add_page(_("Interface"), interface_page(), notebook_page++);
2761 #ifndef _WIN32
2762 /* We use the registered default browser in windows */
2763 /* if the user is running Mac OS X, hide the browsers tab */
2764 if(purple_running_osx() == FALSE)
2765 prefs_notebook_add_page(_("Browser"), browser_page(), notebook_page++);
2766 #endif
2768 prefs_notebook_add_page(_("Conversations"), conv_page(), notebook_page++);
2769 prefs_notebook_add_page(_("Logging"), logging_page(), notebook_page++);
2770 prefs_notebook_add_page(_("Network"), network_page(), notebook_page++);
2771 prefs_notebook_add_page(_("Proxy"), proxy_page(), notebook_page++);
2773 prefs_notebook_add_page(_("Sounds"), sound_page(), notebook_page++);
2774 prefs_notebook_add_page(_("Status / Idle"), away_page(), notebook_page++);
2775 prefs_notebook_add_page(_("Themes"), theme_page(), notebook_page++);
2778 void
2779 pidgin_prefs_show(void)
2781 GtkWidget *vbox;
2782 GtkWidget *notebook;
2783 GtkWidget *button;
2785 if (prefs) {
2786 gtk_window_present(GTK_WINDOW(prefs));
2787 return;
2790 /* copy the preferences to tmp values...
2791 * I liked "take affect immediately" Oh well :-( */
2792 /* (that should have been "effect," right?) */
2794 /* Back to instant-apply! I win! BU-HAHAHA! */
2796 /* Create the window */
2797 prefs = pidgin_create_dialog(_("Preferences"), PIDGIN_HIG_BORDER, "preferences", FALSE);
2798 g_signal_connect(G_OBJECT(prefs), "destroy",
2799 G_CALLBACK(delete_prefs), NULL);
2801 vbox = pidgin_dialog_get_vbox_with_properties(GTK_DIALOG(prefs), FALSE, PIDGIN_HIG_BORDER);
2803 /* The notebook */
2804 prefsnotebook = notebook = gtk_notebook_new ();
2805 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(notebook), GTK_POS_LEFT);
2806 gtk_box_pack_start(GTK_BOX (vbox), notebook, FALSE, FALSE, 0);
2807 gtk_widget_show(prefsnotebook);
2809 button = pidgin_dialog_add_button(GTK_DIALOG(prefs), GTK_STOCK_CLOSE, NULL, NULL);
2810 g_signal_connect_swapped(G_OBJECT(button), "clicked",
2811 G_CALLBACK(gtk_widget_destroy), prefs);
2813 prefs_notebook_init();
2815 /* Refresh the list of themes before showing the preferences window */
2816 prefs_themes_refresh();
2818 /* Show everything. */
2819 gtk_widget_show(prefs);
2822 static void
2823 set_bool_pref(GtkWidget *w, const char *key)
2825 purple_prefs_set_bool(key,
2826 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w)));
2829 GtkWidget *
2830 pidgin_prefs_checkbox(const char *text, const char *key, GtkWidget *page)
2832 GtkWidget *button;
2834 button = gtk_check_button_new_with_mnemonic(text);
2835 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button),
2836 purple_prefs_get_bool(key));
2838 gtk_box_pack_start(GTK_BOX(page), button, FALSE, FALSE, 0);
2840 g_signal_connect(G_OBJECT(button), "clicked",
2841 G_CALLBACK(set_bool_pref), (char *)key);
2843 gtk_widget_show(button);
2845 return button;
2848 static void
2849 smiley_theme_pref_cb(const char *name, PurplePrefType type,
2850 gconstpointer value, gpointer data)
2852 const char *themename = value;
2853 GSList *themes;
2855 for (themes = smiley_themes; themes; themes = themes->next) {
2856 struct smiley_theme *smile = themes->data;
2857 if (smile->name && purple_strequal(themename, smile->name)) {
2858 pidgin_themes_load_smiley_theme(smile->path, TRUE);
2859 break;
2864 void
2865 pidgin_prefs_init(void)
2867 purple_prefs_add_none(PIDGIN_PREFS_ROOT "");
2868 purple_prefs_add_none("/plugins/gtk");
2870 #ifndef _WIN32
2871 /* Browsers */
2872 purple_prefs_add_none(PIDGIN_PREFS_ROOT "/browsers");
2873 purple_prefs_add_int(PIDGIN_PREFS_ROOT "/browsers/place", PIDGIN_BROWSER_DEFAULT);
2874 purple_prefs_add_string(PIDGIN_PREFS_ROOT "/browsers/manual_command", "");
2875 purple_prefs_add_string(PIDGIN_PREFS_ROOT "/browsers/browser", "xdg-open");
2876 #endif
2878 /* Plugins */
2879 purple_prefs_add_none(PIDGIN_PREFS_ROOT "/plugins");
2880 purple_prefs_add_path_list(PIDGIN_PREFS_ROOT "/plugins/loaded", NULL);
2882 /* File locations */
2883 purple_prefs_add_none(PIDGIN_PREFS_ROOT "/filelocations");
2884 purple_prefs_add_path(PIDGIN_PREFS_ROOT "/filelocations/last_save_folder", "");
2885 purple_prefs_add_path(PIDGIN_PREFS_ROOT "/filelocations/last_open_folder", "");
2886 purple_prefs_add_path(PIDGIN_PREFS_ROOT "/filelocations/last_icon_folder", "");
2888 /* Themes */
2889 prefs_themes_init();
2891 /* Smiley Themes */
2892 purple_prefs_add_none(PIDGIN_PREFS_ROOT "/smileys");
2893 purple_prefs_add_string(PIDGIN_PREFS_ROOT "/smileys/theme", "Default");
2895 /* Smiley Callbacks */
2896 purple_prefs_connect_callback(&prefs, PIDGIN_PREFS_ROOT "/smileys/theme",
2897 smiley_theme_pref_cb, NULL);
2899 pidgin_prefs_update_old();
2902 void
2903 pidgin_prefs_update_old(void)
2905 const char *str = NULL;
2907 purple_prefs_rename("/gaim/gtk", PIDGIN_PREFS_ROOT);
2909 /* Rename some old prefs */
2910 purple_prefs_rename(PIDGIN_PREFS_ROOT "/logging/log_ims", "/purple/logging/log_ims");
2911 purple_prefs_rename(PIDGIN_PREFS_ROOT "/logging/log_chats", "/purple/logging/log_chats");
2912 purple_prefs_rename("/purple/conversations/placement",
2913 PIDGIN_PREFS_ROOT "/conversations/placement");
2915 purple_prefs_rename(PIDGIN_PREFS_ROOT "/debug/timestamps", "/purple/debug/timestamps");
2916 purple_prefs_rename(PIDGIN_PREFS_ROOT "/conversations/im/raise_on_events", "/plugins/gtk/X11/notify/method_raise");
2918 purple_prefs_rename_boolean_toggle(PIDGIN_PREFS_ROOT "/conversations/ignore_colors",
2919 PIDGIN_PREFS_ROOT "/conversations/show_incoming_formatting");
2922 * this path pref changed to a string, so migrate. I know this will break
2923 * things for and confuse users that use multiple versions with the same
2924 * config directory, but I'm not inclined to want to deal with that at the
2925 * moment. -- rekkanoryo
2927 if((str = purple_prefs_get_path(PIDGIN_PREFS_ROOT "/browsers/command")) != NULL) {
2928 purple_prefs_set_string(PIDGIN_PREFS_ROOT "/browsers/manual_command", str);
2929 purple_prefs_remove(PIDGIN_PREFS_ROOT "/browsers/command");
2932 /* this string pref moved into the core, try to be friendly */
2933 purple_prefs_rename(PIDGIN_PREFS_ROOT "/idle/reporting_method", "/purple/away/idle_reporting");
2934 if ((str = purple_prefs_get_string("/purple/away/idle_reporting")) &&
2935 purple_strequal(str, "gaim"))
2936 purple_prefs_set_string("/purple/away/idle_reporting", "purple");
2938 /* Remove some no-longer-used prefs */
2939 purple_prefs_remove(PIDGIN_PREFS_ROOT "/blist/auto_expand_contacts");
2940 purple_prefs_remove(PIDGIN_PREFS_ROOT "/blist/button_style");
2941 purple_prefs_remove(PIDGIN_PREFS_ROOT "/blist/grey_idle_buddies");
2942 purple_prefs_remove(PIDGIN_PREFS_ROOT "/blist/raise_on_events");
2943 purple_prefs_remove(PIDGIN_PREFS_ROOT "/blist/show_group_count");
2944 purple_prefs_remove(PIDGIN_PREFS_ROOT "/blist/show_warning_level");
2945 purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/button_type");
2946 purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/ctrl_enter_sends");
2947 purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/enter_sends");
2948 purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/escape_closes");
2949 purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/html_shortcuts");
2950 purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/icons_on_tabs");
2951 purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/send_formatting");
2952 purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/show_smileys");
2953 purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/show_urls_as_links");
2954 purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/smiley_shortcuts");
2955 purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/use_custom_bgcolor");
2956 purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/use_custom_fgcolor");
2957 purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/use_custom_font");
2958 purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/use_custom_size");
2959 purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/chat/old_tab_complete");
2960 purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/chat/tab_completion");
2961 purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/im/hide_on_send");
2962 purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/chat/color_nicks");
2963 purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/chat/raise_on_events");
2964 purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/ignore_fonts");
2965 purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/ignore_font_sizes");
2966 purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/passthrough_unknown_commands");
2967 purple_prefs_remove(PIDGIN_PREFS_ROOT "/idle");
2968 purple_prefs_remove(PIDGIN_PREFS_ROOT "/logging/individual_logs");
2969 purple_prefs_remove(PIDGIN_PREFS_ROOT "/sound/signon");
2970 purple_prefs_remove(PIDGIN_PREFS_ROOT "/sound/silent_signon");
2972 /* Convert old queuing prefs to hide_new 3-way pref. */
2973 if (purple_prefs_exists("/plugins/gtk/docklet/queue_messages") &&
2974 purple_prefs_get_bool("/plugins/gtk/docklet/queue_messages"))
2976 purple_prefs_set_string(PIDGIN_PREFS_ROOT "/conversations/im/hide_new", "always");
2978 else if (purple_prefs_exists(PIDGIN_PREFS_ROOT "/away/queue_messages") &&
2979 purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/away/queue_messages"))
2981 purple_prefs_set_string(PIDGIN_PREFS_ROOT "/conversations/im/hide_new", "away");
2983 purple_prefs_remove(PIDGIN_PREFS_ROOT "/away/queue_messages");
2984 purple_prefs_remove(PIDGIN_PREFS_ROOT "/away");
2985 purple_prefs_remove("/plugins/gtk/docklet/queue_messages");
2987 purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/chat/default_width");
2988 purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/chat/default_height");
2989 purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/im/default_width");
2990 purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/im/default_height");
2991 purple_prefs_rename(PIDGIN_PREFS_ROOT "/conversations/x",
2992 PIDGIN_PREFS_ROOT "/conversations/im/x");
2993 purple_prefs_rename(PIDGIN_PREFS_ROOT "/conversations/y",
2994 PIDGIN_PREFS_ROOT "/conversations/im/y");