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