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