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