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