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