| |
1 /** |
| |
2 * @file gtkprefs.c GTK+ Preferences |
| |
3 * @ingroup gtkui |
| |
4 * |
| |
5 * gaim |
| |
6 * |
| |
7 * Gaim is the legal property of its developers, whose names are too numerous |
| |
8 * to list here. Please refer to the COPYRIGHT file distributed with this |
| |
9 * source distribution. |
| |
10 * |
| |
11 * This program is free software; you can redistribute it and/or modify |
| |
12 * it under the terms of the GNU General Public License as published by |
| |
13 * the Free Software Foundation; either version 2 of the License, or |
| |
14 * (at your option) any later version. |
| |
15 * |
| |
16 * This program is distributed in the hope that it will be useful, |
| |
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| |
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| |
19 * GNU General Public License for more details. |
| |
20 * |
| |
21 * You should have received a copy of the GNU General Public License |
| |
22 * along with this program; if not, write to the Free Software |
| |
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| |
24 * |
| |
25 */ |
| |
26 #include "internal.h" |
| |
27 #include "gtkgaim.h" |
| |
28 |
| |
29 #include "debug.h" |
| |
30 #include "notify.h" |
| |
31 #include "prefs.h" |
| |
32 #include "proxy.h" |
| |
33 #include "prpl.h" |
| |
34 #include "request.h" |
| |
35 #include "savedstatuses.h" |
| |
36 #include "sound.h" |
| |
37 #include "util.h" |
| |
38 #include "network.h" |
| |
39 |
| |
40 #include "gtkblist.h" |
| |
41 #include "gtkconv.h" |
| |
42 #include "gtkdebug.h" |
| |
43 #include "gtkdialogs.h" |
| |
44 #include "gtkimhtml.h" |
| |
45 #include "gtkimhtmltoolbar.h" |
| |
46 #include "gtkprefs.h" |
| |
47 #include "gtksavedstatuses.h" |
| |
48 #include "gtksound.h" |
| |
49 #include "gtkthemes.h" |
| |
50 #include "gtkutils.h" |
| |
51 #include "gaimstock.h" |
| |
52 |
| |
53 #define PROXYHOST 0 |
| |
54 #define PROXYPORT 1 |
| |
55 #define PROXYUSER 2 |
| |
56 #define PROXYPASS 3 |
| |
57 |
| |
58 static int sound_row_sel = 0; |
| |
59 static GtkWidget *prefsnotebook; |
| |
60 |
| |
61 static GtkWidget *sound_entry = NULL; |
| |
62 static GtkListStore *smiley_theme_store = NULL; |
| |
63 static GtkWidget *prefs_proxy_frame = NULL; |
| |
64 |
| |
65 static GtkWidget *prefs = NULL; |
| |
66 static GtkWidget *debugbutton = NULL; |
| |
67 static int notebook_page = 0; |
| |
68 static GtkTreeRowReference *previous_smiley_row = NULL; |
| |
69 |
| |
70 /* |
| |
71 * PROTOTYPES |
| |
72 */ |
| |
73 static int prefs_notebook_add_page(const char*, GdkPixbuf*, |
| |
74 GtkWidget*, GtkTreeIter*, |
| |
75 GtkTreeIter*, int); |
| |
76 static void delete_prefs(GtkWidget *, void *); |
| |
77 |
| |
78 static void |
| |
79 update_spin_value(GtkWidget *w, GtkWidget *spin) |
| |
80 { |
| |
81 const char *key = g_object_get_data(G_OBJECT(spin), "val"); |
| |
82 int value; |
| |
83 |
| |
84 value = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spin)); |
| |
85 |
| |
86 gaim_prefs_set_int(key, value); |
| |
87 } |
| |
88 |
| |
89 GtkWidget * |
| |
90 gaim_gtk_prefs_labeled_spin_button(GtkWidget *box, const gchar *title, |
| |
91 const char *key, int min, int max, GtkSizeGroup *sg) |
| |
92 { |
| |
93 GtkWidget *hbox; |
| |
94 GtkWidget *label; |
| |
95 GtkWidget *spin; |
| |
96 GtkObject *adjust; |
| |
97 int val; |
| |
98 |
| |
99 val = gaim_prefs_get_int(key); |
| |
100 |
| |
101 hbox = gtk_hbox_new(FALSE, 5); |
| |
102 gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, FALSE, 5); |
| |
103 gtk_widget_show(hbox); |
| |
104 |
| |
105 label = gtk_label_new_with_mnemonic(title); |
| |
106 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); |
| |
107 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
| |
108 gtk_widget_show(label); |
| |
109 |
| |
110 adjust = gtk_adjustment_new(val, min, max, 1, 1, 1); |
| |
111 spin = gtk_spin_button_new(GTK_ADJUSTMENT(adjust), 1, 0); |
| |
112 g_object_set_data(G_OBJECT(spin), "val", (char *)key); |
| |
113 if (max < 10000) |
| |
114 gtk_widget_set_size_request(spin, 50, -1); |
| |
115 else |
| |
116 gtk_widget_set_size_request(spin, 60, -1); |
| |
117 gtk_box_pack_start(GTK_BOX(hbox), spin, FALSE, FALSE, 0); |
| |
118 g_signal_connect(G_OBJECT(adjust), "value-changed", |
| |
119 G_CALLBACK(update_spin_value), GTK_WIDGET(spin)); |
| |
120 gtk_widget_show(spin); |
| |
121 |
| |
122 gtk_label_set_mnemonic_widget(GTK_LABEL(label), spin); |
| |
123 |
| |
124 if (sg) { |
| |
125 gtk_size_group_add_widget(sg, label); |
| |
126 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); |
| |
127 } |
| |
128 |
| |
129 gaim_set_accessible_label (spin, label); |
| |
130 |
| |
131 return hbox; |
| |
132 } |
| |
133 |
| |
134 static void |
| |
135 entry_set(GtkEntry *entry, gpointer data) { |
| |
136 const char *key = (const char*)data; |
| |
137 |
| |
138 gaim_prefs_set_string(key, gtk_entry_get_text(entry)); |
| |
139 } |
| |
140 |
| |
141 GtkWidget * |
| |
142 gaim_gtk_prefs_labeled_entry(GtkWidget *page, const gchar *title, |
| |
143 const char *key, GtkSizeGroup *sg) |
| |
144 { |
| |
145 GtkWidget *hbox, *label, *entry; |
| |
146 const gchar *value; |
| |
147 |
| |
148 value = gaim_prefs_get_string(key); |
| |
149 |
| |
150 hbox = gtk_hbox_new(FALSE, 5); |
| |
151 gtk_box_pack_start(GTK_BOX(page), hbox, FALSE, FALSE, 0); |
| |
152 gtk_widget_show(hbox); |
| |
153 |
| |
154 label = gtk_label_new_with_mnemonic(title); |
| |
155 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); |
| |
156 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
| |
157 gtk_widget_show(label); |
| |
158 |
| |
159 entry = gtk_entry_new(); |
| |
160 gtk_entry_set_text(GTK_ENTRY(entry), value); |
| |
161 gtk_box_pack_start(GTK_BOX(hbox), entry, FALSE, FALSE, 0); |
| |
162 g_signal_connect(G_OBJECT(entry), "changed", |
| |
163 G_CALLBACK(entry_set), (char*)key); |
| |
164 gtk_widget_show(entry); |
| |
165 |
| |
166 gtk_label_set_mnemonic_widget(GTK_LABEL(label), entry); |
| |
167 |
| |
168 if(sg) { |
| |
169 gtk_size_group_add_widget(sg, label); |
| |
170 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); |
| |
171 } |
| |
172 |
| |
173 gaim_set_accessible_label(entry, label); |
| |
174 |
| |
175 return hbox; |
| |
176 } |
| |
177 |
| |
178 static void |
| |
179 dropdown_set(GObject *w, const char *key) |
| |
180 { |
| |
181 const char *str_value; |
| |
182 int int_value; |
| |
183 GaimPrefType type; |
| |
184 |
| |
185 type = GPOINTER_TO_INT(g_object_get_data(w, "type")); |
| |
186 |
| |
187 if (type == GAIM_PREF_INT) { |
| |
188 int_value = GPOINTER_TO_INT(g_object_get_data(w, "value")); |
| |
189 |
| |
190 gaim_prefs_set_int(key, int_value); |
| |
191 } |
| |
192 else if (type == GAIM_PREF_STRING) { |
| |
193 str_value = (const char *)g_object_get_data(w, "value"); |
| |
194 |
| |
195 gaim_prefs_set_string(key, str_value); |
| |
196 } |
| |
197 else if (type == GAIM_PREF_BOOLEAN) { |
| |
198 gaim_prefs_set_bool(key, |
| |
199 GPOINTER_TO_INT(g_object_get_data(w, "value"))); |
| |
200 } |
| |
201 } |
| |
202 |
| |
203 GtkWidget * |
| |
204 gaim_gtk_prefs_dropdown_from_list(GtkWidget *box, const gchar *title, |
| |
205 GaimPrefType type, const char *key, GList *menuitems) |
| |
206 { |
| |
207 GtkWidget *dropdown, *opt, *menu; |
| |
208 GtkWidget *label = NULL; |
| |
209 GtkWidget *hbox; |
| |
210 gchar *text; |
| |
211 const char *stored_str = NULL; |
| |
212 int stored_int = 0; |
| |
213 int int_value = 0; |
| |
214 const char *str_value = NULL; |
| |
215 int o = 0; |
| |
216 |
| |
217 g_return_val_if_fail(menuitems != NULL, NULL); |
| |
218 |
| |
219 if (title != NULL) { |
| |
220 hbox = gtk_hbox_new(FALSE, 5); |
| |
221 /*gtk_container_add (GTK_CONTAINER (box), hbox);*/ |
| |
222 gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, FALSE, 0); |
| |
223 gtk_widget_show(hbox); |
| |
224 |
| |
225 label = gtk_label_new_with_mnemonic(title); |
| |
226 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
| |
227 gtk_widget_show(label); |
| |
228 } else { |
| |
229 hbox = box; |
| |
230 } |
| |
231 |
| |
232 #if 0 /* GTK_CHECK_VERSION(2,4,0) */ |
| |
233 if(type == GAIM_PREF_INT) |
| |
234 model = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_INT); |
| |
235 else if(type == GAIM_PREF_STRING) |
| |
236 model = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_STRING); |
| |
237 dropdown = gtk_combo_box_new_with_model(model); |
| |
238 #else |
| |
239 dropdown = gtk_option_menu_new(); |
| |
240 menu = gtk_menu_new(); |
| |
241 #endif |
| |
242 |
| |
243 if (label != NULL) { |
| |
244 gtk_label_set_mnemonic_widget(GTK_LABEL(label), dropdown); |
| |
245 gaim_set_accessible_label (dropdown, label); |
| |
246 } |
| |
247 |
| |
248 if (type == GAIM_PREF_INT) |
| |
249 stored_int = gaim_prefs_get_int(key); |
| |
250 else if (type == GAIM_PREF_STRING) |
| |
251 stored_str = gaim_prefs_get_string(key); |
| |
252 |
| |
253 while (menuitems != NULL && (text = (char *) menuitems->data) != NULL) { |
| |
254 menuitems = g_list_next(menuitems); |
| |
255 g_return_val_if_fail(menuitems != NULL, NULL); |
| |
256 |
| |
257 opt = gtk_menu_item_new_with_label(text); |
| |
258 |
| |
259 g_object_set_data(G_OBJECT(opt), "type", GINT_TO_POINTER(type)); |
| |
260 |
| |
261 if (type == GAIM_PREF_INT) { |
| |
262 int_value = GPOINTER_TO_INT(menuitems->data); |
| |
263 g_object_set_data(G_OBJECT(opt), "value", |
| |
264 GINT_TO_POINTER(int_value)); |
| |
265 } |
| |
266 else if (type == GAIM_PREF_STRING) { |
| |
267 str_value = (const char *)menuitems->data; |
| |
268 |
| |
269 g_object_set_data(G_OBJECT(opt), "value", (char *)str_value); |
| |
270 } |
| |
271 else if (type == GAIM_PREF_BOOLEAN) { |
| |
272 g_object_set_data(G_OBJECT(opt), "value", |
| |
273 menuitems->data); |
| |
274 } |
| |
275 |
| |
276 g_signal_connect(G_OBJECT(opt), "activate", |
| |
277 G_CALLBACK(dropdown_set), (char *)key); |
| |
278 |
| |
279 gtk_widget_show(opt); |
| |
280 gtk_menu_shell_append(GTK_MENU_SHELL(menu), opt); |
| |
281 |
| |
282 if ((type == GAIM_PREF_INT && stored_int == int_value) || |
| |
283 (type == GAIM_PREF_STRING && stored_str != NULL && |
| |
284 !strcmp(stored_str, str_value)) || |
| |
285 (type == GAIM_PREF_BOOLEAN && |
| |
286 (gaim_prefs_get_bool(key) == GPOINTER_TO_INT(menuitems->data)))) { |
| |
287 |
| |
288 gtk_menu_set_active(GTK_MENU(menu), o); |
| |
289 } |
| |
290 |
| |
291 menuitems = g_list_next(menuitems); |
| |
292 |
| |
293 o++; |
| |
294 } |
| |
295 |
| |
296 gtk_option_menu_set_menu(GTK_OPTION_MENU(dropdown), menu); |
| |
297 gtk_box_pack_start(GTK_BOX(hbox), dropdown, FALSE, FALSE, 0); |
| |
298 gtk_widget_show(dropdown); |
| |
299 |
| |
300 return label; |
| |
301 } |
| |
302 |
| |
303 GtkWidget * |
| |
304 gaim_gtk_prefs_dropdown(GtkWidget *box, const gchar *title, GaimPrefType type, |
| |
305 const char *key, ...) |
| |
306 { |
| |
307 va_list ap; |
| |
308 GList *menuitems = NULL; |
| |
309 GtkWidget *dropdown = NULL; |
| |
310 char *name; |
| |
311 int int_value; |
| |
312 const char *str_value; |
| |
313 |
| |
314 g_return_val_if_fail(type == GAIM_PREF_BOOLEAN || type == GAIM_PREF_INT || |
| |
315 type == GAIM_PREF_STRING, NULL); |
| |
316 |
| |
317 va_start(ap, key); |
| |
318 while ((name = va_arg(ap, char *)) != NULL) { |
| |
319 |
| |
320 menuitems = g_list_prepend(menuitems, name); |
| |
321 |
| |
322 if (type == GAIM_PREF_INT || type == GAIM_PREF_BOOLEAN) { |
| |
323 int_value = va_arg(ap, int); |
| |
324 menuitems = g_list_prepend(menuitems, GINT_TO_POINTER(int_value)); |
| |
325 } |
| |
326 else { |
| |
327 str_value = va_arg(ap, const char *); |
| |
328 menuitems = g_list_prepend(menuitems, (char *)str_value); |
| |
329 } |
| |
330 } |
| |
331 va_end(ap); |
| |
332 |
| |
333 g_return_val_if_fail(menuitems != NULL, NULL); |
| |
334 |
| |
335 menuitems = g_list_reverse(menuitems); |
| |
336 |
| |
337 dropdown = gaim_gtk_prefs_dropdown_from_list(box, title, type, key, |
| |
338 menuitems); |
| |
339 |
| |
340 g_list_free(menuitems); |
| |
341 |
| |
342 return dropdown; |
| |
343 } |
| |
344 |
| |
345 static void |
| |
346 delete_prefs(GtkWidget *asdf, void *gdsa) |
| |
347 { |
| |
348 /* Close any "select sound" request dialogs */ |
| |
349 gaim_request_close_with_handle(prefs); |
| |
350 |
| |
351 /* Unregister callbacks. */ |
| |
352 gaim_prefs_disconnect_by_handle(prefs); |
| |
353 |
| |
354 prefs = NULL; |
| |
355 sound_entry = NULL; |
| |
356 debugbutton = NULL; |
| |
357 notebook_page = 0; |
| |
358 smiley_theme_store = NULL; |
| |
359 if (previous_smiley_row) |
| |
360 gtk_tree_row_reference_free(previous_smiley_row); |
| |
361 previous_smiley_row = NULL; |
| |
362 |
| |
363 } |
| |
364 |
| |
365 static void smiley_sel(GtkTreeSelection *sel, GtkTreeModel *model) { |
| |
366 GtkTreeIter iter; |
| |
367 const char *themename; |
| |
368 char *description; |
| |
369 GValue val; |
| |
370 GtkTreePath *path, *oldpath; |
| |
371 struct smiley_theme *new_theme, *old_theme; |
| |
372 |
| |
373 if (!gtk_tree_selection_get_selected(sel, &model, &iter)) |
| |
374 return; |
| |
375 |
| |
376 old_theme = current_smiley_theme; |
| |
377 val.g_type = 0; |
| |
378 gtk_tree_model_get_value(model, &iter, 3, &val); |
| |
379 path = gtk_tree_model_get_path(model, &iter); |
| |
380 themename = g_value_get_string(&val); |
| |
381 gaim_prefs_set_string("/gaim/gtk/smileys/theme", themename); |
| |
382 g_value_unset (&val); |
| |
383 |
| |
384 /* current_smiley_theme is set in callback for the above pref change */ |
| |
385 new_theme = current_smiley_theme; |
| |
386 description = g_strdup_printf("<span size='larger' weight='bold'>%s</span> - %s\n" |
| |
387 "<span size='smaller' foreground='white'>%s</span>", |
| |
388 new_theme->name, new_theme->author, new_theme->desc); |
| |
389 gtk_list_store_set(smiley_theme_store, &iter, 1, description, -1); |
| |
390 g_free(description); |
| |
391 |
| |
392 if (new_theme != old_theme && previous_smiley_row) { |
| |
393 oldpath = gtk_tree_row_reference_get_path(previous_smiley_row); |
| |
394 if (gtk_tree_model_get_iter(model, &iter, oldpath)) { |
| |
395 description = g_strdup_printf("<span size='larger' weight='bold'>%s</span> - %s\n" |
| |
396 "<span size='smaller' foreground='dim grey'>%s</span>", |
| |
397 old_theme->name, old_theme->author, old_theme->desc); |
| |
398 gtk_list_store_set(smiley_theme_store, &iter, 1, |
| |
399 description, -1); |
| |
400 g_free(description); |
| |
401 } |
| |
402 gtk_tree_path_free(oldpath); |
| |
403 } |
| |
404 if (previous_smiley_row) |
| |
405 gtk_tree_row_reference_free(previous_smiley_row); |
| |
406 previous_smiley_row = gtk_tree_row_reference_new(model, path); |
| |
407 gtk_tree_path_free(path); |
| |
408 } |
| |
409 |
| |
410 static GtkTreeRowReference *theme_refresh_theme_list() |
| |
411 { |
| |
412 GdkPixbuf *pixbuf; |
| |
413 GSList *themes; |
| |
414 GtkTreeIter iter; |
| |
415 GtkTreeRowReference *row_ref = NULL; |
| |
416 |
| |
417 if (previous_smiley_row) |
| |
418 gtk_tree_row_reference_free(previous_smiley_row); |
| |
419 previous_smiley_row = NULL; |
| |
420 |
| |
421 gaim_gtkthemes_smiley_theme_probe(); |
| |
422 |
| |
423 if (!(themes = smiley_themes)) |
| |
424 return NULL; |
| |
425 |
| |
426 gtk_list_store_clear(smiley_theme_store); |
| |
427 |
| |
428 while (themes) { |
| |
429 struct smiley_theme *theme = themes->data; |
| |
430 char *description = g_strdup_printf("<span size='larger' weight='bold'>%s</span> - %s\n" |
| |
431 "<span size='smaller' foreground='dim grey'>%s</span>", |
| |
432 theme->name, theme->author, theme->desc); |
| |
433 gtk_list_store_append (smiley_theme_store, &iter); |
| |
434 |
| |
435 /* |
| |
436 * LEAK - Gentoo memprof thinks pixbuf is leaking here... but it |
| |
437 * looks like it should be ok to me. Anyone know what's up? --Mark |
| |
438 */ |
| |
439 pixbuf = (theme->icon ? gdk_pixbuf_new_from_file(theme->icon, NULL) : NULL); |
| |
440 |
| |
441 gtk_list_store_set(smiley_theme_store, &iter, |
| |
442 0, pixbuf, |
| |
443 1, description, |
| |
444 2, theme->path, |
| |
445 3, theme->name, |
| |
446 -1); |
| |
447 |
| |
448 if (pixbuf != NULL) |
| |
449 g_object_unref(G_OBJECT(pixbuf)); |
| |
450 |
| |
451 g_free(description); |
| |
452 themes = themes->next; |
| |
453 |
| |
454 /* If this is the currently selected theme, |
| |
455 * we will need to select it. Grab the row reference. */ |
| |
456 if (theme == current_smiley_theme) { |
| |
457 GtkTreePath *path = gtk_tree_model_get_path( |
| |
458 GTK_TREE_MODEL(smiley_theme_store), &iter); |
| |
459 row_ref = gtk_tree_row_reference_new( |
| |
460 GTK_TREE_MODEL(smiley_theme_store), path); |
| |
461 gtk_tree_path_free(path); |
| |
462 } |
| |
463 } |
| |
464 |
| |
465 return row_ref; |
| |
466 } |
| |
467 |
| |
468 static void theme_install_theme(char *path, char *extn) { |
| |
469 #ifndef _WIN32 |
| |
470 gchar *command; |
| |
471 #endif |
| |
472 gchar *destdir; |
| |
473 gchar *tail; |
| |
474 GtkTreeRowReference *theme_rowref; |
| |
475 |
| |
476 /* Just to be safe */ |
| |
477 g_strchomp(path); |
| |
478 |
| |
479 /* I dont know what you are, get out of here */ |
| |
480 if (extn != NULL) |
| |
481 tail = extn; |
| |
482 else if ((tail = strrchr(path, '.')) == NULL) |
| |
483 return; |
| |
484 |
| |
485 destdir = g_strconcat(gaim_user_dir(), G_DIR_SEPARATOR_S "smileys", NULL); |
| |
486 |
| |
487 /* We'll check this just to make sure. This also lets us do something different on |
| |
488 * other platforms, if need be */ |
| |
489 if (!g_ascii_strcasecmp(tail, ".gz") || !g_ascii_strcasecmp(tail, ".tgz")) { |
| |
490 #ifndef _WIN32 |
| |
491 gchar *path_escaped = g_shell_quote(path); |
| |
492 gchar *destdir_escaped = g_shell_quote(destdir); |
| |
493 command = g_strdup_printf("tar > /dev/null xzf %s -C %s", path_escaped, destdir_escaped); |
| |
494 g_free(path_escaped); |
| |
495 g_free(destdir_escaped); |
| |
496 #else |
| |
497 if(!wgaim_gz_untar(path, destdir)) { |
| |
498 g_free(destdir); |
| |
499 return; |
| |
500 } |
| |
501 #endif |
| |
502 } |
| |
503 else { |
| |
504 g_free(destdir); |
| |
505 return; |
| |
506 } |
| |
507 |
| |
508 #ifndef _WIN32 |
| |
509 /* Fire! */ |
| |
510 if (system(command)) |
| |
511 { |
| |
512 gaim_notify_error(NULL, NULL, _("Smiley theme failed to unpack."), NULL); |
| |
513 } |
| |
514 |
| |
515 g_free(command); |
| |
516 #endif |
| |
517 g_free(destdir); |
| |
518 |
| |
519 theme_rowref = theme_refresh_theme_list(); |
| |
520 if (theme_rowref != NULL) |
| |
521 gtk_tree_row_reference_free(theme_rowref); |
| |
522 } |
| |
523 |
| |
524 static void |
| |
525 theme_got_url(void *data, const char *themedata, size_t len) |
| |
526 { |
| |
527 FILE *f; |
| |
528 gchar *path; |
| |
529 |
| |
530 if (len == 0) |
| |
531 return; |
| |
532 |
| |
533 f = gaim_mkstemp(&path, TRUE); |
| |
534 fwrite(themedata, len, 1, f); |
| |
535 fclose(f); |
| |
536 |
| |
537 theme_install_theme(path, data); |
| |
538 |
| |
539 g_unlink(path); |
| |
540 g_free(path); |
| |
541 } |
| |
542 |
| |
543 static void theme_dnd_recv(GtkWidget *widget, GdkDragContext *dc, guint x, guint y, GtkSelectionData *sd, |
| |
544 guint info, guint t, gpointer data) { |
| |
545 gchar *name = (gchar *)sd->data; |
| |
546 |
| |
547 if ((sd->length >= 0) && (sd->format == 8)) { |
| |
548 /* Well, it looks like the drag event was cool. |
| |
549 * Let's do something with it */ |
| |
550 |
| |
551 if (!g_ascii_strncasecmp(name, "file://", 7)) { |
| |
552 GError *converr = NULL; |
| |
553 gchar *tmp; |
| |
554 /* It looks like we're dealing with a local file. Let's |
| |
555 * just untar it in the right place */ |
| |
556 if(!(tmp = g_filename_from_uri(name, NULL, &converr))) { |
| |
557 gaim_debug(GAIM_DEBUG_ERROR, "theme dnd", "%s\n", |
| |
558 (converr ? converr->message : |
| |
559 "g_filename_from_uri error")); |
| |
560 return; |
| |
561 } |
| |
562 theme_install_theme(tmp, NULL); |
| |
563 g_free(tmp); |
| |
564 } else if (!g_ascii_strncasecmp(name, "http://", 7)) { |
| |
565 /* Oo, a web drag and drop. This is where things |
| |
566 * will start to get interesting */ |
| |
567 gaim_url_fetch(name, TRUE, NULL, FALSE, theme_got_url, ".tgz"); |
| |
568 } else if (!g_ascii_strncasecmp(name, "https://", 8)) { |
| |
569 /* gaim_url_fetch() doesn't support HTTPS, but we want users |
| |
570 * to be able to drag and drop links from the SF trackers, so |
| |
571 * we'll try it as an HTTP URL. */ |
| |
572 char *tmp = g_strdup(name + 1); |
| |
573 tmp[0] = 'h'; |
| |
574 tmp[1] = 't'; |
| |
575 tmp[2] = 't'; |
| |
576 tmp[3] = 'p'; |
| |
577 gaim_url_fetch(tmp, TRUE, NULL, FALSE, theme_got_url, ".tgz"); |
| |
578 g_free(tmp); |
| |
579 } |
| |
580 |
| |
581 gtk_drag_finish(dc, TRUE, FALSE, t); |
| |
582 } |
| |
583 |
| |
584 gtk_drag_finish(dc, FALSE, FALSE, t); |
| |
585 } |
| |
586 |
| |
587 /* Does same as normal sort, except "none" is sorted first */ |
| |
588 static gint gaim_sort_smileys (GtkTreeModel *model, |
| |
589 GtkTreeIter *a, |
| |
590 GtkTreeIter *b, |
| |
591 gpointer userdata) |
| |
592 { |
| |
593 gint ret = 0; |
| |
594 gchar *name1 = NULL, *name2 = NULL; |
| |
595 |
| |
596 gtk_tree_model_get(model, a, 3, &name1, -1); |
| |
597 gtk_tree_model_get(model, b, 3, &name2, -1); |
| |
598 |
| |
599 if (name1 == NULL || name2 == NULL) { |
| |
600 if (!(name1 == NULL && name2 == NULL)) |
| |
601 ret = (name1 == NULL) ? -1: 1; |
| |
602 } else if (!g_ascii_strcasecmp(name1, "none")) { |
| |
603 if (!g_utf8_collate(name1, name2)) |
| |
604 ret = 0; |
| |
605 else |
| |
606 /* Sort name1 first */ |
| |
607 ret = -1; |
| |
608 } else if (!g_ascii_strcasecmp(name2, "none")) { |
| |
609 /* Sort name2 first */ |
| |
610 ret = 1; |
| |
611 } else { |
| |
612 /* Neither string is "none", default to normal sort */ |
| |
613 ret = g_utf8_collate(name1,name2); |
| |
614 } |
| |
615 |
| |
616 g_free(name1); |
| |
617 g_free(name2); |
| |
618 |
| |
619 return ret; |
| |
620 } |
| |
621 |
| |
622 static GtkWidget * |
| |
623 theme_page() |
| |
624 { |
| |
625 GtkWidget *ret; |
| |
626 GtkWidget *sw; |
| |
627 GtkWidget *view; |
| |
628 GtkCellRenderer *rend; |
| |
629 GtkTreeViewColumn *col; |
| |
630 GtkTreeSelection *sel; |
| |
631 GtkTreeRowReference *rowref; |
| |
632 GtkWidget *label; |
| |
633 GtkTargetEntry te[3] = {{"text/plain", 0, 0},{"text/uri-list", 0, 1},{"STRING", 0, 2}}; |
| |
634 |
| |
635 ret = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
| |
636 gtk_container_set_border_width (GTK_CONTAINER (ret), GAIM_HIG_BORDER); |
| |
637 |
| |
638 label = gtk_label_new(_("Select a smiley theme that you would like to use from the list below. New themes can be installed by dragging and dropping them onto the theme list.")); |
| |
639 |
| |
640 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); |
| |
641 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); |
| |
642 gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); |
| |
643 |
| |
644 gtk_box_pack_start(GTK_BOX(ret), label, FALSE, TRUE, 0); |
| |
645 gtk_widget_show(label); |
| |
646 |
| |
647 sw = gtk_scrolled_window_new(NULL,NULL); |
| |
648 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); |
| |
649 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_IN); |
| |
650 |
| |
651 gtk_box_pack_start(GTK_BOX(ret), sw, TRUE, TRUE, 0); |
| |
652 smiley_theme_store = gtk_list_store_new (4, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); |
| |
653 |
| |
654 rowref = theme_refresh_theme_list(); |
| |
655 |
| |
656 view = gtk_tree_view_new_with_model (GTK_TREE_MODEL(smiley_theme_store)); |
| |
657 |
| |
658 gtk_drag_dest_set(view, GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_HIGHLIGHT | GTK_DEST_DEFAULT_DROP, te, |
| |
659 sizeof(te) / sizeof(GtkTargetEntry) , GDK_ACTION_COPY | GDK_ACTION_MOVE); |
| |
660 |
| |
661 g_signal_connect(G_OBJECT(view), "drag_data_received", G_CALLBACK(theme_dnd_recv), smiley_theme_store); |
| |
662 |
| |
663 rend = gtk_cell_renderer_pixbuf_new(); |
| |
664 sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (view)); |
| |
665 |
| |
666 /* Custom sort so "none" theme is at top of list */ |
| |
667 gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(smiley_theme_store), |
| |
668 3, gaim_sort_smileys, NULL, NULL); |
| |
669 |
| |
670 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(smiley_theme_store), |
| |
671 3, GTK_SORT_ASCENDING); |
| |
672 |
| |
673 col = gtk_tree_view_column_new_with_attributes (_("Icon"), |
| |
674 rend, |
| |
675 "pixbuf", 0, |
| |
676 NULL); |
| |
677 gtk_tree_view_append_column (GTK_TREE_VIEW(view), col); |
| |
678 |
| |
679 rend = gtk_cell_renderer_text_new(); |
| |
680 col = gtk_tree_view_column_new_with_attributes (_("Description"), |
| |
681 rend, |
| |
682 "markup", 1, |
| |
683 NULL); |
| |
684 gtk_tree_view_append_column (GTK_TREE_VIEW(view), col); |
| |
685 g_object_unref(G_OBJECT(smiley_theme_store)); |
| |
686 gtk_container_add(GTK_CONTAINER(sw), view); |
| |
687 |
| |
688 g_signal_connect(G_OBJECT(sel), "changed", G_CALLBACK(smiley_sel), NULL); |
| |
689 |
| |
690 if (rowref) { |
| |
691 GtkTreePath *path = gtk_tree_row_reference_get_path(rowref); |
| |
692 gtk_tree_row_reference_free(rowref); |
| |
693 gtk_tree_selection_select_path(sel, path); |
| |
694 gtk_tree_path_free(path); |
| |
695 } |
| |
696 |
| |
697 gtk_widget_show_all(ret); |
| |
698 |
| |
699 gaim_set_accessible_label (view, label); |
| |
700 |
| |
701 return ret; |
| |
702 } |
| |
703 |
| |
704 static void |
| |
705 formatting_toggle_cb(GtkIMHtml *imhtml, GtkIMHtmlButtons buttons, void *toolbar) |
| |
706 { |
| |
707 gboolean bold, italic, uline; |
| |
708 |
| |
709 gtk_imhtml_get_current_format(GTK_IMHTML(imhtml), |
| |
710 &bold, &italic, &uline); |
| |
711 |
| |
712 if (buttons & GTK_IMHTML_BOLD) |
| |
713 gaim_prefs_set_bool("/gaim/gtk/conversations/send_bold", bold); |
| |
714 if (buttons & GTK_IMHTML_ITALIC) |
| |
715 gaim_prefs_set_bool("/gaim/gtk/conversations/send_italic", italic); |
| |
716 if (buttons & GTK_IMHTML_UNDERLINE) |
| |
717 gaim_prefs_set_bool("/gaim/gtk/conversations/send_underline", uline); |
| |
718 |
| |
719 if (buttons & GTK_IMHTML_GROW || buttons & GTK_IMHTML_SHRINK) |
| |
720 gaim_prefs_set_int("/gaim/gtk/conversations/font_size", |
| |
721 gtk_imhtml_get_current_fontsize(GTK_IMHTML(imhtml))); |
| |
722 if (buttons & GTK_IMHTML_FACE) { |
| |
723 char *face = gtk_imhtml_get_current_fontface(GTK_IMHTML(imhtml)); |
| |
724 if (!face) |
| |
725 face = g_strdup(""); |
| |
726 |
| |
727 gaim_prefs_set_string("/gaim/gtk/conversations/font_face", face); |
| |
728 g_free(face); |
| |
729 } |
| |
730 |
| |
731 if (buttons & GTK_IMHTML_FORECOLOR) { |
| |
732 char *color = gtk_imhtml_get_current_forecolor(GTK_IMHTML(imhtml)); |
| |
733 if (!color) |
| |
734 color = g_strdup(""); |
| |
735 |
| |
736 gaim_prefs_set_string("/gaim/gtk/conversations/fgcolor", color); |
| |
737 g_free(color); |
| |
738 } |
| |
739 |
| |
740 if (buttons & GTK_IMHTML_BACKCOLOR) { |
| |
741 char *color; |
| |
742 GObject *object; |
| |
743 |
| |
744 color = gtk_imhtml_get_current_backcolor(GTK_IMHTML(imhtml)); |
| |
745 if (!color) |
| |
746 color = g_strdup(""); |
| |
747 |
| |
748 /* Block the signal to prevent a loop. */ |
| |
749 object = g_object_ref(G_OBJECT(imhtml)); |
| |
750 g_signal_handlers_block_matched(object, G_SIGNAL_MATCH_DATA, 0, 0, NULL, |
| |
751 NULL, toolbar); |
| |
752 /* Clear the backcolor. */ |
| |
753 gtk_imhtml_toggle_backcolor(GTK_IMHTML(imhtml), ""); |
| |
754 /* Unblock the signal. */ |
| |
755 g_signal_handlers_unblock_matched(object, G_SIGNAL_MATCH_DATA, 0, 0, NULL, |
| |
756 NULL, toolbar); |
| |
757 g_object_unref(object); |
| |
758 |
| |
759 /* This will fire a toggle signal and get saved below. */ |
| |
760 gtk_imhtml_toggle_background(GTK_IMHTML(imhtml), color); |
| |
761 |
| |
762 g_free(color); |
| |
763 } |
| |
764 |
| |
765 if (buttons & GTK_IMHTML_BACKGROUND) { |
| |
766 char *color = gtk_imhtml_get_current_background(GTK_IMHTML(imhtml)); |
| |
767 if (!color) |
| |
768 color = g_strdup(""); |
| |
769 |
| |
770 gaim_prefs_set_string("/gaim/gtk/conversations/bgcolor", color); |
| |
771 g_free(color); |
| |
772 } |
| |
773 } |
| |
774 |
| |
775 static void |
| |
776 formatting_clear_cb(GtkIMHtml *imhtml, void *data) |
| |
777 { |
| |
778 gaim_prefs_set_bool("/gaim/gtk/conversations/send_bold", FALSE); |
| |
779 gaim_prefs_set_bool("/gaim/gtk/conversations/send_italic", FALSE); |
| |
780 gaim_prefs_set_bool("/gaim/gtk/conversations/send_underline", FALSE); |
| |
781 |
| |
782 gaim_prefs_set_int("/gaim/gtk/conversations/font_size", 3); |
| |
783 |
| |
784 gaim_prefs_set_string("/gaim/gtk/conversations/font_face", ""); |
| |
785 gaim_prefs_set_string("/gaim/gtk/conversations/fgcolor", ""); |
| |
786 gaim_prefs_set_string("/gaim/gtk/conversations/bgcolor", ""); |
| |
787 } |
| |
788 |
| |
789 static void |
| |
790 conversation_usetabs_cb(const char *name, GaimPrefType type, |
| |
791 gconstpointer value, gpointer data) |
| |
792 { |
| |
793 gboolean usetabs = GPOINTER_TO_INT(value); |
| |
794 |
| |
795 if (usetabs) |
| |
796 gtk_widget_set_sensitive(GTK_WIDGET(data), TRUE); |
| |
797 else |
| |
798 gtk_widget_set_sensitive(GTK_WIDGET(data), FALSE); |
| |
799 } |
| |
800 |
| |
801 static GtkWidget * |
| |
802 conv_page() |
| |
803 { |
| |
804 GtkWidget *ret; |
| |
805 GtkWidget *vbox; |
| |
806 GtkWidget *label; |
| |
807 GList *names = NULL; |
| |
808 GtkWidget *frame; |
| |
809 GtkWidget *imhtml; |
| |
810 GtkWidget *toolbar; |
| |
811 GtkWidget *hbox; |
| |
812 GtkWidget *vbox2; |
| |
813 GtkWidget *iconpref1; |
| |
814 GtkWidget *iconpref2; |
| |
815 |
| |
816 ret = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
| |
817 gtk_container_set_border_width(GTK_CONTAINER(ret), GAIM_HIG_BORDER); |
| |
818 |
| |
819 vbox = gaim_gtk_make_frame(ret, _("Conversations")); |
| |
820 |
| |
821 gaim_gtk_prefs_dropdown(vbox, _("_Hide new IM conversations"), |
| |
822 GAIM_PREF_STRING, "/gaim/gtk/conversations/im/hide_new", |
| |
823 _("Never"), "never", |
| |
824 _("When away"), "away", |
| |
825 _("Always"), "always", |
| |
826 NULL); |
| |
827 |
| |
828 gaim_gtk_prefs_checkbox(_("Send unknown \"_slash\" commands as messages"), |
| |
829 "/gaim/gtk/conversations/passthrough_unknown_commands", vbox); |
| |
830 gaim_gtk_prefs_checkbox(_("Show _formatting on incoming messages"), |
| |
831 "/gaim/gtk/conversations/show_incoming_formatting", vbox); |
| |
832 |
| |
833 iconpref1 = gaim_gtk_prefs_checkbox(_("Show buddy _icons"), |
| |
834 "/gaim/gtk/conversations/im/show_buddy_icons", vbox); |
| |
835 iconpref2 = gaim_gtk_prefs_checkbox(_("Enable buddy ic_on animation"), |
| |
836 "/gaim/gtk/conversations/im/animate_buddy_icons", vbox); |
| |
837 if (!gaim_prefs_get_bool("/gaim/gtk/conversations/im/show_buddy_icons")) |
| |
838 gtk_widget_set_sensitive(iconpref2, FALSE); |
| |
839 g_signal_connect(G_OBJECT(iconpref1), "clicked", |
| |
840 G_CALLBACK(gaim_gtk_toggle_sensitive), iconpref2); |
| |
841 |
| |
842 gaim_gtk_prefs_checkbox(_("_Notify buddies that you are typing to them"), |
| |
843 "/core/conversations/im/send_typing", vbox); |
| |
844 #ifdef USE_GTKSPELL |
| |
845 gaim_gtk_prefs_checkbox(_("Highlight _misspelled words"), |
| |
846 "/gaim/gtk/conversations/spellcheck", vbox); |
| |
847 #endif |
| |
848 |
| |
849 gaim_gtk_prefs_checkbox(_("Use smooth-scrolling"), "/gaim/gtk/conversations/use_smooth_scrolling", vbox); |
| |
850 |
| |
851 frame = gaim_gtk_create_imhtml(TRUE, &imhtml, &toolbar, NULL); |
| |
852 gtk_widget_set_name(imhtml, "gaim_gtkprefs_font_imhtml"); |
| |
853 gtk_imhtml_set_whole_buffer_formatting_only(GTK_IMHTML(imhtml), TRUE); |
| |
854 gtk_imhtml_set_format_functions(GTK_IMHTML(imhtml), |
| |
855 GTK_IMHTML_BOLD | |
| |
856 GTK_IMHTML_ITALIC | |
| |
857 GTK_IMHTML_UNDERLINE | |
| |
858 GTK_IMHTML_GROW | |
| |
859 GTK_IMHTML_SHRINK | |
| |
860 GTK_IMHTML_FACE | |
| |
861 GTK_IMHTML_FORECOLOR | |
| |
862 GTK_IMHTML_BACKCOLOR | |
| |
863 GTK_IMHTML_BACKGROUND); |
| |
864 |
| |
865 gtk_imhtml_append_text(GTK_IMHTML(imhtml), _("This is how your outgoing message text will appear when you use protocols that support formatting. :)"), 0); |
| |
866 |
| |
867 gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 0); |
| |
868 |
| |
869 if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_bold")) |
| |
870 gtk_imhtml_toggle_bold(GTK_IMHTML(imhtml)); |
| |
871 if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_italic")) |
| |
872 gtk_imhtml_toggle_italic(GTK_IMHTML(imhtml)); |
| |
873 if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_underline")) |
| |
874 gtk_imhtml_toggle_underline(GTK_IMHTML(imhtml)); |
| |
875 |
| |
876 gtk_imhtml_font_set_size(GTK_IMHTML(imhtml), gaim_prefs_get_int("/gaim/gtk/conversations/font_size")); |
| |
877 gtk_imhtml_toggle_forecolor(GTK_IMHTML(imhtml), gaim_prefs_get_string("/gaim/gtk/conversations/fgcolor")); |
| |
878 gtk_imhtml_toggle_background(GTK_IMHTML(imhtml), gaim_prefs_get_string("/gaim/gtk/conversations/bgcolor")); |
| |
879 gtk_imhtml_toggle_fontface(GTK_IMHTML(imhtml), gaim_prefs_get_string("/gaim/gtk/conversations/font_face")); |
| |
880 |
| |
881 g_signal_connect_after(G_OBJECT(imhtml), "format_function_toggle", |
| |
882 G_CALLBACK(formatting_toggle_cb), toolbar); |
| |
883 g_signal_connect_after(G_OBJECT(imhtml), "format_function_clear", |
| |
884 G_CALLBACK(formatting_clear_cb), NULL); |
| |
885 |
| |
886 /* All the tab options! */ |
| |
887 vbox = gaim_gtk_make_frame(ret, _("Tab Options")); |
| |
888 |
| |
889 gaim_gtk_prefs_checkbox(_("Show IMs and chats in _tabbed windows"), |
| |
890 "/gaim/gtk/conversations/tabs", vbox); |
| |
891 |
| |
892 /* |
| |
893 * Connect a signal to the above preference. When conversations are not |
| |
894 * shown in a tabbed window then all tabbing options should be disabled. |
| |
895 */ |
| |
896 vbox2 = gtk_vbox_new(FALSE, 9); |
| |
897 gtk_box_pack_start(GTK_BOX(vbox), vbox2, FALSE, FALSE, 0); |
| |
898 gaim_prefs_connect_callback(prefs, "/gaim/gtk/conversations/tabs", |
| |
899 conversation_usetabs_cb, vbox2); |
| |
900 if (!gaim_prefs_get_bool("/gaim/gtk/conversations/tabs")) |
| |
901 gtk_widget_set_sensitive(vbox2, FALSE); |
| |
902 |
| |
903 gaim_gtk_prefs_checkbox(_("Show close b_utton on tabs"), |
| |
904 "/gaim/gtk/conversations/close_on_tabs", vbox2); |
| |
905 |
| |
906 hbox = gtk_hbox_new(FALSE, 9); |
| |
907 gtk_box_pack_start(GTK_BOX(vbox2), hbox, FALSE, FALSE, 0); |
| |
908 |
| |
909 label = gaim_gtk_prefs_dropdown(hbox, _("_Placement:"), GAIM_PREF_INT, |
| |
910 "/gaim/gtk/conversations/tab_side", |
| |
911 _("Top"), GTK_POS_TOP, |
| |
912 _("Bottom"), GTK_POS_BOTTOM, |
| |
913 _("Left"), GTK_POS_LEFT, |
| |
914 _("Right"), GTK_POS_RIGHT, |
| |
915 #if GTK_CHECK_VERSION(2,6,0) |
| |
916 _("Left Vertical"), GTK_POS_LEFT|8, |
| |
917 _("Right Vertical"), GTK_POS_RIGHT|8, |
| |
918 #endif |
| |
919 NULL); |
| |
920 |
| |
921 names = gaim_gtkconv_placement_get_options(); |
| |
922 label = gaim_gtk_prefs_dropdown_from_list(hbox, _("N_ew conversations:"), |
| |
923 GAIM_PREF_STRING, "/gaim/gtk/conversations/placement", names); |
| |
924 g_list_free(names); |
| |
925 |
| |
926 gtk_widget_show_all(ret); |
| |
927 |
| |
928 return ret; |
| |
929 } |
| |
930 |
| |
931 static void network_ip_changed(GtkEntry *entry, gpointer data) |
| |
932 { |
| |
933 gaim_network_set_public_ip(gtk_entry_get_text(entry)); |
| |
934 } |
| |
935 |
| |
936 static void |
| |
937 proxy_changed_cb(const char *name, GaimPrefType type, |
| |
938 gconstpointer value, gpointer data) |
| |
939 { |
| |
940 GtkWidget *frame = data; |
| |
941 const char *proxy = value; |
| |
942 |
| |
943 if (strcmp(proxy, "none") && strcmp(proxy, "envvar")) |
| |
944 gtk_widget_show_all(frame); |
| |
945 else |
| |
946 gtk_widget_hide(frame); |
| |
947 } |
| |
948 |
| |
949 static void proxy_print_option(GtkEntry *entry, int entrynum) |
| |
950 { |
| |
951 if (entrynum == PROXYHOST) |
| |
952 gaim_prefs_set_string("/core/proxy/host", gtk_entry_get_text(entry)); |
| |
953 else if (entrynum == PROXYPORT) |
| |
954 gaim_prefs_set_int("/core/proxy/port", atoi(gtk_entry_get_text(entry))); |
| |
955 else if (entrynum == PROXYUSER) |
| |
956 gaim_prefs_set_string("/core/proxy/username", gtk_entry_get_text(entry)); |
| |
957 else if (entrynum == PROXYPASS) |
| |
958 gaim_prefs_set_string("/core/proxy/password", gtk_entry_get_text(entry)); |
| |
959 } |
| |
960 |
| |
961 static GtkWidget * |
| |
962 network_page() |
| |
963 { |
| |
964 GtkWidget *ret; |
| |
965 GtkWidget *vbox, *hbox, *entry; |
| |
966 GtkWidget *table, *label, *auto_ip_checkbox, *ports_checkbox, *spin_button; |
| |
967 GtkSizeGroup *sg; |
| |
968 GaimProxyInfo *proxy_info = NULL; |
| |
969 |
| |
970 ret = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
| |
971 gtk_container_set_border_width (GTK_CONTAINER (ret), GAIM_HIG_BORDER); |
| |
972 |
| |
973 vbox = gaim_gtk_make_frame (ret, _("IP Address")); |
| |
974 sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); |
| |
975 gaim_gtk_prefs_labeled_entry(vbox,_("ST_UN server:"), |
| |
976 "/core/network/stun_server", sg); |
| |
977 |
| |
978 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
| |
979 gtk_container_add(GTK_CONTAINER(vbox), hbox); |
| |
980 |
| |
981 label = gtk_label_new(NULL); |
| |
982 gtk_container_add(GTK_CONTAINER(hbox), label); |
| |
983 gtk_size_group_add_widget(sg, label); |
| |
984 |
| |
985 label = gtk_label_new(NULL); |
| |
986 gtk_label_set_markup(GTK_LABEL(label), |
| |
987 _("<span style=\"italic\">Example: stunserver.org</span>")); |
| |
988 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); |
| |
989 gtk_container_add(GTK_CONTAINER(hbox), label); |
| |
990 |
| |
991 auto_ip_checkbox = gaim_gtk_prefs_checkbox(_("_Autodetect IP address"), |
| |
992 "/core/network/auto_ip", vbox); |
| |
993 |
| |
994 table = gtk_table_new(2, 2, FALSE); |
| |
995 gtk_container_set_border_width(GTK_CONTAINER(table), 0); |
| |
996 gtk_table_set_col_spacings(GTK_TABLE(table), 5); |
| |
997 gtk_table_set_row_spacings(GTK_TABLE(table), 10); |
| |
998 gtk_container_add(GTK_CONTAINER(vbox), table); |
| |
999 |
| |
1000 label = gtk_label_new_with_mnemonic(_("Public _IP:")); |
| |
1001 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); |
| |
1002 gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1, GTK_FILL, 0, 0, 0); |
| |
1003 gtk_size_group_add_widget(sg, label); |
| |
1004 |
| |
1005 entry = gtk_entry_new(); |
| |
1006 gtk_label_set_mnemonic_widget(GTK_LABEL(label), entry); |
| |
1007 gtk_table_attach(GTK_TABLE(table), entry, 1, 2, 0, 1, GTK_FILL, 0, 0, 0); |
| |
1008 g_signal_connect(G_OBJECT(entry), "changed", |
| |
1009 G_CALLBACK(network_ip_changed), NULL); |
| |
1010 |
| |
1011 /* |
| |
1012 * TODO: This could be better by showing the autodeteced |
| |
1013 * IP separately from the user-specified IP. |
| |
1014 */ |
| |
1015 if (gaim_network_get_my_ip(-1) != NULL) |
| |
1016 gtk_entry_set_text(GTK_ENTRY(entry), |
| |
1017 gaim_network_get_my_ip(-1)); |
| |
1018 |
| |
1019 gaim_set_accessible_label (entry, label); |
| |
1020 |
| |
1021 |
| |
1022 if (gaim_prefs_get_bool("/core/network/auto_ip")) { |
| |
1023 gtk_widget_set_sensitive(GTK_WIDGET(table), FALSE); |
| |
1024 } |
| |
1025 |
| |
1026 g_signal_connect(G_OBJECT(auto_ip_checkbox), "clicked", |
| |
1027 G_CALLBACK(gaim_gtk_toggle_sensitive), table); |
| |
1028 |
| |
1029 vbox = gaim_gtk_make_frame (ret, _("Ports")); |
| |
1030 sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); |
| |
1031 |
| |
1032 ports_checkbox = gaim_gtk_prefs_checkbox(_("_Manually specify range of ports to listen on"), |
| |
1033 "/core/network/ports_range_use", vbox); |
| |
1034 |
| |
1035 spin_button = gaim_gtk_prefs_labeled_spin_button(vbox, _("_Start port:"), |
| |
1036 "/core/network/ports_range_start", 0, 65535, sg); |
| |
1037 if (!gaim_prefs_get_bool("/core/network/ports_range_use")) |
| |
1038 gtk_widget_set_sensitive(GTK_WIDGET(spin_button), FALSE); |
| |
1039 g_signal_connect(G_OBJECT(ports_checkbox), "clicked", |
| |
1040 G_CALLBACK(gaim_gtk_toggle_sensitive), spin_button); |
| |
1041 |
| |
1042 spin_button = gaim_gtk_prefs_labeled_spin_button(vbox, _("_End port:"), |
| |
1043 "/core/network/ports_range_end", 0, 65535, sg); |
| |
1044 if (!gaim_prefs_get_bool("/core/network/ports_range_use")) |
| |
1045 gtk_widget_set_sensitive(GTK_WIDGET(spin_button), FALSE); |
| |
1046 g_signal_connect(G_OBJECT(ports_checkbox), "clicked", |
| |
1047 G_CALLBACK(gaim_gtk_toggle_sensitive), spin_button); |
| |
1048 |
| |
1049 if (!gaim_running_gnome()) { |
| |
1050 vbox = gaim_gtk_make_frame(ret, _("Proxy Server")); |
| |
1051 prefs_proxy_frame = gtk_vbox_new(FALSE, 0); |
| |
1052 gaim_gtk_prefs_dropdown(vbox, _("Proxy _type:"), GAIM_PREF_STRING, |
| |
1053 "/core/proxy/type", |
| |
1054 _("No proxy"), "none", |
| |
1055 "SOCKS 4", "socks4", |
| |
1056 "SOCKS 5", "socks5", |
| |
1057 "HTTP", "http", |
| |
1058 _("Use Environmental Settings"), "envvar", |
| |
1059 NULL); |
| |
1060 gtk_box_pack_start(GTK_BOX(vbox), prefs_proxy_frame, 0, 0, 0); |
| |
1061 proxy_info = gaim_global_proxy_get_info(); |
| |
1062 |
| |
1063 gaim_prefs_connect_callback(prefs, "/core/proxy/type", |
| |
1064 proxy_changed_cb, prefs_proxy_frame); |
| |
1065 |
| |
1066 table = gtk_table_new(4, 2, FALSE); |
| |
1067 gtk_container_set_border_width(GTK_CONTAINER(table), 0); |
| |
1068 gtk_table_set_col_spacings(GTK_TABLE(table), 5); |
| |
1069 gtk_table_set_row_spacings(GTK_TABLE(table), 10); |
| |
1070 gtk_container_add(GTK_CONTAINER(prefs_proxy_frame), table); |
| |
1071 |
| |
1072 |
| |
1073 label = gtk_label_new_with_mnemonic(_("_Host:")); |
| |
1074 gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5); |
| |
1075 gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1, GTK_FILL, 0, 0, 0); |
| |
1076 |
| |
1077 entry = gtk_entry_new(); |
| |
1078 gtk_label_set_mnemonic_widget(GTK_LABEL(label), entry); |
| |
1079 gtk_table_attach(GTK_TABLE(table), entry, 1, 2, 0, 1, GTK_FILL, 0, 0, 0); |
| |
1080 g_signal_connect(G_OBJECT(entry), "changed", |
| |
1081 G_CALLBACK(proxy_print_option), (void *)PROXYHOST); |
| |
1082 |
| |
1083 if (proxy_info != NULL && gaim_proxy_info_get_host(proxy_info)) |
| |
1084 gtk_entry_set_text(GTK_ENTRY(entry), |
| |
1085 gaim_proxy_info_get_host(proxy_info)); |
| |
1086 |
| |
1087 hbox = gtk_hbox_new(TRUE, 5); |
| |
1088 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
| |
1089 gaim_set_accessible_label (entry, label); |
| |
1090 |
| |
1091 label = gtk_label_new_with_mnemonic(_("_Port:")); |
| |
1092 gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5); |
| |
1093 gtk_table_attach(GTK_TABLE(table), label, 2, 3, 0, 1, GTK_FILL, 0, 0, 0); |
| |
1094 |
| |
1095 entry = gtk_entry_new(); |
| |
1096 gtk_label_set_mnemonic_widget(GTK_LABEL(label), entry); |
| |
1097 gtk_table_attach(GTK_TABLE(table), entry, 3, 4, 0, 1, GTK_FILL, 0, 0, 0); |
| |
1098 g_signal_connect(G_OBJECT(entry), "changed", |
| |
1099 G_CALLBACK(proxy_print_option), (void *)PROXYPORT); |
| |
1100 |
| |
1101 if (proxy_info != NULL && gaim_proxy_info_get_port(proxy_info) != 0) { |
| |
1102 char buf[128]; |
| |
1103 g_snprintf(buf, sizeof(buf), "%d", |
| |
1104 gaim_proxy_info_get_port(proxy_info)); |
| |
1105 |
| |
1106 gtk_entry_set_text(GTK_ENTRY(entry), buf); |
| |
1107 } |
| |
1108 gaim_set_accessible_label (entry, label); |
| |
1109 |
| |
1110 label = gtk_label_new_with_mnemonic(_("_User:")); |
| |
1111 gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5); |
| |
1112 gtk_table_attach(GTK_TABLE(table), label, 0, 1, 1, 2, GTK_FILL, 0, 0, 0); |
| |
1113 |
| |
1114 entry = gtk_entry_new(); |
| |
1115 gtk_label_set_mnemonic_widget(GTK_LABEL(label), entry); |
| |
1116 gtk_table_attach(GTK_TABLE(table), entry, 1, 2, 1, 2, GTK_FILL, 0, 0, 0); |
| |
1117 g_signal_connect(G_OBJECT(entry), "changed", |
| |
1118 G_CALLBACK(proxy_print_option), (void *)PROXYUSER); |
| |
1119 |
| |
1120 if (proxy_info != NULL && gaim_proxy_info_get_username(proxy_info) != NULL) |
| |
1121 gtk_entry_set_text(GTK_ENTRY(entry), |
| |
1122 gaim_proxy_info_get_username(proxy_info)); |
| |
1123 |
| |
1124 hbox = gtk_hbox_new(TRUE, 5); |
| |
1125 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
| |
1126 gaim_set_accessible_label (entry, label); |
| |
1127 |
| |
1128 label = gtk_label_new_with_mnemonic(_("Pa_ssword:")); |
| |
1129 gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5); |
| |
1130 gtk_table_attach(GTK_TABLE(table), label, 2, 3, 1, 2, GTK_FILL, 0, 0, 0); |
| |
1131 |
| |
1132 entry = gtk_entry_new(); |
| |
1133 gtk_label_set_mnemonic_widget(GTK_LABEL(label), entry); |
| |
1134 gtk_table_attach(GTK_TABLE(table), entry, 3, 4, 1, 2, GTK_FILL , 0, 0, 0); |
| |
1135 gtk_entry_set_visibility(GTK_ENTRY(entry), FALSE); |
| |
1136 gtk_entry_set_invisible_char(GTK_ENTRY(entry), GAIM_INVISIBLE_CHAR); |
| |
1137 g_signal_connect(G_OBJECT(entry), "changed", |
| |
1138 G_CALLBACK(proxy_print_option), (void *)PROXYPASS); |
| |
1139 |
| |
1140 if (proxy_info != NULL && gaim_proxy_info_get_password(proxy_info) != NULL) |
| |
1141 gtk_entry_set_text(GTK_ENTRY(entry), |
| |
1142 gaim_proxy_info_get_password(proxy_info)); |
| |
1143 gaim_set_accessible_label (entry, label); |
| |
1144 } |
| |
1145 |
| |
1146 gtk_widget_show_all(ret); |
| |
1147 if (proxy_info == NULL || |
| |
1148 gaim_proxy_info_get_type(proxy_info) == GAIM_PROXY_NONE || |
| |
1149 gaim_proxy_info_get_type(proxy_info) == GAIM_PROXY_USE_ENVVAR) |
| |
1150 gtk_widget_hide(table); |
| |
1151 return ret; |
| |
1152 } |
| |
1153 |
| |
1154 #ifndef _WIN32 |
| |
1155 static gboolean manual_browser_set(GtkWidget *entry, GdkEventFocus *event, gpointer data) { |
| |
1156 const char *program = gtk_entry_get_text(GTK_ENTRY(entry)); |
| |
1157 |
| |
1158 gaim_prefs_set_string("/gaim/gtk/browsers/command", program); |
| |
1159 |
| |
1160 /* carry on normally */ |
| |
1161 return FALSE; |
| |
1162 } |
| |
1163 |
| |
1164 static GList *get_available_browsers() |
| |
1165 { |
| |
1166 struct browser { |
| |
1167 char *name; |
| |
1168 char *command; |
| |
1169 }; |
| |
1170 |
| |
1171 static struct browser possible_browsers[] = { |
| |
1172 {N_("Epiphany"), "epiphany"}, |
| |
1173 {N_("Firebird"), "mozilla-firebird"}, |
| |
1174 {N_("Firefox"), "firefox"}, |
| |
1175 {N_("Galeon"), "galeon"}, |
| |
1176 {N_("GNOME Default"), "gnome-open"}, |
| |
1177 {N_("Konqueror"), "kfmclient"}, |
| |
1178 {N_("Mozilla"), "mozilla"}, |
| |
1179 {N_("Netscape"), "netscape"}, |
| |
1180 {N_("Opera"), "opera"} |
| |
1181 }; |
| |
1182 static const int num_possible_browsers = 9; |
| |
1183 |
| |
1184 GList *browsers = NULL; |
| |
1185 int i = 0; |
| |
1186 char *browser_setting = (char *)gaim_prefs_get_string("/gaim/gtk/browsers/browser"); |
| |
1187 |
| |
1188 browsers = g_list_prepend(browsers, (gpointer)"custom"); |
| |
1189 browsers = g_list_prepend(browsers, (gpointer)_("Manual")); |
| |
1190 |
| |
1191 for (i = 0; i < num_possible_browsers; i++) { |
| |
1192 if (gaim_program_is_valid(possible_browsers[i].command)) { |
| |
1193 browsers = g_list_prepend(browsers, |
| |
1194 possible_browsers[i].command); |
| |
1195 browsers = g_list_prepend(browsers, (gpointer)_(possible_browsers[i].name)); |
| |
1196 if(browser_setting && !strcmp(possible_browsers[i].command, browser_setting)) |
| |
1197 browser_setting = NULL; |
| |
1198 } |
| |
1199 } |
| |
1200 |
| |
1201 if(browser_setting) |
| |
1202 gaim_prefs_set_string("/gaim/gtk/browsers/browser", "custom"); |
| |
1203 |
| |
1204 return browsers; |
| |
1205 } |
| |
1206 |
| |
1207 static void |
| |
1208 browser_changed1_cb(const char *name, GaimPrefType type, |
| |
1209 gconstpointer value, gpointer data) |
| |
1210 { |
| |
1211 GtkWidget *hbox = data; |
| |
1212 const char *browser = value; |
| |
1213 |
| |
1214 gtk_widget_set_sensitive(hbox, strcmp(browser, "custom")); |
| |
1215 } |
| |
1216 |
| |
1217 static void |
| |
1218 browser_changed2_cb(const char *name, GaimPrefType type, |
| |
1219 gconstpointer value, gpointer data) |
| |
1220 { |
| |
1221 GtkWidget *hbox = data; |
| |
1222 const char *browser = value; |
| |
1223 |
| |
1224 gtk_widget_set_sensitive(hbox, !strcmp(browser, "custom")); |
| |
1225 } |
| |
1226 |
| |
1227 static GtkWidget * |
| |
1228 browser_page() |
| |
1229 { |
| |
1230 GtkWidget *ret; |
| |
1231 GtkWidget *vbox; |
| |
1232 GtkWidget *hbox; |
| |
1233 GtkWidget *label; |
| |
1234 GtkWidget *entry; |
| |
1235 GtkSizeGroup *sg; |
| |
1236 GList *browsers = NULL; |
| |
1237 |
| |
1238 ret = gtk_vbox_new(FALSE, GAIM_HIG_CAT_SPACE); |
| |
1239 gtk_container_set_border_width (GTK_CONTAINER (ret), GAIM_HIG_BORDER); |
| |
1240 |
| |
1241 sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); |
| |
1242 vbox = gaim_gtk_make_frame (ret, _("Browser Selection")); |
| |
1243 |
| |
1244 browsers = get_available_browsers(); |
| |
1245 if (browsers != NULL) { |
| |
1246 label = gaim_gtk_prefs_dropdown_from_list(vbox,_("_Browser:"), GAIM_PREF_STRING, |
| |
1247 "/gaim/gtk/browsers/browser", |
| |
1248 browsers); |
| |
1249 g_list_free(browsers); |
| |
1250 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); |
| |
1251 gtk_size_group_add_widget(sg, label); |
| |
1252 |
| |
1253 hbox = gtk_hbox_new(FALSE, 0); |
| |
1254 label = gaim_gtk_prefs_dropdown(hbox, _("_Open link in:"), GAIM_PREF_INT, |
| |
1255 "/gaim/gtk/browsers/place", |
| |
1256 _("Browser default"), GAIM_BROWSER_DEFAULT, |
| |
1257 _("Existing window"), GAIM_BROWSER_CURRENT, |
| |
1258 _("New window"), GAIM_BROWSER_NEW_WINDOW, |
| |
1259 _("New tab"), GAIM_BROWSER_NEW_TAB, |
| |
1260 NULL); |
| |
1261 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); |
| |
1262 gtk_size_group_add_widget(sg, label); |
| |
1263 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
| |
1264 |
| |
1265 if (!strcmp(gaim_prefs_get_string("/gaim/gtk/browsers/browser"), "custom")) |
| |
1266 gtk_widget_set_sensitive(hbox, FALSE); |
| |
1267 gaim_prefs_connect_callback(prefs, "/gaim/gtk/browsers/browser", |
| |
1268 browser_changed1_cb, hbox); |
| |
1269 } |
| |
1270 |
| |
1271 hbox = gtk_hbox_new(FALSE, 5); |
| |
1272 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
| |
1273 label = gtk_label_new_with_mnemonic(_("_Manual:\n(%s for URL)")); |
| |
1274 gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); |
| |
1275 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); |
| |
1276 gtk_size_group_add_widget(sg, label); |
| |
1277 |
| |
1278 entry = gtk_entry_new(); |
| |
1279 gtk_label_set_mnemonic_widget(GTK_LABEL(label), entry); |
| |
1280 |
| |
1281 if (strcmp(gaim_prefs_get_string("/gaim/gtk/browsers/browser"), "custom")) |
| |
1282 gtk_widget_set_sensitive(hbox, FALSE); |
| |
1283 gaim_prefs_connect_callback(prefs, "/gaim/gtk/browsers/browser", |
| |
1284 browser_changed2_cb, hbox); |
| |
1285 |
| |
1286 gtk_box_pack_start (GTK_BOX (hbox), entry, FALSE, FALSE, 0); |
| |
1287 |
| |
1288 gtk_entry_set_text(GTK_ENTRY(entry), |
| |
1289 gaim_prefs_get_string("/gaim/gtk/browsers/command")); |
| |
1290 g_signal_connect(G_OBJECT(entry), "focus-out-event", |
| |
1291 G_CALLBACK(manual_browser_set), NULL); |
| |
1292 gaim_set_accessible_label (entry, label); |
| |
1293 |
| |
1294 gtk_widget_show_all(ret); |
| |
1295 return ret; |
| |
1296 } |
| |
1297 #endif /*_WIN32*/ |
| |
1298 |
| |
1299 static GtkWidget * |
| |
1300 logging_page() |
| |
1301 { |
| |
1302 GtkWidget *ret; |
| |
1303 GtkWidget *vbox; |
| |
1304 GList *names; |
| |
1305 |
| |
1306 ret = gtk_vbox_new(FALSE, GAIM_HIG_CAT_SPACE); |
| |
1307 gtk_container_set_border_width (GTK_CONTAINER (ret), GAIM_HIG_BORDER); |
| |
1308 |
| |
1309 vbox = gaim_gtk_make_frame (ret, _("Logging")); |
| |
1310 names = gaim_log_logger_get_options(); |
| |
1311 |
| |
1312 gaim_gtk_prefs_dropdown_from_list(vbox, _("Log _format:"), GAIM_PREF_STRING, |
| |
1313 "/core/logging/format", names); |
| |
1314 |
| |
1315 g_list_free(names); |
| |
1316 |
| |
1317 gaim_gtk_prefs_checkbox(_("Log all _instant messages"), |
| |
1318 "/core/logging/log_ims", vbox); |
| |
1319 gaim_gtk_prefs_checkbox(_("Log all c_hats"), |
| |
1320 "/core/logging/log_chats", vbox); |
| |
1321 gaim_gtk_prefs_checkbox(_("Log all _status changes to system log"), |
| |
1322 "/core/logging/log_system", vbox); |
| |
1323 |
| |
1324 gtk_widget_show_all(ret); |
| |
1325 |
| |
1326 return ret; |
| |
1327 } |
| |
1328 |
| |
1329 #ifndef _WIN32 |
| |
1330 static gint sound_cmd_yeah(GtkEntry *entry, gpointer d) |
| |
1331 { |
| |
1332 gaim_prefs_set_string("/gaim/gtk/sound/command", |
| |
1333 gtk_entry_get_text(GTK_ENTRY(entry))); |
| |
1334 return TRUE; |
| |
1335 } |
| |
1336 |
| |
1337 static void |
| |
1338 sound_changed1_cb(const char *name, GaimPrefType type, |
| |
1339 gconstpointer value, gpointer data) |
| |
1340 { |
| |
1341 GtkWidget *hbox = data; |
| |
1342 const char *method = value; |
| |
1343 |
| |
1344 gtk_widget_set_sensitive(hbox, !strcmp(method, "custom")); |
| |
1345 } |
| |
1346 |
| |
1347 static void |
| |
1348 sound_changed2_cb(const char *name, GaimPrefType type, |
| |
1349 gconstpointer value, gpointer data) |
| |
1350 { |
| |
1351 GtkWidget *vbox = data; |
| |
1352 const char *method = value; |
| |
1353 |
| |
1354 gtk_widget_set_sensitive(vbox, strcmp(method, "none")); |
| |
1355 } |
| |
1356 |
| |
1357 #ifdef USE_GSTREAMER |
| |
1358 static void |
| |
1359 sound_changed3_cb(const char *name, GaimPrefType type, |
| |
1360 gconstpointer value, gpointer data) |
| |
1361 { |
| |
1362 GtkWidget *hbox = data; |
| |
1363 const char *method = value; |
| |
1364 |
| |
1365 gtk_widget_set_sensitive(hbox, |
| |
1366 !strcmp(method, "automatic") || |
| |
1367 !strcmp(method, "arts") || |
| |
1368 !strcmp(method, "esd") || |
| |
1369 !strcmp(method, "nas")); |
| |
1370 } |
| |
1371 #endif /* USE_GSTREAMER */ |
| |
1372 #endif /* !_WIN32 */ |
| |
1373 |
| |
1374 |
| |
1375 static void |
| |
1376 event_toggled(GtkCellRendererToggle *cell, gchar *pth, gpointer data) |
| |
1377 { |
| |
1378 GtkTreeModel *model = (GtkTreeModel *)data; |
| |
1379 GtkTreeIter iter; |
| |
1380 GtkTreePath *path = gtk_tree_path_new_from_string(pth); |
| |
1381 char *pref; |
| |
1382 |
| |
1383 gtk_tree_model_get_iter (model, &iter, path); |
| |
1384 gtk_tree_model_get (model, &iter, |
| |
1385 2, &pref, |
| |
1386 -1); |
| |
1387 |
| |
1388 gaim_prefs_set_bool(pref, !gtk_cell_renderer_toggle_get_active(cell)); |
| |
1389 g_free(pref); |
| |
1390 |
| |
1391 gtk_list_store_set(GTK_LIST_STORE (model), &iter, |
| |
1392 0, !gtk_cell_renderer_toggle_get_active(cell), |
| |
1393 -1); |
| |
1394 |
| |
1395 gtk_tree_path_free(path); |
| |
1396 } |
| |
1397 |
| |
1398 static void |
| |
1399 test_sound(GtkWidget *button, gpointer i_am_NULL) |
| |
1400 { |
| |
1401 char *pref; |
| |
1402 gboolean temp_value; |
| |
1403 |
| |
1404 pref = g_strdup_printf("/gaim/gtk/sound/enabled/%s", |
| |
1405 gaim_gtk_sound_get_event_option(sound_row_sel)); |
| |
1406 |
| |
1407 temp_value = gaim_prefs_get_bool(pref); |
| |
1408 |
| |
1409 if (!temp_value) gaim_prefs_set_bool(pref, TRUE); |
| |
1410 |
| |
1411 gaim_sound_play_event(sound_row_sel, NULL); |
| |
1412 |
| |
1413 if (!temp_value) gaim_prefs_set_bool(pref, FALSE); |
| |
1414 |
| |
1415 g_free(pref); |
| |
1416 } |
| |
1417 |
| |
1418 /* |
| |
1419 * Resets a sound file back to default. |
| |
1420 */ |
| |
1421 static void |
| |
1422 reset_sound(GtkWidget *button, gpointer i_am_also_NULL) |
| |
1423 { |
| |
1424 gchar *pref; |
| |
1425 |
| |
1426 pref = g_strdup_printf("/gaim/gtk/sound/file/%s", |
| |
1427 gaim_gtk_sound_get_event_option(sound_row_sel)); |
| |
1428 gaim_prefs_set_string(pref, ""); |
| |
1429 g_free(pref); |
| |
1430 |
| |
1431 gtk_entry_set_text(GTK_ENTRY(sound_entry), "(default)"); |
| |
1432 } |
| |
1433 |
| |
1434 static void |
| |
1435 sound_chosen_cb(void *user_data, const char *filename) |
| |
1436 { |
| |
1437 gchar *pref; |
| |
1438 int sound; |
| |
1439 |
| |
1440 sound = GPOINTER_TO_INT(user_data); |
| |
1441 |
| |
1442 /* Set it -- and forget it */ |
| |
1443 pref = g_strdup_printf("/gaim/gtk/sound/file/%s", |
| |
1444 gaim_gtk_sound_get_event_option(sound)); |
| |
1445 gaim_prefs_set_string(pref, filename); |
| |
1446 g_free(pref); |
| |
1447 |
| |
1448 /* |
| |
1449 * If the sound we just changed is still the currently selected |
| |
1450 * sound, then update the box showing the file name. |
| |
1451 */ |
| |
1452 if (sound == sound_row_sel) |
| |
1453 gtk_entry_set_text(GTK_ENTRY(sound_entry), filename); |
| |
1454 } |
| |
1455 |
| |
1456 static void select_sound(GtkWidget *button, gpointer being_NULL_is_fun) |
| |
1457 { |
| |
1458 gchar *pref; |
| |
1459 const char *filename; |
| |
1460 |
| |
1461 pref = g_strdup_printf("/gaim/gtk/sound/file/%s", |
| |
1462 gaim_gtk_sound_get_event_option(sound_row_sel)); |
| |
1463 filename = gaim_prefs_get_string(pref); |
| |
1464 g_free(pref); |
| |
1465 |
| |
1466 if (*filename == '\0') |
| |
1467 filename = NULL; |
| |
1468 |
| |
1469 gaim_request_file(prefs, _("Sound Selection"), filename, FALSE, |
| |
1470 G_CALLBACK(sound_chosen_cb), NULL, GINT_TO_POINTER(sound_row_sel)); |
| |
1471 } |
| |
1472 |
| |
1473 #ifdef USE_GSTREAMER |
| |
1474 static gchar* prefs_sound_volume_format(GtkScale *scale, gdouble val) |
| |
1475 { |
| |
1476 if(val < 15) { |
| |
1477 return g_strdup_printf(_("Quietest")); |
| |
1478 } else if(val < 30) { |
| |
1479 return g_strdup_printf(_("Quieter")); |
| |
1480 } else if(val < 45) { |
| |
1481 return g_strdup_printf(_("Quiet")); |
| |
1482 } else if(val < 55) { |
| |
1483 return g_strdup_printf(_("Normal")); |
| |
1484 } else if(val < 70) { |
| |
1485 return g_strdup_printf(_("Loud")); |
| |
1486 } else if(val < 85) { |
| |
1487 return g_strdup_printf(_("Louder")); |
| |
1488 } else { |
| |
1489 return g_strdup_printf(_("Loudest")); |
| |
1490 } |
| |
1491 } |
| |
1492 |
| |
1493 static void prefs_sound_volume_changed(GtkRange *range) |
| |
1494 { |
| |
1495 int val = (int)gtk_range_get_value(GTK_RANGE(range)); |
| |
1496 gaim_prefs_set_int("/gaim/gtk/sound/volume", val); |
| |
1497 } |
| |
1498 #endif |
| |
1499 |
| |
1500 static void prefs_sound_sel(GtkTreeSelection *sel, GtkTreeModel *model) { |
| |
1501 GtkTreeIter iter; |
| |
1502 GValue val; |
| |
1503 const char *file; |
| |
1504 char *pref; |
| |
1505 |
| |
1506 if (! gtk_tree_selection_get_selected (sel, &model, &iter)) |
| |
1507 return; |
| |
1508 |
| |
1509 val.g_type = 0; |
| |
1510 gtk_tree_model_get_value (model, &iter, 3, &val); |
| |
1511 sound_row_sel = g_value_get_uint(&val); |
| |
1512 |
| |
1513 pref = g_strdup_printf("/gaim/gtk/sound/file/%s", |
| |
1514 gaim_gtk_sound_get_event_option(sound_row_sel)); |
| |
1515 file = gaim_prefs_get_string(pref); |
| |
1516 g_free(pref); |
| |
1517 if (sound_entry) |
| |
1518 gtk_entry_set_text(GTK_ENTRY(sound_entry), (file && *file != '\0') ? file : "(default)"); |
| |
1519 g_value_unset (&val); |
| |
1520 } |
| |
1521 |
| |
1522 static GtkWidget * |
| |
1523 sound_page() |
| |
1524 { |
| |
1525 GtkWidget *ret; |
| |
1526 GtkWidget *vbox, *sw, *button; |
| |
1527 GtkSizeGroup *sg; |
| |
1528 GtkTreeIter iter; |
| |
1529 GtkWidget *event_view; |
| |
1530 GtkListStore *event_store; |
| |
1531 GtkCellRenderer *rend; |
| |
1532 GtkTreeViewColumn *col; |
| |
1533 GtkTreeSelection *sel; |
| |
1534 GtkTreePath *path; |
| |
1535 GtkWidget *hbox; |
| |
1536 int j; |
| |
1537 const char *file; |
| |
1538 char *pref; |
| |
1539 #ifndef _WIN32 |
| |
1540 GtkWidget *dd; |
| |
1541 GtkWidget *label; |
| |
1542 GtkWidget *entry; |
| |
1543 const char *cmd; |
| |
1544 #endif |
| |
1545 |
| |
1546 ret = gtk_vbox_new(FALSE, GAIM_HIG_CAT_SPACE); |
| |
1547 gtk_container_set_border_width (GTK_CONTAINER (ret), GAIM_HIG_BORDER); |
| |
1548 |
| |
1549 sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); |
| |
1550 |
| |
1551 #ifndef _WIN32 |
| |
1552 vbox = gaim_gtk_make_frame (ret, _("Sound Method")); |
| |
1553 dd = gaim_gtk_prefs_dropdown(vbox, _("_Method:"), GAIM_PREF_STRING, |
| |
1554 "/gaim/gtk/sound/method", |
| |
1555 _("Console beep"), "beep", |
| |
1556 #ifdef USE_GSTREAMER |
| |
1557 _("Automatic"), "automatic", |
| |
1558 "Arts", "arts", |
| |
1559 "ESD", "esd", |
| |
1560 "NAS", "nas", |
| |
1561 #endif |
| |
1562 _("Command"), "custom", |
| |
1563 _("No sounds"), "none", |
| |
1564 NULL); |
| |
1565 gtk_size_group_add_widget(sg, dd); |
| |
1566 gtk_misc_set_alignment(GTK_MISC(dd), 0, 0.5); |
| |
1567 |
| |
1568 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
| |
1569 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
| |
1570 |
| |
1571 label = gtk_label_new_with_mnemonic(_("Sound c_ommand:\n(%s for filename)")); |
| |
1572 gtk_size_group_add_widget(sg, label); |
| |
1573 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); |
| |
1574 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
| |
1575 |
| |
1576 entry = gtk_entry_new(); |
| |
1577 gtk_label_set_mnemonic_widget(GTK_LABEL(label), entry); |
| |
1578 |
| |
1579 gtk_editable_set_editable(GTK_EDITABLE(entry), TRUE); |
| |
1580 cmd = gaim_prefs_get_string("/gaim/gtk/sound/command"); |
| |
1581 if(cmd) |
| |
1582 gtk_entry_set_text(GTK_ENTRY(entry), cmd); |
| |
1583 |
| |
1584 gtk_box_pack_start(GTK_BOX(hbox), entry, TRUE, TRUE, 0); |
| |
1585 g_signal_connect(G_OBJECT(entry), "changed", |
| |
1586 G_CALLBACK(sound_cmd_yeah), NULL); |
| |
1587 |
| |
1588 gaim_prefs_connect_callback(prefs, "/gaim/gtk/sound/method", |
| |
1589 sound_changed1_cb, hbox); |
| |
1590 gtk_widget_set_sensitive(hbox, |
| |
1591 !strcmp(gaim_prefs_get_string("/gaim/gtk/sound/method"), |
| |
1592 "custom")); |
| |
1593 |
| |
1594 gaim_set_accessible_label (entry, label); |
| |
1595 #endif /* _WIN32 */ |
| |
1596 |
| |
1597 vbox = gaim_gtk_make_frame (ret, _("Sound Options")); |
| |
1598 gaim_gtk_prefs_checkbox(_("Sounds when conversation has _focus"), |
| |
1599 "/gaim/gtk/sound/conv_focus", vbox); |
| |
1600 gaim_gtk_prefs_checkbox(_("_Sounds while away"), |
| |
1601 "/core/sound/while_away", vbox); |
| |
1602 |
| |
1603 #ifdef USE_GSTREAMER |
| |
1604 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
| |
1605 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
| |
1606 |
| |
1607 label = gtk_label_new_with_mnemonic(_("Volume:")); |
| |
1608 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); |
| |
1609 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
| |
1610 |
| |
1611 sw = gtk_hscale_new_with_range(0.0, 100.0, 5.0); |
| |
1612 gtk_range_set_increments(GTK_RANGE(sw), 5.0, 25.0); |
| |
1613 gtk_range_set_value(GTK_RANGE(sw), gaim_prefs_get_int("/gaim/gtk/sound/volume")); |
| |
1614 g_signal_connect (G_OBJECT (sw), "format-value", |
| |
1615 G_CALLBACK (prefs_sound_volume_format), |
| |
1616 NULL); |
| |
1617 g_signal_connect (G_OBJECT (sw), "value-changed", |
| |
1618 G_CALLBACK (prefs_sound_volume_changed), |
| |
1619 NULL); |
| |
1620 gtk_box_pack_start(GTK_BOX(hbox), sw, TRUE, TRUE, 0); |
| |
1621 |
| |
1622 gaim_prefs_connect_callback(prefs, "/gaim/gtk/sound/method", |
| |
1623 sound_changed3_cb, hbox); |
| |
1624 sound_changed3_cb("/gaim/gtk/sound/method", GAIM_PREF_STRING, |
| |
1625 gaim_prefs_get_string("/gaim/gtk/sound/method"), hbox); |
| |
1626 #endif |
| |
1627 |
| |
1628 #ifndef _WIN32 |
| |
1629 gtk_widget_set_sensitive(vbox, |
| |
1630 strcmp(gaim_prefs_get_string("/gaim/gtk/sound/method"), "none")); |
| |
1631 gaim_prefs_connect_callback(prefs, "/gaim/gtk/sound/method", |
| |
1632 sound_changed2_cb, vbox); |
| |
1633 #endif |
| |
1634 |
| |
1635 vbox = gaim_gtk_make_frame(ret, _("Sound Events")); |
| |
1636 |
| |
1637 /* The following is an ugly hack to make the frame expand so the |
| |
1638 * sound events list is big enough to be usable */ |
| |
1639 gtk_box_set_child_packing(GTK_BOX(vbox->parent), vbox, TRUE, TRUE, 0, |
| |
1640 GTK_PACK_START); |
| |
1641 gtk_box_set_child_packing(GTK_BOX(vbox->parent->parent), vbox->parent, TRUE, |
| |
1642 TRUE, 0, GTK_PACK_START); |
| |
1643 gtk_box_set_child_packing(GTK_BOX(vbox->parent->parent->parent), |
| |
1644 vbox->parent->parent, TRUE, TRUE, 0, GTK_PACK_START); |
| |
1645 |
| |
1646 sw = gtk_scrolled_window_new(NULL,NULL); |
| |
1647 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); |
| |
1648 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_IN); |
| |
1649 |
| |
1650 gtk_box_pack_start(GTK_BOX(vbox), sw, TRUE, TRUE, 0); |
| |
1651 event_store = gtk_list_store_new (4, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_UINT); |
| |
1652 |
| |
1653 for (j=0; j < GAIM_NUM_SOUNDS; j++) { |
| |
1654 char *pref = g_strdup_printf("/gaim/gtk/sound/enabled/%s", |
| |
1655 gaim_gtk_sound_get_event_option(j)); |
| |
1656 const char *label = gaim_gtk_sound_get_event_label(j); |
| |
1657 |
| |
1658 if (label == NULL) { |
| |
1659 g_free(pref); |
| |
1660 continue; |
| |
1661 } |
| |
1662 |
| |
1663 gtk_list_store_append (event_store, &iter); |
| |
1664 gtk_list_store_set(event_store, &iter, |
| |
1665 0, gaim_prefs_get_bool(pref), |
| |
1666 1, _(label), |
| |
1667 2, pref, |
| |
1668 3, j, |
| |
1669 -1); |
| |
1670 g_free(pref); |
| |
1671 } |
| |
1672 |
| |
1673 event_view = gtk_tree_view_new_with_model (GTK_TREE_MODEL(event_store)); |
| |
1674 |
| |
1675 rend = gtk_cell_renderer_toggle_new(); |
| |
1676 sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (event_view)); |
| |
1677 g_signal_connect (G_OBJECT (sel), "changed", |
| |
1678 G_CALLBACK (prefs_sound_sel), |
| |
1679 NULL); |
| |
1680 g_signal_connect (G_OBJECT(rend), "toggled", |
| |
1681 G_CALLBACK(event_toggled), event_store); |
| |
1682 path = gtk_tree_path_new_first(); |
| |
1683 gtk_tree_selection_select_path(sel, path); |
| |
1684 gtk_tree_path_free(path); |
| |
1685 |
| |
1686 col = gtk_tree_view_column_new_with_attributes (_("Play"), |
| |
1687 rend, |
| |
1688 "active", 0, |
| |
1689 NULL); |
| |
1690 gtk_tree_view_append_column (GTK_TREE_VIEW(event_view), col); |
| |
1691 |
| |
1692 rend = gtk_cell_renderer_text_new(); |
| |
1693 col = gtk_tree_view_column_new_with_attributes (_("Event"), |
| |
1694 rend, |
| |
1695 "text", 1, |
| |
1696 NULL); |
| |
1697 gtk_tree_view_append_column (GTK_TREE_VIEW(event_view), col); |
| |
1698 g_object_unref(G_OBJECT(event_store)); |
| |
1699 gtk_container_add(GTK_CONTAINER(sw), event_view); |
| |
1700 |
| |
1701 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
| |
1702 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
| |
1703 sound_entry = gtk_entry_new(); |
| |
1704 pref = g_strdup_printf("/gaim/gtk/sound/file/%s", |
| |
1705 gaim_gtk_sound_get_event_option(0)); |
| |
1706 file = gaim_prefs_get_string(pref); |
| |
1707 g_free(pref); |
| |
1708 gtk_entry_set_text(GTK_ENTRY(sound_entry), (file && *file != '\0') ? file : "(default)"); |
| |
1709 gtk_editable_set_editable(GTK_EDITABLE(sound_entry), FALSE); |
| |
1710 gtk_box_pack_start(GTK_BOX(hbox), sound_entry, FALSE, FALSE, GAIM_HIG_BOX_SPACE); |
| |
1711 |
| |
1712 button = gtk_button_new_with_label(_("Test")); |
| |
1713 g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(test_sound), NULL); |
| |
1714 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 1); |
| |
1715 |
| |
1716 button = gtk_button_new_with_label(_("Reset")); |
| |
1717 g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(reset_sound), NULL); |
| |
1718 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 1); |
| |
1719 |
| |
1720 button = gtk_button_new_with_label(_("Choose...")); |
| |
1721 g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(select_sound), NULL); |
| |
1722 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 1); |
| |
1723 gtk_widget_show_all(ret); |
| |
1724 |
| |
1725 return ret; |
| |
1726 } |
| |
1727 |
| |
1728 |
| |
1729 static void |
| |
1730 set_idle_away(GaimSavedStatus *status) |
| |
1731 { |
| |
1732 gaim_prefs_set_int("/core/savedstatus/idleaway", gaim_savedstatus_get_creation_time(status)); |
| |
1733 } |
| |
1734 |
| |
1735 static void |
| |
1736 set_startupstatus(GaimSavedStatus *status) |
| |
1737 { |
| |
1738 gaim_prefs_set_int("/core/savedstatus/startup", gaim_savedstatus_get_creation_time(status)); |
| |
1739 } |
| |
1740 |
| |
1741 static GtkWidget * |
| |
1742 away_page() |
| |
1743 { |
| |
1744 GtkWidget *ret; |
| |
1745 GtkWidget *vbox; |
| |
1746 GtkWidget *hbox; |
| |
1747 GtkWidget *dd; |
| |
1748 GtkWidget *label; |
| |
1749 GtkWidget *button; |
| |
1750 GtkWidget *select; |
| |
1751 GtkWidget *menu; |
| |
1752 GtkSizeGroup *sg; |
| |
1753 |
| |
1754 ret = gtk_vbox_new(FALSE, GAIM_HIG_CAT_SPACE); |
| |
1755 gtk_container_set_border_width (GTK_CONTAINER (ret), GAIM_HIG_BORDER); |
| |
1756 |
| |
1757 sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); |
| |
1758 |
| |
1759 /* Idle stuff */ |
| |
1760 vbox = gaim_gtk_make_frame(ret, _("Idle")); |
| |
1761 |
| |
1762 dd = gaim_gtk_prefs_dropdown(vbox, _("_Report idle time:"), |
| |
1763 GAIM_PREF_STRING, "/core/away/idle_reporting", |
| |
1764 _("Never"), "none", |
| |
1765 _("From last sent message"), "gaim", |
| |
1766 #if defined(USE_SCREENSAVER) || defined(HAVE_IOKIT) |
| |
1767 _("Based on keyboard or mouse use"), "system", |
| |
1768 #endif |
| |
1769 NULL); |
| |
1770 gtk_size_group_add_widget(sg, dd); |
| |
1771 gtk_misc_set_alignment(GTK_MISC(dd), 0, 0.5); |
| |
1772 |
| |
1773 /* Away stuff */ |
| |
1774 vbox = gaim_gtk_make_frame(ret, _("Away")); |
| |
1775 |
| |
1776 dd = gaim_gtk_prefs_dropdown(vbox, _("_Auto-reply:"), |
| |
1777 GAIM_PREF_STRING, "/core/away/auto_reply", |
| |
1778 _("Never"), "never", |
| |
1779 _("When away"), "away", |
| |
1780 _("When both away and idle"), "awayidle", |
| |
1781 NULL); |
| |
1782 gtk_size_group_add_widget(sg, dd); |
| |
1783 gtk_misc_set_alignment(GTK_MISC(dd), 0, 0.5); |
| |
1784 |
| |
1785 /* Auto-away stuff */ |
| |
1786 vbox = gaim_gtk_make_frame(ret, _("Auto-away")); |
| |
1787 |
| |
1788 button = gaim_gtk_prefs_checkbox(_("Change status when _idle"), |
| |
1789 "/core/away/away_when_idle", vbox); |
| |
1790 |
| |
1791 select = gaim_gtk_prefs_labeled_spin_button(vbox, |
| |
1792 _("_Minutes before changing status:"), "/core/away/mins_before_away", |
| |
1793 1, 24 * 60, sg); |
| |
1794 g_signal_connect(G_OBJECT(button), "clicked", |
| |
1795 G_CALLBACK(gaim_gtk_toggle_sensitive), select); |
| |
1796 |
| |
1797 hbox = gtk_hbox_new(FALSE, 0); |
| |
1798 gtk_container_add(GTK_CONTAINER(vbox), hbox); |
| |
1799 |
| |
1800 label = gtk_label_new_with_mnemonic(_("Change _status to:")); |
| |
1801 gtk_size_group_add_widget(sg, label); |
| |
1802 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); |
| |
1803 g_signal_connect(G_OBJECT(button), "clicked", |
| |
1804 G_CALLBACK(gaim_gtk_toggle_sensitive), label); |
| |
1805 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
| |
1806 |
| |
1807 /* TODO: Show something useful if we don't have any saved statuses. */ |
| |
1808 menu = gaim_gtk_status_menu(gaim_savedstatus_get_idleaway(), G_CALLBACK(set_idle_away)); |
| |
1809 gtk_box_pack_start(GTK_BOX(hbox), menu, FALSE, FALSE, 0); |
| |
1810 g_signal_connect(G_OBJECT(button), "clicked", |
| |
1811 G_CALLBACK(gaim_gtk_toggle_sensitive), menu); |
| |
1812 gtk_label_set_mnemonic_widget(GTK_LABEL(label), menu); |
| |
1813 |
| |
1814 if (!gaim_prefs_get_bool("/core/away/away_when_idle")) { |
| |
1815 gtk_widget_set_sensitive(GTK_WIDGET(menu), FALSE); |
| |
1816 gtk_widget_set_sensitive(GTK_WIDGET(select), FALSE); |
| |
1817 gtk_widget_set_sensitive(GTK_WIDGET(label), FALSE); |
| |
1818 } |
| |
1819 |
| |
1820 /* Signon status stuff */ |
| |
1821 vbox = gaim_gtk_make_frame(ret, _("Status at Startup")); |
| |
1822 |
| |
1823 button = gaim_gtk_prefs_checkbox(_("Use status from last _exit at startup"), |
| |
1824 "/core/savedstatus/startup_current_status", vbox); |
| |
1825 |
| |
1826 hbox = gtk_hbox_new(FALSE, 0); |
| |
1827 gtk_container_add(GTK_CONTAINER(vbox), hbox); |
| |
1828 |
| |
1829 label = gtk_label_new_with_mnemonic(_("Status to a_pply at startup:")); |
| |
1830 gtk_size_group_add_widget(sg, label); |
| |
1831 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); |
| |
1832 g_signal_connect(G_OBJECT(button), "clicked", |
| |
1833 G_CALLBACK(gaim_gtk_toggle_sensitive), label); |
| |
1834 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
| |
1835 |
| |
1836 /* TODO: Show something useful if we don't have any saved statuses. */ |
| |
1837 menu = gaim_gtk_status_menu(gaim_savedstatus_get_startup(), G_CALLBACK(set_startupstatus)); |
| |
1838 gtk_box_pack_start(GTK_BOX(hbox), menu, FALSE, FALSE, 0); |
| |
1839 g_signal_connect(G_OBJECT(button), "clicked", |
| |
1840 G_CALLBACK(gaim_gtk_toggle_sensitive), menu); |
| |
1841 gtk_label_set_mnemonic_widget(GTK_LABEL(label), menu); |
| |
1842 |
| |
1843 if (gaim_prefs_get_bool("/core/savedstatus/startup_current_status")) { |
| |
1844 gtk_widget_set_sensitive(GTK_WIDGET(menu), FALSE); |
| |
1845 gtk_widget_set_sensitive(GTK_WIDGET(label), FALSE); |
| |
1846 } |
| |
1847 |
| |
1848 gtk_widget_show_all(ret); |
| |
1849 |
| |
1850 return ret; |
| |
1851 } |
| |
1852 |
| |
1853 int prefs_notebook_add_page(const char *text, |
| |
1854 GdkPixbuf *pixbuf, |
| |
1855 GtkWidget *page, |
| |
1856 GtkTreeIter *iter, |
| |
1857 GtkTreeIter *parent, |
| |
1858 int ind) { |
| |
1859 GdkPixbuf *icon = NULL; |
| |
1860 |
| |
1861 if (pixbuf) |
| |
1862 icon = gdk_pixbuf_scale_simple (pixbuf, 18, 18, GDK_INTERP_BILINEAR); |
| |
1863 |
| |
1864 if (pixbuf) |
| |
1865 g_object_unref(pixbuf); |
| |
1866 if (icon) |
| |
1867 g_object_unref(icon); |
| |
1868 |
| |
1869 #if GTK_CHECK_VERSION(2,4,0) |
| |
1870 return gtk_notebook_append_page(GTK_NOTEBOOK(prefsnotebook), page, gtk_label_new(text)); |
| |
1871 #else |
| |
1872 gtk_notebook_append_page(GTK_NOTEBOOK(prefsnotebook), page, gtk_label_new(text)); |
| |
1873 return gtk_notebook_page_num(GTK_NOTEBOOK(prefsnotebook), page); |
| |
1874 #endif |
| |
1875 } |
| |
1876 |
| |
1877 static void prefs_notebook_init() { |
| |
1878 GtkTreeIter p, c, c2; |
| |
1879 prefs_notebook_add_page(_("Conversations"), NULL, conv_page(), &c, &p, notebook_page++); |
| |
1880 prefs_notebook_add_page(_("Smiley Themes"), NULL, theme_page(), &c2, &c, notebook_page++); |
| |
1881 prefs_notebook_add_page(_("Sounds"), NULL, sound_page(), &c, &p, notebook_page++); |
| |
1882 prefs_notebook_add_page(_("Network"), NULL, network_page(), &p, NULL, notebook_page++); |
| |
1883 #ifndef _WIN32 |
| |
1884 /* We use the registered default browser in windows */ |
| |
1885 /* if the user is running gnome 2.x, hide the browsers tab */ |
| |
1886 if (gaim_running_gnome() == FALSE) { |
| |
1887 prefs_notebook_add_page(_("Browser"), NULL, browser_page(), &p, NULL, notebook_page++); |
| |
1888 } |
| |
1889 #endif |
| |
1890 prefs_notebook_add_page(_("Logging"), NULL, logging_page(), &p, NULL, notebook_page++); |
| |
1891 prefs_notebook_add_page(_("Away / Idle"), NULL, away_page(), &p, NULL, notebook_page++); |
| |
1892 } |
| |
1893 |
| |
1894 void gaim_gtk_prefs_show(void) |
| |
1895 { |
| |
1896 GtkWidget *vbox; |
| |
1897 GtkWidget *bbox; |
| |
1898 GtkWidget *notebook; |
| |
1899 GtkWidget *button; |
| |
1900 |
| |
1901 if (prefs) { |
| |
1902 gtk_window_present(GTK_WINDOW(prefs)); |
| |
1903 return; |
| |
1904 } |
| |
1905 |
| |
1906 /* copy the preferences to tmp values... |
| |
1907 * I liked "take affect immediately" Oh well :-( */ |
| |
1908 /* (that should have been "effect," right?) */ |
| |
1909 |
| |
1910 /* Back to instant-apply! I win! BU-HAHAHA! */ |
| |
1911 |
| |
1912 /* Create the window */ |
| |
1913 prefs = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
| |
1914 gtk_window_set_role(GTK_WINDOW(prefs), "preferences"); |
| |
1915 gtk_window_set_title(GTK_WINDOW(prefs), _("Preferences")); |
| |
1916 gtk_window_set_resizable (GTK_WINDOW(prefs), FALSE); |
| |
1917 gtk_container_set_border_width(GTK_CONTAINER(prefs), GAIM_HIG_BORDER); |
| |
1918 g_signal_connect(G_OBJECT(prefs), "destroy", |
| |
1919 G_CALLBACK(delete_prefs), NULL); |
| |
1920 |
| |
1921 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BORDER); |
| |
1922 gtk_container_add(GTK_CONTAINER(prefs), vbox); |
| |
1923 gtk_widget_show(vbox); |
| |
1924 |
| |
1925 /* The notebook */ |
| |
1926 prefsnotebook = notebook = gtk_notebook_new (); |
| |
1927 gtk_box_pack_start (GTK_BOX (vbox), notebook, FALSE, FALSE, 0); |
| |
1928 gtk_widget_show(prefsnotebook); |
| |
1929 |
| |
1930 /* The buttons to press! */ |
| |
1931 bbox = gtk_hbutton_box_new(); |
| |
1932 gtk_box_set_spacing(GTK_BOX(bbox), GAIM_HIG_BOX_SPACE); |
| |
1933 gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END); |
| |
1934 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0); |
| |
1935 gtk_widget_show (bbox); |
| |
1936 |
| |
1937 button = gtk_button_new_from_stock (GTK_STOCK_CLOSE); |
| |
1938 g_signal_connect_swapped(G_OBJECT(button), "clicked", |
| |
1939 G_CALLBACK(gtk_widget_destroy), prefs); |
| |
1940 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); |
| |
1941 gtk_widget_show(button); |
| |
1942 |
| |
1943 prefs_notebook_init(); |
| |
1944 |
| |
1945 /* Show everything. */ |
| |
1946 gtk_widget_show(prefs); |
| |
1947 } |
| |
1948 |
| |
1949 static void |
| |
1950 set_bool_pref(GtkWidget *w, const char *key) |
| |
1951 { |
| |
1952 gaim_prefs_set_bool(key, |
| |
1953 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w))); |
| |
1954 } |
| |
1955 |
| |
1956 GtkWidget * |
| |
1957 gaim_gtk_prefs_checkbox(const char *text, const char *key, GtkWidget *page) |
| |
1958 { |
| |
1959 GtkWidget *button; |
| |
1960 |
| |
1961 button = gtk_check_button_new_with_mnemonic(text); |
| |
1962 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), |
| |
1963 gaim_prefs_get_bool(key)); |
| |
1964 |
| |
1965 gtk_box_pack_start(GTK_BOX(page), button, FALSE, FALSE, 0); |
| |
1966 |
| |
1967 g_signal_connect(G_OBJECT(button), "clicked", |
| |
1968 G_CALLBACK(set_bool_pref), (char *)key); |
| |
1969 |
| |
1970 gtk_widget_show(button); |
| |
1971 |
| |
1972 return button; |
| |
1973 } |
| |
1974 |
| |
1975 static void |
| |
1976 smiley_theme_pref_cb(const char *name, GaimPrefType type, |
| |
1977 gconstpointer value, gpointer data) |
| |
1978 { |
| |
1979 const char *themename = value; |
| |
1980 GSList *themes; |
| |
1981 |
| |
1982 for (themes = smiley_themes; themes; themes = themes->next) { |
| |
1983 struct smiley_theme *smile = themes->data; |
| |
1984 if (smile->name && strcmp(themename, smile->name) == 0) { |
| |
1985 gaim_gtkthemes_load_smiley_theme(smile->path, TRUE); |
| |
1986 break; |
| |
1987 } |
| |
1988 } |
| |
1989 } |
| |
1990 |
| |
1991 void |
| |
1992 gaim_gtk_prefs_init(void) |
| |
1993 { |
| |
1994 gaim_prefs_add_none("/gaim"); |
| |
1995 gaim_prefs_add_none("/gaim/gtk"); |
| |
1996 gaim_prefs_add_none("/plugins/gtk"); |
| |
1997 |
| |
1998 #ifndef _WIN32 |
| |
1999 /* Browsers */ |
| |
2000 gaim_prefs_add_none("/gaim/gtk/browsers"); |
| |
2001 gaim_prefs_add_int("/gaim/gtk/browsers/place", GAIM_BROWSER_DEFAULT); |
| |
2002 gaim_prefs_add_string("/gaim/gtk/browsers/command", ""); |
| |
2003 gaim_prefs_add_string("/gaim/gtk/browsers/browser", "mozilla"); |
| |
2004 #endif |
| |
2005 |
| |
2006 /* Plugins */ |
| |
2007 gaim_prefs_add_none("/gaim/gtk/plugins"); |
| |
2008 gaim_prefs_add_string_list("/gaim/gtk/plugins/loaded", NULL); |
| |
2009 |
| |
2010 /* File locations */ |
| |
2011 gaim_prefs_add_none("/gaim/gtk/filelocations"); |
| |
2012 gaim_prefs_add_string("/gaim/gtk/filelocations/last_save_folder", ""); |
| |
2013 gaim_prefs_add_string("/gaim/gtk/filelocations/last_open_folder", ""); |
| |
2014 gaim_prefs_add_string("/gaim/gtk/filelocations/last_icon_folder", ""); |
| |
2015 |
| |
2016 /* Smiley Themes */ |
| |
2017 gaim_prefs_add_none("/gaim/gtk/smileys"); |
| |
2018 gaim_prefs_add_string("/gaim/gtk/smileys/theme", "Default"); |
| |
2019 |
| |
2020 /* Smiley Callbacks */ |
| |
2021 gaim_prefs_connect_callback(prefs, "/gaim/gtk/smileys/theme", |
| |
2022 smiley_theme_pref_cb, NULL); |
| |
2023 } |
| |
2024 |
| |
2025 void gaim_gtk_prefs_update_old() { |
| |
2026 /* Rename some old prefs */ |
| |
2027 gaim_prefs_rename("/gaim/gtk/logging/log_ims", "/core/logging/log_ims"); |
| |
2028 gaim_prefs_rename("/gaim/gtk/logging/log_chats", "/core/logging/log_chats"); |
| |
2029 gaim_prefs_rename("/core/conversations/placement", |
| |
2030 "/gaim/gtk/conversations/placement"); |
| |
2031 |
| |
2032 gaim_prefs_rename("/gaim/gtk/debug/timestamps", "/core/debug/timestamps"); |
| |
2033 gaim_prefs_rename("/gaim/gtk/conversations/im/raise_on_events", "/plugins/gtk/X11/notify/method_raise"); |
| |
2034 |
| |
2035 gaim_prefs_rename_boolean_toggle("/gaim/gtk/conversations/ignore_colors", |
| |
2036 "/gaim/gtk/conversations/show_incoming_formatting"); |
| |
2037 |
| |
2038 /* this string pref moved into the core, try to be friendly */ |
| |
2039 gaim_prefs_rename("/gaim/gtk/idle/reporting_method", "/core/away/idle_reporting"); |
| |
2040 |
| |
2041 /* Remove some no-longer-used prefs */ |
| |
2042 gaim_prefs_remove("/gaim/gtk/blist/auto_expand_contacts"); |
| |
2043 gaim_prefs_remove("/gaim/gtk/blist/button_style"); |
| |
2044 gaim_prefs_remove("/gaim/gtk/blist/grey_idle_buddies"); |
| |
2045 gaim_prefs_remove("/gaim/gtk/blist/raise_on_events"); |
| |
2046 gaim_prefs_remove("/gaim/gtk/blist/show_group_count"); |
| |
2047 gaim_prefs_remove("/gaim/gtk/blist/show_warning_level"); |
| |
2048 gaim_prefs_remove("/gaim/gtk/conversations/button_type"); |
| |
2049 gaim_prefs_remove("/gaim/gtk/conversations/ctrl_enter_sends"); |
| |
2050 gaim_prefs_remove("/gaim/gtk/conversations/enter_sends"); |
| |
2051 gaim_prefs_remove("/gaim/gtk/conversations/escape_closes"); |
| |
2052 gaim_prefs_remove("/gaim/gtk/conversations/html_shortcuts"); |
| |
2053 gaim_prefs_remove("/gaim/gtk/conversations/icons_on_tabs"); |
| |
2054 gaim_prefs_remove("/gaim/gtk/conversations/send_formatting"); |
| |
2055 gaim_prefs_remove("/gaim/gtk/conversations/show_smileys"); |
| |
2056 gaim_prefs_remove("/gaim/gtk/conversations/show_urls_as_links"); |
| |
2057 gaim_prefs_remove("/gaim/gtk/conversations/smiley_shortcuts"); |
| |
2058 gaim_prefs_remove("/gaim/gtk/conversations/use_custom_bgcolor"); |
| |
2059 gaim_prefs_remove("/gaim/gtk/conversations/use_custom_fgcolor"); |
| |
2060 gaim_prefs_remove("/gaim/gtk/conversations/use_custom_font"); |
| |
2061 gaim_prefs_remove("/gaim/gtk/conversations/use_custom_size"); |
| |
2062 gaim_prefs_remove("/gaim/gtk/conversations/chat/old_tab_complete"); |
| |
2063 gaim_prefs_remove("/gaim/gtk/conversations/chat/tab_completion"); |
| |
2064 gaim_prefs_remove("/gaim/gtk/conversations/im/hide_on_send"); |
| |
2065 gaim_prefs_remove("/gaim/gtk/conversations/chat/color_nicks"); |
| |
2066 gaim_prefs_remove("/gaim/gtk/conversations/chat/raise_on_events"); |
| |
2067 gaim_prefs_remove("/gaim/gtk/conversations/ignore_fonts"); |
| |
2068 gaim_prefs_remove("/gaim/gtk/conversations/ignore_font_sizes"); |
| |
2069 gaim_prefs_remove("/gaim/gtk/idle"); |
| |
2070 gaim_prefs_remove("/gaim/gtk/logging/individual_logs"); |
| |
2071 gaim_prefs_remove("/gaim/gtk/sound/signon"); |
| |
2072 gaim_prefs_remove("/gaim/gtk/sound/silent_signon"); |
| |
2073 |
| |
2074 /* Convert old queuing prefs to hide_new 3-way pref. */ |
| |
2075 if (gaim_prefs_exists("/plugins/gtk/docklet/queue_messages") && |
| |
2076 gaim_prefs_get_bool("/plugins/gtk/docklet/queue_messages")) |
| |
2077 { |
| |
2078 gaim_prefs_set_string("/gaim/gtk/conversations/im/hide_new", "always"); |
| |
2079 } |
| |
2080 else if (gaim_prefs_exists("/gaim/gtk/away/queue_messages") && |
| |
2081 gaim_prefs_get_bool("/gaim/gtk/away/queue_messages")) |
| |
2082 { |
| |
2083 gaim_prefs_set_string("/gaim/gtk/conversations/im/hide_new", "away"); |
| |
2084 } |
| |
2085 gaim_prefs_remove("/gaim/gtk/away/queue_messages"); |
| |
2086 gaim_prefs_remove("/gaim/gtk/away"); |
| |
2087 gaim_prefs_remove("/plugins/gtk/docklet/queue_messages"); |
| |
2088 } |