Mercurial > geeqie
annotate src/options.c @ 1367:fe4da037be21
When g_new0() is used, drop redundant initializations to NULL, FALSE or 0, second pass.
| author | zas_ |
|---|---|
| date | Sun, 01 Mar 2009 23:14:19 +0000 |
| parents | 77c3d9dcd6bc |
| children | df58e511d90e |
| rev | line source |
|---|---|
| 508 | 1 /* |
| 2 * Geeqie | |
| 1284 | 3 * Copyright (C) 2008 - 2009 The Geeqie Team |
| 508 | 4 * |
| 5 * Authors: Vladimir Nadvornik, Laurent Monin | |
| 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 #include "main.h" | |
| 13 #include "options.h" | |
| 14 | |
|
740
9b0ac8d58c89
Move setup_default_options() and sync_options_with_current_state() to options.[ch].
zas_
parents:
638
diff
changeset
|
15 #include "bar_exif.h" |
|
9b0ac8d58c89
Move setup_default_options() and sync_options_with_current_state() to options.[ch].
zas_
parents:
638
diff
changeset
|
16 #include "editors.h" |
|
9b0ac8d58c89
Move setup_default_options() and sync_options_with_current_state() to options.[ch].
zas_
parents:
638
diff
changeset
|
17 #include "filefilter.h" |
| 612 | 18 #include "histogram.h" /* HCHAN_RGB */ |
|
619
2ccc7d856d55
Initialize to correct value (OSD_SHOW_NOTHING instead of FALSE).
zas_
parents:
612
diff
changeset
|
19 #include "image-overlay.h" /* OSD_SHOW_NOTHING */ |
|
740
9b0ac8d58c89
Move setup_default_options() and sync_options_with_current_state() to options.[ch].
zas_
parents:
638
diff
changeset
|
20 #include "layout.h" |
|
9b0ac8d58c89
Move setup_default_options() and sync_options_with_current_state() to options.[ch].
zas_
parents:
638
diff
changeset
|
21 #include "layout_image.h" |
| 1019 | 22 #include "rcfile.h" |
|
740
9b0ac8d58c89
Move setup_default_options() and sync_options_with_current_state() to options.[ch].
zas_
parents:
638
diff
changeset
|
23 #include "ui_bookmark.h" |
|
9b0ac8d58c89
Move setup_default_options() and sync_options_with_current_state() to options.[ch].
zas_
parents:
638
diff
changeset
|
24 #include "ui_fileops.h" |
|
9b0ac8d58c89
Move setup_default_options() and sync_options_with_current_state() to options.[ch].
zas_
parents:
638
diff
changeset
|
25 #include "window.h" |
| 612 | 26 |
| 508 | 27 ConfOptions *init_options(ConfOptions *options) |
| 28 { | |
| 29 if (!options) options = g_new0(ConfOptions, 1); | |
| 30 | |
| 31 options->collections.rectangular_selection = FALSE; | |
| 32 | |
| 1034 | 33 options->color_profile.enabled = TRUE; |
| 508 | 34 options->color_profile.input_type = 0; |
| 35 options->color_profile.screen_file = NULL; | |
| 36 options->color_profile.screen_type = 0; | |
| 37 options->color_profile.use_image = TRUE; | |
| 38 | |
| 39 options->dnd_icon_size = 48; | |
| 40 options->duplicates_similarity_threshold = 99; | |
|
594
4cfce4ed35e0
Use a dedicated option to enable keywords and comment saving as XMP tags
zas_
parents:
556
diff
changeset
|
41 |
| 508 | 42 options->file_filter.disable = FALSE; |
| 43 options->file_filter.show_dot_directory = FALSE; | |
| 44 options->file_filter.show_hidden_files = FALSE; | |
| 45 | |
| 46 options->file_ops.confirm_delete = TRUE; | |
| 47 options->file_ops.enable_delete_key = TRUE; | |
| 48 options->file_ops.enable_in_place_rename = TRUE; | |
| 49 options->file_ops.safe_delete_enable = FALSE; | |
| 50 options->file_ops.safe_delete_folder_maxsize = 128; | |
| 51 options->file_ops.safe_delete_path = NULL; | |
| 52 | |
| 53 options->file_sort.ascending = TRUE; | |
| 54 options->file_sort.case_sensitive = FALSE; | |
| 55 options->file_sort.method = SORT_NAME; | |
| 56 | |
| 57 options->fullscreen.above = FALSE; | |
| 58 options->fullscreen.clean_flip = FALSE; | |
| 59 options->fullscreen.disable_saver = TRUE; | |
| 60 options->fullscreen.screen = -1; | |
| 61 | |
| 62 memset(&options->image.border_color, 0, sizeof(options->image.border_color)); | |
|
870
3dd2cb78d0f9
Make better matching between options types in options.h and the rest of the code.
zas_
parents:
848
diff
changeset
|
63 options->image.dither_quality = GDK_RGB_DITHER_NORMAL; |
| 508 | 64 options->image.enable_read_ahead = TRUE; |
| 65 options->image.exif_rotate_enable = TRUE; | |
| 66 options->image.fit_window_to_image = FALSE; | |
| 67 options->image.idle_read_loop_count = IMAGE_LOADER_IDLE_READ_LOOP_COUNT_DEFAULT; | |
| 68 options->image.limit_autofit_size = FALSE; | |
| 1034 | 69 options->image.limit_window_size = TRUE; |
| 508 | 70 options->image.max_autofit_size = 100; |
| 1034 | 71 options->image.max_window_size = 90; |
| 508 | 72 options->image.read_buffer_size = IMAGE_LOADER_READ_BUFFER_SIZE_DEFAULT; |
|
1037
86148ec8a299
fixed various problems with preserving viewport on image change,
nadvornik
parents:
1034
diff
changeset
|
73 options->image.scroll_reset_method = SCROLL_RESET_NOCHANGE; |
| 508 | 74 options->image.tile_cache_max = 10; |
| 848 | 75 options->image.image_cache_max = 128; /* 4 x 10MPix */ |
| 508 | 76 options->image.use_custom_border_color = FALSE; |
| 77 options->image.zoom_2pass = TRUE; | |
| 78 options->image.zoom_increment = 5; | |
| 1034 | 79 options->image.zoom_mode = ZOOM_RESET_NONE; |
|
870
3dd2cb78d0f9
Make better matching between options types in options.h and the rest of the code.
zas_
parents:
848
diff
changeset
|
80 options->image.zoom_quality = GDK_INTERP_BILINEAR; |
| 1034 | 81 options->image.zoom_to_fit_allow_expand = FALSE; |
| 508 | 82 |
| 1336 | 83 options->image_overlay.template_string = NULL; |
| 84 options->image_overlay.x = 10; | |
| 85 options->image_overlay.y = -10; | |
| 508 | 86 |
| 87 options->layout.dir_view_type = DIRVIEW_LIST; | |
|
556
fe675761d091
Replace Layout icon_view field by more generic file_view_type.
zas_
parents:
508
diff
changeset
|
88 options->layout.file_view_type = FILEVIEW_LIST; |
| 508 | 89 options->layout.float_window.h = 450; |
| 90 options->layout.float_window.vdivider_pos = -1; | |
| 91 options->layout.float_window.w = 260; | |
| 92 options->layout.float_window.x = 0; | |
| 93 options->layout.float_window.y = 0; | |
|
980
a4a38ea9fbaa
Add an option named layout.home_path which modifies the behavior of the Home button.
zas_
parents:
870
diff
changeset
|
94 options->layout.home_path = NULL; |
| 1034 | 95 options->layout.main_window.h = 540; |
| 508 | 96 options->layout.main_window.hdivider_pos = -1; |
| 97 options->layout.main_window.maximized = FALSE; | |
| 98 options->layout.main_window.vdivider_pos = 200; | |
| 1034 | 99 options->layout.main_window.w = 720; |
| 508 | 100 options->layout.main_window.x = 0; |
| 101 options->layout.main_window.y = 0; | |
| 102 options->layout.order = NULL; | |
| 1034 | 103 options->layout.save_window_positions = TRUE; |
| 825 | 104 options->layout.show_directory_date = FALSE; |
| 508 | 105 options->layout.show_marks = FALSE; |
| 106 options->layout.show_thumbnails = FALSE; | |
| 107 options->layout.style = 0; | |
| 108 options->layout.toolbar_hidden = FALSE; | |
| 109 options->layout.tools_float = FALSE; | |
| 110 options->layout.tools_hidden = FALSE; | |
| 1034 | 111 options->layout.tools_restore_state = TRUE; |
| 1336 | 112 options->layout.image_overlay.histogram_channel = HCHAN_RGB; |
| 113 options->layout.image_overlay.histogram_mode = 1; | |
| 114 options->layout.image_overlay.state = OSD_SHOW_NOTHING; | |
| 115 | |
| 508 | 116 options->lazy_image_sync = FALSE; |
| 117 options->mousewheel_scrolls = FALSE; | |
| 118 options->open_recent_list_maxsize = 10; | |
| 119 options->place_dialogs_under_mouse = FALSE; | |
| 120 | |
| 1034 | 121 options->progressive_key_scrolling = TRUE; |
|
594
4cfce4ed35e0
Use a dedicated option to enable keywords and comment saving as XMP tags
zas_
parents:
556
diff
changeset
|
122 |
| 1208 | 123 options->metadata.enable_metadata_dirs = FALSE; |
| 124 options->metadata.save_in_image_file = FALSE; | |
| 125 options->metadata.save_legacy_IPTC = FALSE; | |
| 126 options->metadata.warn_on_write_problems = TRUE; | |
| 127 options->metadata.save_legacy_format = FALSE; | |
| 128 options->metadata.sync_grouped_files = TRUE; | |
| 129 options->metadata.confirm_write = TRUE; | |
| 1244 | 130 options->metadata.confirm_after_timeout = FALSE; |
| 131 options->metadata.confirm_timeout = 10; | |
| 1208 | 132 options->metadata.confirm_on_image_change = FALSE; |
| 133 options->metadata.confirm_on_dir_change = TRUE; | |
|
594
4cfce4ed35e0
Use a dedicated option to enable keywords and comment saving as XMP tags
zas_
parents:
556
diff
changeset
|
134 |
| 1034 | 135 options->show_copy_path = TRUE; |
| 508 | 136 options->show_icon_names = TRUE; |
| 137 | |
| 1034 | 138 options->slideshow.delay = 50; |
| 508 | 139 options->slideshow.random = FALSE; |
| 140 options->slideshow.repeat = FALSE; | |
| 141 | |
|
630
83d3ded39e49
An option to save and restore the last path used was added.
zas_
parents:
629
diff
changeset
|
142 options->startup.path = NULL; |
| 629 | 143 options->startup.restore_path = FALSE; |
|
630
83d3ded39e49
An option to save and restore the last path used was added.
zas_
parents:
629
diff
changeset
|
144 options->startup.use_last_path = FALSE; |
| 508 | 145 |
| 146 options->thumbnails.cache_into_dirs = FALSE; | |
| 147 options->thumbnails.enable_caching = TRUE; | |
| 148 options->thumbnails.fast = TRUE; | |
| 149 options->thumbnails.max_height = DEFAULT_THUMB_HEIGHT; | |
| 150 options->thumbnails.max_width = DEFAULT_THUMB_WIDTH; | |
|
870
3dd2cb78d0f9
Make better matching between options types in options.h and the rest of the code.
zas_
parents:
848
diff
changeset
|
151 options->thumbnails.quality = GDK_INTERP_TILES; |
| 508 | 152 options->thumbnails.spec_standard = TRUE; |
| 153 options->thumbnails.use_xvpics = TRUE; | |
| 1060 | 154 options->thumbnails.use_exif = FALSE; |
| 508 | 155 |
| 156 options->tree_descend_subdirs = FALSE; | |
| 157 options->update_on_time_change = TRUE; | |
| 158 | |
| 159 return options; | |
| 160 } | |
|
740
9b0ac8d58c89
Move setup_default_options() and sync_options_with_current_state() to options.[ch].
zas_
parents:
638
diff
changeset
|
161 |
|
9b0ac8d58c89
Move setup_default_options() and sync_options_with_current_state() to options.[ch].
zas_
parents:
638
diff
changeset
|
162 void setup_default_options(ConfOptions *options) |
|
9b0ac8d58c89
Move setup_default_options() and sync_options_with_current_state() to options.[ch].
zas_
parents:
638
diff
changeset
|
163 { |
|
9b0ac8d58c89
Move setup_default_options() and sync_options_with_current_state() to options.[ch].
zas_
parents:
638
diff
changeset
|
164 gchar *path; |
|
9b0ac8d58c89
Move setup_default_options() and sync_options_with_current_state() to options.[ch].
zas_
parents:
638
diff
changeset
|
165 gint i; |
|
9b0ac8d58c89
Move setup_default_options() and sync_options_with_current_state() to options.[ch].
zas_
parents:
638
diff
changeset
|
166 |
|
9b0ac8d58c89
Move setup_default_options() and sync_options_with_current_state() to options.[ch].
zas_
parents:
638
diff
changeset
|
167 bookmark_add_default(_("Home"), homedir()); |
|
9b0ac8d58c89
Move setup_default_options() and sync_options_with_current_state() to options.[ch].
zas_
parents:
638
diff
changeset
|
168 path = g_build_filename(homedir(), "Desktop", NULL); |
|
9b0ac8d58c89
Move setup_default_options() and sync_options_with_current_state() to options.[ch].
zas_
parents:
638
diff
changeset
|
169 bookmark_add_default(_("Desktop"), path); |
|
9b0ac8d58c89
Move setup_default_options() and sync_options_with_current_state() to options.[ch].
zas_
parents:
638
diff
changeset
|
170 g_free(path); |
|
1145
3a7af6a8cd5f
Use functions to return directories instead of constants.
zas_
parents:
1060
diff
changeset
|
171 bookmark_add_default(_("Collections"), get_collections_dir()); |
|
740
9b0ac8d58c89
Move setup_default_options() and sync_options_with_current_state() to options.[ch].
zas_
parents:
638
diff
changeset
|
172 |
|
9b0ac8d58c89
Move setup_default_options() and sync_options_with_current_state() to options.[ch].
zas_
parents:
638
diff
changeset
|
173 g_free(options->file_ops.safe_delete_path); |
|
1145
3a7af6a8cd5f
Use functions to return directories instead of constants.
zas_
parents:
1060
diff
changeset
|
174 options->file_ops.safe_delete_path = g_strdup(get_trash_dir()); |
|
740
9b0ac8d58c89
Move setup_default_options() and sync_options_with_current_state() to options.[ch].
zas_
parents:
638
diff
changeset
|
175 |
|
9b0ac8d58c89
Move setup_default_options() and sync_options_with_current_state() to options.[ch].
zas_
parents:
638
diff
changeset
|
176 for (i = 0; i < COLOR_PROFILE_INPUTS; i++) |
|
9b0ac8d58c89
Move setup_default_options() and sync_options_with_current_state() to options.[ch].
zas_
parents:
638
diff
changeset
|
177 { |
|
9b0ac8d58c89
Move setup_default_options() and sync_options_with_current_state() to options.[ch].
zas_
parents:
638
diff
changeset
|
178 options->color_profile.input_file[i] = NULL; |
|
9b0ac8d58c89
Move setup_default_options() and sync_options_with_current_state() to options.[ch].
zas_
parents:
638
diff
changeset
|
179 options->color_profile.input_name[i] = NULL; |
|
9b0ac8d58c89
Move setup_default_options() and sync_options_with_current_state() to options.[ch].
zas_
parents:
638
diff
changeset
|
180 } |
|
9b0ac8d58c89
Move setup_default_options() and sync_options_with_current_state() to options.[ch].
zas_
parents:
638
diff
changeset
|
181 |
| 1336 | 182 set_default_image_overlay_template_string(&options->image_overlay.template_string); |
|
1229
878718372aca
sidecar files grouping was made case-insensitive
nadvornik
parents:
1208
diff
changeset
|
183 options->sidecar.ext = g_strdup(".jpg;%raw;.xmp"); |
|
740
9b0ac8d58c89
Move setup_default_options() and sync_options_with_current_state() to options.[ch].
zas_
parents:
638
diff
changeset
|
184 options->layout.order = g_strdup("123"); |
|
9b0ac8d58c89
Move setup_default_options() and sync_options_with_current_state() to options.[ch].
zas_
parents:
638
diff
changeset
|
185 |
|
9b0ac8d58c89
Move setup_default_options() and sync_options_with_current_state() to options.[ch].
zas_
parents:
638
diff
changeset
|
186 options->shell.path = g_strdup(GQ_DEFAULT_SHELL_PATH); |
|
9b0ac8d58c89
Move setup_default_options() and sync_options_with_current_state() to options.[ch].
zas_
parents:
638
diff
changeset
|
187 options->shell.options = g_strdup(GQ_DEFAULT_SHELL_OPTIONS); |
| 1353 | 188 |
| 189 #if 0 | |
|
740
9b0ac8d58c89
Move setup_default_options() and sync_options_with_current_state() to options.[ch].
zas_
parents:
638
diff
changeset
|
190 for (i = 0; ExifUIList[i].key; i++) |
|
9b0ac8d58c89
Move setup_default_options() and sync_options_with_current_state() to options.[ch].
zas_
parents:
638
diff
changeset
|
191 ExifUIList[i].current = ExifUIList[i].default_value; |
| 1353 | 192 #endif |
|
740
9b0ac8d58c89
Move setup_default_options() and sync_options_with_current_state() to options.[ch].
zas_
parents:
638
diff
changeset
|
193 } |
|
9b0ac8d58c89
Move setup_default_options() and sync_options_with_current_state() to options.[ch].
zas_
parents:
638
diff
changeset
|
194 |
| 1309 | 195 void copy_layout_options(LayoutOptions *dest, const LayoutOptions *src) |
| 196 { | |
| 197 free_layout_options_content(dest); | |
| 198 | |
| 199 *dest = *src; | |
| 200 dest->order = g_strdup(src->order); | |
| 201 dest->home_path = g_strdup(src->home_path); | |
| 202 } | |
| 203 | |
| 204 void free_layout_options_content(LayoutOptions *dest) | |
| 205 { | |
| 206 if (dest->order) g_free(dest->order); | |
| 207 if (dest->home_path) g_free(dest->home_path); | |
| 208 } | |
| 209 | |
| 1019 | 210 static void sync_options_with_current_state(ConfOptions *options) |
|
740
9b0ac8d58c89
Move setup_default_options() and sync_options_with_current_state() to options.[ch].
zas_
parents:
638
diff
changeset
|
211 { |
|
9b0ac8d58c89
Move setup_default_options() and sync_options_with_current_state() to options.[ch].
zas_
parents:
638
diff
changeset
|
212 LayoutWindow *lw = NULL; |
|
9b0ac8d58c89
Move setup_default_options() and sync_options_with_current_state() to options.[ch].
zas_
parents:
638
diff
changeset
|
213 |
|
9b0ac8d58c89
Move setup_default_options() and sync_options_with_current_state() to options.[ch].
zas_
parents:
638
diff
changeset
|
214 if (layout_valid(&lw)) |
|
9b0ac8d58c89
Move setup_default_options() and sync_options_with_current_state() to options.[ch].
zas_
parents:
638
diff
changeset
|
215 { |
| 1309 | 216 layout_sync_options_with_current_state(lw); |
| 217 copy_layout_options(&options->layout, &lw->options); | |
| 218 layout_sort_get(lw, &options->file_sort.method, &options->file_sort.ascending); | |
| 219 | |
| 220 | |
| 221 | |
| 222 options->color_profile.enabled = layout_image_color_profile_get_use(lw); | |
| 223 layout_image_color_profile_get(lw, | |
| 224 &options->color_profile.input_type, | |
| 225 &options->color_profile.screen_type, | |
| 226 &options->color_profile.use_image); | |
| 227 | |
| 228 if (options->startup.restore_path && options->startup.use_last_path) | |
|
740
9b0ac8d58c89
Move setup_default_options() and sync_options_with_current_state() to options.[ch].
zas_
parents:
638
diff
changeset
|
229 { |
| 1309 | 230 g_free(options->startup.path); |
| 231 options->startup.path = g_strdup(layout_get_path(lw)); | |
|
740
9b0ac8d58c89
Move setup_default_options() and sync_options_with_current_state() to options.[ch].
zas_
parents:
638
diff
changeset
|
232 } |
|
9b0ac8d58c89
Move setup_default_options() and sync_options_with_current_state() to options.[ch].
zas_
parents:
638
diff
changeset
|
233 } |
|
9b0ac8d58c89
Move setup_default_options() and sync_options_with_current_state() to options.[ch].
zas_
parents:
638
diff
changeset
|
234 |
|
9b0ac8d58c89
Move setup_default_options() and sync_options_with_current_state() to options.[ch].
zas_
parents:
638
diff
changeset
|
235 } |
| 1019 | 236 |
| 237 void save_options(ConfOptions *options) | |
| 238 { | |
| 239 gchar *rc_path; | |
| 240 | |
| 241 sync_options_with_current_state(options); | |
| 242 | |
|
1145
3a7af6a8cd5f
Use functions to return directories instead of constants.
zas_
parents:
1060
diff
changeset
|
243 rc_path = g_build_filename(get_rc_dir(), RC_FILE_NAME, NULL); |
| 1019 | 244 save_options_to(rc_path, options); |
| 245 g_free(rc_path); | |
| 246 } | |
| 247 | |
| 1313 | 248 gboolean load_options(ConfOptions *options) |
| 1019 | 249 { |
| 250 gboolean success; | |
| 251 gchar *rc_path; | |
| 252 | |
| 253 if (isdir(GQ_SYSTEM_WIDE_DIR)) | |
| 254 { | |
| 255 rc_path = g_build_filename(GQ_SYSTEM_WIDE_DIR, RC_FILE_NAME, NULL); | |
| 1313 | 256 success = load_options_from(rc_path, options, TRUE); |
| 1019 | 257 DEBUG_1("Loading options from %s ... %s", rc_path, success ? "done" : "failed"); |
| 258 g_free(rc_path); | |
| 259 } | |
| 260 | |
|
1145
3a7af6a8cd5f
Use functions to return directories instead of constants.
zas_
parents:
1060
diff
changeset
|
261 rc_path = g_build_filename(get_rc_dir(), RC_FILE_NAME, NULL); |
| 1313 | 262 success = load_options_from(rc_path, options, TRUE); |
| 1019 | 263 DEBUG_1("Loading options from %s ... %s", rc_path, success ? "done" : "failed"); |
| 264 g_free(rc_path); | |
| 1313 | 265 return(success); |
| 1019 | 266 } |
|
1055
1646720364cf
Adding a vim modeline to all files - patch by Klaus Ethgen
nadvornik
parents:
1037
diff
changeset
|
267 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */ |
