Remove whitespace between function name and first parenthesis for the sake of consist...
[geeqie.git] / src / preferences.c
1 /*
2  * Geeqie
3  * (C) 2006 John Ellis
4  * Copyright (C) 2008 The Geeqie Team
5  *
6  * Author: John Ellis
7  *
8  * This software is released under the GNU General Public License (GNU GPL).
9  * Please read the included file COPYING for more information.
10  * This software comes with no warranty of any kind, use at your own risk!
11  */
12
13
14 #include "main.h"
15 #include "preferences.h"
16
17 #include "cache_maint.h"
18 #include "debug.h"
19 #include "editors.h"
20 #include "filelist.h"
21 #include "fullscreen.h"
22 #include "image.h"
23 #include "image-overlay.h"
24 #include "color-man.h"
25 #include "img-view.h"
26 #include "layout_config.h"
27 #include "layout_util.h"
28 #include "pixbuf_util.h"
29 #include "slideshow.h"
30 #include "utilops.h"
31 #include "ui_fileops.h"
32 #include "ui_misc.h"
33 #include "ui_tabcomp.h"
34 #include "ui_utildlg.h"
35 #include "bar_exif.h"
36 #include "exif.h"
37
38 #include <math.h>
39
40
41 #define EDITOR_NAME_MAX_LENGTH 32
42 #define EDITOR_COMMAND_MAX_LENGTH 1024
43
44
45 typedef struct _ThumbSize ThumbSize;
46 struct _ThumbSize
47 {
48         gint w;
49         gint h;
50 };
51
52 static ThumbSize thumb_size_list[] =
53 {
54         { 24, 24 },
55         { 32, 32 },
56         { 48, 48 },
57         { 64, 64 },
58         { 96, 72 },
59         { 96, 96 },
60         { 128, 96 },
61         { 128, 128 },
62         { 160, 120 },
63         { 160, 160 },
64         { 192, 144 },
65         { 192, 192 },
66         { 256, 192 },
67         { 256, 256 }
68 };
69
70 enum {
71         FE_ENABLE,
72         FE_EXTENSION,
73         FE_DESCRIPTION
74 };
75
76 /* config memory values */
77 static ConfOptions *c_options = NULL;
78
79
80 #ifdef DEBUG
81 static gint debug_c;
82 #endif
83
84 static GtkWidget *configwindow = NULL;
85 static GtkWidget *startup_path_entry;
86 static GtkListStore *filter_store = NULL;
87 static GtkWidget *editor_name_entry[GQ_EDITOR_SLOTS];
88 static GtkWidget *editor_command_entry[GQ_EDITOR_SLOTS];
89
90 static GtkWidget *layout_widget;
91
92 static GtkWidget *safe_delete_path_entry;
93
94 static GtkWidget *color_profile_input_file_entry[COLOR_PROFILE_INPUTS];
95 static GtkWidget *color_profile_input_name_entry[COLOR_PROFILE_INPUTS];
96 static GtkWidget *color_profile_screen_file_entry;
97
98 static GtkWidget *sidecar_ext_entry;
99
100
101 #define CONFIG_WINDOW_DEF_WIDTH         700
102 #define CONFIG_WINDOW_DEF_HEIGHT        500
103
104 /*
105  *-----------------------------------------------------------------------------
106  * option widget callbacks (private)
107  *-----------------------------------------------------------------------------
108  */
109
110 static void startup_path_set_current(GtkWidget *widget, gpointer data)
111 {
112         gtk_entry_set_text(GTK_ENTRY(startup_path_entry), layout_get_path(NULL));
113 }
114
115 static void zoom_mode_original_cb(GtkWidget *widget, gpointer data)
116 {
117         if (GTK_TOGGLE_BUTTON (widget)->active)
118                 c_options->image.zoom_mode = ZOOM_RESET_ORIGINAL;
119 }
120
121 static void zoom_mode_fit_cb(GtkWidget *widget, gpointer data)
122 {
123         if (GTK_TOGGLE_BUTTON (widget)->active)
124                 c_options->image.zoom_mode = ZOOM_RESET_FIT_WINDOW;
125 }
126
127 static void zoom_mode_none_cb(GtkWidget *widget, gpointer data)
128 {
129         if (GTK_TOGGLE_BUTTON (widget)->active)
130                 c_options->image.zoom_mode = ZOOM_RESET_NONE;
131 }
132
133 static void zoom_increment_cb(GtkWidget *spin, gpointer data)
134 {
135         c_options->image.zoom_increment = (gint)(gtk_spin_button_get_value(GTK_SPIN_BUTTON(spin)) * 10.0 + 0.01);
136 }
137
138 static void slideshow_delay_cb(GtkWidget *spin, gpointer data)
139 {
140         c_options->slideshow.delay = (gint)(gtk_spin_button_get_value(GTK_SPIN_BUTTON(spin)) *
141                                    (double)SLIDESHOW_SUBSECOND_PRECISION + 0.01);
142 }
143
144 /*
145  *-----------------------------------------------------------------------------
146  * sync progam to config window routine (private)
147  *-----------------------------------------------------------------------------
148  */
149
150 static void config_window_apply(void)
151 {
152         const gchar *buf;
153         gint new_style;
154         gint i;
155         gint refresh = FALSE;
156
157         for(i = 0; i < GQ_EDITOR_SLOTS; i++)
158                 {
159                 if (i < GQ_EDITOR_GENERIC_SLOTS)
160                         {
161                         g_free(options->editor_name[i]);
162                         options->editor_name[i] = NULL;
163                         buf = gtk_entry_get_text(GTK_ENTRY(editor_name_entry[i]));
164                         if (buf && strlen(buf) > 0) options->editor_name[i] = g_strdup(buf);
165                         }
166
167                 g_free(options->editor_command[i]);
168                 options->editor_command[i] = NULL;
169                 buf = gtk_entry_get_text(GTK_ENTRY(editor_command_entry[i]));
170                 if (buf && strlen(buf) > 0) options->editor_command[i] = g_strdup(buf);
171                 }
172         layout_edit_update_all();
173
174         g_free(options->startup_path);
175         options->startup_path = NULL;
176         buf = gtk_entry_get_text(GTK_ENTRY(startup_path_entry));
177         if (buf && strlen(buf) > 0) options->startup_path = remove_trailing_slash(buf);
178
179         g_free(options->file_ops.safe_delete_path);
180         options->file_ops.safe_delete_path = NULL;
181         buf = gtk_entry_get_text(GTK_ENTRY(safe_delete_path_entry));
182         if (buf && strlen(buf) > 0) options->file_ops.safe_delete_path = remove_trailing_slash(buf);
183
184         if (options->file_filter.show_hidden_files != c_options->file_filter.show_hidden_files) refresh = TRUE;
185         if (options->file_filter.show_dot_directory != c_options->file_filter.show_dot_directory) refresh = TRUE;
186         if (options->file_sort.case_sensitive != c_options->file_sort.case_sensitive) refresh = TRUE;
187         if (options->file_filter.disable != c_options->file_filter.disable) refresh = TRUE;
188
189         options->startup_path_enable = c_options->startup_path_enable;
190         options->file_ops.confirm_delete = c_options->file_ops.confirm_delete;
191         options->file_ops.enable_delete_key = c_options->file_ops.enable_delete_key;
192         options->file_ops.safe_delete_enable = c_options->file_ops.safe_delete_enable;
193         options->file_ops.safe_delete_folder_maxsize = c_options->file_ops.safe_delete_folder_maxsize;
194         options->layout.tools_restore_state = c_options->layout.tools_restore_state;
195         options->layout.save_window_positions = c_options->layout.save_window_positions;
196         options->image.zoom_mode = c_options->image.zoom_mode;
197         options->image.zoom_2pass = c_options->image.zoom_2pass;
198         options->image.fit_window_to_image = c_options->image.fit_window_to_image;
199         options->image.limit_window_size = c_options->image.limit_window_size;
200         options->image.zoom_to_fit_allow_expand = c_options->image.zoom_to_fit_allow_expand;
201         options->image.max_window_size = c_options->image.max_window_size;
202         options->image.limit_autofit_size = c_options->image.limit_autofit_size;
203         options->image.max_autofit_size = c_options->image.max_autofit_size;
204         options->progressive_key_scrolling = c_options->progressive_key_scrolling;
205         options->thumbnails.max_width = c_options->thumbnails.max_width;
206         options->thumbnails.max_height = c_options->thumbnails.max_height;
207         options->thumbnails.enable_caching = c_options->thumbnails.enable_caching;
208         options->thumbnails.cache_into_dirs = c_options->thumbnails.cache_into_dirs;
209         options->thumbnails.fast = c_options->thumbnails.fast;
210 #if 0
211         options->thumbnails.use_xvpics = c_options->thumbnails.use_xvpics;
212 #endif
213         options->thumbnails.spec_standard = c_options->thumbnails.spec_standard;
214         options->enable_metadata_dirs = c_options->enable_metadata_dirs;
215         options->file_filter.show_hidden_files = c_options->file_filter.show_hidden_files;
216         options->file_filter.show_dot_directory = c_options->file_filter.show_dot_directory;
217
218         options->file_sort.case_sensitive = c_options->file_sort.case_sensitive;
219         options->file_filter.disable = c_options->file_filter.disable;
220
221         sidecar_ext_parse(gtk_entry_get_text(GTK_ENTRY(sidecar_ext_entry)), FALSE);
222
223         options->slideshow.random = c_options->slideshow.random;
224         options->slideshow.repeat = c_options->slideshow.repeat;
225         options->slideshow.delay = c_options->slideshow.delay;
226
227         options->mousewheel_scrolls = c_options->mousewheel_scrolls;
228
229         options->file_ops.enable_in_place_rename = c_options->file_ops.enable_in_place_rename;
230
231         options->collections.rectangular_selection = c_options->collections.rectangular_selection;
232
233         options->image.tile_cache_max = c_options->image.tile_cache_max;
234
235         options->image.read_buffer_size = c_options->image.read_buffer_size;
236         options->image.idle_read_loop_count = c_options->image.idle_read_loop_count;
237
238         options->thumbnails.quality = c_options->thumbnails.quality;
239         options->image.zoom_quality = c_options->image.zoom_quality;
240
241         options->image.zoom_increment = c_options->image.zoom_increment;
242
243         options->image.enable_read_ahead = c_options->image.enable_read_ahead;
244
245         if (options->image.use_custom_border_color != c_options->image.use_custom_border_color
246             || !gdk_color_equal(&options->image.border_color, &c_options->image.border_color))
247                 {
248                 options->image.use_custom_border_color = c_options->image.use_custom_border_color;
249                 options->image.border_color = c_options->image.border_color;
250                 layout_colors_update();
251                 view_window_colors_update();
252                 }
253
254         options->fullscreen.screen = c_options->fullscreen.screen;
255         options->fullscreen.clean_flip = c_options->fullscreen.clean_flip;
256         options->fullscreen.disable_saver = c_options->fullscreen.disable_saver;
257         options->fullscreen.above = c_options->fullscreen.above;
258         options->image_overlay.common.show_at_startup = c_options->image_overlay.common.show_at_startup;
259         if (c_options->image_overlay.common.template_string)
260                 {
261                 g_free(options->image_overlay.common.template_string);
262                 options->image_overlay.common.template_string = g_strdup(c_options->image_overlay.common.template_string);
263                 }
264
265         options->update_on_time_change = c_options->update_on_time_change;
266         options->image.exif_rotate_enable = c_options->image.exif_rotate_enable;
267
268         options->duplicates_similarity_threshold = c_options->duplicates_similarity_threshold;
269
270         options->tree_descend_subdirs = c_options->tree_descend_subdirs;
271
272         options->open_recent_list_maxsize = c_options->open_recent_list_maxsize;
273         options->dnd_icon_size = c_options->dnd_icon_size;
274         
275         if (options->show_copy_path != c_options->show_copy_path)
276                 {
277                 options->show_copy_path = c_options->show_copy_path;
278                 layout_copy_path_update_all();
279                 }
280
281 #ifdef DEBUG
282         set_debug_level(debug_c);
283 #endif
284
285 #ifdef HAVE_LCMS
286         for (i = 0; i < COLOR_PROFILE_INPUTS; i++)
287                 {
288                 g_free(options->color_profile.input_name[i]);
289                 options->color_profile.input_name[i] = NULL;
290                 buf = gtk_entry_get_text(GTK_ENTRY(color_profile_input_name_entry[i]));
291                 if (buf && strlen(buf) > 0) options->color_profile.input_name[i] = g_strdup(buf);
292
293                 g_free(options->color_profile.input_file[i]);
294                 options->color_profile.input_file[i] = NULL;
295                 buf = gtk_entry_get_text(GTK_ENTRY(color_profile_input_file_entry[i]));
296                 if (buf && strlen(buf) > 0) options->color_profile.input_file[i] = g_strdup(buf);
297                 }
298         g_free(options->color_profile.screen_file);
299         options->color_profile.screen_file = NULL;
300         buf = gtk_entry_get_text(GTK_ENTRY(color_profile_screen_file_entry));
301         if (buf && strlen(buf) > 0) options->color_profile.screen_file = g_strdup(buf);
302 #endif
303
304         for (i=0; ExifUIList[i].key; i++)
305                 {
306                 ExifUIList[i].current = ExifUIList[i].temp;
307                 }
308
309         {
310         gchar *layout_order = layout_config_get(layout_widget, &new_style);
311
312         if (new_style != options->layout.style ||
313             (layout_order == NULL) != (options->layout.order == NULL) ||
314             !options->layout.order ||
315             strcmp(layout_order, options->layout.order) != 0)
316                 {
317                 if (refresh) filter_rebuild();
318                 refresh = FALSE;
319
320                 g_free(options->layout.order);
321                 options->layout.order = layout_order;
322                 layout_order = NULL; /* g_free() later */
323
324                 options->layout.style = new_style;
325
326                 layout_styles_update();
327                 }
328
329         g_free(layout_order);
330         }
331
332         image_options_sync();
333
334         if (refresh)
335                 {
336                 filter_rebuild();
337                 layout_refresh(NULL);
338                 }
339 }
340
341 /*
342  *-----------------------------------------------------------------------------
343  * config window main button callbacks (private)
344  *-----------------------------------------------------------------------------
345  */
346
347 static void config_window_close_cb(GtkWidget *widget, gpointer data)
348 {
349         gtk_widget_destroy(configwindow);
350         configwindow = NULL;
351         filter_store = NULL;
352 }
353
354 static gint config_window_delete(GtkWidget *w, GdkEventAny *event, gpointer data)
355 {
356         config_window_close_cb(NULL, NULL);
357         return TRUE;
358 }
359
360 static void config_window_ok_cb(GtkWidget *widget, gpointer data)
361 {
362         config_window_apply();
363         config_window_close_cb(NULL, NULL);
364 }
365
366 static void config_window_apply_cb(GtkWidget *widget, gpointer data)
367 {
368         config_window_apply();
369 }
370
371 /*
372  *-----------------------------------------------------------------------------
373  * config window setup (private)
374  *-----------------------------------------------------------------------------
375  */
376
377 static void exif_item_cb(GtkWidget *combo, gpointer data)
378 {
379         gint *option = data;
380         *option = gtk_combo_box_get_active(GTK_COMBO_BOX(combo));
381 }
382
383 static void exif_item(GtkWidget *table, gint column, gint row,
384                       const gchar *text, gint option, gint *option_c)
385 {
386         GtkWidget *combo;
387
388         *option_c = option;
389
390         pref_table_label(table, column, row, text, 0.0);
391
392         combo = gtk_combo_box_new_text();
393
394         /* note: the order is important, it must match the values of
395          * EXIF_UI_OFF, _IFSET, _ON */
396         gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _("Never"));
397         gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _("If set"));
398         gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _("Always"));
399
400         gtk_combo_box_set_active(GTK_COMBO_BOX(combo), option);
401
402         g_signal_connect(G_OBJECT(combo), "changed",
403                          G_CALLBACK(exif_item_cb), option_c);
404
405         gtk_table_attach(GTK_TABLE(table), combo,
406                          column + 1, column + 2, row, row + 1,
407                          GTK_EXPAND | GTK_FILL, 0, 0, 0);
408         gtk_widget_show(combo);
409 }
410
411 static void quality_menu_cb(GtkWidget *combo, gpointer data)
412 {
413         gint *option = data;
414
415         switch (gtk_combo_box_get_active(GTK_COMBO_BOX(combo)))
416                 {
417                 case 0:
418                 default:
419                         *option = GDK_INTERP_NEAREST;
420                         break;
421                 case 1:
422                         *option = GDK_INTERP_TILES;
423                         break;
424                 case 2:
425                         *option = GDK_INTERP_BILINEAR;
426                         break;
427                 case 3:
428                         *option = GDK_INTERP_HYPER;
429                         break;
430                 }
431 }
432
433 static void add_quality_menu(GtkWidget *table, gint column, gint row, const gchar *text,
434                              gint option, gint *option_c)
435 {
436         GtkWidget *combo;
437         gint current = 0;
438
439         *option_c = option;
440
441         pref_table_label(table, column, row, text, 0.0);
442
443         combo = gtk_combo_box_new_text();
444
445         gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _("Nearest (worst, but fastest)"));
446         if (option == GDK_INTERP_NEAREST) current = 0;
447         gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _("Tiles"));
448         if (option == GDK_INTERP_TILES) current = 1;
449         gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _("Bilinear"));
450         if (option == GDK_INTERP_BILINEAR) current = 2;
451         gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _("Hyper (best, but slowest)"));
452         if (option == GDK_INTERP_HYPER) current = 3;
453
454         gtk_combo_box_set_active(GTK_COMBO_BOX(combo), current);
455
456         g_signal_connect(G_OBJECT(combo), "changed",
457                          G_CALLBACK(quality_menu_cb), option_c);
458
459         gtk_table_attach(GTK_TABLE(table), combo, column + 1, column + 2, row, row + 1,
460                          GTK_EXPAND | GTK_FILL, 0, 0, 0);
461         gtk_widget_show(combo);
462 }
463
464 #if 0
465 static void add_dither_menu(gint option, gint *option_c, gchar *text, GtkWidget *box)
466 {
467         GtkWidget *hbox;
468         GtkWidget *omenu;
469         GtkWidget *menu;
470
471         *option_c = option;
472
473         hbox = pref_box_new(box, FALSE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_SPACE);
474         pref_label_new(hbox, text);
475
476         omenu = gtk_option_menu_new();
477         menu = gtk_menu_new();
478
479         add_menu_item(menu, _("None"), option_c, (gint)GDK_RGB_DITHER_NONE);
480         add_menu_item(menu, _("Normal"), option_c, (gint)GDK_RGB_DITHER_NORMAL);
481         add_menu_item(menu, _("Best"), option_c, (gint)GDK_RGB_DITHER_MAX);
482
483         gtk_option_menu_set_menu(GTK_OPTION_MENU(omenu), menu);
484         gtk_option_menu_set_history(GTK_OPTION_MENU(omenu), *option_c);
485
486         gtk_box_pack_start(GTK_BOX(hbox), omenu, FALSE, FALSE, 0);
487         gtk_widget_show(omenu);
488 }
489 #endif
490
491 static void thumb_size_menu_cb(GtkWidget *combo, gpointer data)
492 {
493         gint n;
494
495         n = gtk_combo_box_get_active(GTK_COMBO_BOX(combo));
496
497         if (n >= 0 && n < sizeof(thumb_size_list) / sizeof(ThumbSize))
498                 {
499                 c_options->thumbnails.max_width = thumb_size_list[n].w;
500                 c_options->thumbnails.max_height = thumb_size_list[n].h;
501                 }
502         else if (n > 0)
503                 {
504                 c_options->thumbnails.max_width = options->thumbnails.max_width;
505                 c_options->thumbnails.max_height = options->thumbnails.max_height;
506                 }
507 }
508
509 static void add_thumb_size_menu(GtkWidget *table, gint column, gint row, gchar *text)
510 {
511         GtkWidget *combo;
512         gint current;
513         gint i;
514
515         c_options->thumbnails.max_width = options->thumbnails.max_width;
516         c_options->thumbnails.max_height = options->thumbnails.max_height;
517
518         pref_table_label(table, column, row, text, 0.0);
519
520         combo = gtk_combo_box_new_text();
521
522         current = -1;
523         for (i = 0; i < sizeof(thumb_size_list) / sizeof(ThumbSize); i++)
524                 {
525                 gint w, h;
526                 gchar *buf;
527
528                 w = thumb_size_list[i].w;
529                 h = thumb_size_list[i].h;
530
531                 buf = g_strdup_printf("%d x %d", w, h);
532                 gtk_combo_box_append_text(GTK_COMBO_BOX(combo), buf);
533                 g_free(buf);
534
535                 if (w == options->thumbnails.max_width && h == options->thumbnails.max_height) current = i;
536                 }
537
538         if (current == -1)
539                 {
540                 gchar *buf;
541
542                 buf = g_strdup_printf("%s %d x %d", _("Custom"), options->thumbnails.max_width, options->thumbnails.max_height);
543                 gtk_combo_box_append_text(GTK_COMBO_BOX(combo), buf);
544                 g_free(buf);
545
546                 current = i;
547                 }
548
549         gtk_combo_box_set_active(GTK_COMBO_BOX(combo), current);
550         g_signal_connect(G_OBJECT(combo), "changed",
551                          G_CALLBACK(thumb_size_menu_cb), NULL);
552
553         gtk_table_attach(GTK_TABLE(table), combo, column + 1, column + 2, row, row + 1,
554                          GTK_EXPAND | GTK_FILL, 0, 0, 0);
555         gtk_widget_show(combo);
556 }
557
558 static void filter_store_populate(void)
559 {
560         GList *work;
561
562         if (!filter_store) return;
563
564         gtk_list_store_clear(filter_store);
565
566         work = filter_get_list();
567         while (work)
568                 {
569                 FilterEntry *fe;
570                 GtkTreeIter iter;
571
572                 fe = work->data;
573                 work = work->next;
574
575                 gtk_list_store_append(filter_store, &iter);
576                 gtk_list_store_set(filter_store, &iter, 0, fe, -1);
577                 }
578 }
579
580 static void filter_store_ext_edit_cb(GtkCellRendererText *cell, gchar *path_str,
581                                      gchar *new_text, gpointer data)
582 {
583         GtkWidget *model = data;
584         FilterEntry *fe = data;
585         GtkTreePath *tpath;
586         GtkTreeIter iter;
587
588         if (!new_text || strlen(new_text) < 1) return;
589
590         tpath = gtk_tree_path_new_from_string(path_str);
591         gtk_tree_model_get_iter(GTK_TREE_MODEL(model), &iter, tpath);
592         gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, 0, &fe, -1);
593
594         g_free(fe->extensions);
595         fe->extensions = g_strdup(new_text);
596
597         gtk_tree_path_free(tpath);
598         filter_rebuild();
599 }
600
601 static void filter_store_desc_edit_cb(GtkCellRendererText *cell, gchar *path_str,
602                                       gchar *new_text, gpointer data)
603 {
604         GtkWidget *model = data;
605         FilterEntry *fe;
606         GtkTreePath *tpath;
607         GtkTreeIter iter;
608
609         if (!new_text || strlen(new_text) < 1) return;
610
611         tpath = gtk_tree_path_new_from_string(path_str);
612         gtk_tree_model_get_iter(GTK_TREE_MODEL(model), &iter, tpath);
613         gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, 0, &fe, -1);
614
615         g_free(fe->description);
616         fe->description = g_strdup(new_text);
617
618         gtk_tree_path_free(tpath);
619 }
620
621 static void filter_store_enable_cb(GtkCellRendererToggle *renderer,
622                                    gchar *path_str, gpointer data)
623 {
624         GtkWidget *model = data;
625         FilterEntry *fe;
626         GtkTreePath *tpath;
627         GtkTreeIter iter;
628
629         tpath = gtk_tree_path_new_from_string(path_str);
630         gtk_tree_model_get_iter(GTK_TREE_MODEL(model), &iter, tpath);
631         gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, 0, &fe, -1);
632
633         fe->enabled = !fe->enabled;
634
635         gtk_tree_path_free(tpath);
636         filter_rebuild();
637 }
638
639 static void filter_set_func(GtkTreeViewColumn *tree_column, GtkCellRenderer *cell,
640                             GtkTreeModel *tree_model, GtkTreeIter *iter, gpointer data)
641 {
642         FilterEntry *fe;
643
644         gtk_tree_model_get(tree_model, iter, 0, &fe, -1);
645
646         switch(GPOINTER_TO_INT(data))
647                 {
648                 case FE_ENABLE:
649                         g_object_set(GTK_CELL_RENDERER(cell),
650                                      "active", fe->enabled, NULL);
651                         break;
652                 case FE_EXTENSION:
653                         g_object_set(GTK_CELL_RENDERER(cell),
654                                      "text", fe->extensions, NULL);
655                         break;
656                 case FE_DESCRIPTION:
657                         g_object_set(GTK_CELL_RENDERER(cell),
658                                      "text", fe->description, NULL);
659                         break;
660                 }
661 }
662
663 static void filter_add_cb(GtkWidget *widget, gpointer data)
664 {
665         filter_add_unique("description", ".new", FORMAT_CLASS_IMAGE, TRUE);
666         filter_store_populate();
667
668         /* FIXME: implement the scroll to/select row stuff for tree view */
669 }
670
671 static void filter_remove_cb(GtkWidget *widget, gpointer data)
672 {
673         GtkWidget *filter_view = data;
674         GtkTreeSelection *selection;
675         GtkTreeIter iter;
676         FilterEntry *fe;
677
678         if (!filter_store) return;
679         selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(filter_view));
680         if (!gtk_tree_selection_get_selected(selection, NULL, &iter)) return;
681         gtk_tree_model_get(GTK_TREE_MODEL(filter_store), &iter, 0, &fe, -1);
682         if (!fe) return;
683
684         filter_remove_entry(fe);
685         filter_rebuild();
686         filter_store_populate();
687 }
688
689 static void filter_default_ok_cb(GenericDialog *gd, gpointer data)
690 {
691         filter_reset();
692         filter_add_defaults();
693         filter_rebuild();
694         filter_store_populate();
695 }
696
697 static void dummy_cancel_cb(GenericDialog *gd, gpointer data)
698 {
699         /* no op, only so cancel button appears */
700 }
701
702 static void filter_default_cb(GtkWidget *widget, gpointer data)
703 {
704         GenericDialog *gd;
705
706         gd = generic_dialog_new(_("Reset filters"),
707                                 GQ_WMCLASS, "reset_filter", widget, TRUE,
708                                 dummy_cancel_cb, NULL);
709         generic_dialog_add_message(gd, GTK_STOCK_DIALOG_QUESTION, _("Reset filters"),
710                                    _("This will reset the file filters to the defaults.\nContinue?"));
711         generic_dialog_add_button(gd, GTK_STOCK_OK, NULL, filter_default_ok_cb, TRUE);
712         gtk_widget_show(gd->dialog);
713 }
714
715 static void filter_disable_cb(GtkWidget* widget, gpointer data)
716 {
717         GtkWidget *frame = data;
718
719         gtk_widget_set_sensitive(frame,
720                                  !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)));
721 }
722
723 static void editor_default_ok_cb(GenericDialog *gd, gpointer data)
724 {
725         gint i;
726
727         editor_reset_defaults();
728         if (!configwindow) return;
729
730         for (i = 0; i < GQ_EDITOR_SLOTS; i++)
731                 {
732                 if (i < GQ_EDITOR_GENERIC_SLOTS)
733                         gtk_entry_set_text(GTK_ENTRY(editor_name_entry[i]),
734                                    (options->editor_name[i]) ? options->editor_name[i] : "");
735                 gtk_entry_set_text(GTK_ENTRY(editor_command_entry[i]),
736                                    (options->editor_command[i]) ? options->editor_command[i] : "");
737                 }
738 }
739
740 static void editor_default_cb(GtkWidget *widget, gpointer data)
741 {
742         GenericDialog *gd;
743
744         gd = generic_dialog_new(_("Reset editors"),
745                                 GQ_WMCLASS, "reset_filter", widget, TRUE,
746                                 dummy_cancel_cb, NULL);
747         generic_dialog_add_message(gd, GTK_STOCK_DIALOG_QUESTION, _("Reset editors"),
748                                    _("This will reset the edit commands to the defaults.\nContinue?"));
749         generic_dialog_add_button(gd, GTK_STOCK_OK, NULL, editor_default_ok_cb, TRUE);
750         gtk_widget_show(gd->dialog);
751 }
752
753 static void editor_help_cb(GtkWidget *widget, gpointer data)
754 {
755         help_window_show("editors");
756 }
757
758 static void safe_delete_view_cb(GtkWidget* widget, gpointer data)
759 {
760         layout_set_path(NULL, gtk_entry_get_text(GTK_ENTRY(safe_delete_path_entry)));
761 }
762
763 static void safe_delete_clear_ok_cb(GenericDialog *gd, gpointer data)
764 {
765         file_util_trash_clear();
766 }
767
768 static void safe_delete_clear_cb(GtkWidget* widget, gpointer data)
769 {
770         GenericDialog *gd;
771         GtkWidget *entry;
772         gd = generic_dialog_new(_("Clear trash"),
773                                 GQ_WMCLASS, "clear_trash", widget, TRUE,
774                                 dummy_cancel_cb, NULL);
775         generic_dialog_add_message(gd, GTK_STOCK_DIALOG_QUESTION, _("Clear trash"),
776                                     _("This will remove the trash contents."));
777         generic_dialog_add_button(gd, GTK_STOCK_OK, NULL, safe_delete_clear_ok_cb, TRUE);
778         entry = gtk_entry_new();
779         GTK_WIDGET_UNSET_FLAGS(entry, GTK_CAN_FOCUS);
780         gtk_editable_set_editable(GTK_EDITABLE(entry), FALSE);
781         if (options->file_ops.safe_delete_path) gtk_entry_set_text(GTK_ENTRY(entry), options->file_ops.safe_delete_path);
782         gtk_box_pack_start(GTK_BOX(gd->vbox), entry, FALSE, FALSE, 0);
783         gtk_widget_show(entry);
784         gtk_widget_show(gd->dialog);
785 }
786
787 static void image_overlay_template_view_changed_cb(GtkWidget* widget, gpointer data)
788 {
789         GtkWidget *pTextView;
790         GtkTextBuffer* pTextBuffer;
791         GtkTextIter iStart;
792         GtkTextIter iEnd;
793
794         pTextView = GTK_WIDGET(data);
795
796         pTextBuffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(pTextView));
797         gtk_text_buffer_get_start_iter(pTextBuffer, &iStart);
798         gtk_text_buffer_get_end_iter(pTextBuffer, &iEnd);
799
800         if (c_options->image_overlay.common.template_string) g_free(c_options->image_overlay.common.template_string);
801         c_options->image_overlay.common.template_string = gtk_text_buffer_get_text(pTextBuffer, &iStart, &iEnd, TRUE);
802 }
803
804 static void image_overlay_default_template_ok_cb(GenericDialog *gd, gpointer data)
805 {
806         GtkTextView *text_view = data;
807         GtkTextBuffer *buffer;
808
809         set_default_image_overlay_template_string(options);
810         if (!configwindow) return;
811
812         buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_view));
813         gtk_text_buffer_set_text(buffer, options->image_overlay.common.template_string, -1);
814 }
815
816 static void image_overlay_default_template_cb(GtkWidget *widget, gpointer data)
817 {
818         GenericDialog *gd;
819
820         gd = generic_dialog_new(_("Reset image overlay template string"),
821                                 GQ_WMCLASS, "reset_image_overlay_template_string", widget, TRUE,
822                                 dummy_cancel_cb, data);
823         generic_dialog_add_message(gd, GTK_STOCK_DIALOG_QUESTION, _("Reset image overlay template string"),
824                                    _("This will reset the image overlay template string to the default.\nContinue?"));
825         generic_dialog_add_button(gd, GTK_STOCK_OK, NULL, image_overlay_default_template_ok_cb, TRUE);
826         gtk_widget_show(gd->dialog);
827 }
828
829
830 /* general options tab */
831 static void config_tab_general(GtkWidget *notebook)
832 {
833         GtkWidget *label;
834         GtkWidget *hbox;
835         GtkWidget *vbox;
836         GtkWidget *group;
837         GtkWidget *subgroup;
838         GtkWidget *button;
839         GtkWidget *tabcomp;
840         GtkWidget *ct_button;
841         GtkWidget *table;
842         GtkWidget *spin;
843
844         vbox = gtk_vbox_new(FALSE, 0);
845         gtk_container_set_border_width(GTK_CONTAINER(vbox), PREF_PAD_BORDER);
846         gtk_widget_show(vbox);
847         label = gtk_label_new(_("General"));
848         gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox, label);
849
850         group = pref_group_new(vbox, FALSE, _("Startup"), GTK_ORIENTATION_VERTICAL);
851
852         button = pref_checkbox_new_int(group, _("Change to folder:"),
853                                        options->startup_path_enable, &c_options->startup_path_enable);
854
855         hbox = pref_box_new(group, FALSE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_SPACE);
856         pref_checkbox_link_sensitivity(button, hbox);
857
858         tabcomp = tab_completion_new(&startup_path_entry, options->startup_path, NULL, NULL);
859         tab_completion_add_select_button(startup_path_entry, NULL, TRUE);
860         gtk_box_pack_start(GTK_BOX(hbox), tabcomp, TRUE, TRUE, 0);
861         gtk_widget_show(tabcomp);
862
863         button = pref_button_new(hbox, NULL, _("Use current"), FALSE,
864                                  G_CALLBACK(startup_path_set_current), NULL);
865
866         group = pref_group_new(vbox, FALSE, _("Thumbnails"), GTK_ORIENTATION_VERTICAL);
867
868         table = pref_table_new(group, 2, 2, FALSE, FALSE);
869         add_thumb_size_menu(table, 0, 0, _("Size:"));
870         add_quality_menu(table, 0, 1, _("Quality:"), options->thumbnails.quality, &c_options->thumbnails.quality);
871
872         ct_button = pref_checkbox_new_int(group, _("Cache thumbnails"),
873                                           options->thumbnails.enable_caching, &c_options->thumbnails.enable_caching);
874
875         subgroup = pref_box_new(group, FALSE, GTK_ORIENTATION_VERTICAL, PREF_PAD_GAP);
876         pref_checkbox_link_sensitivity(ct_button, subgroup);
877
878         button = pref_checkbox_new_int(subgroup, _("Use shared thumbnail cache"),
879                                        options->thumbnails.spec_standard, &c_options->thumbnails.spec_standard);
880
881         subgroup = pref_box_new(subgroup, FALSE, GTK_ORIENTATION_VERTICAL, PREF_PAD_GAP);
882         pref_checkbox_link_sensitivity_swap(button, subgroup);
883
884         pref_checkbox_new_int(subgroup, _("Cache thumbnails into .thumbnails"),
885                               options->thumbnails.cache_into_dirs, &c_options->thumbnails.cache_into_dirs);
886
887 #if 0
888         pref_checkbox_new_int(subgroup, _("Use xvpics thumbnails when found (read only)"),
889                               options->thumbnails.use_xvpics, &c_options->thumbnails.use_xvpics);
890 #endif
891
892         pref_checkbox_new_int(group, _("Faster jpeg thumbnailing (may reduce quality)"),
893                               options->thumbnails.fast, &c_options->thumbnails.fast);
894
895         group = pref_group_new(vbox, FALSE, _("Slide show"), GTK_ORIENTATION_VERTICAL);
896
897         c_options->slideshow.delay = options->slideshow.delay;
898         spin = pref_spin_new(group, _("Delay between image change:"), _("seconds"),
899                              SLIDESHOW_MIN_SECONDS, SLIDESHOW_MAX_SECONDS, 1.0, 1,
900                              options->slideshow.delay ? (double)options->slideshow.delay / SLIDESHOW_SUBSECOND_PRECISION : 10.0,
901                              G_CALLBACK(slideshow_delay_cb), NULL);
902         gtk_spin_button_set_update_policy(GTK_SPIN_BUTTON(spin), GTK_UPDATE_ALWAYS);
903
904         pref_checkbox_new_int(group, _("Random"), options->slideshow.random, &c_options->slideshow.random);
905         pref_checkbox_new_int(group, _("Repeat"), options->slideshow.repeat, &c_options->slideshow.repeat);
906 }
907
908 /* image tab */
909 static void config_tab_image(GtkWidget *notebook)
910 {
911         GtkWidget *label;
912         GtkWidget *hbox;
913         GtkWidget *vbox;
914         GtkWidget *group;
915         GtkWidget *button;
916         GtkWidget *ct_button;
917         GtkWidget *table;
918         GtkWidget *spin;
919
920         vbox = gtk_vbox_new(FALSE, 0);
921         gtk_container_set_border_width(GTK_CONTAINER(vbox), PREF_PAD_BORDER);
922         gtk_widget_show(vbox);
923         label = gtk_label_new(_("Image"));
924         gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox, label);
925
926         group = pref_group_new(vbox, FALSE, _("Zoom"), GTK_ORIENTATION_VERTICAL);
927
928 #if 0
929         add_dither_menu(dither_quality, &c_options->image.dither_quality, _("Dithering method:"), group);
930 #endif
931         table = pref_table_new(group, 2, 1, FALSE, FALSE);
932         add_quality_menu(table, 0, 0, _("Quality:"), options->image.zoom_quality, &c_options->image.zoom_quality);
933
934         pref_checkbox_new_int(group, _("Two pass zooming"),
935                               options->image.zoom_2pass, &c_options->image.zoom_2pass);
936
937         pref_checkbox_new_int(group, _("Allow enlargement of image for zoom to fit"),
938                               options->image.zoom_to_fit_allow_expand, &c_options->image.zoom_to_fit_allow_expand);
939
940         hbox = pref_box_new(group, FALSE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_SPACE);
941         ct_button = pref_checkbox_new_int(hbox, _("Limit image size when autofitting (%):"),
942                                           options->image.limit_autofit_size, &c_options->image.limit_autofit_size);
943         spin = pref_spin_new_int(hbox, NULL, NULL,
944                                  10, 150, 1,
945                                  options->image.max_autofit_size, &c_options->image.max_autofit_size);
946         pref_checkbox_link_sensitivity(ct_button, spin);
947
948         c_options->image.zoom_increment = options->image.zoom_increment;
949         spin = pref_spin_new(group, _("Zoom increment:"), NULL,
950                              0.1, 4.0, 0.1, 1, (double)options->image.zoom_increment / 10.0,
951                              G_CALLBACK(zoom_increment_cb), NULL);
952         gtk_spin_button_set_update_policy(GTK_SPIN_BUTTON(spin), GTK_UPDATE_ALWAYS);
953
954         group = pref_group_new(vbox, FALSE, _("When new image is selected:"), GTK_ORIENTATION_VERTICAL);
955
956         c_options->image.zoom_mode = options->image.zoom_mode;
957         button = pref_radiobutton_new(group, NULL, _("Zoom to original size"),
958                                       (options->image.zoom_mode == ZOOM_RESET_ORIGINAL),
959                                       G_CALLBACK(zoom_mode_original_cb), NULL);
960         button = pref_radiobutton_new(group, button, _("Fit image to window"),
961                                       (options->image.zoom_mode == ZOOM_RESET_FIT_WINDOW),
962                                       G_CALLBACK(zoom_mode_fit_cb), NULL);
963         button = pref_radiobutton_new(group, button, _("Leave Zoom at previous setting"),
964                                       (options->image.zoom_mode == ZOOM_RESET_NONE),
965                                       G_CALLBACK(zoom_mode_none_cb), NULL);
966
967         group = pref_group_new(vbox, FALSE, _("Appearance"), GTK_ORIENTATION_VERTICAL);
968
969         pref_checkbox_new_int(group, _("Custom border color"),
970                               options->image.use_custom_border_color, &c_options->image.use_custom_border_color);
971
972         pref_color_button_new(group, _("Border color"), &options->image.border_color,
973                               G_CALLBACK(pref_color_button_set_cb), &c_options->image.border_color);
974
975         group = pref_group_new(vbox, FALSE, _("Convenience"), GTK_ORIENTATION_VERTICAL);
976
977         pref_checkbox_new_int(group, _("Refresh on file change"),
978                               options->update_on_time_change, &c_options->update_on_time_change);
979         pref_checkbox_new_int(group, _("Preload next image"),
980                               options->image.enable_read_ahead, &c_options->image.enable_read_ahead);
981         pref_checkbox_new_int(group, _("Auto rotate image using Exif information"),
982                               options->image.exif_rotate_enable, &c_options->image.exif_rotate_enable);
983 }
984
985 /* windows tab */
986 static void config_tab_windows(GtkWidget *notebook)
987 {
988         GtkWidget *label;
989         GtkWidget *hbox;
990         GtkWidget *vbox;
991         GtkWidget *group;
992         GtkWidget *ct_button;
993         GtkWidget *spin;
994
995         vbox = gtk_vbox_new(FALSE, 0);
996         gtk_container_set_border_width(GTK_CONTAINER(vbox), PREF_PAD_BORDER);
997         gtk_widget_show(vbox);
998         label = gtk_label_new(_("Windows"));
999         gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox, label);
1000
1001         group = pref_group_new(vbox, FALSE, _("State"), GTK_ORIENTATION_VERTICAL);
1002
1003         pref_checkbox_new_int(group, _("Remember window positions"),
1004                               options->layout.save_window_positions, &c_options->layout.save_window_positions);
1005         pref_checkbox_new_int(group, _("Remember tool state (float/hidden)"),
1006                               options->layout.tools_restore_state, &c_options->layout.tools_restore_state);
1007
1008         group = pref_group_new(vbox, FALSE, _("Size"), GTK_ORIENTATION_VERTICAL);
1009
1010         pref_checkbox_new_int(group, _("Fit window to image when tools are hidden/floating"),
1011                               options->image.fit_window_to_image, &c_options->image.fit_window_to_image);
1012
1013         hbox = pref_box_new(group, FALSE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_SPACE);
1014         ct_button = pref_checkbox_new_int(hbox, _("Limit size when auto-sizing window (%):"),
1015                                           options->image.limit_window_size, &c_options->image.limit_window_size);
1016         spin = pref_spin_new_int(hbox, NULL, NULL,
1017                                  10, 150, 1,
1018                                  options->image.max_window_size, &c_options->image.max_window_size);
1019         pref_checkbox_link_sensitivity(ct_button, spin);
1020
1021         group = pref_group_new(vbox, FALSE, _("Layout"), GTK_ORIENTATION_VERTICAL);
1022
1023         layout_widget = layout_config_new();
1024         layout_config_set(layout_widget, options->layout.style, options->layout.order);
1025         gtk_box_pack_start(GTK_BOX(group), layout_widget, FALSE, FALSE, 0);
1026         gtk_widget_show(layout_widget);
1027 }
1028
1029 /* filtering tab */
1030 static void config_tab_filtering(GtkWidget *notebook)
1031 {
1032         GtkWidget *hbox;
1033         GtkWidget *frame;
1034         GtkWidget *label;
1035         GtkWidget *vbox;
1036         GtkWidget *group;
1037         GtkWidget *button;
1038         GtkWidget *ct_button;
1039         GtkWidget *scrolled;
1040         GtkWidget *filter_view;
1041         GtkCellRenderer *renderer;
1042         GtkTreeSelection *selection;
1043         GtkTreeViewColumn *column;
1044
1045         vbox = gtk_vbox_new(FALSE, 0);
1046         gtk_container_set_border_width(GTK_CONTAINER(vbox), PREF_PAD_BORDER);
1047         gtk_widget_show(vbox);
1048         label = gtk_label_new(_("Filtering"));
1049         gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox, label);
1050
1051         group = pref_box_new(vbox, FALSE, GTK_ORIENTATION_VERTICAL, PREF_PAD_GAP);
1052
1053         pref_checkbox_new_int(group, _("Show hidden files or folders"),
1054                               options->file_filter.show_hidden_files, &c_options->file_filter.show_hidden_files);
1055         pref_checkbox_new_int(group, _("Show dot directory"),
1056                               options->file_filter.show_dot_directory, &c_options->file_filter.show_dot_directory);
1057         pref_checkbox_new_int(group, _("Case sensitive sort"),
1058                               options->file_sort.case_sensitive, &c_options->file_sort.case_sensitive);
1059
1060         ct_button = pref_checkbox_new_int(group, _("Disable File Filtering"),
1061                                           options->file_filter.disable, &c_options->file_filter.disable);
1062
1063
1064         group = pref_group_new(vbox, FALSE, _("Grouping sidecar extensions"), GTK_ORIENTATION_VERTICAL);
1065
1066         sidecar_ext_entry = gtk_entry_new();
1067         gtk_entry_set_text(GTK_ENTRY(sidecar_ext_entry), sidecar_ext_to_string());
1068         gtk_box_pack_start(GTK_BOX(group), sidecar_ext_entry, FALSE, FALSE, 0);
1069         gtk_widget_show(sidecar_ext_entry);
1070
1071         group = pref_group_new(vbox, TRUE, _("File types"), GTK_ORIENTATION_VERTICAL);
1072
1073         frame = pref_group_parent(group);
1074         g_signal_connect(G_OBJECT(ct_button), "toggled",
1075                          G_CALLBACK(filter_disable_cb), frame);
1076         gtk_widget_set_sensitive(frame, !options->file_filter.disable);
1077
1078         scrolled = gtk_scrolled_window_new(NULL, NULL);
1079         gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled), GTK_SHADOW_IN);
1080         gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled), GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
1081         gtk_box_pack_start(GTK_BOX(group), scrolled, TRUE, TRUE, 0);
1082         gtk_widget_show(scrolled);
1083
1084         filter_store = gtk_list_store_new(1, G_TYPE_POINTER);
1085         filter_view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(filter_store));
1086         g_object_unref(filter_store);
1087         selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(filter_view));
1088         gtk_tree_selection_set_mode(GTK_TREE_SELECTION(selection), GTK_SELECTION_SINGLE);
1089
1090         gtk_tree_view_set_enable_search(GTK_TREE_VIEW(filter_view), FALSE);
1091
1092         column = gtk_tree_view_column_new();
1093         gtk_tree_view_column_set_title(column, _("Filter"));
1094         gtk_tree_view_column_set_resizable(column, TRUE);
1095
1096         renderer = gtk_cell_renderer_toggle_new();
1097         g_signal_connect(G_OBJECT(renderer), "toggled",
1098                          G_CALLBACK(filter_store_enable_cb), filter_store);
1099         gtk_tree_view_column_pack_start(column, renderer, FALSE);
1100         gtk_tree_view_column_set_cell_data_func(column, renderer, filter_set_func,
1101                                                 GINT_TO_POINTER(FE_ENABLE), NULL);
1102
1103         renderer = gtk_cell_renderer_text_new();
1104         g_signal_connect(G_OBJECT(renderer), "edited",
1105                          G_CALLBACK(filter_store_ext_edit_cb), filter_store);
1106         gtk_tree_view_column_pack_start(column, renderer, TRUE);
1107         g_object_set(G_OBJECT(renderer), "editable", (gboolean)TRUE, NULL);
1108         gtk_tree_view_column_set_cell_data_func(column, renderer, filter_set_func,
1109                                                 GINT_TO_POINTER(FE_EXTENSION), NULL);
1110         gtk_tree_view_append_column(GTK_TREE_VIEW(filter_view), column);
1111
1112         column = gtk_tree_view_column_new();
1113         gtk_tree_view_column_set_title(column, _("Description"));
1114         gtk_tree_view_column_set_resizable(column, TRUE);
1115         renderer = gtk_cell_renderer_text_new();
1116         g_signal_connect(G_OBJECT(renderer), "edited",
1117                          G_CALLBACK(filter_store_desc_edit_cb), filter_store);
1118         g_object_set(G_OBJECT(renderer), "editable", (gboolean)TRUE, NULL);
1119         gtk_tree_view_column_pack_start(column, renderer, FALSE);
1120         gtk_tree_view_column_set_cell_data_func(column, renderer, filter_set_func,
1121                                                 GINT_TO_POINTER(FE_DESCRIPTION), NULL);
1122         gtk_tree_view_append_column(GTK_TREE_VIEW(filter_view), column);
1123
1124         filter_store_populate();
1125         gtk_container_add(GTK_CONTAINER(scrolled), filter_view);
1126         gtk_widget_show(filter_view);
1127
1128         hbox = pref_box_new(group, FALSE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_BUTTON_GAP);
1129
1130         button = pref_button_new(NULL, NULL, _("Defaults"), FALSE,
1131                                  G_CALLBACK(filter_default_cb), NULL);
1132         gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0);
1133         gtk_widget_show(button);
1134
1135         button = pref_button_new(NULL, GTK_STOCK_REMOVE, NULL, FALSE,
1136                                  G_CALLBACK(filter_remove_cb), filter_view);
1137         gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0);
1138         gtk_widget_show(button);
1139
1140         button = pref_button_new(NULL, GTK_STOCK_ADD, NULL, FALSE,
1141                                  G_CALLBACK(filter_add_cb), NULL);
1142         gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0);
1143         gtk_widget_show(button);
1144 }
1145
1146 /* editors tab */
1147 static void config_tab_editors(GtkWidget *notebook)
1148 {
1149         GtkWidget *hbox;
1150         GtkWidget *label;
1151         GtkWidget *vbox;
1152         GtkWidget *button;
1153         GtkWidget *table;
1154         gint i;
1155
1156         vbox = gtk_vbox_new(FALSE, PREF_PAD_GAP);
1157         gtk_container_set_border_width(GTK_CONTAINER(vbox), PREF_PAD_BORDER);
1158         gtk_widget_show(vbox);
1159         label = gtk_label_new(_("Editors"));
1160         gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox, label);
1161
1162         table = pref_table_new(vbox, 3, 9, FALSE, FALSE);
1163         gtk_table_set_col_spacings(GTK_TABLE(table), PREF_PAD_GAP);
1164
1165         label = pref_table_label(table, 0, 0, _("#"), 1.0);
1166         pref_label_bold(label, TRUE, FALSE);
1167
1168         label = pref_table_label(table, 1, 0, _("Menu name"), 0.0);
1169         pref_label_bold(label, TRUE, FALSE);
1170
1171         label = pref_table_label(table, 2, 0, _("Command Line"), 0.0);
1172         pref_label_bold(label, TRUE, FALSE);
1173
1174         for (i = 0; i < GQ_EDITOR_SLOTS; i++)
1175                 {
1176                 GtkWidget *entry;
1177
1178                 if (i < GQ_EDITOR_GENERIC_SLOTS)
1179                         {
1180                         gchar *buf;
1181
1182                         buf = g_strdup_printf("%d", i+1);
1183                         pref_table_label(table, 0, i+1, buf, 1.0);
1184                         g_free(buf);
1185                         entry = gtk_entry_new();
1186                         gtk_entry_set_max_length(GTK_ENTRY(entry), EDITOR_NAME_MAX_LENGTH);
1187                         gtk_widget_set_size_request(entry, 80, -1);
1188                         if (options->editor_name[i])
1189                                 gtk_entry_set_text(GTK_ENTRY(entry), options->editor_name[i]);
1190                         }
1191                 else
1192                         {
1193                         entry = gtk_label_new(options->editor_name[i]);
1194                         gtk_misc_set_alignment(GTK_MISC(entry), 0.0, 0.5);
1195                         }
1196
1197                 gtk_table_attach(GTK_TABLE(table), entry, 1, 2, i+1, i+2,
1198                                  GTK_FILL | GTK_SHRINK, 0, 0, 0);
1199                 gtk_widget_show(entry);
1200                 editor_name_entry[i] = entry;
1201
1202                 entry = gtk_entry_new();
1203                 gtk_entry_set_max_length(GTK_ENTRY(entry), EDITOR_COMMAND_MAX_LENGTH);
1204                 gtk_widget_set_size_request(entry, 160, -1);
1205                 tab_completion_add_to_entry(entry, NULL, NULL);
1206                 if (options->editor_command[i])
1207                         gtk_entry_set_text(GTK_ENTRY(entry), options->editor_command[i]);
1208                 gtk_table_attach(GTK_TABLE(table), entry, 2, 3, i+1, i+2,
1209                                  GTK_FILL | GTK_EXPAND, 0, 0, 0);
1210                 gtk_widget_show(entry);
1211                 editor_command_entry[i] = entry;
1212                 }
1213
1214         hbox = pref_box_new(vbox, FALSE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_BUTTON_GAP);
1215
1216         button = pref_button_new(NULL, NULL, _("Defaults"), FALSE,
1217                                  G_CALLBACK(editor_default_cb), NULL);
1218         gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0);
1219         gtk_widget_show(button);
1220
1221         button = pref_button_new(NULL, GTK_STOCK_HELP, NULL, FALSE,
1222                                  G_CALLBACK(editor_help_cb), NULL);
1223         gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0);
1224         gtk_widget_show(button);
1225 }
1226
1227 /* properties tab */
1228 static void config_tab_properties(GtkWidget *notebook)
1229 {
1230         GtkWidget *label;
1231         GtkWidget *vbox;
1232         GtkWidget *group;
1233         GtkWidget *table;
1234         GtkWidget *scrolled;
1235         GtkWidget *viewport;
1236         gint i;
1237
1238         scrolled = gtk_scrolled_window_new(NULL, NULL);
1239         gtk_container_set_border_width(GTK_CONTAINER(scrolled), PREF_PAD_BORDER);
1240         gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),
1241                                        GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
1242
1243         label = gtk_label_new(_("Properties"));
1244         gtk_notebook_append_page(GTK_NOTEBOOK(notebook), scrolled, label);
1245         gtk_widget_show(scrolled);
1246
1247         viewport = gtk_viewport_new(NULL, NULL);
1248         gtk_viewport_set_shadow_type(GTK_VIEWPORT(viewport), GTK_SHADOW_NONE);
1249         gtk_container_add(GTK_CONTAINER(scrolled), viewport);
1250         gtk_widget_show(viewport);
1251
1252         vbox = gtk_vbox_new(FALSE, 0);
1253         gtk_container_add(GTK_CONTAINER(viewport), vbox);
1254         gtk_widget_show(vbox);
1255
1256         group = pref_group_new(vbox, FALSE, _("Exif"),
1257                                GTK_ORIENTATION_VERTICAL);
1258
1259
1260         pref_spacer(group, PREF_PAD_INDENT - PREF_PAD_SPACE);
1261         label = pref_label_new(group, _("What to show in properties dialog:"));
1262         gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
1263
1264         table = pref_table_new(group, 2, 2, FALSE, FALSE);
1265
1266         for (i = 0; ExifUIList[i].key; i++)
1267                 {
1268                 const gchar *title;
1269
1270                 title = exif_get_description_by_key(ExifUIList[i].key);
1271                 exif_item(table, 0, i, title, ExifUIList[i].current,
1272                           &ExifUIList[i].temp);
1273                 }
1274 }
1275
1276 /* advanced entry tab */
1277 static void config_tab_advanced(GtkWidget *notebook)
1278 {
1279         GtkWidget *label;
1280         GtkWidget *hbox;
1281         GtkWidget *vbox;
1282         GtkWidget *group;
1283         GtkWidget *button;
1284         GtkWidget *tabcomp;
1285         GtkWidget *ct_button;
1286         GtkWidget *table;
1287         GtkWidget *spin;
1288         GtkWidget *scrolled;
1289         GtkWidget *viewport;
1290         GtkWidget *image_overlay_template_view;
1291         GtkTextBuffer *buffer;
1292         gint i;
1293
1294         scrolled = gtk_scrolled_window_new(NULL, NULL);
1295         gtk_container_set_border_width(GTK_CONTAINER(scrolled), PREF_PAD_BORDER);
1296         gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),
1297                                        GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
1298         label = gtk_label_new(_("Advanced"));
1299         gtk_notebook_append_page(GTK_NOTEBOOK(notebook), scrolled, label);
1300         gtk_widget_show(scrolled);
1301
1302         viewport = gtk_viewport_new(NULL, NULL);
1303         gtk_viewport_set_shadow_type(GTK_VIEWPORT(viewport), GTK_SHADOW_NONE);
1304         gtk_container_add(GTK_CONTAINER(scrolled), viewport);
1305         gtk_widget_show(viewport);
1306
1307         vbox = gtk_vbox_new(FALSE, 0);
1308         gtk_container_add(GTK_CONTAINER(viewport), vbox);
1309         gtk_widget_show(vbox);
1310
1311         group = pref_group_new(vbox, FALSE, _("Full screen"), GTK_ORIENTATION_VERTICAL);
1312
1313         c_options->fullscreen.screen = options->fullscreen.screen;
1314         c_options->fullscreen.above = options->fullscreen.above;
1315         hbox = fullscreen_prefs_selection_new(_("Location:"), &c_options->fullscreen.screen, &c_options->fullscreen.above);
1316         gtk_box_pack_start(GTK_BOX(group), hbox, FALSE, FALSE, 0);
1317         gtk_widget_show(hbox);
1318
1319         pref_checkbox_new_int(group, _("Smooth image flip"),
1320                               options->fullscreen.clean_flip, &c_options->fullscreen.clean_flip);
1321         pref_checkbox_new_int(group, _("Disable screen saver"),
1322                               options->fullscreen.disable_saver, &c_options->fullscreen.disable_saver);
1323         pref_checkbox_new_int(group, _("Always show image overlay at startup"),
1324                               options->image_overlay.common.show_at_startup, &c_options->image_overlay.common.show_at_startup);
1325         pref_label_new(group, _("Image overlay template"));
1326
1327         scrolled = gtk_scrolled_window_new(NULL, NULL);
1328         gtk_widget_set_size_request(scrolled, 200, 150);
1329         gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled), GTK_SHADOW_IN);
1330         gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),
1331                                        GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
1332         gtk_box_pack_start(GTK_BOX(group), scrolled, TRUE, TRUE, 5);
1333         gtk_widget_show(scrolled);
1334
1335         image_overlay_template_view = gtk_text_view_new();
1336
1337 #if GTK_CHECK_VERSION(2,12,0)
1338         gtk_widget_set_tooltip_markup(image_overlay_template_view,
1339         _("<i>%name%</i> results in the filename of the picture.\n"
1340           "Also available: <i>%collection%</i>, <i>%number%</i>, <i>%total%</i>, <i>%date%</i>,\n"
1341           "<i>%size%</i> (filesize), <i>%width%</i>, <i>%height%</i>, <i>%res%</i> (resolution)\n"
1342           "To access exif data use the exif name, e. g. <i>%fCamera%</i> is the formatted camera name,\n"
1343           "<i>%Exif.Photo.DateTimeOriginal%</i> the date of the original shot.\n"
1344           "<i>%fCamera:20</i> notation will truncate the displayed data to 20 characters and will add 3 dots at the end to denote the truncation.\n"
1345           "If two or more variables are connected with the |-sign, it prints available variables with a separator.\n"
1346           "<i>%fShutterSpeed%</i>|<i>%fISOSpeedRating%</i>|<i>%fFocalLength%</i> could show \"1/20s - 400 - 80 mm\" or \"1/200 - 80 mm\",\n"
1347           "if there's no ISO information in the Exif data.\n"
1348           "If a line is empty, it is removed. This allows to add lines that totally disappear when no data is available.\n"
1349 ));
1350 #endif
1351         gtk_container_add(GTK_CONTAINER(scrolled), image_overlay_template_view);
1352         gtk_widget_show(image_overlay_template_view);
1353
1354         hbox = pref_box_new(group, FALSE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_BUTTON_GAP);
1355
1356         button = pref_button_new(NULL, NULL, _("Defaults"), FALSE,
1357                                  G_CALLBACK(image_overlay_default_template_cb), image_overlay_template_view);
1358         gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0);
1359         gtk_widget_show(button);
1360
1361         buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(image_overlay_template_view));
1362         if (options->image_overlay.common.template_string) gtk_text_buffer_set_text(buffer, options->image_overlay.common.template_string, -1);
1363         g_signal_connect(G_OBJECT(buffer), "changed",
1364                          G_CALLBACK(image_overlay_template_view_changed_cb), image_overlay_template_view);
1365
1366         group = pref_group_new(vbox, FALSE, _("Delete"), GTK_ORIENTATION_VERTICAL);
1367
1368         pref_checkbox_new_int(group, _("Confirm file delete"),
1369                               options->file_ops.confirm_delete, &c_options->file_ops.confirm_delete);
1370         pref_checkbox_new_int(group, _("Enable Delete key"),
1371                               options->file_ops.enable_delete_key, &c_options->file_ops.enable_delete_key);
1372
1373         ct_button = pref_checkbox_new_int(group, _("Safe delete"),
1374                                           options->file_ops.safe_delete_enable, &c_options->file_ops.safe_delete_enable);
1375
1376         hbox = pref_box_new(group, FALSE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_SPACE);
1377         pref_checkbox_link_sensitivity(ct_button, hbox);
1378
1379         pref_spacer(hbox, PREF_PAD_INDENT - PREF_PAD_SPACE);
1380         pref_label_new(hbox, _("Folder:"));
1381
1382         tabcomp = tab_completion_new(&safe_delete_path_entry, options->file_ops.safe_delete_path, NULL, NULL);
1383         tab_completion_add_select_button(safe_delete_path_entry, NULL, TRUE);
1384         gtk_box_pack_start(GTK_BOX(hbox), tabcomp, TRUE, TRUE, 0);
1385         gtk_widget_show(tabcomp);
1386
1387         hbox = pref_box_new(group, FALSE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_BUTTON_GAP);
1388         pref_checkbox_link_sensitivity(ct_button, hbox);
1389
1390         pref_spacer(hbox, PREF_PAD_INDENT - PREF_PAD_GAP);
1391         spin = pref_spin_new_int(hbox, _("Maximum size:"), _("MB"),
1392                                  0, 2048, 1, options->file_ops.safe_delete_folder_maxsize, &c_options->file_ops.safe_delete_folder_maxsize);
1393 #if GTK_CHECK_VERSION(2,12,0)
1394         gtk_widget_set_tooltip_markup(spin, _("Set to 0 for unlimited size"));
1395 #endif
1396         button = pref_button_new(NULL, NULL, _("View"), FALSE,
1397                                  G_CALLBACK(safe_delete_view_cb), NULL);
1398         gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0);
1399         gtk_widget_show(button);
1400
1401         button = pref_button_new(NULL, GTK_STOCK_CLEAR, NULL, FALSE,
1402                                  G_CALLBACK(safe_delete_clear_cb), NULL);
1403         gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0);
1404         gtk_widget_show(button);
1405
1406
1407         group = pref_group_new(vbox, FALSE, _("Behavior"), GTK_ORIENTATION_VERTICAL);
1408
1409         pref_checkbox_new_int(group, _("Rectangular selection in icon view"),
1410                               options->collections.rectangular_selection, &c_options->collections.rectangular_selection);
1411
1412         pref_checkbox_new_int(group, _("Descend folders in tree view"),
1413                               options->tree_descend_subdirs, &c_options->tree_descend_subdirs);
1414
1415         pref_checkbox_new_int(group, _("In place renaming"),
1416                               options->file_ops.enable_in_place_rename, &c_options->file_ops.enable_in_place_rename);
1417
1418         pref_checkbox_new_int(group, _("Show \"Copy path\" menu item which write the path of selected files to clipboard"),
1419                               options->show_copy_path, &c_options->show_copy_path);
1420
1421         pref_spin_new_int(group, _("Open recent list maximum size"), NULL,
1422                           1, 50, 1, options->open_recent_list_maxsize, &c_options->open_recent_list_maxsize);
1423         
1424         pref_spin_new_int(group, _("Drag'n drop icon size"), NULL,
1425                           16, 256, 16, options->dnd_icon_size, &c_options->dnd_icon_size);
1426
1427         group = pref_group_new(vbox, FALSE, _("Navigation"), GTK_ORIENTATION_VERTICAL);
1428
1429         pref_checkbox_new_int(group, _("Progressive keyboard scrolling"),
1430                               options->progressive_key_scrolling, &c_options->progressive_key_scrolling);
1431         pref_checkbox_new_int(group, _("Mouse wheel scrolls image"),
1432                               options->mousewheel_scrolls, &c_options->mousewheel_scrolls);
1433
1434         group = pref_group_new(vbox, FALSE, _("Miscellaneous"), GTK_ORIENTATION_VERTICAL);
1435
1436         pref_checkbox_new_int(group, _("Store keywords and comments local to source images"),
1437                               options->enable_metadata_dirs, &c_options->enable_metadata_dirs);
1438
1439         pref_spin_new_int(group, _("Custom similarity threshold:"), NULL,
1440                           0, 100, 1, options->duplicates_similarity_threshold, &c_options->duplicates_similarity_threshold);
1441
1442         group = pref_group_new(vbox, FALSE, _("Image loading and caching"), GTK_ORIENTATION_VERTICAL);
1443
1444         pref_spin_new_int(group, _("Offscreen cache size (Mb per image):"), NULL,
1445                           0, 128, 1, options->image.tile_cache_max, &c_options->image.tile_cache_max);
1446
1447         pref_spin_new_int(group, _("Image read buffer size (bytes):"), NULL,
1448                           IMAGE_LOADER_READ_BUFFER_SIZE_MIN, IMAGE_LOADER_READ_BUFFER_SIZE_MAX, 512,
1449                           options->image.read_buffer_size, &c_options->image.read_buffer_size);
1450
1451         pref_spin_new_int(group, _("Image idle loop read count:"), NULL,
1452                           IMAGE_LOADER_IDLE_READ_LOOP_COUNT_MIN, IMAGE_LOADER_IDLE_READ_LOOP_COUNT_MAX, 1,
1453                           options->image.idle_read_loop_count, &c_options->image.idle_read_loop_count);
1454
1455
1456         group =  pref_group_new(vbox, FALSE, _("Color profiles"), GTK_ORIENTATION_VERTICAL);
1457 #ifndef HAVE_LCMS
1458         gtk_widget_set_sensitive(pref_group_parent(group), FALSE);
1459 #endif
1460
1461         table = pref_table_new(group, 3, COLOR_PROFILE_INPUTS + 2, FALSE, FALSE);
1462         gtk_table_set_col_spacings(GTK_TABLE(table), PREF_PAD_GAP);
1463
1464         label = pref_table_label(table, 0, 0, _("Type"), 0.0);
1465         pref_label_bold(label, TRUE, FALSE);
1466
1467         label = pref_table_label(table, 1, 0, _("Menu name"), 0.0);
1468         pref_label_bold(label, TRUE, FALSE);
1469
1470         label = pref_table_label(table, 2, 0, _("File"), 0.0);
1471         pref_label_bold(label, TRUE, FALSE);
1472
1473         for (i = 0; i < COLOR_PROFILE_INPUTS; i++)
1474                 {
1475                 GtkWidget *entry;
1476                 gchar *buf;
1477
1478                 buf = g_strdup_printf("Input %d:", i + COLOR_PROFILE_FILE);
1479                 pref_table_label(table, 0, i + 1, buf, 1.0);
1480                 g_free(buf);
1481
1482                 entry = gtk_entry_new();
1483                 gtk_entry_set_max_length(GTK_ENTRY(entry), EDITOR_NAME_MAX_LENGTH);
1484                 gtk_widget_set_size_request(editor_name_entry[i], 30, -1);
1485                 if (options->color_profile.input_name[i])
1486                         {
1487                         gtk_entry_set_text(GTK_ENTRY(entry), options->color_profile.input_name[i]);
1488                         }
1489                 gtk_table_attach(GTK_TABLE(table), entry, 1, 2, i + 1, i + 2,
1490                                  GTK_FILL | GTK_EXPAND, 0, 0, 0);
1491                 gtk_widget_show(entry);
1492                 color_profile_input_name_entry[i] = entry;
1493
1494                 tabcomp = tab_completion_new(&entry, options->color_profile.input_file[i], NULL, NULL);
1495                 tab_completion_add_select_button(entry, _("Select color profile"), FALSE);
1496                 gtk_widget_set_size_request(entry, 160, -1);
1497                 gtk_table_attach(GTK_TABLE(table), tabcomp, 2, 3, i + 1, i + 2,
1498                                  GTK_FILL | GTK_EXPAND, 0, 0, 0);
1499                 gtk_widget_show(tabcomp);
1500                 color_profile_input_file_entry[i] = entry;
1501                 }
1502
1503         pref_table_label(table, 0, COLOR_PROFILE_INPUTS + 1, _("Screen:"), 1.0);
1504         tabcomp = tab_completion_new(&color_profile_screen_file_entry,
1505                                      options->color_profile.screen_file, NULL, NULL);
1506         tab_completion_add_select_button(color_profile_screen_file_entry, _("Select color profile"), FALSE);
1507         gtk_widget_set_size_request(color_profile_screen_file_entry, 160, -1);
1508         gtk_table_attach(GTK_TABLE(table), tabcomp, 2, 3,
1509                          COLOR_PROFILE_INPUTS + 1, COLOR_PROFILE_INPUTS + 2,
1510                          GTK_FILL | GTK_EXPAND, 0, 0, 0);
1511         gtk_widget_show(tabcomp);
1512
1513 #ifdef DEBUG
1514         group = pref_group_new(vbox, FALSE, _("Debugging"), GTK_ORIENTATION_VERTICAL);
1515
1516         pref_spin_new_int(group, _("Debug level:"), NULL,
1517                           DEBUG_LEVEL_MIN, DEBUG_LEVEL_MAX, 1, get_debug_level(), &debug_c);
1518 #endif
1519 }
1520
1521 /* Main preferences window */
1522 static void config_window_create(void)
1523 {
1524         GtkWidget *win_vbox;
1525         GtkWidget *hbox;
1526         GtkWidget *notebook;
1527         GtkWidget *button;
1528         GtkWidget *ct_button;
1529
1530         if (!c_options) c_options = init_options(NULL);
1531
1532         configwindow = window_new(GTK_WINDOW_TOPLEVEL, "preferences", PIXBUF_INLINE_ICON_CONFIG, NULL, _("Preferences"));
1533         gtk_window_set_type_hint(GTK_WINDOW(configwindow), GDK_WINDOW_TYPE_HINT_DIALOG);
1534         g_signal_connect(G_OBJECT(configwindow), "delete_event",
1535                          G_CALLBACK(config_window_delete), NULL);
1536         gtk_window_set_default_size(GTK_WINDOW(configwindow), CONFIG_WINDOW_DEF_WIDTH, CONFIG_WINDOW_DEF_HEIGHT);
1537         gtk_window_set_resizable(GTK_WINDOW(configwindow), TRUE);
1538         gtk_container_set_border_width(GTK_CONTAINER(configwindow), PREF_PAD_BORDER);
1539
1540         win_vbox = gtk_vbox_new(FALSE, PREF_PAD_SPACE);
1541         gtk_container_add(GTK_CONTAINER(configwindow), win_vbox);
1542         gtk_widget_show(win_vbox);
1543
1544         hbox = gtk_hbutton_box_new();
1545         gtk_button_box_set_layout(GTK_BUTTON_BOX(hbox), GTK_BUTTONBOX_END);
1546         gtk_box_set_spacing(GTK_BOX(hbox), PREF_PAD_BUTTON_GAP);
1547         gtk_box_pack_end(GTK_BOX(win_vbox), hbox, FALSE, FALSE, 0);
1548         gtk_widget_show(hbox);
1549
1550         button = pref_button_new(NULL, GTK_STOCK_OK, NULL, FALSE,
1551                                  G_CALLBACK(config_window_ok_cb), NULL);
1552         gtk_container_add(GTK_CONTAINER(hbox), button);
1553         GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
1554         gtk_widget_grab_default(button);
1555         gtk_widget_show(button);
1556
1557         ct_button = button;
1558
1559         button = pref_button_new(NULL, GTK_STOCK_APPLY, NULL, FALSE,
1560                                  G_CALLBACK(config_window_apply_cb), NULL);
1561         gtk_container_add(GTK_CONTAINER(hbox), button);
1562         GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
1563         gtk_widget_show(button);
1564
1565         button = pref_button_new(NULL, GTK_STOCK_CANCEL, NULL, FALSE,
1566                                  G_CALLBACK(config_window_close_cb), NULL);
1567         gtk_container_add(GTK_CONTAINER(hbox), button);
1568         GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
1569         gtk_widget_show(button);
1570
1571         if (!generic_dialog_get_alternative_button_order(configwindow))
1572                 {
1573                 gtk_box_reorder_child(GTK_BOX(hbox), ct_button, -1);
1574                 }
1575
1576         notebook = gtk_notebook_new();
1577         gtk_notebook_set_tab_pos(GTK_NOTEBOOK(notebook), GTK_POS_TOP);
1578         gtk_box_pack_start(GTK_BOX(win_vbox), notebook, TRUE, TRUE, 0);
1579
1580         config_tab_general(notebook);
1581         config_tab_image(notebook);
1582         config_tab_windows(notebook);
1583         config_tab_filtering(notebook);
1584         config_tab_editors(notebook);
1585         config_tab_properties(notebook);
1586         config_tab_advanced(notebook);
1587
1588         gtk_widget_show(notebook);
1589
1590         gtk_widget_show(configwindow);
1591 }
1592
1593 /*
1594  *-----------------------------------------------------------------------------
1595  * config window show (public)
1596  *-----------------------------------------------------------------------------
1597  */
1598
1599 void show_config_window(void)
1600 {
1601         if (configwindow)
1602                 {
1603                 gtk_window_present(GTK_WINDOW(configwindow));
1604                 return;
1605                 }
1606
1607         config_window_create();
1608 }
1609
1610 /*
1611  *-----------------
1612  * about window
1613  *-----------------
1614  */
1615
1616 static GtkWidget *about = NULL;
1617
1618 static gint about_delete_cb(GtkWidget *widget, GdkEventAny *event, gpointer data)
1619 {
1620         gtk_widget_destroy(about);
1621         about = NULL;
1622
1623         return TRUE;
1624 }
1625
1626 static void about_window_close(GtkWidget *widget, gpointer data)
1627 {
1628         if (!about) return;
1629
1630         gtk_widget_destroy(about);
1631         about = NULL;
1632 }
1633
1634 static void about_credits_cb(GtkWidget *widget, gpointer data)
1635 {
1636         help_window_show("credits");
1637 }
1638
1639 void show_about_window(void)
1640 {
1641         GtkWidget *vbox;
1642         GtkWidget *hbox;
1643         GtkWidget *label;
1644         GtkWidget *button;
1645         GdkPixbuf *pixbuf;
1646
1647         gchar *buf;
1648
1649         if (about)
1650                 {
1651                 gtk_window_present(GTK_WINDOW(about));
1652                 return;
1653                 }
1654
1655         about = window_new(GTK_WINDOW_TOPLEVEL, "about", NULL, NULL, _("About"));
1656         gtk_window_set_type_hint(GTK_WINDOW(about), GDK_WINDOW_TYPE_HINT_DIALOG);
1657         g_signal_connect(G_OBJECT(about), "delete_event",
1658                          G_CALLBACK(about_delete_cb), NULL);
1659
1660         gtk_container_set_border_width(GTK_CONTAINER(about), PREF_PAD_BORDER);
1661
1662         vbox = gtk_vbox_new(FALSE, PREF_PAD_SPACE);
1663         gtk_container_add(GTK_CONTAINER(about), vbox);
1664         gtk_widget_show(vbox);
1665
1666         pixbuf = pixbuf_inline(PIXBUF_INLINE_LOGO);
1667         button = gtk_image_new_from_pixbuf(pixbuf);
1668         g_object_unref(pixbuf);
1669         gtk_box_pack_start(GTK_BOX(vbox), button, TRUE, TRUE, 0);
1670         gtk_widget_show(button);
1671
1672         buf = g_strdup_printf(_("%s %s\n\nCopyright (c) 2006 John Ellis\nCopyright (c) %s The Geeqie Team\nwebsite: %s\nemail: %s\n\nReleased under the GNU General Public License"),
1673                               GQ_APPNAME,
1674                               VERSION,
1675                               "2008",
1676                               GQ_WEBSITE,
1677                               GQ_EMAIL_ADDRESS);
1678         label = gtk_label_new(buf);
1679         g_free(buf);
1680
1681         gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_CENTER);
1682         gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, TRUE, 0);
1683         gtk_widget_show(label);
1684
1685         hbox = gtk_hbutton_box_new();
1686         gtk_button_box_set_layout(GTK_BUTTON_BOX(hbox), GTK_BUTTONBOX_END);
1687         gtk_box_set_spacing(GTK_BOX(hbox), PREF_PAD_BUTTON_GAP);
1688         gtk_box_pack_end(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1689         gtk_widget_show(hbox);
1690
1691         button = pref_button_new(NULL, NULL, _("Credits..."), FALSE,
1692                                  G_CALLBACK(about_credits_cb), NULL);
1693         gtk_container_add(GTK_CONTAINER(hbox), button);
1694         GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
1695         gtk_widget_show(button);
1696
1697         button = pref_button_new(NULL, GTK_STOCK_CLOSE, NULL, FALSE,
1698                                  G_CALLBACK(about_window_close), NULL);
1699         gtk_container_add(GTK_CONTAINER(hbox), button);
1700         GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
1701         gtk_widget_grab_default(button);
1702         gtk_widget_show(button);
1703
1704         gtk_widget_show(about);
1705 }