2 * Copyright (C) 2008, 2016 The Geeqie Team -
4 * Authors: Vladimir Nadvornik, Laurent Monin
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */
24 #include <gdk-pixbuf/gdk-pixbuf.h>
27 #include "histogram.h" /* HCHAN_RGB */
28 #include "image-overlay.h" /* OSD_SHOW_NOTHING */
30 #include "layout-image.h"
32 #include "main-defines.h"
35 #include "ui-bookmark.h"
36 #include "ui-fileops.h"
39 CommandLine *command_line;
41 ConfOptions *init_options(ConfOptions *options)
45 if (!options) options = g_new0(ConfOptions, 1);
47 options->collections.rectangular_selection = FALSE;
49 options->color_profile.enabled = TRUE;
50 options->color_profile.input_type = 0;
51 options->color_profile.screen_file = nullptr;
52 options->color_profile.use_image = TRUE;
53 options->color_profile.use_x11_screen_profile = TRUE;
54 options->color_profile.render_intent = 0;
56 options->dnd_icon_size = 48;
57 options->dnd_default_action = DND_ACTION_ASK;
58 options->duplicates_similarity_threshold = 99;
59 options->rot_invariant_sim = TRUE;
60 options->sort_totals = FALSE;
62 options->file_filter.disable = FALSE;
63 options->file_filter.show_dot_directory = FALSE;
64 options->file_filter.show_hidden_files = FALSE;
65 options->file_filter.show_parent_directory = TRUE;
66 options->file_filter.disable_file_extension_checks = FALSE;
68 options->save_window_positions = TRUE;
69 options->use_saved_window_positions_for_new_windows = FALSE;
70 options->save_window_workspace = FALSE;
71 options->tools_restore_state = TRUE;
72 options->save_dialog_window_positions = FALSE;
73 options->show_window_ids = FALSE;
75 options->file_ops.confirm_delete = TRUE;
76 options->file_ops.confirm_move_to_trash = TRUE;
77 options->file_ops.enable_delete_key = TRUE;
78 options->file_ops.use_system_trash = TRUE;
79 options->file_ops.enable_in_place_rename = TRUE;
80 options->file_ops.safe_delete_enable = TRUE;
81 options->file_ops.safe_delete_folder_maxsize = 128;
82 options->file_ops.safe_delete_path = nullptr;
83 options->file_ops.no_trash = FALSE;
85 options->file_sort.case_sensitive = FALSE;
87 options->fullscreen.above = FALSE;
88 options->fullscreen.clean_flip = FALSE;
89 options->fullscreen.disable_saver = TRUE;
90 options->fullscreen.screen = -1;
92 options->appimage_notifications = TRUE;
93 options->marks_save = TRUE;
94 options->with_rename = FALSE;
95 options->collections_duplicates = FALSE;
96 options->collections_on_top = FALSE;
97 options->hide_window_in_fullscreen = TRUE;
98 options->hide_osd_in_fullscreen = FALSE;
100 memset(&options->image.border_color, 0, sizeof(options->image.border_color));
101 memset(&options->image.alpha_color_1, 0, sizeof(options->image.alpha_color_1));
102 memset(&options->image.alpha_color_2, 0, sizeof(options->image.alpha_color_2));
103 options->image.border_color.red = static_cast<gdouble>(0x009999) / 65535;
104 options->image.border_color.green = static_cast<gdouble>(0x009999) / 65535;
105 options->image.border_color.blue = static_cast<gdouble>(0x009999) / 65535;
106 /* alpha channel checkerboard background (same as gimp) */
107 options->image.alpha_color_1.red = static_cast<gdouble>(0x009999) / 65535;
108 options->image.alpha_color_1.green = static_cast<gdouble>(0x009999) / 65535;
109 options->image.alpha_color_1.blue = static_cast<gdouble>(0x009999) / 65535;
110 options->image.alpha_color_2.red = static_cast<gdouble>(0x006666) / 65535;
111 options->image.alpha_color_2.green = static_cast<gdouble>(0x006666) / 65535;
112 options->image.alpha_color_2.blue = static_cast<gdouble>(0x006666) / 65535;
113 options->image.enable_read_ahead = TRUE;
114 options->image.exif_rotate_enable = TRUE;
115 options->image.fit_window_to_image = FALSE;
116 options->image.limit_autofit_size = FALSE;
117 options->image.limit_window_size = TRUE;
118 options->image.max_autofit_size = 100;
119 options->image.max_enlargement_size = 900;
120 options->image.max_window_size = 90;
121 options->image.scroll_reset_method = SCROLL_RESET_NOCHANGE;
122 options->image.tile_cache_max = 10;
123 options->image.image_cache_max = 128; /* 4 x 10MPix */
124 options->image.use_custom_border_color = FALSE;
125 options->image.use_custom_border_color_in_fullscreen = TRUE;
126 options->image.zoom_2pass = TRUE;
127 options->image.zoom_increment = 5;
128 options->image.zoom_mode = ZOOM_RESET_NONE;
129 options->image.zoom_quality = GDK_INTERP_BILINEAR;
130 options->image.zoom_to_fit_allow_expand = FALSE;
131 options->image.zoom_style = ZOOM_GEOMETRIC;
132 options->image.tile_size = 128;
134 options->image_overlay.template_string = nullptr;
135 options->image_overlay.x = 10;
136 options->image_overlay.y = -10;
137 options->image_overlay.font = g_strdup("Sans 10");
138 options->image_overlay.text_red = 0;
139 options->image_overlay.text_green = 0;
140 options->image_overlay.text_blue = 0;
141 options->image_overlay.text_alpha = 255;
142 options->image_overlay.background_red = 240;
143 options->image_overlay.background_green = 240;
144 options->image_overlay.background_blue = 240;
145 options->image_overlay.background_alpha = 210;
147 options->lazy_image_sync = FALSE;
148 options->mousewheel_scrolls = FALSE;
149 options->image_lm_click_nav = TRUE;
150 options->image_l_click_archive = FALSE;
151 options->image_l_click_video = TRUE;
152 options->image_l_click_video_editor = g_strdup("video-player.desktop");
153 options->open_recent_list_maxsize = 10;
154 options->recent_folder_image_list_maxsize = 10;
155 options->place_dialogs_under_mouse = FALSE;
157 options->progressive_key_scrolling = TRUE;
158 options->keyboard_scroll_step = 1;
160 options->metadata.enable_metadata_dirs = FALSE;
161 options->metadata.save_in_image_file = FALSE;
162 options->metadata.save_legacy_IPTC = FALSE;
163 options->metadata.warn_on_write_problems = TRUE;
164 options->metadata.save_legacy_format = FALSE;
165 options->metadata.sync_grouped_files = TRUE;
166 options->metadata.confirm_write = TRUE;
167 options->metadata.confirm_after_timeout = FALSE;
168 options->metadata.confirm_timeout = 10;
169 options->metadata.confirm_on_image_change = FALSE;
170 options->metadata.confirm_on_dir_change = TRUE;
171 options->metadata.keywords_case_sensitive = FALSE;
172 options->metadata.write_orientation = TRUE;
173 options->metadata.sidecar_extended_name = FALSE;
174 options->metadata.check_spelling = TRUE;
176 options->show_icon_names = TRUE;
177 options->show_star_rating = FALSE;
178 options->show_predefined_keyword_tree = TRUE;
179 options->expand_menu_toolbar = FALSE;
180 options->hamburger_menu = FALSE;
182 options->slideshow.delay = 50;
183 options->slideshow.random = FALSE;
184 options->slideshow.repeat = FALSE;
186 options->thumbnails.cache_into_dirs = FALSE;
187 options->thumbnails.enable_caching = TRUE;
188 options->thumbnails.max_height = DEFAULT_THUMB_HEIGHT;
189 options->thumbnails.max_width = DEFAULT_THUMB_WIDTH;
190 options->thumbnails.quality = GDK_INTERP_TILES;
191 options->thumbnails.spec_standard = TRUE;
192 options->thumbnails.use_xvpics = TRUE;
193 options->thumbnails.use_exif = FALSE;
194 options->thumbnails.use_color_management = FALSE;
195 options->thumbnails.use_ft_metadata = TRUE;
196 options->thumbnails.collection_preview = 20;
198 options->tree_descend_subdirs = FALSE;
199 options->view_dir_list_single_click_enter = TRUE;
200 options->circular_selection_lists = TRUE;
201 options->update_on_time_change = TRUE;
202 options->clipboard_selection = CLIPBOARD_BOTH;
204 options->stereo.fixed_w = 1920;
205 options->stereo.fixed_h = 1080;
206 options->stereo.fixed_x1 = 0;
207 options->stereo.fixed_y1 = 0;
208 options->stereo.fixed_x2 = 0;
209 options->stereo.fixed_y2 = 1125;
211 options->log_window_lines = 1000;
212 options->log_window.line_wrap = FALSE;
213 options->log_window.paused = FALSE;
214 options->log_window.timer_data = FALSE;
215 options->log_window.action = g_strdup("echo");
217 options->read_metadata_in_idle = FALSE;
218 options->star_rating.star = STAR_RATING_STAR;
219 options->star_rating.rejected = STAR_RATING_REJECTED;
221 options->printer.template_string = nullptr;
222 options->printer.image_font = g_strdup("Serif 10");
223 options->printer.page_font = g_strdup("Serif 10");
224 options->printer.page_text = nullptr;
225 options->printer.image_text_position = 1;
226 options->printer.page_text_position = 3;
228 options->threads.duplicates = get_cpu_cores() - 1;
230 options->disabled_plugins = nullptr;
232 options->mouse_button_8 = g_strdup("Back");
233 options->mouse_button_9 = g_strdup("Forward");
235 options->disable_gpu = FALSE;
236 options->override_disable_gpu = FALSE;
238 for (i = 0; i < FILE_FORMAT_CLASSES; i++)
240 options->class_filter[i] = TRUE;
245 void setup_default_options(ConfOptions *options)
250 bookmark_add_default(".", get_current_dir());
251 bookmark_add_default(_("Home"), homedir());
252 path = g_build_filename(homedir(), "Desktop", NULL);
253 bookmark_add_default(_("Desktop"), path);
255 bookmark_add_default(_("Collections"), get_collections_dir());
257 g_free(options->file_ops.safe_delete_path);
258 options->file_ops.safe_delete_path = g_strdup(get_trash_dir());
260 for (i = 0; i < COLOR_PROFILE_INPUTS; i++)
262 options->color_profile.input_file[i] = nullptr;
263 options->color_profile.input_name[i] = nullptr;
266 set_default_image_overlay_template_string(&options->image_overlay.template_string);
267 options->sidecar.ext = g_strdup(".jpg;%raw;.gqv;.xmp;%unknown");
269 options->shell.path = g_strdup(GQ_DEFAULT_SHELL_PATH);
270 options->shell.options = g_strdup(GQ_DEFAULT_SHELL_OPTIONS);
272 for (i = 0; i < FILEDATA_MARKS_SIZE; i++)
274 options->marks_tooltips[i] = g_strdup_printf("%s%d", _("Mark "), i + 1);
277 options->help_search_engine = g_strdup(HELP_SEARCH_ENGINE);
280 void copy_layout_options(LayoutOptions *dest, const LayoutOptions *src)
282 free_layout_options_content(dest);
285 dest->id = g_strdup(src->id);
286 dest->order = g_strdup(src->order);
287 dest->home_path = g_strdup(src->home_path);
288 dest->last_path = g_strdup(src->last_path);
291 void free_layout_options_content(LayoutOptions *dest)
295 g_free(dest->home_path);
296 g_free(dest->last_path);
299 LayoutOptions *init_layout_options(LayoutOptions *options)
301 memset(options, 0, sizeof(LayoutOptions));
303 options->dir_view_type = DIRVIEW_LIST;
304 options->dir_view_list_sort.ascend = TRUE;
305 options->dir_view_list_sort.case_sensitive = TRUE;
306 options->dir_view_list_sort.method = SORT_NAME;
307 options->file_view_list_sort.ascend = TRUE;
308 options->file_view_list_sort.case_sensitive = TRUE;
309 options->file_view_list_sort.method = SORT_NAME;
310 options->file_view_type = FILEVIEW_LIST;
311 options->float_window.h = 450;
312 options->float_window.vdivider_pos = -1;
313 options->float_window.w = 260;
314 options->float_window.x = 0;
315 options->float_window.y = 0;
316 options->home_path = nullptr;
317 options->id = g_strdup("lw1");
318 options->main_window.h = 540;
319 options->main_window.hdivider_pos = -1;
320 options->main_window.maximized = FALSE;
321 options->main_window.vdivider_pos = 200;
322 options->main_window.w = 720;
323 options->main_window.x = 0;
324 options->main_window.y = 0;
325 options->dupe_window.w = 800;
326 options->dupe_window.h = 400;
327 options->dupe_window.x = 100;
328 options->dupe_window.y = 100;
329 options->search_window.w = 700;
330 options->search_window.h = 650;
331 options->search_window.x = 100;
332 options->search_window.y = 100;
333 options->advanced_exif_window.w = 900;
334 options->advanced_exif_window.h = 600;
335 options->advanced_exif_window.x = 0;
336 options->advanced_exif_window.y = 0;
337 options->folder_window.vdivider_pos = 100;
338 options->order = g_strdup("123");
339 options->show_directory_date = FALSE;
340 options->show_marks = FALSE;
341 options->show_file_filter = FALSE;
342 options->show_thumbnails = FALSE;
344 options->show_info_pixel = FALSE;
345 options->selectable_toolbars_hidden = FALSE;
346 options->tools_float = FALSE;
347 options->tools_hidden = FALSE;
348 options->image_overlay.histogram_channel = HCHAN_RGB;
349 options->image_overlay.histogram_mode = 1;
350 options->image_overlay.state = OSD_SHOW_NOTHING;
351 options->animate = TRUE;
352 options->bars_state.hidden = FALSE;
353 options->log_window.width = 520;
354 options->log_window.height = 400;
355 options->preferences_window.w = 700;
356 options->preferences_window.h = 600;
357 options->split_pane_sync = FALSE;
358 options->workspace = -1;
362 static void sync_options_with_current_state(ConfOptions *options)
364 LayoutWindow *lw = nullptr;
366 if (layout_valid(&lw))
368 layout_sync_options_with_current_state(lw);
370 options->color_profile.enabled = layout_image_color_profile_get_use(lw);
371 layout_image_color_profile_get(lw,
372 &options->color_profile.input_type,
373 &options->color_profile.use_image);
378 void save_options(ConfOptions *options)
382 sync_options_with_current_state(options);
384 rc_path = g_build_filename(get_rc_dir(), RC_FILE_NAME, NULL);
385 save_config_to_file(rc_path, options, nullptr);
389 gboolean load_options(ConfOptions *)
394 if (isdir(GQ_SYSTEM_WIDE_DIR))
396 rc_path = g_build_filename(GQ_SYSTEM_WIDE_DIR, RC_FILE_NAME, NULL);
397 success = load_config_from_file(rc_path, TRUE);
398 DEBUG_1("Loading options from %s ... %s", rc_path, success ? "done" : "failed");
402 rc_path = g_build_filename(get_rc_dir(), RC_FILE_NAME, NULL);
403 success = load_config_from_file(rc_path, TRUE);
404 DEBUG_1("Loading options from %s ... %s", rc_path, success ? "done" : "failed");
408 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */