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