2 * @file gtkprefs.c GTK+ Preferences
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
37 #include "savedstatuses.h"
39 #include "sound-theme.h"
41 #include "theme-manager.h"
49 #include "gtkdialogs.h"
50 #include "gtkimhtml.h"
51 #include "gtkimhtmltoolbar.h"
53 #include "gtksavedstatuses.h"
55 #include "gtkstatus-icon-theme.h"
56 #include "gtkthemes.h"
58 #include "pidginstock.h"
65 #define PREFS_OPTIMAL_ICON_SIZE 32
74 static GtkWidget
*prefs
= NULL
;
77 static GtkWidget
*prefsnotebook
= NULL
;
78 static int notebook_page
= 0;
80 /* Conversations page */
81 static GtkWidget
*sample_imhtml
= NULL
;
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
;
103 static void delete_prefs(GtkWidget
*, void *);
106 update_spin_value(GtkWidget
*w
, GtkWidget
*spin
)
108 const char *key
= g_object_get_data(G_OBJECT(spin
), "val");
111 value
= gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spin
));
113 purple_prefs_set_int(key
, value
);
117 pidgin_prefs_labeled_spin_button(GtkWidget
*box
, const gchar
*title
,
118 const char *key
, int min
, int max
, GtkSizeGroup
*sg
)
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
);
130 gtk_widget_set_size_request(spin
, 50, -1);
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
);
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
));
149 pidgin_prefs_labeled_entry(GtkWidget
*page
, const gchar
*title
,
150 const char *key
, GtkSizeGroup
*sg
)
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
);
167 pidgin_prefs_labeled_password(GtkWidget
*page
, const gchar
*title
,
168 const char *key
, GtkSizeGroup
*sg
)
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
);
187 dropdown_set(GObject
*w
, const char *key
)
189 const char *str_value
;
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")));
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
;
218 const char *stored_str
= NULL
;
221 const char *str_value
= NULL
;
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",
257 g_signal_connect(G_OBJECT(opt
), "activate",
258 G_CALLBACK(dropdown_set
), (char *)key
);
260 gtk_widget_show(opt
);
261 gtk_menu_shell_append(GTK_MENU_SHELL(menu
), opt
);
263 if ((type
== PURPLE_PREF_INT
&& stored_int
== int_value
) ||
264 (type
== PURPLE_PREF_STRING
&& stored_str
!= NULL
&&
265 !strcmp(stored_str
, str_value
)) ||
266 (type
== PURPLE_PREF_BOOLEAN
&&
267 (purple_prefs_get_bool(key
) == GPOINTER_TO_INT(menuitems
->data
)))) {
269 gtk_menu_set_active(GTK_MENU(menu
), o
);
272 menuitems
= g_list_next(menuitems
);
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
);
285 pidgin_prefs_dropdown(GtkWidget
*box
, const gchar
*title
, PurplePrefType type
,
286 const char *key
, ...)
289 GList
*menuitems
= NULL
;
290 GtkWidget
*dropdown
= NULL
;
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
);
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
));
308 str_value
= va_arg(ap
, const char *);
309 menuitems
= g_list_prepend(menuitems
, (char *)str_value
);
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
,
321 g_list_free(menuitems
);
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 */
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
;
348 prefsnotebook
= NULL
;
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
: "");
364 smileys_refresh_theme_list(void)
370 pidgin_themes_smiley_theme_probe();
372 if (!(themes
= smiley_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
? gdk_pixbuf_new_from_file(theme
->icon
, NULL
) : NULL
);
387 gtk_list_store_set(prefs_smiley_themes
, &iter
,
394 g_object_unref(G_OBJECT(pixbuf
));
397 themes
= themes
->next
;
401 /* Rebuild the markup for the sound theme selection for "(Custom)" themes */
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
;
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
)) {
416 gtk_tree_model_get(GTK_TREE_MODEL(prefs_sound_themes
), &iter
, 2, &name
, -1);
418 print_custom
= customized
&& name
&& g_str_equal(current_theme
, name
);
420 if (!name
|| *name
== '\0') {
422 name
= g_strdup(_("Default"));
423 author
= _("Penguin Pimps");
424 description
= _("The default Pidgin sound theme");
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);
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 */
444 prefs_themes_sort(PurpleTheme
*theme
)
446 GdkPixbuf
*pixbuf
= NULL
;
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
= gdk_pixbuf_new_from_file_at_scale(image_full
, PREFS_OPTIMAL_ICON_SIZE
, PREFS_OPTIMAL_ICON_SIZE
, TRUE
, 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);
464 g_object_unref(G_OBJECT(pixbuf
));
466 } else if (PIDGIN_IS_BLIST_THEME(theme
) || PIDGIN_IS_STATUS_ICON_THEME(theme
)){
469 if (PIDGIN_IS_BLIST_THEME(theme
))
470 store
= prefs_blist_themes
;
472 store
= prefs_status_icon_themes
;
474 image_full
= purple_theme_get_image_full(theme
);
475 if (image_full
!= NULL
){
476 pixbuf
= gdk_pixbuf_new_from_file_at_scale(image_full
, PREFS_OPTIMAL_ICON_SIZE
, PREFS_OPTIMAL_ICON_SIZE
, TRUE
, 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);
492 g_object_unref(G_OBJECT(pixbuf
));
497 prefs_set_active_theme_combo(GtkWidget
*combo_box
, GtkListStore
*store
, const gchar
*current_theme
)
501 gboolean unset
= TRUE
;
503 if (current_theme
&& *current_theme
&& gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store
), &iter
)) {
505 gtk_tree_model_get(GTK_TREE_MODEL(store
), &iter
, 2, &theme
, -1);
507 if (g_str_equal(current_theme
, theme
)) {
508 gtk_combo_box_set_active_iter(GTK_COMBO_BOX(combo_box
), &iter
);
513 } while (gtk_tree_model_iter_next(GTK_TREE_MODEL(store
), &iter
));
517 gtk_combo_box_set_active(GTK_COMBO_BOX(combo_box
), 0);
521 prefs_themes_refresh(void)
523 GdkPixbuf
*pixbuf
= NULL
;
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
= gdk_pixbuf_new_from_file_at_scale(tmp
, PREFS_OPTIMAL_ICON_SIZE
, PREFS_OPTIMAL_ICON_SIZE
, TRUE
, NULL
);
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);
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);
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);
556 g_object_unref(G_OBJECT(pixbuf
));
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();
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 */
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
);
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
);
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
);
607 /* Eww. Seriously ewww. But thanks, grim! This is taken from guifications2 */
609 purple_theme_file_copy(const gchar
*source
, const gchar
*destination
)
614 if(!(src
= g_fopen(source
, "rb")))
616 if(!(dest
= g_fopen(destination
, "wb"))) {
621 while((chr
= fgetc(src
)) != EOF
) {
632 free_theme_info(struct theme_info
*info
)
636 g_free(info
->extension
);
637 g_free(info
->original_name
);
642 /* installs a theme, info is freed by function */
644 theme_install_theme(char *path
, struct theme_info
*info
)
651 gboolean is_smiley_theme
, is_archive
;
652 PurpleTheme
*theme
= NULL
;
657 /* check the extension */
658 tail
= info
->extension
? info
->extension
: strrchr(path
, '.');
661 free_theme_info(info
);
665 is_archive
= !g_ascii_strcasecmp(tail
, ".gz") || !g_ascii_strcasecmp(tail
, ".tgz");
667 /* Just to be safe */
670 if ((is_smiley_theme
= g_str_equal(info
->type
, "smiley")))
671 destdir
= g_build_filename(purple_user_dir(), "smileys", NULL
);
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 */
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
);
690 if (system(command
)) {
691 purple_notify_error(NULL
, NULL
, _("Theme failed to unpack."), NULL
);
694 free_theme_info(info
);
698 if (!winpidgin_gz_untar(path
, destdir
)) {
699 purple_notify_error(NULL
, NULL
, _("Theme failed to unpack."), NULL
);
701 free_theme_info(info
);
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
);
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
);
733 g_object_unref(theme
);
735 prefs_themes_refresh();
738 /* something was wrong with the theme archive */
740 purple_notify_error(NULL
, NULL
, _("Theme failed to load."), NULL
);
743 } else { /* just a single file so copy it to a new temp directory and attempt to load it*/
744 gchar
*temp_path
, *temp_file
;
746 temp_path
= g_build_filename(purple_user_dir(), "themes", "temp", "sub_folder", NULL
);
748 if (info
->original_name
!= NULL
) {
749 /* name was changed from the original (probably a dnd) change it back before loading */
750 temp_file
= g_build_filename(temp_path
, info
->original_name
, NULL
);
753 gchar
*source_name
= g_path_get_basename(path
);
754 temp_file
= g_build_filename(temp_path
, source_name
, NULL
);
758 if (!g_file_test(temp_path
, G_FILE_TEST_IS_DIR
))
759 purple_build_dir(temp_path
, S_IRUSR
| S_IWUSR
| S_IXUSR
);
761 if (purple_theme_file_copy(path
, temp_file
)) {
762 /* find the theme, could be in subfolder */
763 theme
= prefs_theme_find_theme(temp_path
, info
->type
);
765 if (PURPLE_IS_THEME(theme
)) {
766 gchar
*theme_dest
= g_build_filename(purple_user_dir(), "themes",
767 purple_theme_get_name(theme
),
768 "purple", info
->type
, NULL
);
770 if(!g_file_test(theme_dest
, G_FILE_TEST_IS_DIR
))
771 purple_build_dir(theme_dest
, S_IRUSR
| S_IWUSR
| S_IXUSR
);
773 g_rename(purple_theme_get_dir(theme
), theme_dest
);
776 g_object_unref(theme
);
778 prefs_themes_refresh();
781 purple_notify_error(NULL
, NULL
, _("Theme failed to load."), NULL
);
784 purple_notify_error(NULL
, NULL
, _("Theme failed to copy."), NULL
);
792 free_theme_info(info
);
796 theme_got_url(PurpleUtilFetchUrlData
*url_data
, gpointer user_data
,
797 const gchar
*themedata
, size_t len
, const gchar
*error_message
)
803 if ((error_message
!= NULL
) || (len
== 0)) {
804 free_theme_info(user_data
);
808 f
= purple_mkstemp(&path
, TRUE
);
809 wc
= fwrite(themedata
, len
, 1, f
);
811 purple_debug_warning("theme_got_url", "Unable to write theme data.\n");
815 free_theme_info(user_data
);
820 theme_install_theme(path
, user_data
);
827 theme_dnd_recv(GtkWidget
*widget
, GdkDragContext
*dc
, guint x
, guint y
,
828 GtkSelectionData
*sd
, guint info
, guint t
, gpointer user_data
)
830 gchar
*name
= g_strchomp((gchar
*)sd
->data
);
832 if ((sd
->length
>= 0) && (sd
->format
== 8)) {
833 /* Well, it looks like the drag event was cool.
834 * Let's do something with it */
836 struct theme_info
*info
= g_new0(struct theme_info
, 1);
837 info
->type
= g_strdup((gchar
*)user_data
);
838 info
->extension
= g_strdup(g_strrstr(name
,"."));
839 temp
= g_strrstr(name
, "/");
840 info
->original_name
= temp
? g_strdup(++temp
) : NULL
;
842 if (!g_ascii_strncasecmp(name
, "file://", 7)) {
843 GError
*converr
= NULL
;
845 /* It looks like we're dealing with a local file. Let's
846 * just untar it in the right place */
847 if(!(tmp
= g_filename_from_uri(name
, NULL
, &converr
))) {
848 purple_debug(PURPLE_DEBUG_ERROR
, "theme dnd", "%s\n",
849 (converr
? converr
->message
:
850 "g_filename_from_uri error"));
851 free_theme_info(info
);
854 theme_install_theme(tmp
, info
);
856 } else if (!g_ascii_strncasecmp(name
, "http://", 7)) {
857 /* Oo, a web drag and drop. This is where things
858 * will start to get interesting */
859 purple_util_fetch_url(name
, TRUE
, NULL
, FALSE
, theme_got_url
, info
);
860 } else if (!g_ascii_strncasecmp(name
, "https://", 8)) {
861 /* purple_util_fetch_url() doesn't support HTTPS, but we want users
862 * to be able to drag and drop links from the SF trackers, so
863 * we'll try it as an HTTP URL. */
864 char *tmp
= g_strdup(name
+ 1);
870 purple_util_fetch_url(tmp
, TRUE
, NULL
, FALSE
, theme_got_url
, info
);
873 free_theme_info(info
);
875 gtk_drag_finish(dc
, TRUE
, FALSE
, t
);
878 gtk_drag_finish(dc
, FALSE
, FALSE
, t
);
881 /* builds a theme combo box from a list store with colums: icon preview, markup, theme name */
883 prefs_build_theme_combo_box(GtkListStore
*store
, const char *current_theme
, const char *type
)
885 GtkCellRenderer
*cell_rend
;
886 GtkWidget
*combo_box
;
887 GtkTargetEntry te
[3] = {
888 {"text/plain", 0, 0},
889 {"text/uri-list", 0, 1},
893 g_return_val_if_fail(store
!= NULL
&& current_theme
!= NULL
, NULL
);
895 combo_box
= gtk_combo_box_new_with_model(GTK_TREE_MODEL(store
));
897 cell_rend
= gtk_cell_renderer_pixbuf_new();
898 gtk_cell_renderer_set_fixed_size(cell_rend
, PREFS_OPTIMAL_ICON_SIZE
, PREFS_OPTIMAL_ICON_SIZE
);
899 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT (combo_box
), cell_rend
, FALSE
);
900 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo_box
), cell_rend
, "pixbuf", 0, NULL
);
902 cell_rend
= gtk_cell_renderer_text_new();
903 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT (combo_box
), cell_rend
, TRUE
);
904 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo_box
), cell_rend
, "markup", 1, NULL
);
905 g_object_set(cell_rend
, "ellipsize", PANGO_ELLIPSIZE_END
, NULL
);
907 gtk_drag_dest_set(combo_box
, GTK_DEST_DEFAULT_MOTION
| GTK_DEST_DEFAULT_HIGHLIGHT
| GTK_DEST_DEFAULT_DROP
, te
,
908 sizeof(te
) / sizeof(GtkTargetEntry
) , GDK_ACTION_COPY
| GDK_ACTION_MOVE
);
910 g_signal_connect(G_OBJECT(combo_box
), "drag_data_received", G_CALLBACK(theme_dnd_recv
), (gpointer
) type
);
915 /* sets the current sound theme */
917 prefs_set_sound_theme_cb(GtkComboBox
*combo_box
, gpointer user_data
)
922 GtkTreeIter new_iter
;
924 if(gtk_combo_box_get_active_iter(combo_box
, &new_iter
) && !prefs_sound_themes_loading
) {
926 gtk_tree_model_get(GTK_TREE_MODEL(prefs_sound_themes
), &new_iter
, 2, &new_theme
, -1);
928 purple_prefs_set_string(PIDGIN_PREFS_ROOT
"/sound/theme", new_theme
);
930 /* New theme removes all customization */
931 for(i
= 0; i
< PURPLE_NUM_SOUNDS
; i
++){
932 pref
= g_strdup_printf(PIDGIN_PREFS_ROOT
"/sound/file/%s",
933 pidgin_sound_get_event_option(i
));
934 purple_prefs_set_path(pref
, "");
938 /* gets rid of the "(Custom)" from the last selection */
939 pref_sound_generate_markup();
941 gtk_entry_set_text(GTK_ENTRY(sound_entry
), _("(default)"));
947 /* sets the current smiley theme */
949 prefs_set_smiley_theme_cb(GtkComboBox
*combo_box
, gpointer user_data
)
952 GtkTreeIter new_iter
;
954 if (gtk_combo_box_get_active_iter(combo_box
, &new_iter
)) {
956 gtk_tree_model_get(GTK_TREE_MODEL(prefs_smiley_themes
), &new_iter
, 2, &new_theme
, -1);
958 purple_prefs_set_string(PIDGIN_PREFS_ROOT
"/smileys/theme", new_theme
);
959 pidgin_themes_smiley_themeize(sample_imhtml
);
966 /* Does same as normal sort, except "none" is sorted first */
967 static gint
pidgin_sort_smileys (GtkTreeModel
*model
,
973 gchar
*name1
= NULL
, *name2
= NULL
;
975 gtk_tree_model_get(model
, a
, 2, &name1
, -1);
976 gtk_tree_model_get(model
, b
, 2, &name2
, -1);
978 if (name1
== NULL
|| name2
== NULL
) {
979 if (!(name1
== NULL
&& name2
== NULL
))
980 ret
= (name1
== NULL
) ? -1: 1;
981 } else if (!g_ascii_strcasecmp(name1
, "none")) {
982 if (!g_utf8_collate(name1
, name2
))
985 /* Sort name1 first */
987 } else if (!g_ascii_strcasecmp(name2
, "none")) {
988 /* Sort name2 first */
991 /* Neither string is "none", default to normal sort */
992 ret
= purple_utf8_strcasecmp(name1
, name2
);
1001 /* sets the current buddy list theme */
1003 prefs_set_blist_theme_cb(GtkComboBox
*combo_box
, gpointer user_data
)
1005 PidginBlistTheme
*theme
= NULL
;
1009 if(gtk_combo_box_get_active_iter(combo_box
, &iter
)) {
1011 gtk_tree_model_get(GTK_TREE_MODEL(prefs_blist_themes
), &iter
, 2, &name
, -1);
1013 if(!name
|| !g_str_equal(name
, ""))
1014 theme
= PIDGIN_BLIST_THEME(purple_theme_manager_find_theme(name
, "blist"));
1018 pidgin_blist_set_theme(theme
);
1022 /* sets the current icon theme */
1024 prefs_set_status_icon_theme_cb(GtkComboBox
*combo_box
, gpointer user_data
)
1026 PidginStatusIconTheme
*theme
= NULL
;
1030 if(gtk_combo_box_get_active_iter(combo_box
, &iter
)) {
1032 gtk_tree_model_get(GTK_TREE_MODEL(prefs_status_icon_themes
), &iter
, 2, &name
, -1);
1034 if(!name
|| !g_str_equal(name
, ""))
1035 theme
= PIDGIN_STATUS_ICON_THEME(purple_theme_manager_find_theme(name
, "status-icon"));
1039 pidgin_stock_load_status_icon_theme(theme
);
1040 pidgin_blist_refresh(purple_get_blist());
1045 add_theme_prefs_combo(GtkWidget
*vbox
,
1046 GtkSizeGroup
*combo_sg
, GtkSizeGroup
*label_sg
,
1047 GtkListStore
*theme_store
,
1048 GCallback combo_box_cb
, gpointer combo_box_cb_user_data
,
1049 const char *label_str
, const char *prefs_path
,
1050 const char *theme_type
)
1053 GtkWidget
*combo_box
= NULL
;
1054 GtkWidget
*themesel_hbox
= gtk_hbox_new(FALSE
, PIDGIN_HIG_BOX_SPACE
);
1056 label
= gtk_label_new(label_str
);
1057 gtk_misc_set_alignment(GTK_MISC(label
), 0, 0.5);
1058 gtk_size_group_add_widget(label_sg
, label
);
1059 gtk_box_pack_start(GTK_BOX(themesel_hbox
), label
, FALSE
, FALSE
, 0);
1061 combo_box
= prefs_build_theme_combo_box(theme_store
,
1062 purple_prefs_get_string(prefs_path
),
1064 g_signal_connect(G_OBJECT(combo_box
), "changed",
1065 (GCallback
)combo_box_cb
, combo_box_cb_user_data
);
1066 gtk_size_group_add_widget(combo_sg
, combo_box
);
1067 gtk_box_pack_start(GTK_BOX(themesel_hbox
), combo_box
, TRUE
, TRUE
, 0);
1069 gtk_box_pack_start(GTK_BOX(vbox
), themesel_hbox
, FALSE
, FALSE
, 0);
1078 GtkWidget
*ret
, *vbox
;
1079 GtkSizeGroup
*label_sg
= gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL
);
1080 GtkSizeGroup
*combo_sg
= gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL
);
1082 ret
= gtk_vbox_new(FALSE
, PIDGIN_HIG_CAT_SPACE
);
1083 gtk_container_set_border_width (GTK_CONTAINER (ret
), PIDGIN_HIG_BORDER
);
1085 vbox
= pidgin_make_frame(ret
, _("Theme Selections"));
1088 label
= gtk_label_new(_("Select a theme that you would like to use from "
1089 "the lists below.\nNew themes can be installed by "
1090 "dragging and dropping them onto the theme list."));
1092 gtk_misc_set_alignment(GTK_MISC(label
), 0, 0.5);
1093 gtk_label_set_justify(GTK_LABEL(label
), GTK_JUSTIFY_LEFT
);
1095 gtk_box_pack_start(GTK_BOX(vbox
), label
, TRUE
, FALSE
, 0);
1096 gtk_widget_show(label
);
1098 /* Buddy List Themes */
1099 prefs_blist_themes_combo_box
= add_theme_prefs_combo(
1100 vbox
, combo_sg
, label_sg
, prefs_blist_themes
,
1101 (GCallback
)prefs_set_blist_theme_cb
, NULL
,
1102 _("Buddy List Theme:"), PIDGIN_PREFS_ROOT
"/blist/theme", "blist");
1104 /* Status Icon Themes */
1105 prefs_status_themes_combo_box
= add_theme_prefs_combo(
1106 vbox
, combo_sg
, label_sg
, prefs_status_icon_themes
,
1107 (GCallback
)prefs_set_status_icon_theme_cb
, NULL
,
1108 _("Status Icon Theme:"), PIDGIN_PREFS_ROOT
"/status/icon-theme", "icon");
1111 prefs_sound_themes_combo_box
= add_theme_prefs_combo(
1112 vbox
, combo_sg
, label_sg
, prefs_sound_themes
,
1113 (GCallback
)prefs_set_sound_theme_cb
, NULL
,
1114 _("Sound Theme:"), PIDGIN_PREFS_ROOT
"/sound/theme", "sound");
1117 prefs_smiley_themes_combo_box
= add_theme_prefs_combo(
1118 vbox
, combo_sg
, label_sg
, prefs_smiley_themes
,
1119 (GCallback
)prefs_set_smiley_theme_cb
, NULL
,
1120 _("Smiley Theme:"), PIDGIN_PREFS_ROOT
"/smileys/theme", "smiley");
1122 /* Custom sort so "none" theme is at top of list */
1123 gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(prefs_smiley_themes
),
1124 2, pidgin_sort_smileys
, NULL
, NULL
);
1125 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(prefs_smiley_themes
),
1126 2, GTK_SORT_ASCENDING
);
1128 gtk_widget_show_all(ret
);
1134 formatting_toggle_cb(GtkIMHtml
*imhtml
, GtkIMHtmlButtons buttons
, void *toolbar
)
1136 gboolean bold
, italic
, uline
;
1138 gtk_imhtml_get_current_format(GTK_IMHTML(imhtml
),
1139 &bold
, &italic
, &uline
);
1141 if (buttons
& GTK_IMHTML_BOLD
)
1142 purple_prefs_set_bool(PIDGIN_PREFS_ROOT
"/conversations/send_bold", bold
);
1143 if (buttons
& GTK_IMHTML_ITALIC
)
1144 purple_prefs_set_bool(PIDGIN_PREFS_ROOT
"/conversations/send_italic", italic
);
1145 if (buttons
& GTK_IMHTML_UNDERLINE
)
1146 purple_prefs_set_bool(PIDGIN_PREFS_ROOT
"/conversations/send_underline", uline
);
1148 if (buttons
& GTK_IMHTML_GROW
|| buttons
& GTK_IMHTML_SHRINK
)
1149 purple_prefs_set_int(PIDGIN_PREFS_ROOT
"/conversations/font_size",
1150 gtk_imhtml_get_current_fontsize(GTK_IMHTML(imhtml
)));
1151 if (buttons
& GTK_IMHTML_FACE
) {
1152 char *face
= gtk_imhtml_get_current_fontface(GTK_IMHTML(imhtml
));
1154 face
= g_strdup("");
1156 purple_prefs_set_string(PIDGIN_PREFS_ROOT
"/conversations/font_face", face
);
1160 if (buttons
& GTK_IMHTML_FORECOLOR
) {
1161 char *color
= gtk_imhtml_get_current_forecolor(GTK_IMHTML(imhtml
));
1163 color
= g_strdup("");
1165 purple_prefs_set_string(PIDGIN_PREFS_ROOT
"/conversations/fgcolor", color
);
1169 if (buttons
& GTK_IMHTML_BACKCOLOR
) {
1173 color
= gtk_imhtml_get_current_backcolor(GTK_IMHTML(imhtml
));
1175 color
= g_strdup("");
1177 /* Block the signal to prevent a loop. */
1178 object
= g_object_ref(G_OBJECT(imhtml
));
1179 g_signal_handlers_block_matched(object
, G_SIGNAL_MATCH_DATA
, 0, 0, NULL
,
1181 /* Clear the backcolor. */
1182 gtk_imhtml_toggle_backcolor(GTK_IMHTML(imhtml
), "");
1183 /* Unblock the signal. */
1184 g_signal_handlers_unblock_matched(object
, G_SIGNAL_MATCH_DATA
, 0, 0, NULL
,
1186 g_object_unref(object
);
1188 /* This will fire a toggle signal and get saved below. */
1189 gtk_imhtml_toggle_background(GTK_IMHTML(imhtml
), color
);
1194 if (buttons
& GTK_IMHTML_BACKGROUND
) {
1195 char *color
= gtk_imhtml_get_current_background(GTK_IMHTML(imhtml
));
1197 color
= g_strdup("");
1199 purple_prefs_set_string(PIDGIN_PREFS_ROOT
"/conversations/bgcolor", color
);
1205 formatting_clear_cb(GtkIMHtml
*imhtml
, void *data
)
1207 purple_prefs_set_bool(PIDGIN_PREFS_ROOT
"/conversations/send_bold", FALSE
);
1208 purple_prefs_set_bool(PIDGIN_PREFS_ROOT
"/conversations/send_italic", FALSE
);
1209 purple_prefs_set_bool(PIDGIN_PREFS_ROOT
"/conversations/send_underline", FALSE
);
1211 purple_prefs_set_int(PIDGIN_PREFS_ROOT
"/conversations/font_size", 3);
1213 purple_prefs_set_string(PIDGIN_PREFS_ROOT
"/conversations/font_face", "");
1214 purple_prefs_set_string(PIDGIN_PREFS_ROOT
"/conversations/fgcolor", "");
1215 purple_prefs_set_string(PIDGIN_PREFS_ROOT
"/conversations/bgcolor", "");
1219 conversation_usetabs_cb(const char *name
, PurplePrefType type
,
1220 gconstpointer value
, gpointer data
)
1222 gboolean usetabs
= GPOINTER_TO_INT(value
);
1225 gtk_widget_set_sensitive(GTK_WIDGET(data
), TRUE
);
1227 gtk_widget_set_sensitive(GTK_WIDGET(data
), FALSE
);
1231 #define CONVERSATION_CLOSE_ACCEL_PATH "<main>/Conversation/Close"
1233 /* Filled in in keyboard_shortcuts(). */
1234 static GtkAccelKey ctrl_w
= { 0, 0, 0 };
1235 static GtkAccelKey escape
= { 0, 0, 0 };
1237 static guint escape_closes_conversation_cb_id
= 0;
1240 accel_is_escape(GtkAccelKey
*k
)
1242 return (k
->accel_key
== escape
.accel_key
1243 && k
->accel_mods
== escape
.accel_mods
);
1246 /* Update the tickybox in Preferences when the keybinding for Conversation ->
1247 * Close is changed via Gtk.
1250 conversation_close_accel_changed_cb (GtkAccelMap
*object
,
1253 GdkModifierType accel_mods
,
1256 GtkToggleButton
*checkbox
= GTK_TOGGLE_BUTTON(checkbox_
);
1257 GtkAccelKey
new = { accel_key
, accel_mods
, 0 };
1259 g_signal_handler_block(checkbox
, escape_closes_conversation_cb_id
);
1260 gtk_toggle_button_set_active(checkbox
, accel_is_escape(&new));
1261 g_signal_handler_unblock(checkbox
, escape_closes_conversation_cb_id
);
1266 escape_closes_conversation_cb(GtkWidget
*w
,
1269 gboolean active
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w
));
1271 GtkAccelKey
*new_key
= active
? &escape
: &ctrl_w
;
1273 changed
= gtk_accel_map_change_entry(CONVERSATION_CLOSE_ACCEL_PATH
,
1274 new_key
->accel_key
, new_key
->accel_mods
, TRUE
);
1276 /* If another path is already bound to the new accelerator,
1277 * _change_entry tries to delete that binding (because it was passed
1278 * replace=TRUE). If that other path is locked, then _change_entry
1279 * will fail. We don't ever lock any accelerator paths, so this case
1280 * should never arise.
1283 purple_debug_warning("gtkprefs", "Escape accel failed to change\n");
1287 /* Creates preferences for keyboard shortcuts that it's hard to change with the
1288 * standard Gtk accelerator-changing mechanism.
1291 keyboard_shortcuts(GtkWidget
*page
)
1293 GtkWidget
*vbox
= pidgin_make_frame(page
, _("Keyboard Shortcuts"));
1294 GtkWidget
*checkbox
;
1295 GtkAccelKey current
= { 0, 0, 0 };
1296 GtkAccelMap
*map
= gtk_accel_map_get();
1298 /* Maybe it would be better just to hardcode the values?
1299 * -- resiak, 2007-04-30
1301 if (ctrl_w
.accel_key
== 0)
1303 gtk_accelerator_parse ("<Control>w", &(ctrl_w
.accel_key
),
1304 &(ctrl_w
.accel_mods
));
1305 g_assert(ctrl_w
.accel_key
!= 0);
1307 gtk_accelerator_parse ("Escape", &(escape
.accel_key
),
1308 &(escape
.accel_mods
));
1309 g_assert(escape
.accel_key
!= 0);
1312 checkbox
= gtk_check_button_new_with_mnemonic(
1313 _("Cl_ose conversations with the Escape key"));
1314 gtk_accel_map_lookup_entry(CONVERSATION_CLOSE_ACCEL_PATH
, ¤t
);
1315 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox
),
1316 accel_is_escape(¤t
));
1318 escape_closes_conversation_cb_id
= g_signal_connect(checkbox
,
1319 "clicked", G_CALLBACK(escape_closes_conversation_cb
), NULL
);
1321 g_signal_connect_object(map
, "changed::" CONVERSATION_CLOSE_ACCEL_PATH
,
1322 G_CALLBACK(conversation_close_accel_changed_cb
), checkbox
, (GConnectFlags
)0);
1324 gtk_box_pack_start(GTK_BOX(vbox
), checkbox
, FALSE
, FALSE
, 0);
1328 interface_page(void)
1335 GList
*names
= NULL
;
1337 ret
= gtk_vbox_new(FALSE
, PIDGIN_HIG_CAT_SPACE
);
1338 gtk_container_set_border_width(GTK_CONTAINER(ret
), PIDGIN_HIG_BORDER
);
1340 sg
= gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL
);
1343 vbox
= pidgin_make_frame(ret
, _("System Tray Icon"));
1344 label
= pidgin_prefs_dropdown(vbox
, _("_Show system tray icon:"), PURPLE_PREF_STRING
,
1345 PIDGIN_PREFS_ROOT
"/docklet/show",
1346 _("Always"), "always",
1347 _("On unread messages"), "pending",
1348 _("Never"), "never",
1350 gtk_size_group_add_widget(sg
, label
);
1351 gtk_misc_set_alignment(GTK_MISC(label
), 0.0, 0.5);
1353 vbox
= pidgin_make_frame(ret
, _("Conversation Window"));
1354 label
= pidgin_prefs_dropdown(vbox
, _("_Hide new IM conversations:"),
1355 PURPLE_PREF_STRING
, PIDGIN_PREFS_ROOT
"/conversations/im/hide_new",
1356 _("Never"), "never",
1357 _("When away"), "away",
1358 _("Always"), "always",
1360 gtk_size_group_add_widget(sg
, label
);
1361 gtk_misc_set_alignment(GTK_MISC(label
), 0.0, 0.5);
1364 pidgin_prefs_checkbox(_("Minimi_ze new conversation windows"), PIDGIN_PREFS_ROOT
"/win32/minimize_new_convs", vbox
);
1367 /* All the tab options! */
1368 vbox
= pidgin_make_frame(ret
, _("Tabs"));
1370 pidgin_prefs_checkbox(_("Show IMs and chats in _tabbed windows"),
1371 PIDGIN_PREFS_ROOT
"/conversations/tabs", vbox
);
1374 * Connect a signal to the above preference. When conversations are not
1375 * shown in a tabbed window then all tabbing options should be disabled.
1377 vbox2
= gtk_vbox_new(FALSE
, 9);
1378 gtk_box_pack_start(GTK_BOX(vbox
), vbox2
, FALSE
, FALSE
, 0);
1379 purple_prefs_connect_callback(prefs
, PIDGIN_PREFS_ROOT
"/conversations/tabs",
1380 conversation_usetabs_cb
, vbox2
);
1381 if (!purple_prefs_get_bool(PIDGIN_PREFS_ROOT
"/conversations/tabs"))
1382 gtk_widget_set_sensitive(vbox2
, FALSE
);
1384 pidgin_prefs_checkbox(_("Show close b_utton on tabs"),
1385 PIDGIN_PREFS_ROOT
"/conversations/close_on_tabs", vbox2
);
1387 label
= pidgin_prefs_dropdown(vbox2
, _("_Placement:"), PURPLE_PREF_INT
,
1388 PIDGIN_PREFS_ROOT
"/conversations/tab_side",
1389 _("Top"), GTK_POS_TOP
,
1390 _("Bottom"), GTK_POS_BOTTOM
,
1391 _("Left"), GTK_POS_LEFT
,
1392 _("Right"), GTK_POS_RIGHT
,
1393 _("Left Vertical"), GTK_POS_LEFT
|8,
1394 _("Right Vertical"), GTK_POS_RIGHT
|8,
1396 gtk_size_group_add_widget(sg
, label
);
1397 gtk_misc_set_alignment(GTK_MISC(label
), 0.0, 0.5);
1399 names
= pidgin_conv_placement_get_options();
1400 label
= pidgin_prefs_dropdown_from_list(vbox2
, _("N_ew conversations:"),
1401 PURPLE_PREF_STRING
, PIDGIN_PREFS_ROOT
"/conversations/placement", names
);
1402 gtk_misc_set_alignment(GTK_MISC(label
), 0.0, 0.5);
1404 gtk_size_group_add_widget(sg
, label
);
1408 keyboard_shortcuts(ret
);
1410 gtk_widget_show_all(ret
);
1417 apply_custom_font(void)
1419 PangoFontDescription
*desc
= NULL
;
1420 if (!purple_prefs_get_bool(PIDGIN_PREFS_ROOT
"/conversations/use_theme_font")) {
1421 const char *font
= purple_prefs_get_string(PIDGIN_PREFS_ROOT
"/conversations/custom_font");
1422 desc
= pango_font_description_from_string(font
);
1425 gtk_widget_modify_font(sample_imhtml
, desc
);
1427 pango_font_description_free(desc
);
1431 pidgin_custom_font_set(GtkFontButton
*font_button
, gpointer nul
)
1434 purple_prefs_set_string(PIDGIN_PREFS_ROOT
"/conversations/custom_font",
1435 gtk_font_button_get_font_name(font_button
));
1437 apply_custom_font();
1447 GtkWidget
*iconpref1
;
1448 GtkWidget
*iconpref2
;
1452 ret
= gtk_vbox_new(FALSE
, PIDGIN_HIG_CAT_SPACE
);
1453 gtk_container_set_border_width(GTK_CONTAINER(ret
), PIDGIN_HIG_BORDER
);
1455 vbox
= pidgin_make_frame(ret
, _("Conversations"));
1457 pidgin_prefs_checkbox(_("Show _formatting on incoming messages"),
1458 PIDGIN_PREFS_ROOT
"/conversations/show_incoming_formatting", vbox
);
1459 pidgin_prefs_checkbox(_("Close IMs immediately when the tab is closed"),
1460 PIDGIN_PREFS_ROOT
"/conversations/im/close_immediately", vbox
);
1462 iconpref1
= pidgin_prefs_checkbox(_("Show _detailed information"),
1463 PIDGIN_PREFS_ROOT
"/conversations/im/show_buddy_icons", vbox
);
1464 iconpref2
= pidgin_prefs_checkbox(_("Enable buddy ic_on animation"),
1465 PIDGIN_PREFS_ROOT
"/conversations/im/animate_buddy_icons", vbox
);
1466 if (!purple_prefs_get_bool(PIDGIN_PREFS_ROOT
"/conversations/im/show_buddy_icons"))
1467 gtk_widget_set_sensitive(iconpref2
, FALSE
);
1468 g_signal_connect(G_OBJECT(iconpref1
), "clicked",
1469 G_CALLBACK(pidgin_toggle_sensitive
), iconpref2
);
1471 pidgin_prefs_checkbox(_("_Notify buddies that you are typing to them"),
1472 "/purple/conversations/im/send_typing", vbox
);
1474 pidgin_prefs_checkbox(_("Highlight _misspelled words"),
1475 PIDGIN_PREFS_ROOT
"/conversations/spellcheck", vbox
);
1478 pidgin_prefs_checkbox(_("Use smooth-scrolling"), PIDGIN_PREFS_ROOT
"/conversations/use_smooth_scrolling", vbox
);
1481 pidgin_prefs_checkbox(_("F_lash window when IMs are received"), PIDGIN_PREFS_ROOT
"/win32/blink_im", vbox
);
1484 pidgin_prefs_labeled_spin_button(vbox
,
1485 _("Minimum input area height in lines:"),
1486 PIDGIN_PREFS_ROOT
"/conversations/minimum_entry_lines",
1491 GtkWidget
*fontpref
, *font_button
, *hbox
;
1492 const char *font_name
;
1493 vbox
= pidgin_make_frame(ret
, _("Font"));
1495 fontpref
= pidgin_prefs_checkbox(_("Use font from _theme"),
1496 PIDGIN_PREFS_ROOT
"/conversations/use_theme_font", vbox
);
1498 font_name
= purple_prefs_get_string(PIDGIN_PREFS_ROOT
"/conversations/custom_font");
1499 if ((font_name
== NULL
) || (*font_name
== '\0')) {
1500 font_button
= gtk_font_button_new();
1502 font_button
= gtk_font_button_new_with_font(font_name
);
1505 gtk_font_button_set_show_style(GTK_FONT_BUTTON(font_button
), TRUE
);
1506 hbox
= pidgin_add_widget_to_vbox(GTK_BOX(vbox
), _("Conversation _font:"), NULL
, font_button
, FALSE
, NULL
);
1507 if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT
"/conversations/use_theme_font"))
1508 gtk_widget_set_sensitive(hbox
, FALSE
);
1509 g_signal_connect(G_OBJECT(fontpref
), "clicked", G_CALLBACK(pidgin_toggle_sensitive
), hbox
);
1510 g_signal_connect(G_OBJECT(fontpref
), "clicked", G_CALLBACK(apply_custom_font
), hbox
);
1511 g_signal_connect(G_OBJECT(font_button
), "font-set", G_CALLBACK(pidgin_custom_font_set
), NULL
);
1516 vbox
= pidgin_make_frame(ret
, _("Default Formatting"));
1518 frame
= pidgin_create_imhtml(TRUE
, &imhtml
, &toolbar
, NULL
);
1519 gtk_widget_show(frame
);
1520 gtk_widget_set_name(imhtml
, "pidgin_prefs_font_imhtml");
1521 gtk_widget_set_size_request(frame
, 450, -1);
1522 gtk_imhtml_set_whole_buffer_formatting_only(GTK_IMHTML(imhtml
), TRUE
);
1523 gtk_imhtml_set_format_functions(GTK_IMHTML(imhtml
),
1526 GTK_IMHTML_UNDERLINE
|
1530 GTK_IMHTML_FORECOLOR
|
1531 GTK_IMHTML_BACKCOLOR
|
1532 GTK_IMHTML_BACKGROUND
);
1534 gtk_imhtml_append_text(GTK_IMHTML(imhtml
), _("This is how your outgoing message text will appear when you use protocols that support formatting."), 0);
1536 gtk_box_pack_start(GTK_BOX(vbox
), frame
, TRUE
, TRUE
, 0);
1538 gtk_imhtml_setup_entry(GTK_IMHTML(imhtml
), PURPLE_CONNECTION_HTML
| PURPLE_CONNECTION_FORMATTING_WBFO
);
1540 g_signal_connect_after(G_OBJECT(imhtml
), "format_function_toggle",
1541 G_CALLBACK(formatting_toggle_cb
), toolbar
);
1542 g_signal_connect_after(G_OBJECT(imhtml
), "format_function_clear",
1543 G_CALLBACK(formatting_clear_cb
), NULL
);
1544 sample_imhtml
= imhtml
;
1546 gtk_widget_show(ret
);
1552 network_ip_changed(GtkEntry
*entry
, gpointer data
)
1554 const gchar
*text
= gtk_entry_get_text(entry
);
1557 if (text
&& *text
) {
1558 if (purple_ip_address_is_valid(text
)) {
1560 color
.green
= 0xFFFF;
1561 color
.blue
= 0xAFFF;
1563 purple_network_set_public_ip(text
);
1566 color
.green
= 0xAFFF;
1567 color
.blue
= 0xAFFF;
1570 gtk_widget_modify_base(GTK_WIDGET(entry
), GTK_STATE_NORMAL
, &color
);
1573 purple_network_set_public_ip("");
1574 gtk_widget_modify_base(GTK_WIDGET(entry
), GTK_STATE_NORMAL
, NULL
);
1579 network_stun_server_changed_cb(GtkWidget
*widget
,
1580 GdkEventFocus
*event
, gpointer data
)
1582 GtkEntry
*entry
= GTK_ENTRY(widget
);
1583 purple_prefs_set_string("/purple/network/stun_server",
1584 gtk_entry_get_text(entry
));
1585 purple_network_set_stun_server(gtk_entry_get_text(entry
));
1591 network_turn_server_changed_cb(GtkWidget
*widget
,
1592 GdkEventFocus
*event
, gpointer data
)
1594 GtkEntry
*entry
= GTK_ENTRY(widget
);
1595 purple_prefs_set_string("/purple/network/turn_server",
1596 gtk_entry_get_text(entry
));
1597 purple_network_set_turn_server(gtk_entry_get_text(entry
));
1603 proxy_changed_cb(const char *name
, PurplePrefType type
,
1604 gconstpointer value
, gpointer data
)
1606 GtkWidget
*frame
= data
;
1607 const char *proxy
= value
;
1609 if (strcmp(proxy
, "none") && strcmp(proxy
, "envvar"))
1610 gtk_widget_show_all(frame
);
1612 gtk_widget_hide(frame
);
1616 proxy_print_option(GtkEntry
*entry
, int entrynum
)
1618 if (entrynum
== PROXYHOST
)
1619 purple_prefs_set_string("/purple/proxy/host", gtk_entry_get_text(entry
));
1620 else if (entrynum
== PROXYPORT
)
1621 purple_prefs_set_int("/purple/proxy/port", atoi(gtk_entry_get_text(entry
)));
1622 else if (entrynum
== PROXYUSER
)
1623 purple_prefs_set_string("/purple/proxy/username", gtk_entry_get_text(entry
));
1624 else if (entrynum
== PROXYPASS
)
1625 purple_prefs_set_string("/purple/proxy/password", gtk_entry_get_text(entry
));
1629 proxy_button_clicked_cb(GtkWidget
*button
, gchar
*program
)
1633 if (g_spawn_command_line_async(program
, &err
))
1636 purple_notify_error(NULL
, NULL
, _("Cannot start proxy configuration program."), err
->message
);
1642 browser_button_clicked_cb(GtkWidget
*button
, gpointer null
)
1646 if (g_spawn_command_line_async ("gnome-default-applications-properties", &err
))
1649 purple_notify_error(NULL
, NULL
, _("Cannot start browser configuration program."), err
->message
);
1655 auto_ip_button_clicked_cb(GtkWidget
*button
, gpointer null
)
1658 PurpleStunNatDiscovery
*stun
;
1661 /* purple_network_get_my_ip will return the IP that was set by the user with
1662 purple_network_set_public_ip, so make a lookup for the auto-detected IP
1665 if (purple_prefs_get_bool("/purple/network/auto_ip")) {
1666 /* Check if STUN discovery was already done */
1667 stun
= purple_stun_discover(NULL
);
1668 if ((stun
!= NULL
) && (stun
->status
== PURPLE_STUN_STATUS_DISCOVERED
)) {
1669 ip
= stun
->publicip
;
1671 /* Attempt to get the IP from a NAT device using UPnP */
1672 ip
= purple_upnp_get_public_ip();
1674 /* Attempt to get the IP from a NAT device using NAT-PMP */
1675 ip
= purple_pmp_get_public_ip();
1677 /* Just fetch the IP of the local system */
1678 ip
= purple_network_get_local_system_ip(-1);
1686 auto_ip_text
= g_strdup_printf(_("Use _automatically detected IP address: %s"), ip
);
1687 gtk_button_set_label(GTK_BUTTON(button
), auto_ip_text
);
1688 g_free(auto_ip_text
);
1695 GtkWidget
*vbox
, *hbox
, *entry
;
1696 GtkWidget
*label
, *auto_ip_checkbox
, *ports_checkbox
, *spin_button
;
1699 ret
= gtk_vbox_new(FALSE
, PIDGIN_HIG_CAT_SPACE
);
1700 gtk_container_set_border_width (GTK_CONTAINER (ret
), PIDGIN_HIG_BORDER
);
1702 vbox
= pidgin_make_frame (ret
, _("IP Address"));
1703 sg
= gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL
);
1705 entry
= gtk_entry_new();
1706 gtk_entry_set_text(GTK_ENTRY(entry
), purple_prefs_get_string(
1707 "/purple/network/stun_server"));
1708 g_signal_connect(G_OBJECT(entry
), "focus-out-event",
1709 G_CALLBACK(network_stun_server_changed_cb
), NULL
);
1710 gtk_widget_show(entry
);
1712 pidgin_add_widget_to_vbox(GTK_BOX(vbox
), _("ST_UN server:"),
1713 sg
, entry
, TRUE
, NULL
);
1715 hbox
= gtk_hbox_new(FALSE
, PIDGIN_HIG_BOX_SPACE
);
1716 gtk_container_add(GTK_CONTAINER(vbox
), hbox
);
1718 label
= gtk_label_new(NULL
);
1719 gtk_container_add(GTK_CONTAINER(hbox
), label
);
1720 gtk_size_group_add_widget(sg
, label
);
1722 label
= gtk_label_new(NULL
);
1723 gtk_label_set_markup(GTK_LABEL(label
),
1724 _("<span style=\"italic\">Example: stunserver.org</span>"));
1725 gtk_misc_set_alignment(GTK_MISC(label
), 0.0, 0.5);
1726 gtk_container_add(GTK_CONTAINER(hbox
), label
);
1728 auto_ip_checkbox
= pidgin_prefs_checkbox("Use _automatically detected IP address",
1729 "/purple/network/auto_ip", vbox
);
1730 g_signal_connect(G_OBJECT(auto_ip_checkbox
), "clicked",
1731 G_CALLBACK(auto_ip_button_clicked_cb
), NULL
);
1732 auto_ip_button_clicked_cb(auto_ip_checkbox
, NULL
); /* Update label */
1734 entry
= gtk_entry_new();
1735 gtk_entry_set_text(GTK_ENTRY(entry
), purple_network_get_public_ip());
1736 g_signal_connect(G_OBJECT(entry
), "changed",
1737 G_CALLBACK(network_ip_changed
), NULL
);
1739 hbox
= pidgin_add_widget_to_vbox(GTK_BOX(vbox
), _("Public _IP:"),
1740 sg
, entry
, TRUE
, NULL
);
1742 if (purple_prefs_get_bool("/purple/network/auto_ip")) {
1743 gtk_widget_set_sensitive(GTK_WIDGET(hbox
), FALSE
);
1746 g_signal_connect(G_OBJECT(auto_ip_checkbox
), "clicked",
1747 G_CALLBACK(pidgin_toggle_sensitive
), hbox
);
1751 vbox
= pidgin_make_frame (ret
, _("Ports"));
1752 sg
= gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL
);
1754 pidgin_prefs_checkbox(_("_Enable automatic router port forwarding"),
1755 "/purple/network/map_ports", vbox
);
1757 hbox
= gtk_hbox_new(FALSE
, PIDGIN_HIG_BOX_SPACE
);
1759 ports_checkbox
= pidgin_prefs_checkbox(_("_Manually specify range of ports to listen on:"),
1760 "/purple/network/ports_range_use", hbox
);
1762 spin_button
= pidgin_prefs_labeled_spin_button(hbox
, _("_Start:"),
1763 "/purple/network/ports_range_start", 0, 65535, sg
);
1764 if (!purple_prefs_get_bool("/purple/network/ports_range_use"))
1765 gtk_widget_set_sensitive(GTK_WIDGET(spin_button
), FALSE
);
1766 g_signal_connect(G_OBJECT(ports_checkbox
), "clicked",
1767 G_CALLBACK(pidgin_toggle_sensitive
), spin_button
);
1769 spin_button
= pidgin_prefs_labeled_spin_button(hbox
, _("_End:"),
1770 "/purple/network/ports_range_end", 0, 65535, sg
);
1771 if (!purple_prefs_get_bool("/purple/network/ports_range_use"))
1772 gtk_widget_set_sensitive(GTK_WIDGET(spin_button
), FALSE
);
1773 g_signal_connect(G_OBJECT(ports_checkbox
), "clicked",
1774 G_CALLBACK(pidgin_toggle_sensitive
), spin_button
);
1776 pidgin_add_widget_to_vbox(GTK_BOX(vbox
), NULL
, NULL
, hbox
, TRUE
, NULL
);
1781 vbox
= pidgin_make_frame(ret
, _("Relay Server (TURN)"));
1782 sg
= gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL
);
1784 entry
= gtk_entry_new();
1785 gtk_entry_set_text(GTK_ENTRY(entry
), purple_prefs_get_string(
1786 "/purple/network/turn_server"));
1787 g_signal_connect(G_OBJECT(entry
), "focus-out-event",
1788 G_CALLBACK(network_turn_server_changed_cb
), NULL
);
1789 gtk_widget_show(entry
);
1791 hbox
= pidgin_add_widget_to_vbox(GTK_BOX(vbox
), _("_TURN server:"),
1792 sg
, entry
, TRUE
, NULL
);
1794 pidgin_prefs_labeled_spin_button(hbox
, _("_UDP Port:"),
1795 "/purple/network/turn_port", 0, 65535, NULL
);
1797 hbox
= pidgin_prefs_labeled_entry(vbox
, _("Use_rname:"),
1798 "/purple/network/turn_username", sg
);
1799 pidgin_prefs_labeled_password(hbox
, _("Pass_word:"),
1800 "/purple/network/turn_password", NULL
);
1802 gtk_widget_show_all(ret
);
1810 manual_browser_set(GtkWidget
*entry
, GdkEventFocus
*event
, gpointer data
)
1812 const char *program
= gtk_entry_get_text(GTK_ENTRY(entry
));
1814 purple_prefs_set_string(PIDGIN_PREFS_ROOT
"/browsers/command", program
);
1816 /* carry on normally */
1821 get_available_browsers(void)
1828 /* Sorted reverse alphabetically */
1829 static const struct browser possible_browsers
[] = {
1830 {N_("Seamonkey"), "seamonkey"},
1831 {N_("Opera"), "opera"},
1832 {N_("Netscape"), "netscape"},
1833 {N_("Mozilla"), "mozilla"},
1834 {N_("Konqueror"), "kfmclient"},
1835 {N_("Google Chrome"), "google-chrome"},
1836 /* Do not move the line below. Code below expects gnome-open to be in
1837 * this list immediately after xdg-open! */
1838 {N_("Desktop Default"), "xdg-open"},
1839 {N_("GNOME Default"), "gnome-open"},
1840 {N_("Galeon"), "galeon"},
1841 {N_("Firefox"), "firefox"},
1842 {N_("Firebird"), "mozilla-firebird"},
1843 {N_("Epiphany"), "epiphany"},
1844 /* Translators: please do not translate "chromium-browser" here! */
1845 {N_("Chromium (chromium-browser)"), "chromium-browser"},
1846 /* Translators: please do not translate "chrome" here! */
1847 {N_("Chromium (chrome)"), "chrome"}
1849 static const int num_possible_browsers
= G_N_ELEMENTS(possible_browsers
);
1851 GList
*browsers
= NULL
;
1853 char *browser_setting
= (char *)purple_prefs_get_string(PIDGIN_PREFS_ROOT
"/browsers/browser");
1855 browsers
= g_list_prepend(browsers
, (gpointer
)"custom");
1856 browsers
= g_list_prepend(browsers
, (gpointer
)_("Manual"));
1858 for (i
= 0; i
< num_possible_browsers
; i
++) {
1859 if (purple_program_is_valid(possible_browsers
[i
].command
)) {
1860 browsers
= g_list_prepend(browsers
,
1861 possible_browsers
[i
].command
);
1862 browsers
= g_list_prepend(browsers
, (gpointer
)_(possible_browsers
[i
].name
));
1863 if(browser_setting
&& !strcmp(possible_browsers
[i
].command
, browser_setting
))
1864 browser_setting
= NULL
;
1865 /* If xdg-open is valid, prefer it over gnome-open and skip forward */
1866 if(!strcmp(possible_browsers
[i
].command
, "xdg-open")) {
1867 if (browser_setting
&& !strcmp("gnome-open", browser_setting
)) {
1868 purple_prefs_set_string(PIDGIN_PREFS_ROOT
"/browsers/browser", possible_browsers
[i
].command
);
1869 browser_setting
= NULL
;
1877 purple_prefs_set_string(PIDGIN_PREFS_ROOT
"/browsers/browser", "custom");
1883 browser_changed1_cb(const char *name
, PurplePrefType type
,
1884 gconstpointer value
, gpointer data
)
1886 GtkWidget
*hbox
= data
;
1887 const char *browser
= value
;
1889 gtk_widget_set_sensitive(hbox
, strcmp(browser
, "custom"));
1893 browser_changed2_cb(const char *name
, PurplePrefType type
,
1894 gconstpointer value
, gpointer data
)
1896 GtkWidget
*hbox
= data
;
1897 const char *browser
= value
;
1899 gtk_widget_set_sensitive(hbox
, !strcmp(browser
, "custom"));
1905 GtkWidget
*ret
, *vbox
, *hbox
, *label
, *entry
, *browser_button
;
1907 GList
*browsers
= NULL
;
1909 ret
= gtk_vbox_new(FALSE
, PIDGIN_HIG_CAT_SPACE
);
1910 gtk_container_set_border_width (GTK_CONTAINER (ret
), PIDGIN_HIG_BORDER
);
1912 vbox
= pidgin_make_frame (ret
, _("Browser Selection"));
1914 if(purple_running_gnome()) {
1915 gchar
*path
= g_find_program_in_path("gnome-default-applications-properties");
1917 hbox
= gtk_hbox_new(FALSE
, PIDGIN_HIG_BOX_SPACE
);
1918 label
= gtk_label_new(_("Browser preferences are configured in GNOME preferences"));
1919 gtk_container_add(GTK_CONTAINER(vbox
), hbox
);
1920 gtk_box_pack_start(GTK_BOX(hbox
), label
, FALSE
, FALSE
, 0);
1922 hbox
= gtk_hbox_new(FALSE
, PIDGIN_HIG_BOX_SPACE
);
1923 gtk_container_add(GTK_CONTAINER(vbox
), hbox
);
1926 label
= gtk_label_new(NULL
);
1927 gtk_label_set_markup(GTK_LABEL(label
),
1928 _("<b>Browser configuration program was not found.</b>"));
1929 gtk_box_pack_start(GTK_BOX(hbox
), label
, FALSE
, FALSE
, 0);
1931 browser_button
= gtk_button_new_with_mnemonic(_("Configure _Browser"));
1932 g_signal_connect(G_OBJECT(browser_button
), "clicked",
1933 G_CALLBACK(browser_button_clicked_cb
), NULL
);
1934 gtk_box_pack_start(GTK_BOX(hbox
), browser_button
, FALSE
, FALSE
, 0);
1938 gtk_widget_show_all(ret
);
1940 sg
= gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL
);
1942 browsers
= get_available_browsers();
1943 if (browsers
!= NULL
) {
1944 label
= pidgin_prefs_dropdown_from_list(vbox
,_("_Browser:"), PURPLE_PREF_STRING
,
1945 PIDGIN_PREFS_ROOT
"/browsers/browser",
1947 g_list_free(browsers
);
1948 gtk_misc_set_alignment(GTK_MISC(label
), 0, 0.5);
1949 gtk_size_group_add_widget(sg
, label
);
1951 hbox
= gtk_hbox_new(FALSE
, 0);
1952 label
= pidgin_prefs_dropdown(hbox
, _("_Open link in:"), PURPLE_PREF_INT
,
1953 PIDGIN_PREFS_ROOT
"/browsers/place",
1954 _("Browser default"), PIDGIN_BROWSER_DEFAULT
,
1955 _("Existing window"), PIDGIN_BROWSER_CURRENT
,
1956 _("New window"), PIDGIN_BROWSER_NEW_WINDOW
,
1957 _("New tab"), PIDGIN_BROWSER_NEW_TAB
,
1959 gtk_misc_set_alignment(GTK_MISC(label
), 0, 0.5);
1960 gtk_size_group_add_widget(sg
, label
);
1961 gtk_box_pack_start(GTK_BOX(vbox
), hbox
, FALSE
, FALSE
, 0);
1963 if (!strcmp(purple_prefs_get_string(PIDGIN_PREFS_ROOT
"/browsers/browser"), "custom"))
1964 gtk_widget_set_sensitive(hbox
, FALSE
);
1965 purple_prefs_connect_callback(prefs
, PIDGIN_PREFS_ROOT
"/browsers/browser",
1966 browser_changed1_cb
, hbox
);
1969 entry
= gtk_entry_new();
1970 gtk_entry_set_text(GTK_ENTRY(entry
),
1971 purple_prefs_get_string(PIDGIN_PREFS_ROOT
"/browsers/command"));
1972 g_signal_connect(G_OBJECT(entry
), "focus-out-event",
1973 G_CALLBACK(manual_browser_set
), NULL
);
1974 hbox
= pidgin_add_widget_to_vbox(GTK_BOX(vbox
), _("_Manual:\n(%s for URL)"), sg
, entry
, TRUE
, NULL
);
1975 if (strcmp(purple_prefs_get_string(PIDGIN_PREFS_ROOT
"/browsers/browser"), "custom"))
1976 gtk_widget_set_sensitive(hbox
, FALSE
);
1977 purple_prefs_connect_callback(prefs
, PIDGIN_PREFS_ROOT
"/browsers/browser",
1978 browser_changed2_cb
, hbox
);
1980 gtk_widget_show_all(ret
);
1991 GtkWidget
*ret
= NULL
, *vbox
= NULL
, *hbox
= NULL
;
1992 GtkWidget
*table
= NULL
, *entry
= NULL
, *label
= NULL
, *proxy_button
= NULL
;
1993 GtkWidget
*prefs_proxy_frame
= NULL
;
1994 PurpleProxyInfo
*proxy_info
;
1996 ret
= gtk_vbox_new(FALSE
, PIDGIN_HIG_CAT_SPACE
);
1997 gtk_container_set_border_width(GTK_CONTAINER(ret
), PIDGIN_HIG_BORDER
);
1998 vbox
= pidgin_make_frame(ret
, _("Proxy Server"));
1999 prefs_proxy_frame
= gtk_vbox_new(FALSE
, PIDGIN_HIG_BOX_SPACE
);
2001 if(purple_running_gnome()) {
2004 hbox
= gtk_hbox_new(FALSE
, PIDGIN_HIG_BOX_SPACE
);
2005 label
= gtk_label_new(_("Proxy preferences are configured in GNOME preferences"));
2006 gtk_container_add(GTK_CONTAINER(vbox
), hbox
);
2007 gtk_box_pack_start(GTK_BOX(hbox
), label
, FALSE
, FALSE
, 0);
2009 hbox
= gtk_hbox_new(FALSE
, PIDGIN_HIG_BOX_SPACE
);
2010 gtk_container_add(GTK_CONTAINER(vbox
), hbox
);
2012 path
= g_find_program_in_path("gnome-network-properties");
2014 path
= g_find_program_in_path("gnome-network-preferences");
2017 label
= gtk_label_new(NULL
);
2018 gtk_label_set_markup(GTK_LABEL(label
),
2019 _("<b>Proxy configuration program was not found.</b>"));
2020 gtk_box_pack_start(GTK_BOX(hbox
), label
, FALSE
, FALSE
, 0);
2022 proxy_button
= gtk_button_new_with_mnemonic(_("Configure _Proxy"));
2023 g_signal_connect(G_OBJECT(proxy_button
), "clicked",
2024 G_CALLBACK(proxy_button_clicked_cb
),
2026 gtk_box_pack_start(GTK_BOX(hbox
), proxy_button
, FALSE
, FALSE
, 0);
2029 /* NOTE: path leaks, but only when the prefs window is destroyed,
2031 gtk_widget_show_all(ret
);
2033 GtkWidget
*prefs_proxy_subframe
= gtk_vbox_new(FALSE
, 0);
2035 /* This is a global option that affects SOCKS4 usage even with
2036 * account-specific proxy settings */
2037 pidgin_prefs_checkbox(_("Use remote _DNS with SOCKS4 proxies"),
2038 "/purple/proxy/socks4_remotedns", prefs_proxy_frame
);
2039 gtk_box_pack_start(GTK_BOX(vbox
), prefs_proxy_frame
, 0, 0, 0);
2041 pidgin_prefs_dropdown(prefs_proxy_frame
, _("Proxy t_ype:"), PURPLE_PREF_STRING
,
2042 "/purple/proxy/type",
2043 _("No proxy"), "none",
2044 "SOCKS 4", "socks4",
2045 "SOCKS 5", "socks5",
2047 _("Use Environmental Settings"), "envvar",
2049 gtk_box_pack_start(GTK_BOX(prefs_proxy_frame
), prefs_proxy_subframe
, 0, 0, 0);
2050 proxy_info
= purple_global_proxy_get_info();
2052 gtk_widget_show_all(ret
);
2054 purple_prefs_connect_callback(prefs
, "/purple/proxy/type",
2055 proxy_changed_cb
, prefs_proxy_subframe
);
2057 table
= gtk_table_new(4, 2, FALSE
);
2058 gtk_container_set_border_width(GTK_CONTAINER(table
), 0);
2059 gtk_table_set_col_spacings(GTK_TABLE(table
), 5);
2060 gtk_table_set_row_spacings(GTK_TABLE(table
), 10);
2061 gtk_container_add(GTK_CONTAINER(prefs_proxy_subframe
), table
);
2063 label
= gtk_label_new_with_mnemonic(_("_Host:"));
2064 gtk_misc_set_alignment(GTK_MISC(label
), 1.0, 0.5);
2065 gtk_table_attach(GTK_TABLE(table
), label
, 0, 1, 0, 1, GTK_FILL
, 0, 0, 0);
2067 entry
= gtk_entry_new();
2068 gtk_label_set_mnemonic_widget(GTK_LABEL(label
), entry
);
2069 gtk_table_attach(GTK_TABLE(table
), entry
, 1, 2, 0, 1, GTK_FILL
, 0, 0, 0);
2070 g_signal_connect(G_OBJECT(entry
), "changed",
2071 G_CALLBACK(proxy_print_option
), (void *)PROXYHOST
);
2073 if (proxy_info
!= NULL
&& purple_proxy_info_get_host(proxy_info
))
2074 gtk_entry_set_text(GTK_ENTRY(entry
),
2075 purple_proxy_info_get_host(proxy_info
));
2077 hbox
= gtk_hbox_new(TRUE
, 5);
2078 gtk_box_pack_start(GTK_BOX(vbox
), hbox
, FALSE
, FALSE
, 0);
2079 pidgin_set_accessible_label (entry
, label
);
2081 label
= gtk_label_new_with_mnemonic(_("P_ort:"));
2082 gtk_misc_set_alignment(GTK_MISC(label
), 1.0, 0.5);
2083 gtk_table_attach(GTK_TABLE(table
), label
, 2, 3, 0, 1, GTK_FILL
, 0, 0, 0);
2085 entry
= gtk_spin_button_new_with_range(0, 65535, 1);
2086 gtk_label_set_mnemonic_widget(GTK_LABEL(label
), entry
);
2087 gtk_table_attach(GTK_TABLE(table
), entry
, 3, 4, 0, 1, GTK_FILL
, 0, 0, 0);
2088 g_signal_connect(G_OBJECT(entry
), "changed",
2089 G_CALLBACK(proxy_print_option
), (void *)PROXYPORT
);
2091 if (proxy_info
!= NULL
&& purple_proxy_info_get_port(proxy_info
) != 0) {
2092 gtk_spin_button_set_value(GTK_SPIN_BUTTON(entry
),
2093 purple_proxy_info_get_port(proxy_info
));
2095 pidgin_set_accessible_label (entry
, label
);
2097 label
= gtk_label_new_with_mnemonic(_("User_name:"));
2098 gtk_misc_set_alignment(GTK_MISC(label
), 1.0, 0.5);
2099 gtk_table_attach(GTK_TABLE(table
), label
, 0, 1, 1, 2, GTK_FILL
, 0, 0, 0);
2101 entry
= gtk_entry_new();
2102 gtk_label_set_mnemonic_widget(GTK_LABEL(label
), entry
);
2103 gtk_table_attach(GTK_TABLE(table
), entry
, 1, 2, 1, 2, GTK_FILL
, 0, 0, 0);
2104 g_signal_connect(G_OBJECT(entry
), "changed",
2105 G_CALLBACK(proxy_print_option
), (void *)PROXYUSER
);
2107 if (proxy_info
!= NULL
&& purple_proxy_info_get_username(proxy_info
) != NULL
)
2108 gtk_entry_set_text(GTK_ENTRY(entry
),
2109 purple_proxy_info_get_username(proxy_info
));
2111 hbox
= gtk_hbox_new(TRUE
, 5);
2112 gtk_box_pack_start(GTK_BOX(vbox
), hbox
, FALSE
, FALSE
, 0);
2113 pidgin_set_accessible_label (entry
, label
);
2115 label
= gtk_label_new_with_mnemonic(_("Pa_ssword:"));
2116 gtk_misc_set_alignment(GTK_MISC(label
), 1.0, 0.5);
2117 gtk_table_attach(GTK_TABLE(table
), label
, 2, 3, 1, 2, GTK_FILL
, 0, 0, 0);
2119 entry
= gtk_entry_new();
2120 gtk_label_set_mnemonic_widget(GTK_LABEL(label
), entry
);
2121 gtk_table_attach(GTK_TABLE(table
), entry
, 3, 4, 1, 2, GTK_FILL
, 0, 0, 0);
2122 gtk_entry_set_visibility(GTK_ENTRY(entry
), FALSE
);
2123 #if !GTK_CHECK_VERSION(2,16,0)
2124 if (gtk_entry_get_invisible_char(GTK_ENTRY(entry
)) == '*')
2125 gtk_entry_set_invisible_char(GTK_ENTRY(entry
), PIDGIN_INVISIBLE_CHAR
);
2126 #endif /* Less than GTK+ 2.16 */
2127 g_signal_connect(G_OBJECT(entry
), "changed",
2128 G_CALLBACK(proxy_print_option
), (void *)PROXYPASS
);
2130 if (proxy_info
!= NULL
&& purple_proxy_info_get_password(proxy_info
) != NULL
)
2131 gtk_entry_set_text(GTK_ENTRY(entry
),
2132 purple_proxy_info_get_password(proxy_info
));
2133 pidgin_set_accessible_label (entry
, label
);
2135 proxy_changed_cb("/purple/proxy/type", PURPLE_PREF_STRING
,
2136 purple_prefs_get_string("/purple/proxy/type"),
2137 prefs_proxy_subframe
);
2151 ret
= gtk_vbox_new(FALSE
, PIDGIN_HIG_CAT_SPACE
);
2152 gtk_container_set_border_width (GTK_CONTAINER (ret
), PIDGIN_HIG_BORDER
);
2155 vbox
= pidgin_make_frame (ret
, _("Logging"));
2156 names
= purple_log_logger_get_options();
2158 pidgin_prefs_dropdown_from_list(vbox
, _("Log _format:"), PURPLE_PREF_STRING
,
2159 "/purple/logging/format", names
);
2163 pidgin_prefs_checkbox(_("Log all _instant messages"),
2164 "/purple/logging/log_ims", vbox
);
2165 pidgin_prefs_checkbox(_("Log all c_hats"),
2166 "/purple/logging/log_chats", vbox
);
2167 pidgin_prefs_checkbox(_("Log all _status changes to system log"),
2168 "/purple/logging/log_system", vbox
);
2170 gtk_widget_show_all(ret
);
2177 sound_cmd_yeah(GtkEntry
*entry
, gpointer d
)
2179 purple_prefs_set_path(PIDGIN_PREFS_ROOT
"/sound/command",
2180 gtk_entry_get_text(GTK_ENTRY(entry
)));
2185 sound_changed1_cb(const char *name
, PurplePrefType type
,
2186 gconstpointer value
, gpointer data
)
2188 GtkWidget
*hbox
= data
;
2189 const char *method
= value
;
2191 gtk_widget_set_sensitive(hbox
, !strcmp(method
, "custom"));
2195 sound_changed2_cb(const char *name
, PurplePrefType type
,
2196 gconstpointer value
, gpointer data
)
2198 GtkWidget
*vbox
= data
;
2199 const char *method
= value
;
2201 gtk_widget_set_sensitive(vbox
, strcmp(method
, "none"));
2203 #endif /* !_WIN32 */
2205 #ifdef USE_GSTREAMER
2207 sound_changed3_cb(const char *name
, PurplePrefType type
,
2208 gconstpointer value
, gpointer data
)
2210 GtkWidget
*hbox
= data
;
2211 const char *method
= value
;
2213 gtk_widget_set_sensitive(hbox
,
2214 !strcmp(method
, "automatic") ||
2215 !strcmp(method
, "alsa") ||
2216 !strcmp(method
, "esd"));
2218 #endif /* USE_GSTREAMER */
2222 event_toggled(GtkCellRendererToggle
*cell
, gchar
*pth
, gpointer data
)
2224 GtkTreeModel
*model
= (GtkTreeModel
*)data
;
2226 GtkTreePath
*path
= gtk_tree_path_new_from_string(pth
);
2229 gtk_tree_model_get_iter (model
, &iter
, path
);
2230 gtk_tree_model_get (model
, &iter
,
2234 purple_prefs_set_bool(pref
, !gtk_cell_renderer_toggle_get_active(cell
));
2237 gtk_list_store_set(GTK_LIST_STORE (model
), &iter
,
2238 0, !gtk_cell_renderer_toggle_get_active(cell
),
2241 gtk_tree_path_free(path
);
2245 test_sound(GtkWidget
*button
, gpointer i_am_NULL
)
2248 gboolean temp_enabled
;
2251 pref
= g_strdup_printf(PIDGIN_PREFS_ROOT
"/sound/enabled/%s",
2252 pidgin_sound_get_event_option(sound_row_sel
));
2254 temp_enabled
= purple_prefs_get_bool(pref
);
2255 temp_mute
= purple_prefs_get_bool(PIDGIN_PREFS_ROOT
"/sound/mute");
2257 if (!temp_enabled
) purple_prefs_set_bool(pref
, TRUE
);
2258 if (temp_mute
) purple_prefs_set_bool(PIDGIN_PREFS_ROOT
"/sound/mute", FALSE
);
2260 purple_sound_play_event(sound_row_sel
, NULL
);
2262 if (!temp_enabled
) purple_prefs_set_bool(pref
, FALSE
);
2263 if (temp_mute
) purple_prefs_set_bool(PIDGIN_PREFS_ROOT
"/sound/mute", TRUE
);
2269 * Resets a sound file back to default.
2272 reset_sound(GtkWidget
*button
, gpointer i_am_also_NULL
)
2276 pref
= g_strdup_printf(PIDGIN_PREFS_ROOT
"/sound/file/%s",
2277 pidgin_sound_get_event_option(sound_row_sel
));
2278 purple_prefs_set_path(pref
, "");
2281 gtk_entry_set_text(GTK_ENTRY(sound_entry
), _("(default)"));
2283 pref_sound_generate_markup();
2287 sound_chosen_cb(void *user_data
, const char *filename
)
2292 sound
= GPOINTER_TO_INT(user_data
);
2294 /* Set it -- and forget it */
2295 pref
= g_strdup_printf(PIDGIN_PREFS_ROOT
"/sound/file/%s",
2296 pidgin_sound_get_event_option(sound
));
2297 purple_prefs_set_path(pref
, filename
);
2301 * If the sound we just changed is still the currently selected
2302 * sound, then update the box showing the file name.
2304 if (sound
== sound_row_sel
)
2305 gtk_entry_set_text(GTK_ENTRY(sound_entry
), filename
);
2307 pref_sound_generate_markup();
2311 select_sound(GtkWidget
*button
, gpointer being_NULL_is_fun
)
2314 const char *filename
;
2316 pref
= g_strdup_printf(PIDGIN_PREFS_ROOT
"/sound/file/%s",
2317 pidgin_sound_get_event_option(sound_row_sel
));
2318 filename
= purple_prefs_get_path(pref
);
2321 if (*filename
== '\0')
2324 purple_request_file(prefs
, _("Sound Selection"), filename
, FALSE
,
2325 G_CALLBACK(sound_chosen_cb
), NULL
,
2327 GINT_TO_POINTER(sound_row_sel
));
2330 #ifdef USE_GSTREAMER
2332 prefs_sound_volume_format(GtkScale
*scale
, gdouble val
)
2335 return g_strdup_printf(_("Quietest"));
2336 } else if(val
< 30) {
2337 return g_strdup_printf(_("Quieter"));
2338 } else if(val
< 45) {
2339 return g_strdup_printf(_("Quiet"));
2340 } else if(val
< 55) {
2341 return g_strdup_printf(_("Normal"));
2342 } else if(val
< 70) {
2343 return g_strdup_printf(_("Loud"));
2344 } else if(val
< 85) {
2345 return g_strdup_printf(_("Louder"));
2347 return g_strdup_printf(_("Loudest"));
2352 prefs_sound_volume_changed(GtkRange
*range
)
2354 int val
= (int)gtk_range_get_value(GTK_RANGE(range
));
2355 purple_prefs_set_int(PIDGIN_PREFS_ROOT
"/sound/volume", val
);
2360 prefs_sound_sel(GtkTreeSelection
*sel
, GtkTreeModel
*model
)
2367 if (! gtk_tree_selection_get_selected (sel
, &model
, &iter
))
2371 gtk_tree_model_get_value (model
, &iter
, 3, &val
);
2372 sound_row_sel
= g_value_get_uint(&val
);
2374 pref
= g_strdup_printf(PIDGIN_PREFS_ROOT
"/sound/file/%s",
2375 pidgin_sound_get_event_option(sound_row_sel
));
2376 file
= purple_prefs_get_path(pref
);
2379 gtk_entry_set_text(GTK_ENTRY(sound_entry
), (file
&& *file
!= '\0') ? file
: _("(default)"));
2380 g_value_unset (&val
);
2382 pref_sound_generate_markup();
2387 mute_changed_cb(const char *pref_name
,
2388 PurplePrefType pref_type
,
2392 GtkToggleButton
*button
= data
;
2393 gboolean muted
= GPOINTER_TO_INT(val
);
2395 g_return_if_fail(!strcmp (pref_name
, PIDGIN_PREFS_ROOT
"/sound/mute"));
2397 /* Block the handler that re-sets the preference. */
2398 g_signal_handlers_block_matched(button
, G_SIGNAL_MATCH_DATA
, 0, 0, NULL
, NULL
, (gpointer
)pref_name
);
2399 gtk_toggle_button_set_active (button
, muted
);
2400 g_signal_handlers_unblock_matched(button
, G_SIGNAL_MATCH_DATA
, 0, 0, NULL
, NULL
, (gpointer
)pref_name
);
2408 GtkWidget
*vbox
, *vbox2
, *sw
, *button
;
2411 GtkWidget
*event_view
;
2412 GtkListStore
*event_store
;
2413 GtkCellRenderer
*rend
;
2414 GtkTreeViewColumn
*col
;
2415 GtkTreeSelection
*sel
;
2427 ret
= gtk_vbox_new(FALSE
, PIDGIN_HIG_CAT_SPACE
);
2428 gtk_container_set_border_width (GTK_CONTAINER (ret
), PIDGIN_HIG_BORDER
);
2430 sg
= gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL
);
2432 vbox2
= pidgin_make_frame(ret
, _("Sound Options"));
2434 vbox
= gtk_vbox_new(FALSE
, PIDGIN_HIG_BOX_SPACE
);
2435 gtk_box_pack_start(GTK_BOX(vbox2
), vbox
, FALSE
, FALSE
, 0);
2438 dd
= pidgin_prefs_dropdown(vbox2
, _("_Method:"), PURPLE_PREF_STRING
,
2439 PIDGIN_PREFS_ROOT
"/sound/method",
2440 _("Console beep"), "beep",
2441 #ifdef USE_GSTREAMER
2442 _("Automatic"), "automatic",
2446 _("Command"), "custom",
2447 _("No sounds"), "none",
2449 gtk_size_group_add_widget(sg
, dd
);
2450 gtk_misc_set_alignment(GTK_MISC(dd
), 0, 0.5);
2452 entry
= gtk_entry_new();
2453 gtk_editable_set_editable(GTK_EDITABLE(entry
), TRUE
);
2454 cmd
= purple_prefs_get_path(PIDGIN_PREFS_ROOT
"/sound/command");
2456 gtk_entry_set_text(GTK_ENTRY(entry
), cmd
);
2457 g_signal_connect(G_OBJECT(entry
), "changed",
2458 G_CALLBACK(sound_cmd_yeah
), NULL
);
2460 hbox
= pidgin_add_widget_to_vbox(GTK_BOX(vbox
), _("Sound c_ommand:\n(%s for filename)"), sg
, entry
, TRUE
, NULL
);
2461 purple_prefs_connect_callback(prefs
, PIDGIN_PREFS_ROOT
"/sound/method",
2462 sound_changed1_cb
, hbox
);
2463 gtk_widget_set_sensitive(hbox
,
2464 !strcmp(purple_prefs_get_string(PIDGIN_PREFS_ROOT
"/sound/method"),
2468 button
= pidgin_prefs_checkbox(_("M_ute sounds"), PIDGIN_PREFS_ROOT
"/sound/mute", vbox
);
2469 purple_prefs_connect_callback(prefs
, PIDGIN_PREFS_ROOT
"/sound/mute", mute_changed_cb
, button
);
2471 pidgin_prefs_checkbox(_("Sounds when conversation has _focus"),
2472 PIDGIN_PREFS_ROOT
"/sound/conv_focus", vbox
);
2473 pidgin_prefs_dropdown(vbox
, _("_Enable sounds:"),
2474 PURPLE_PREF_INT
, "/purple/sound/while_status",
2475 _("Only when available"), 1,
2476 _("Only when not available"), 2,
2480 #ifdef USE_GSTREAMER
2481 sw
= gtk_hscale_new_with_range(0.0, 100.0, 5.0);
2482 gtk_range_set_increments(GTK_RANGE(sw
), 5.0, 25.0);
2483 gtk_range_set_value(GTK_RANGE(sw
), purple_prefs_get_int(PIDGIN_PREFS_ROOT
"/sound/volume"));
2484 g_signal_connect (G_OBJECT (sw
), "format-value",
2485 G_CALLBACK (prefs_sound_volume_format
),
2487 g_signal_connect (G_OBJECT (sw
), "value-changed",
2488 G_CALLBACK (prefs_sound_volume_changed
),
2490 hbox
= pidgin_add_widget_to_vbox(GTK_BOX(vbox
), _("V_olume:"), NULL
, sw
, TRUE
, NULL
);
2492 purple_prefs_connect_callback(prefs
, PIDGIN_PREFS_ROOT
"/sound/method",
2493 sound_changed3_cb
, hbox
);
2494 sound_changed3_cb(PIDGIN_PREFS_ROOT
"/sound/method", PURPLE_PREF_STRING
,
2495 purple_prefs_get_string(PIDGIN_PREFS_ROOT
"/sound/method"), hbox
);
2499 gtk_widget_set_sensitive(vbox
,
2500 strcmp(purple_prefs_get_string(PIDGIN_PREFS_ROOT
"/sound/method"), "none"));
2501 purple_prefs_connect_callback(prefs
, PIDGIN_PREFS_ROOT
"/sound/method",
2502 sound_changed2_cb
, vbox
);
2504 vbox
= pidgin_make_frame(ret
, _("Sound Events"));
2506 /* The following is an ugly hack to make the frame expand so the
2507 * sound events list is big enough to be usable */
2508 gtk_box_set_child_packing(GTK_BOX(vbox
->parent
), vbox
, TRUE
, TRUE
, 0,
2510 gtk_box_set_child_packing(GTK_BOX(vbox
->parent
->parent
), vbox
->parent
, TRUE
,
2511 TRUE
, 0, GTK_PACK_START
);
2512 gtk_box_set_child_packing(GTK_BOX(vbox
->parent
->parent
->parent
),
2513 vbox
->parent
->parent
, TRUE
, TRUE
, 0, GTK_PACK_START
);
2515 /* SOUND SELECTION */
2516 sw
= gtk_scrolled_window_new(NULL
,NULL
);
2517 gtk_widget_set_size_request(sw
, -1, 100);
2518 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw
), GTK_POLICY_NEVER
, GTK_POLICY_AUTOMATIC
);
2519 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW(sw
), GTK_SHADOW_IN
);
2521 gtk_box_pack_start(GTK_BOX(vbox
), sw
, TRUE
, TRUE
, 0);
2522 event_store
= gtk_list_store_new (4, G_TYPE_BOOLEAN
, G_TYPE_STRING
, G_TYPE_STRING
, G_TYPE_UINT
);
2524 for (j
=0; j
< PURPLE_NUM_SOUNDS
; j
++) {
2525 char *pref
= g_strdup_printf(PIDGIN_PREFS_ROOT
"/sound/enabled/%s",
2526 pidgin_sound_get_event_option(j
));
2527 const char *label
= pidgin_sound_get_event_label(j
);
2529 if (label
== NULL
) {
2534 gtk_list_store_append (event_store
, &iter
);
2535 gtk_list_store_set(event_store
, &iter
,
2536 0, purple_prefs_get_bool(pref
),
2544 event_view
= gtk_tree_view_new_with_model (GTK_TREE_MODEL(event_store
));
2546 rend
= gtk_cell_renderer_toggle_new();
2547 sel
= gtk_tree_view_get_selection (GTK_TREE_VIEW (event_view
));
2548 g_signal_connect (G_OBJECT (sel
), "changed",
2549 G_CALLBACK (prefs_sound_sel
),
2551 g_signal_connect (G_OBJECT(rend
), "toggled",
2552 G_CALLBACK(event_toggled
), event_store
);
2553 path
= gtk_tree_path_new_first();
2554 gtk_tree_selection_select_path(sel
, path
);
2555 gtk_tree_path_free(path
);
2557 col
= gtk_tree_view_column_new_with_attributes (_("Play"),
2561 gtk_tree_view_append_column (GTK_TREE_VIEW(event_view
), col
);
2563 rend
= gtk_cell_renderer_text_new();
2564 col
= gtk_tree_view_column_new_with_attributes (_("Event"),
2568 gtk_tree_view_append_column (GTK_TREE_VIEW(event_view
), col
);
2569 g_object_unref(G_OBJECT(event_store
));
2570 gtk_container_add(GTK_CONTAINER(sw
), event_view
);
2572 hbox
= gtk_hbox_new(FALSE
, PIDGIN_HIG_BOX_SPACE
);
2573 gtk_box_pack_start(GTK_BOX(vbox
), hbox
, FALSE
, FALSE
, 0);
2574 sound_entry
= gtk_entry_new();
2575 pref
= g_strdup_printf(PIDGIN_PREFS_ROOT
"/sound/file/%s",
2576 pidgin_sound_get_event_option(0));
2577 file
= purple_prefs_get_path(pref
);
2579 gtk_entry_set_text(GTK_ENTRY(sound_entry
), (file
&& *file
!= '\0') ? file
: _("(default)"));
2580 gtk_editable_set_editable(GTK_EDITABLE(sound_entry
), FALSE
);
2581 gtk_box_pack_start(GTK_BOX(hbox
), sound_entry
, FALSE
, FALSE
, PIDGIN_HIG_BOX_SPACE
);
2583 button
= gtk_button_new_with_mnemonic(_("_Browse..."));
2584 g_signal_connect(G_OBJECT(button
), "clicked", G_CALLBACK(select_sound
), NULL
);
2585 gtk_box_pack_start(GTK_BOX(hbox
), button
, FALSE
, FALSE
, 1);
2587 button
= gtk_button_new_with_mnemonic(_("Pre_view"));
2588 g_signal_connect(G_OBJECT(button
), "clicked", G_CALLBACK(test_sound
), NULL
);
2589 gtk_box_pack_start(GTK_BOX(hbox
), button
, FALSE
, FALSE
, 1);
2591 button
= gtk_button_new_with_mnemonic(_("_Reset"));
2592 g_signal_connect(G_OBJECT(button
), "clicked", G_CALLBACK(reset_sound
), NULL
);
2593 gtk_box_pack_start(GTK_BOX(hbox
), button
, FALSE
, FALSE
, 1);
2595 gtk_widget_show_all(ret
);
2603 set_idle_away(PurpleSavedStatus
*status
)
2605 purple_prefs_set_int("/purple/savedstatus/idleaway", purple_savedstatus_get_creation_time(status
));
2609 set_startupstatus(PurpleSavedStatus
*status
)
2611 purple_prefs_set_int("/purple/savedstatus/startup", purple_savedstatus_get_creation_time(status
));
2627 ret
= gtk_vbox_new(FALSE
, PIDGIN_HIG_CAT_SPACE
);
2628 gtk_container_set_border_width (GTK_CONTAINER (ret
), PIDGIN_HIG_BORDER
);
2630 sg
= gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL
);
2633 vbox
= pidgin_make_frame(ret
, _("Idle"));
2635 dd
= pidgin_prefs_dropdown(vbox
, _("_Report idle time:"),
2636 PURPLE_PREF_STRING
, "/purple/away/idle_reporting",
2638 _("From last sent message"), "purple",
2639 #if defined(USE_SCREENSAVER) || defined(HAVE_IOKIT)
2640 _("Based on keyboard or mouse use"), "system",
2643 gtk_size_group_add_widget(sg
, dd
);
2644 gtk_misc_set_alignment(GTK_MISC(dd
), 0, 0.5);
2646 select
= pidgin_prefs_labeled_spin_button(vbox
,
2647 _("_Minutes before becoming idle:"), "/purple/away/mins_before_away",
2650 hbox
= gtk_hbox_new(FALSE
, PIDGIN_HIG_BOX_SPACE
);
2651 gtk_box_pack_start(GTK_BOX(vbox
), hbox
, FALSE
, FALSE
, 0);
2653 button
= pidgin_prefs_checkbox(_("Change to this status when _idle:"),
2654 "/purple/away/away_when_idle", hbox
);
2655 gtk_size_group_add_widget(sg
, button
);
2657 /* TODO: Show something useful if we don't have any saved statuses. */
2658 menu
= pidgin_status_menu(purple_savedstatus_get_idleaway(), G_CALLBACK(set_idle_away
));
2659 gtk_size_group_add_widget(sg
, menu
);
2660 gtk_box_pack_start(GTK_BOX(hbox
), menu
, FALSE
, FALSE
, 0);
2662 g_signal_connect(G_OBJECT(button
), "clicked",
2663 G_CALLBACK(pidgin_toggle_sensitive
), menu
);
2665 if(!purple_prefs_get_bool("/purple/away/away_when_idle"))
2666 gtk_widget_set_sensitive(GTK_WIDGET(menu
), FALSE
);
2669 vbox
= pidgin_make_frame(ret
, _("Away"));
2671 dd
= pidgin_prefs_dropdown(vbox
, _("_Auto-reply:"),
2672 PURPLE_PREF_STRING
, "/purple/away/auto_reply",
2673 _("Never"), "never",
2674 _("When away"), "away",
2675 _("When both away and idle"), "awayidle",
2677 gtk_size_group_add_widget(sg
, dd
);
2678 gtk_misc_set_alignment(GTK_MISC(dd
), 0, 0.5);
2680 /* Signon status stuff */
2681 vbox
= pidgin_make_frame(ret
, _("Status at Startup"));
2683 button
= pidgin_prefs_checkbox(_("Use status from last _exit at startup"),
2684 "/purple/savedstatus/startup_current_status", vbox
);
2685 gtk_size_group_add_widget(sg
, button
);
2687 /* TODO: Show something useful if we don't have any saved statuses. */
2688 menu
= pidgin_status_menu(purple_savedstatus_get_startup(), G_CALLBACK(set_startupstatus
));
2689 gtk_size_group_add_widget(sg
, menu
);
2690 g_signal_connect(G_OBJECT(button
), "clicked",
2691 G_CALLBACK(pidgin_toggle_sensitive
), menu
);
2692 pidgin_add_widget_to_vbox(GTK_BOX(vbox
), _("Status to a_pply at startup:"), sg
, menu
, TRUE
, &label
);
2693 g_signal_connect(G_OBJECT(button
), "clicked",
2694 G_CALLBACK(pidgin_toggle_sensitive
), label
);
2696 if(purple_prefs_get_bool("/purple/savedstatus/startup_current_status")) {
2697 gtk_widget_set_sensitive(GTK_WIDGET(menu
), FALSE
);
2698 gtk_widget_set_sensitive(GTK_WIDGET(label
), FALSE
);
2701 gtk_widget_show_all(ret
);
2708 prefs_notebook_add_page(const char *text
, GtkWidget
*page
, int ind
)
2710 return gtk_notebook_append_page(GTK_NOTEBOOK(prefsnotebook
), page
, gtk_label_new(text
));
2714 prefs_notebook_init(void)
2716 prefs_notebook_add_page(_("Interface"), interface_page(), notebook_page
++);
2719 /* We use the registered default browser in windows */
2720 /* if the user is running Mac OS X, hide the browsers tab */
2721 if(purple_running_osx() == FALSE
)
2722 prefs_notebook_add_page(_("Browser"), browser_page(), notebook_page
++);
2725 prefs_notebook_add_page(_("Conversations"), conv_page(), notebook_page
++);
2726 prefs_notebook_add_page(_("Logging"), logging_page(), notebook_page
++);
2727 prefs_notebook_add_page(_("Network"), network_page(), notebook_page
++);
2728 prefs_notebook_add_page(_("Proxy"), proxy_page(), notebook_page
++);
2730 prefs_notebook_add_page(_("Sounds"), sound_page(), notebook_page
++);
2731 prefs_notebook_add_page(_("Status / Idle"), away_page(), notebook_page
++);
2732 prefs_notebook_add_page(_("Themes"), theme_page(), notebook_page
++);
2736 pidgin_prefs_show(void)
2739 GtkWidget
*notebook
;
2743 gtk_window_present(GTK_WINDOW(prefs
));
2747 /* copy the preferences to tmp values...
2748 * I liked "take affect immediately" Oh well :-( */
2749 /* (that should have been "effect," right?) */
2751 /* Back to instant-apply! I win! BU-HAHAHA! */
2753 /* Create the window */
2754 prefs
= pidgin_create_dialog(_("Preferences"), PIDGIN_HIG_BORDER
, "preferences", FALSE
);
2755 g_signal_connect(G_OBJECT(prefs
), "destroy",
2756 G_CALLBACK(delete_prefs
), NULL
);
2758 vbox
= pidgin_dialog_get_vbox_with_properties(GTK_DIALOG(prefs
), FALSE
, PIDGIN_HIG_BORDER
);
2761 prefsnotebook
= notebook
= gtk_notebook_new ();
2762 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(notebook
), GTK_POS_LEFT
);
2763 gtk_box_pack_start(GTK_BOX (vbox
), notebook
, FALSE
, FALSE
, 0);
2764 gtk_widget_show(prefsnotebook
);
2766 button
= pidgin_dialog_add_button(GTK_DIALOG(prefs
), GTK_STOCK_CLOSE
, NULL
, NULL
);
2767 g_signal_connect_swapped(G_OBJECT(button
), "clicked",
2768 G_CALLBACK(gtk_widget_destroy
), prefs
);
2770 prefs_notebook_init();
2772 /* Refresh the list of themes before showing the preferences window */
2773 prefs_themes_refresh();
2775 /* Show everything. */
2776 gtk_widget_show(prefs
);
2780 set_bool_pref(GtkWidget
*w
, const char *key
)
2782 purple_prefs_set_bool(key
,
2783 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w
)));
2787 pidgin_prefs_checkbox(const char *text
, const char *key
, GtkWidget
*page
)
2791 button
= gtk_check_button_new_with_mnemonic(text
);
2792 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button
),
2793 purple_prefs_get_bool(key
));
2795 gtk_box_pack_start(GTK_BOX(page
), button
, FALSE
, FALSE
, 0);
2797 g_signal_connect(G_OBJECT(button
), "clicked",
2798 G_CALLBACK(set_bool_pref
), (char *)key
);
2800 gtk_widget_show(button
);
2806 smiley_theme_pref_cb(const char *name
, PurplePrefType type
,
2807 gconstpointer value
, gpointer data
)
2809 const char *themename
= value
;
2812 for (themes
= smiley_themes
; themes
; themes
= themes
->next
) {
2813 struct smiley_theme
*smile
= themes
->data
;
2814 if (smile
->name
&& strcmp(themename
, smile
->name
) == 0) {
2815 pidgin_themes_load_smiley_theme(smile
->path
, TRUE
);
2822 pidgin_prefs_init(void)
2824 purple_prefs_add_none(PIDGIN_PREFS_ROOT
"");
2825 purple_prefs_add_none("/plugins/gtk");
2829 purple_prefs_add_none(PIDGIN_PREFS_ROOT
"/browsers");
2830 purple_prefs_add_int(PIDGIN_PREFS_ROOT
"/browsers/place", PIDGIN_BROWSER_DEFAULT
);
2831 purple_prefs_add_string(PIDGIN_PREFS_ROOT
"/browsers/manual_command", "");
2832 purple_prefs_add_string(PIDGIN_PREFS_ROOT
"/browsers/browser", "mozilla");
2836 purple_prefs_add_none(PIDGIN_PREFS_ROOT
"/plugins");
2837 purple_prefs_add_path_list(PIDGIN_PREFS_ROOT
"/plugins/loaded", NULL
);
2839 /* File locations */
2840 purple_prefs_add_none(PIDGIN_PREFS_ROOT
"/filelocations");
2841 purple_prefs_add_path(PIDGIN_PREFS_ROOT
"/filelocations/last_save_folder", "");
2842 purple_prefs_add_path(PIDGIN_PREFS_ROOT
"/filelocations/last_open_folder", "");
2843 purple_prefs_add_path(PIDGIN_PREFS_ROOT
"/filelocations/last_icon_folder", "");
2846 prefs_themes_init();
2849 purple_prefs_add_none(PIDGIN_PREFS_ROOT
"/smileys");
2850 purple_prefs_add_string(PIDGIN_PREFS_ROOT
"/smileys/theme", "Default");
2852 /* Smiley Callbacks */
2853 purple_prefs_connect_callback(&prefs
, PIDGIN_PREFS_ROOT
"/smileys/theme",
2854 smiley_theme_pref_cb
, NULL
);
2856 pidgin_prefs_update_old();
2860 pidgin_prefs_update_old(void)
2862 const char *str
= NULL
;
2864 purple_prefs_rename("/gaim/gtk", PIDGIN_PREFS_ROOT
);
2866 /* Rename some old prefs */
2867 purple_prefs_rename(PIDGIN_PREFS_ROOT
"/logging/log_ims", "/purple/logging/log_ims");
2868 purple_prefs_rename(PIDGIN_PREFS_ROOT
"/logging/log_chats", "/purple/logging/log_chats");
2869 purple_prefs_rename("/purple/conversations/placement",
2870 PIDGIN_PREFS_ROOT
"/conversations/placement");
2872 purple_prefs_rename(PIDGIN_PREFS_ROOT
"/debug/timestamps", "/purple/debug/timestamps");
2873 purple_prefs_rename(PIDGIN_PREFS_ROOT
"/conversations/im/raise_on_events", "/plugins/gtk/X11/notify/method_raise");
2875 purple_prefs_rename_boolean_toggle(PIDGIN_PREFS_ROOT
"/conversations/ignore_colors",
2876 PIDGIN_PREFS_ROOT
"/conversations/show_incoming_formatting");
2879 * this path pref changed to a string, so migrate. I know this will break
2880 * things for and confuse users that use multiple versions with the same
2881 * config directory, but I'm not inclined to want to deal with that at the
2882 * moment. -- rekkanoryo
2884 if((str
= purple_prefs_get_path(PIDGIN_PREFS_ROOT
"/browsers/command")) != NULL
) {
2885 purple_prefs_set_string(PIDGIN_PREFS_ROOT
"/browsers/manual_command", str
);
2886 purple_prefs_remove(PIDGIN_PREFS_ROOT
"/browsers/command");
2889 /* this string pref moved into the core, try to be friendly */
2890 purple_prefs_rename(PIDGIN_PREFS_ROOT
"/idle/reporting_method", "/purple/away/idle_reporting");
2891 if ((str
= purple_prefs_get_string("/purple/away/idle_reporting")) &&
2892 strcmp(str
, "gaim") == 0)
2893 purple_prefs_set_string("/purple/away/idle_reporting", "purple");
2895 /* Remove some no-longer-used prefs */
2896 purple_prefs_remove(PIDGIN_PREFS_ROOT
"/blist/auto_expand_contacts");
2897 purple_prefs_remove(PIDGIN_PREFS_ROOT
"/blist/button_style");
2898 purple_prefs_remove(PIDGIN_PREFS_ROOT
"/blist/grey_idle_buddies");
2899 purple_prefs_remove(PIDGIN_PREFS_ROOT
"/blist/raise_on_events");
2900 purple_prefs_remove(PIDGIN_PREFS_ROOT
"/blist/show_group_count");
2901 purple_prefs_remove(PIDGIN_PREFS_ROOT
"/blist/show_warning_level");
2902 purple_prefs_remove(PIDGIN_PREFS_ROOT
"/conversations/button_type");
2903 purple_prefs_remove(PIDGIN_PREFS_ROOT
"/conversations/ctrl_enter_sends");
2904 purple_prefs_remove(PIDGIN_PREFS_ROOT
"/conversations/enter_sends");
2905 purple_prefs_remove(PIDGIN_PREFS_ROOT
"/conversations/escape_closes");
2906 purple_prefs_remove(PIDGIN_PREFS_ROOT
"/conversations/html_shortcuts");
2907 purple_prefs_remove(PIDGIN_PREFS_ROOT
"/conversations/icons_on_tabs");
2908 purple_prefs_remove(PIDGIN_PREFS_ROOT
"/conversations/send_formatting");
2909 purple_prefs_remove(PIDGIN_PREFS_ROOT
"/conversations/show_smileys");
2910 purple_prefs_remove(PIDGIN_PREFS_ROOT
"/conversations/show_urls_as_links");
2911 purple_prefs_remove(PIDGIN_PREFS_ROOT
"/conversations/smiley_shortcuts");
2912 purple_prefs_remove(PIDGIN_PREFS_ROOT
"/conversations/use_custom_bgcolor");
2913 purple_prefs_remove(PIDGIN_PREFS_ROOT
"/conversations/use_custom_fgcolor");
2914 purple_prefs_remove(PIDGIN_PREFS_ROOT
"/conversations/use_custom_font");
2915 purple_prefs_remove(PIDGIN_PREFS_ROOT
"/conversations/use_custom_size");
2916 purple_prefs_remove(PIDGIN_PREFS_ROOT
"/conversations/chat/old_tab_complete");
2917 purple_prefs_remove(PIDGIN_PREFS_ROOT
"/conversations/chat/tab_completion");
2918 purple_prefs_remove(PIDGIN_PREFS_ROOT
"/conversations/im/hide_on_send");
2919 purple_prefs_remove(PIDGIN_PREFS_ROOT
"/conversations/chat/color_nicks");
2920 purple_prefs_remove(PIDGIN_PREFS_ROOT
"/conversations/chat/raise_on_events");
2921 purple_prefs_remove(PIDGIN_PREFS_ROOT
"/conversations/ignore_fonts");
2922 purple_prefs_remove(PIDGIN_PREFS_ROOT
"/conversations/ignore_font_sizes");
2923 purple_prefs_remove(PIDGIN_PREFS_ROOT
"/conversations/passthrough_unknown_commands");
2924 purple_prefs_remove(PIDGIN_PREFS_ROOT
"/idle");
2925 purple_prefs_remove(PIDGIN_PREFS_ROOT
"/logging/individual_logs");
2926 purple_prefs_remove(PIDGIN_PREFS_ROOT
"/sound/signon");
2927 purple_prefs_remove(PIDGIN_PREFS_ROOT
"/sound/silent_signon");
2929 /* Convert old queuing prefs to hide_new 3-way pref. */
2930 if (purple_prefs_exists("/plugins/gtk/docklet/queue_messages") &&
2931 purple_prefs_get_bool("/plugins/gtk/docklet/queue_messages"))
2933 purple_prefs_set_string(PIDGIN_PREFS_ROOT
"/conversations/im/hide_new", "always");
2935 else if (purple_prefs_exists(PIDGIN_PREFS_ROOT
"/away/queue_messages") &&
2936 purple_prefs_get_bool(PIDGIN_PREFS_ROOT
"/away/queue_messages"))
2938 purple_prefs_set_string(PIDGIN_PREFS_ROOT
"/conversations/im/hide_new", "away");
2940 purple_prefs_remove(PIDGIN_PREFS_ROOT
"/away/queue_messages");
2941 purple_prefs_remove(PIDGIN_PREFS_ROOT
"/away");
2942 purple_prefs_remove("/plugins/gtk/docklet/queue_messages");
2944 purple_prefs_remove(PIDGIN_PREFS_ROOT
"/conversations/chat/default_width");
2945 purple_prefs_remove(PIDGIN_PREFS_ROOT
"/conversations/chat/default_height");
2946 purple_prefs_remove(PIDGIN_PREFS_ROOT
"/conversations/im/default_width");
2947 purple_prefs_remove(PIDGIN_PREFS_ROOT
"/conversations/im/default_height");
2948 purple_prefs_rename(PIDGIN_PREFS_ROOT
"/conversations/x",
2949 PIDGIN_PREFS_ROOT
"/conversations/im/x");
2950 purple_prefs_rename(PIDGIN_PREFS_ROOT
"/conversations/y",
2951 PIDGIN_PREFS_ROOT
"/conversations/im/y");