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 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
);
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
? pidgin_pixbuf_new_from_file(theme
->icon
) : 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
&& purple_strequal(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
= pidgin_pixbuf_new_from_file_at_scale(image_full
, PREFS_OPTIMAL_ICON_SIZE
, PREFS_OPTIMAL_ICON_SIZE
, TRUE
);
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
= pidgin_pixbuf_new_from_file_at_scale(image_full
, PREFS_OPTIMAL_ICON_SIZE
, PREFS_OPTIMAL_ICON_SIZE
, TRUE
);
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 (purple_strequal(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
= pidgin_pixbuf_new_from_file_at_scale(tmp
, PREFS_OPTIMAL_ICON_SIZE
, PREFS_OPTIMAL_ICON_SIZE
, TRUE
);
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
= purple_strequal(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
);
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();
741 /* something was wrong with the theme archive */
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
);
756 gchar
*source_name
= g_path_get_basename(path
);
757 temp_file
= g_build_filename(temp_path
, source_name
, NULL
);
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
);
779 g_object_unref(theme
);
781 prefs_themes_refresh();
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
);
790 purple_notify_error(NULL
, NULL
, _("Theme failed to copy."), NULL
);
798 free_theme_info(info
);
802 theme_got_url(PurpleUtilFetchUrlData
*url_data
, gpointer user_data
,
803 const gchar
*themedata
, size_t len
, const gchar
*error_message
)
809 if ((error_message
!= NULL
) || (len
== 0)) {
810 free_theme_info(user_data
);
814 f
= purple_mkstemp(&path
, TRUE
);
815 wc
= fwrite(themedata
, len
, 1, f
);
817 purple_debug_warning("theme_got_url", "Unable to write theme data.\n");
821 free_theme_info(user_data
);
826 theme_install_theme(path
, user_data
);
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 */
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
;
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
);
860 theme_install_theme(tmp
, info
);
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);
876 purple_util_fetch_url(tmp
, TRUE
, NULL
, FALSE
, theme_got_url
, info
);
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 */
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},
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
);
921 /* sets the current sound theme */
923 prefs_set_sound_theme_cb(GtkComboBox
*combo_box
, gpointer user_data
)
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
, "");
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)"));
953 /* sets the current smiley theme */
955 prefs_set_smiley_theme_cb(GtkComboBox
*combo_box
, gpointer user_data
)
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
);
972 /* Does same as normal sort, except "none" is sorted first */
973 static gint
pidgin_sort_smileys (GtkTreeModel
*model
,
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
))
991 /* Sort name1 first */
993 } else if (!g_ascii_strcasecmp(name2
, "none")) {
994 /* Sort name2 first */
997 /* Neither string is "none", default to normal sort */
998 ret
= purple_utf8_strcasecmp(name1
, name2
);
1007 /* sets the current buddy list theme */
1009 prefs_set_blist_theme_cb(GtkComboBox
*combo_box
, gpointer user_data
)
1011 PidginBlistTheme
*theme
= 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"));
1024 pidgin_blist_set_theme(theme
);
1028 /* sets the current icon theme */
1030 prefs_set_status_icon_theme_cb(GtkComboBox
*combo_box
, gpointer user_data
)
1032 PidginStatusIconTheme
*theme
= 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"));
1045 pidgin_stock_load_status_icon_theme(theme
);
1046 pidgin_blist_refresh(purple_get_blist());
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
)
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
),
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);
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"));
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");
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");
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
);
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
));
1160 face
= g_strdup("");
1162 purple_prefs_set_string(PIDGIN_PREFS_ROOT
"/conversations/font_face", face
);
1166 if (buttons
& GTK_IMHTML_FORECOLOR
) {
1167 char *color
= gtk_imhtml_get_current_forecolor(GTK_IMHTML(imhtml
));
1169 color
= g_strdup("");
1171 purple_prefs_set_string(PIDGIN_PREFS_ROOT
"/conversations/fgcolor", color
);
1175 if (buttons
& GTK_IMHTML_BACKCOLOR
) {
1179 color
= gtk_imhtml_get_current_backcolor(GTK_IMHTML(imhtml
));
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
,
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
,
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
);
1200 if (buttons
& GTK_IMHTML_BACKGROUND
) {
1201 char *color
= gtk_imhtml_get_current_background(GTK_IMHTML(imhtml
));
1203 color
= g_strdup("");
1205 purple_prefs_set_string(PIDGIN_PREFS_ROOT
"/conversations/bgcolor", color
);
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", "");
1225 conversation_usetabs_cb(const char *name
, PurplePrefType type
,
1226 gconstpointer value
, gpointer data
)
1228 gboolean usetabs
= GPOINTER_TO_INT(value
);
1231 gtk_widget_set_sensitive(GTK_WIDGET(data
), TRUE
);
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;
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.
1256 conversation_close_accel_changed_cb (GtkAccelMap
*object
,
1259 GdkModifierType accel_mods
,
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
);
1272 escape_closes_conversation_cb(GtkWidget
*w
,
1275 gboolean active
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w
));
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.
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.
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
, ¤t
);
1321 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox
),
1322 accel_is_escape(¤t
));
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);
1334 interface_page(void)
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
);
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",
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",
1366 gtk_size_group_add_widget(sg
, label
);
1367 gtk_misc_set_alignment(GTK_MISC(label
), 0.0, 0.5);
1370 pidgin_prefs_checkbox(_("Minimi_ze new conversation windows"), PIDGIN_PREFS_ROOT
"/win32/minimize_new_convs", vbox
);
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,
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
);
1414 keyboard_shortcuts(ret
);
1416 gtk_widget_show_all(ret
);
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
);
1433 pango_font_description_free(desc
);
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();
1453 GtkWidget
*iconpref1
;
1454 GtkWidget
*iconpref2
;
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
);
1483 pidgin_prefs_checkbox(_("Highlight _misspelled words"),
1484 PIDGIN_PREFS_ROOT
"/conversations/spellcheck", vbox
);
1487 pidgin_prefs_checkbox(_("Use smooth-scrolling"), PIDGIN_PREFS_ROOT
"/conversations/use_smooth_scrolling", vbox
);
1490 pidgin_prefs_checkbox(_("F_lash window when IMs are received"), PIDGIN_PREFS_ROOT
"/win32/blink_im", vbox
);
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
,
1499 PIDGIN_PREFS_ROOT
"/conversations/custom_smileys_size",
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",
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();
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
);
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
),
1553 GTK_IMHTML_UNDERLINE
|
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
);
1579 network_ip_changed(GtkEntry
*entry
, gpointer data
)
1581 const gchar
*text
= gtk_entry_get_text(entry
);
1584 if (text
&& *text
) {
1585 if (purple_ip_address_is_valid(text
)) {
1587 color
.green
= 0xFFFF;
1588 color
.blue
= 0xAFFF;
1590 purple_network_set_public_ip(text
);
1593 color
.green
= 0xAFFF;
1594 color
.blue
= 0xAFFF;
1597 gtk_widget_modify_base(GTK_WIDGET(entry
), GTK_STATE_NORMAL
, &color
);
1600 purple_network_set_public_ip("");
1601 gtk_widget_modify_base(GTK_WIDGET(entry
), GTK_STATE_NORMAL
, NULL
);
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
));
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
));
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
);
1639 gtk_widget_hide(frame
);
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
));
1656 proxy_button_clicked_cb(GtkWidget
*button
, gchar
*program
)
1660 if (g_spawn_command_line_async(program
, &err
))
1663 purple_notify_error(NULL
, NULL
, _("Cannot start proxy configuration program."), err
->message
);
1669 browser_button_clicked_cb(GtkWidget
*button
, gchar
*path
)
1673 if (g_spawn_command_line_async(path
, &err
))
1676 purple_notify_error(NULL
, NULL
, _("Cannot start browser configuration program."), err
->message
);
1682 auto_ip_button_clicked_cb(GtkWidget
*button
, gpointer null
)
1685 PurpleStunNatDiscovery
*stun
;
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
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
;
1698 /* Attempt to get the IP from a NAT device using UPnP */
1699 ip
= purple_upnp_get_public_ip();
1701 /* Attempt to get the IP from a NAT device using NAT-PMP */
1702 ip
= purple_pmp_get_public_ip();
1704 /* Just fetch the IP of the local system */
1705 ip
= purple_network_get_local_system_ip(-1);
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
);
1722 GtkWidget
*vbox
, *hbox
, *entry
;
1723 GtkWidget
*label
, *auto_ip_checkbox
, *ports_checkbox
, *spin_button
;
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
);
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
);
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
);
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 */
1851 get_available_browsers(void)
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
;
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
;
1907 purple_prefs_set_string(PIDGIN_PREFS_ROOT
"/browsers/browser", "custom");
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"));
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"));
1935 GtkWidget
*ret
, *vbox
, *hbox
, *label
, *entry
, *browser_button
;
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()) {
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");
1957 gchar
*tmp
= g_strdup_printf("%s info", path
);
1961 path
= g_find_program_in_path("gnome-default-applications-properties");
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);
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
);
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",
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
,
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
);
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()) {
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");
2053 path
= g_find_program_in_path("gnome-network-preferences");
2055 path
= g_find_program_in_path("gnome-control-center");
2057 char *tmp
= g_strdup_printf("%s network", path
);
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);
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
),
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,
2078 gtk_widget_show_all(ret
);
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",
2095 _("Use Environmental Settings"), "envvar",
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
);
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
);
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
);
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
)));
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"));
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
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 */
2270 event_toggled(GtkCellRendererToggle
*cell
, gchar
*pth
, gpointer data
)
2272 GtkTreeModel
*model
= (GtkTreeModel
*)data
;
2274 GtkTreePath
*path
= gtk_tree_path_new_from_string(pth
);
2277 gtk_tree_model_get_iter (model
, &iter
, path
);
2278 gtk_tree_model_get (model
, &iter
,
2282 purple_prefs_set_bool(pref
, !gtk_cell_renderer_toggle_get_active(cell
));
2285 gtk_list_store_set(GTK_LIST_STORE (model
), &iter
,
2286 0, !gtk_cell_renderer_toggle_get_active(cell
),
2289 gtk_tree_path_free(path
);
2293 test_sound(GtkWidget
*button
, gpointer i_am_NULL
)
2296 gboolean temp_enabled
;
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
);
2317 * Resets a sound file back to default.
2320 reset_sound(GtkWidget
*button
, gpointer i_am_also_NULL
)
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
, "");
2329 gtk_entry_set_text(GTK_ENTRY(sound_entry
), _("(default)"));
2331 pref_sound_generate_markup();
2335 sound_chosen_cb(void *user_data
, const char *filename
)
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
);
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();
2359 select_sound(GtkWidget
*button
, gpointer being_NULL_is_fun
)
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
);
2369 if (*filename
== '\0')
2372 purple_request_file(prefs
, _("Sound Selection"), filename
, FALSE
,
2373 G_CALLBACK(sound_chosen_cb
), NULL
,
2375 GINT_TO_POINTER(sound_row_sel
));
2378 #ifdef USE_GSTREAMER
2380 prefs_sound_volume_format(GtkScale
*scale
, gdouble val
)
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"));
2395 return g_strdup_printf(_("Loudest"));
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
);
2408 prefs_sound_sel(GtkTreeSelection
*sel
, GtkTreeModel
*model
)
2415 if (! gtk_tree_selection_get_selected (sel
, &model
, &iter
))
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
);
2427 gtk_entry_set_text(GTK_ENTRY(sound_entry
), (file
&& *file
!= '\0') ? file
: _("(default)"));
2428 g_value_unset (&val
);
2430 pref_sound_generate_markup();
2435 mute_changed_cb(const char *pref_name
,
2436 PurplePrefType pref_type
,
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
);
2456 GtkWidget
*vbox
, *vbox2
, *sw
, *button
;
2459 GtkWidget
*event_view
;
2460 GtkListStore
*event_store
;
2461 GtkCellRenderer
*rend
;
2462 GtkTreeViewColumn
*col
;
2463 GtkTreeSelection
*sel
;
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);
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",
2494 _("Command"), "custom",
2495 _("No sounds"), "none",
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");
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"),
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,
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
),
2535 g_signal_connect (G_OBJECT (sw
), "value-changed",
2536 G_CALLBACK (prefs_sound_volume_changed
),
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
);
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
);
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,
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
) {
2576 gtk_list_store_append (event_store
, &iter
);
2577 gtk_list_store_set(event_store
, &iter
,
2578 0, purple_prefs_get_bool(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
),
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"),
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"),
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),
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
);
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
);
2647 set_idle_away(PurpleSavedStatus
*status
)
2649 purple_prefs_set_int("/purple/savedstatus/idleaway", purple_savedstatus_get_creation_time(status
));
2653 set_startupstatus(PurpleSavedStatus
*status
)
2655 purple_prefs_set_int("/purple/savedstatus/startup", purple_savedstatus_get_creation_time(status
));
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
);
2676 vbox
= pidgin_make_frame(ret
, _("Idle"));
2678 dd
= pidgin_prefs_dropdown(vbox
, _("_Report idle time:"),
2679 PURPLE_PREF_STRING
, "/purple/away/idle_reporting",
2681 _("From last sent message"), "purple",
2682 #if defined(USE_SCREENSAVER) || defined(HAVE_IOKIT)
2683 _("Based on keyboard or mouse use"), "system",
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",
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
);
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",
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
);
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
));
2757 prefs_notebook_init(void)
2759 prefs_notebook_add_page(_("Interface"), interface_page(), notebook_page
++);
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
++);
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
++);
2779 pidgin_prefs_show(void)
2782 GtkWidget
*notebook
;
2786 gtk_window_present(GTK_WINDOW(prefs
));
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
);
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
);
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
)));
2830 pidgin_prefs_checkbox(const char *text
, const char *key
, GtkWidget
*page
)
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
);
2849 smiley_theme_pref_cb(const char *name
, PurplePrefType type
,
2850 gconstpointer value
, gpointer data
)
2852 const char *themename
= value
;
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
);
2865 pidgin_prefs_init(void)
2867 purple_prefs_add_none(PIDGIN_PREFS_ROOT
"");
2868 purple_prefs_add_none("/plugins/gtk");
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");
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", "");
2889 prefs_themes_init();
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();
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");