/*
* Geeqie
* (C) 2006 John Ellis
- * Copyright (C) 2008 - 2009 The Geeqie Team
+ * Copyright (C) 2008 - 2012 The Geeqie Team
*
* Author: John Ellis
*
#include "layout.h"
#include "layout_util.h"
#include "bar.h"
+#include "metadata.h"
+#include "bar_gps.h"
/*
void write_indent(GString *str, gint indent)
{
- g_string_append_printf(str, "%*s", indent * 4, "");
+ g_string_append_printf(str, "\n%*s", indent * 4, "");
}
void write_char_option(GString *str, gint indent, const gchar *label, const gchar *text)
{
- /* this is needed for overlay string, because g_markup_escape_text does not handle \n and such,
+ /* this is needed for overlay string, because g_markup_escape_text does not handle \n and such,
ideas for improvement are welcome
*/
static const unsigned char no_quote_utf[] = {
'"', 0 /* '"' is handled in g_markup_escape_text */
};
- gchar *escval1 = g_strescape(text ? text : "", (gchar *) no_quote_utf);
+ gchar *escval1 = g_strescape(text ? text : "", (gchar *) no_quote_utf);
gchar *escval2 = g_markup_escape_text(escval1, -1);
- write_indent(str, indent);
- g_string_append_printf(str, "%s = \"%s\"\n", label, escval2);
+ g_string_append_printf(str, "%s = \"%s\" ", label, escval2);
g_free(escval2);
g_free(escval1);
}
+/* dummy read for old/obsolete/futur/deprecated/unused options */
+gboolean read_dummy_option(const gchar *option, const gchar *label, const gchar *message)
+{
+ if (g_ascii_strcasecmp(option, label) != 0) return FALSE;
+ log_printf(_("Option %s ignored: %s\n"), option, message);
+ return TRUE;
+}
+
+
gboolean read_char_option(const gchar *option, const gchar *label, const gchar *value, gchar **text)
{
if (g_ascii_strcasecmp(option, label) != 0) return FALSE;
void write_int_option(GString *str, gint indent, const gchar *label, gint n)
{
- write_indent(str, indent);
- g_string_append_printf(str, "%s = \"%d\"\n", label, n);
+ g_string_append_printf(str, "%s = \"%d\" ", label, n);
}
gboolean read_int_option(const gchar *option, const gchar *label, const gchar *value, gint *n)
void write_uint_option(GString *str, gint indent, const gchar *label, guint n)
{
- write_indent(str, indent);
- g_string_append_printf(str, "%s = \"%u\"\n", label, n);
+ g_string_append_printf(str, "%s = \"%u\" ", label, n);
}
gboolean read_uint_option(const gchar *option, const gchar *label, const gchar *value, guint *n)
r = 0;
}
- write_indent(str, indent);
- g_string_append_printf(str, "%s = \"%d.%d\"\n", label, l, r);
+ g_string_append_printf(str, "%s = \"%d.%d\" ", label, l, r);
}
gboolean read_int_unit_option(const gchar *option, const gchar *label, const gchar *value, gint *n, gint subunits)
void write_bool_option(GString *str, gint indent, gchar *label, gint n)
{
- write_indent(str, indent);
- g_string_append_printf(str, "%s = \"%s\"\n", label, n ? "true" : "false");
+ g_string_append_printf(str, "%s = \"%s\" ", label, n ? "true" : "false");
}
gboolean read_bool_option(const gchar *option, const gchar *label, const gchar *value, gint *n)
static void write_global_attributes(GString *outstr, gint indent)
{
-// WRITE_SUBTITLE("General Options");
-
- WRITE_BOOL(*options, show_icon_names);
- WRITE_BOOL(*options, show_copy_path);
+ /* General Options */
+ WRITE_NL(); WRITE_BOOL(*options, show_icon_names);
WRITE_SEPARATOR();
- WRITE_BOOL(*options, tree_descend_subdirs);
- WRITE_BOOL(*options, lazy_image_sync);
- WRITE_BOOL(*options, update_on_time_change);
+ WRITE_NL(); WRITE_BOOL(*options, tree_descend_subdirs);
+ WRITE_NL(); WRITE_BOOL(*options, lazy_image_sync);
+ WRITE_NL(); WRITE_BOOL(*options, update_on_time_change);
WRITE_SEPARATOR();
- WRITE_BOOL(*options, progressive_key_scrolling);
+ WRITE_NL(); WRITE_BOOL(*options, progressive_key_scrolling);
- WRITE_UINT(*options, duplicates_similarity_threshold);
+ WRITE_NL(); WRITE_UINT(*options, duplicates_similarity_threshold);
WRITE_SEPARATOR();
- WRITE_BOOL(*options, mousewheel_scrolls);
- WRITE_INT(*options, open_recent_list_maxsize);
- WRITE_INT(*options, dnd_icon_size);
- WRITE_BOOL(*options, place_dialogs_under_mouse);
-
-
-// WRITE_SUBTITLE("Startup Options");
-
- WRITE_BOOL(*options, startup.restore_path);
- WRITE_BOOL(*options, startup.use_last_path);
- WRITE_CHAR(*options, startup.path);
-
-
-// WRITE_SUBTITLE("File operations Options");
+ WRITE_NL(); WRITE_BOOL(*options, mousewheel_scrolls);
+ WRITE_NL(); WRITE_INT(*options, open_recent_list_maxsize);
+ WRITE_NL(); WRITE_INT(*options, dnd_icon_size);
+ WRITE_NL(); WRITE_BOOL(*options, place_dialogs_under_mouse);
- WRITE_BOOL(*options, file_ops.enable_in_place_rename);
- WRITE_BOOL(*options, file_ops.confirm_delete);
- WRITE_BOOL(*options, file_ops.enable_delete_key);
- WRITE_BOOL(*options, file_ops.safe_delete_enable);
- WRITE_CHAR(*options, file_ops.safe_delete_path);
- WRITE_INT(*options, file_ops.safe_delete_folder_maxsize);
+ WRITE_NL(); WRITE_BOOL(*options, save_window_positions);
+ WRITE_NL(); WRITE_BOOL(*options, tools_restore_state);
+ /* File operations Options */
+ WRITE_NL(); WRITE_BOOL(*options, file_ops.enable_in_place_rename);
+ WRITE_NL(); WRITE_BOOL(*options, file_ops.confirm_delete);
+ WRITE_NL(); WRITE_BOOL(*options, file_ops.enable_delete_key);
+ WRITE_NL(); WRITE_BOOL(*options, file_ops.safe_delete_enable);
+ WRITE_NL(); WRITE_CHAR(*options, file_ops.safe_delete_path);
+ WRITE_NL(); WRITE_INT(*options, file_ops.safe_delete_folder_maxsize);
+ /* Properties dialog Options */
+ WRITE_NL(); WRITE_CHAR(*options, properties.tabs_order);
+ /* Image Options */
+ WRITE_NL(); WRITE_UINT(*options, image.zoom_mode);
-// WRITE_SUBTITLE("Properties dialog Options");
- WRITE_CHAR(*options, properties.tabs_order);
-
-// WRITE_SUBTITLE("Image Options");
-
- WRITE_UINT(*options, image.zoom_mode);
-
-// g_string_append_printf(outstr, "# image.zoom_mode possible values are:\n"
-// "# original\n"
-// "# fit\n"
-// "# dont_change\n");
-// g_string_append_printf(outstr, "image.zoom_mode: ");
-// switch (options->image.zoom_mode)
-// {
-// case ZOOM_RESET_ORIGINAL: g_string_append_printf(outstr, "original\n"); break;
-// case ZOOM_RESET_FIT_WINDOW: g_string_append_printf(outstr, "fit\n"); break;
-// case ZOOM_RESET_NONE: g_string_append_printf(outstr, "dont_change\n"); break;
-// }
WRITE_SEPARATOR();
- WRITE_BOOL(*options, image.zoom_2pass);
- WRITE_BOOL(*options, image.zoom_to_fit_allow_expand);
- WRITE_UINT(*options, image.zoom_quality);
- WRITE_INT(*options, image.zoom_increment);
- WRITE_BOOL(*options, image.fit_window_to_image);
- WRITE_BOOL(*options, image.limit_window_size);
- WRITE_INT(*options, image.max_window_size);
- WRITE_BOOL(*options, image.limit_autofit_size);
- WRITE_INT(*options, image.max_autofit_size);
- WRITE_UINT(*options, image.scroll_reset_method);
- WRITE_INT(*options, image.tile_cache_max);
- WRITE_INT(*options, image.image_cache_max);
- WRITE_UINT(*options, image.dither_quality);
- WRITE_BOOL(*options, image.enable_read_ahead);
- WRITE_BOOL(*options, image.exif_rotate_enable);
- WRITE_BOOL(*options, image.use_custom_border_color);
- WRITE_COLOR(*options, image.border_color);
- WRITE_INT(*options, image.read_buffer_size);
- WRITE_INT(*options, image.idle_read_loop_count);
-
-// WRITE_SUBTITLE("Thumbnails Options");
-
- WRITE_INT(*options, thumbnails.max_width);
- WRITE_INT(*options, thumbnails.max_height);
- WRITE_BOOL(*options, thumbnails.enable_caching);
- WRITE_BOOL(*options, thumbnails.cache_into_dirs);
- WRITE_BOOL(*options, thumbnails.fast);
- WRITE_BOOL(*options, thumbnails.use_xvpics);
- WRITE_BOOL(*options, thumbnails.spec_standard);
- WRITE_UINT(*options, thumbnails.quality);
- WRITE_BOOL(*options, thumbnails.use_exif);
-
-
-// WRITE_SUBTITLE("File sorting Options");
-
- WRITE_INT(*options, file_sort.method);
- WRITE_BOOL(*options, file_sort.ascending);
- WRITE_BOOL(*options, file_sort.case_sensitive);
-
-
-// WRITE_SUBTITLE("Fullscreen Options");
-
- WRITE_INT(*options, fullscreen.screen);
- WRITE_BOOL(*options, fullscreen.clean_flip);
- WRITE_BOOL(*options, fullscreen.disable_saver);
- WRITE_BOOL(*options, fullscreen.above);
+ WRITE_NL(); WRITE_BOOL(*options, image.zoom_2pass);
+ WRITE_NL(); WRITE_BOOL(*options, image.zoom_to_fit_allow_expand);
+ WRITE_NL(); WRITE_UINT(*options, image.zoom_quality);
+ WRITE_NL(); WRITE_INT(*options, image.zoom_increment);
+ WRITE_NL(); WRITE_BOOL(*options, image.fit_window_to_image);
+ WRITE_NL(); WRITE_BOOL(*options, image.limit_window_size);
+ WRITE_NL(); WRITE_INT(*options, image.max_window_size);
+ WRITE_NL(); WRITE_BOOL(*options, image.limit_autofit_size);
+ WRITE_NL(); WRITE_INT(*options, image.max_autofit_size);
+ WRITE_NL(); WRITE_UINT(*options, image.scroll_reset_method);
+ WRITE_NL(); WRITE_INT(*options, image.tile_cache_max);
+ WRITE_NL(); WRITE_INT(*options, image.image_cache_max);
+ WRITE_NL(); WRITE_BOOL(*options, image.enable_read_ahead);
+ WRITE_NL(); WRITE_BOOL(*options, image.exif_rotate_enable);
+ WRITE_NL(); WRITE_BOOL(*options, image.use_custom_border_color);
+ WRITE_NL(); WRITE_BOOL(*options, image.use_custom_border_color_in_fullscreen);
+ WRITE_NL(); WRITE_COLOR(*options, image.border_color);
+ WRITE_NL(); WRITE_BOOL(*options, image.use_clutter_renderer);
+
+ /* Thumbnails Options */
+ WRITE_NL(); WRITE_INT(*options, thumbnails.max_width);
+ WRITE_NL(); WRITE_INT(*options, thumbnails.max_height);
+ WRITE_NL(); WRITE_BOOL(*options, thumbnails.enable_caching);
+ WRITE_NL(); WRITE_BOOL(*options, thumbnails.cache_into_dirs);
+ WRITE_NL(); WRITE_BOOL(*options, thumbnails.use_xvpics);
+ WRITE_NL(); WRITE_BOOL(*options, thumbnails.spec_standard);
+ WRITE_NL(); WRITE_UINT(*options, thumbnails.quality);
+ WRITE_NL(); WRITE_BOOL(*options, thumbnails.use_exif);
+
+ /* File sorting Options */
+ WRITE_NL(); WRITE_INT(*options, file_sort.method);
+ WRITE_NL(); WRITE_BOOL(*options, file_sort.ascending);
+ WRITE_NL(); WRITE_BOOL(*options, file_sort.case_sensitive);
+
+ /* Fullscreen Options */
+ WRITE_NL(); WRITE_INT(*options, fullscreen.screen);
+ WRITE_NL(); WRITE_BOOL(*options, fullscreen.clean_flip);
+ WRITE_NL(); WRITE_BOOL(*options, fullscreen.disable_saver);
+ WRITE_NL(); WRITE_BOOL(*options, fullscreen.above);
WRITE_SEPARATOR();
-// WRITE_SUBTITLE("Image Overlay Options");
- WRITE_CHAR(*options, image_overlay.template_string);
-
-// g_string_append_printf(outstr, "# these are relative positions:\n");
-// g_string_append_printf(outstr, "# x >= 0: |x| pixels from left border\n");
-// g_string_append_printf(outstr, "# x < 0 : |x| pixels from right border\n");
-// g_string_append_printf(outstr, "# y >= 0: |y| pixels from top border\n");
-// g_string_append_printf(outstr, "# y < 0 : |y| pixels from bottom border\n");
- WRITE_INT(*options, image_overlay.x);
- WRITE_INT(*options, image_overlay.y);
-
-
-// WRITE_SUBTITLE("Slideshow Options");
+ /* Image Overlay Options */
+ WRITE_NL(); WRITE_CHAR(*options, image_overlay.template_string);
- WRITE_INT_UNIT(*options, slideshow.delay, SLIDESHOW_SUBSECOND_PRECISION);
- WRITE_BOOL(*options, slideshow.random);
- WRITE_BOOL(*options, slideshow.repeat);
+ WRITE_NL(); WRITE_INT(*options, image_overlay.x);
+ WRITE_NL(); WRITE_INT(*options, image_overlay.y);
+ /* Slideshow Options */
+ WRITE_NL(); WRITE_INT_UNIT(*options, slideshow.delay, SLIDESHOW_SUBSECOND_PRECISION);
+ WRITE_NL(); WRITE_BOOL(*options, slideshow.random);
+ WRITE_NL(); WRITE_BOOL(*options, slideshow.repeat);
-// WRITE_SUBTITLE("Collection Options");
+ /* Collection Options */
+ WRITE_NL(); WRITE_BOOL(*options, collections.rectangular_selection);
- WRITE_BOOL(*options, collections.rectangular_selection);
-
-
-// WRITE_SUBTITLE("Filtering Options");
-
- WRITE_BOOL(*options, file_filter.show_hidden_files);
- WRITE_BOOL(*options, file_filter.show_dot_directory);
- WRITE_BOOL(*options, file_filter.disable);
+ /* Filtering Options */
+ WRITE_NL(); WRITE_BOOL(*options, file_filter.show_hidden_files);
+ WRITE_NL(); WRITE_BOOL(*options, file_filter.show_dot_directory);
+ WRITE_NL(); WRITE_BOOL(*options, file_filter.disable);
WRITE_SEPARATOR();
-
-// WRITE_SUBTITLE("Sidecars Options");
-
- WRITE_CHAR(*options, sidecar.ext);
-
-
-
-// WRITE_SUBTITLE("Shell command");
- WRITE_CHAR(*options, shell.path);
- WRITE_CHAR(*options, shell.options);
-
-
-// WRITE_SUBTITLE("Helpers");
-// g_string_append_printf(outstr, "# Html browser\n");
-// g_string_append_printf(outstr, "# command_name is: the binary's name to look for in the path\n");
-// g_string_append_printf(outstr, "# If command_name is empty, the program will try various common html browsers\n");
-// g_string_append_printf(outstr, "# command_line is:\n");
-// g_string_append_printf(outstr, "# \"\" (empty string) = execute binary with html file path as command line\n");
-// g_string_append_printf(outstr, "# \"string\" = execute string and use results for command line\n");
-// g_string_append_printf(outstr, "# \"!string\" = use text following ! as command line, replacing optional %%s with html file path\n");
- WRITE_CHAR(*options, helpers.html_browser.command_name);
- WRITE_CHAR(*options, helpers.html_browser.command_line);
-
-/* FIXME:
- WRITE_SUBTITLE("Exif Options");
- g_string_append_printf(outstr, "# Display: 0: never\n"
- "# 1: if set\n"
- "# 2: always\n\n");
- for (i = 0; ExifUIList[i].key; i++)
- {
- g_string_append_printf(outstr, "exif.display.");
- write_int_option(outstr, 2, (gchar *)ExifUIList[i].key, ExifUIList[i].current);
- }
-*/
-
-// WRITE_SUBTITLE("Metadata Options");
- WRITE_BOOL(*options, metadata.enable_metadata_dirs);
- WRITE_BOOL(*options, metadata.save_in_image_file);
- WRITE_BOOL(*options, metadata.save_legacy_IPTC);
- WRITE_BOOL(*options, metadata.warn_on_write_problems);
- WRITE_BOOL(*options, metadata.save_legacy_format);
- WRITE_BOOL(*options, metadata.sync_grouped_files);
- WRITE_BOOL(*options, metadata.confirm_write);
- WRITE_INT(*options, metadata.confirm_timeout);
- WRITE_BOOL(*options, metadata.confirm_after_timeout);
- WRITE_BOOL(*options, metadata.confirm_on_image_change);
- WRITE_BOOL(*options, metadata.confirm_on_dir_change);
-
+ /* Sidecars Options */
+ WRITE_NL(); WRITE_CHAR(*options, sidecar.ext);
+
+ /* Shell command */
+ WRITE_NL(); WRITE_CHAR(*options, shell.path);
+ WRITE_NL(); WRITE_CHAR(*options, shell.options);
+
+ /* Helpers */
+ WRITE_NL(); WRITE_CHAR(*options, helpers.html_browser.command_name);
+ WRITE_NL(); WRITE_CHAR(*options, helpers.html_browser.command_line);
+
+ /* Metadata Options */
+ WRITE_NL(); WRITE_BOOL(*options, metadata.enable_metadata_dirs);
+ WRITE_NL(); WRITE_BOOL(*options, metadata.save_in_image_file);
+ WRITE_NL(); WRITE_BOOL(*options, metadata.save_legacy_IPTC);
+ WRITE_NL(); WRITE_BOOL(*options, metadata.warn_on_write_problems);
+ WRITE_NL(); WRITE_BOOL(*options, metadata.save_legacy_format);
+ WRITE_NL(); WRITE_BOOL(*options, metadata.sync_grouped_files);
+ WRITE_NL(); WRITE_BOOL(*options, metadata.confirm_write);
+ WRITE_NL(); WRITE_INT(*options, metadata.confirm_timeout);
+ WRITE_NL(); WRITE_BOOL(*options, metadata.confirm_after_timeout);
+ WRITE_NL(); WRITE_BOOL(*options, metadata.confirm_on_image_change);
+ WRITE_NL(); WRITE_BOOL(*options, metadata.confirm_on_dir_change);
+ WRITE_NL(); WRITE_BOOL(*options, metadata.keywords_case_sensitive);
+ WRITE_NL(); WRITE_BOOL(*options, metadata.write_orientation);
+
+ WRITE_NL(); WRITE_INT(*options, stereo.mode);
+ WRITE_NL(); WRITE_INT(*options, stereo.fsmode);
+ WRITE_NL(); WRITE_BOOL(*options, stereo.enable_fsmode);
+ WRITE_NL(); WRITE_INT(*options, stereo.fixed_w);
+ WRITE_NL(); WRITE_INT(*options, stereo.fixed_h);
+ WRITE_NL(); WRITE_INT(*options, stereo.fixed_x1);
+ WRITE_NL(); WRITE_INT(*options, stereo.fixed_y1);
+ WRITE_NL(); WRITE_INT(*options, stereo.fixed_x2);
+ WRITE_NL(); WRITE_INT(*options, stereo.fixed_y2);
}
static void write_color_profile(GString *outstr, gint indent)
" color profile options will have no effect.\n-->\n", GQ_APPNAME);
#endif
- WRITE_STRING("<color_profiles\n");
- indent++;
- WRITE_INT(options->color_profile, screen_type);
+ WRITE_NL(); WRITE_STRING("<color_profiles ");
WRITE_CHAR(options->color_profile, screen_file);
WRITE_BOOL(options->color_profile, enabled);
WRITE_BOOL(options->color_profile, use_image);
WRITE_INT(options->color_profile, input_type);
- indent--;
- WRITE_STRING(">\n");
+ WRITE_BOOL(options->color_profile, use_x11_screen_profile);
+ WRITE_STRING(">");
indent++;
for (i = 0; i < COLOR_PROFILE_INPUTS; i++)
{
- WRITE_STRING("<profile\n");
- indent++;
+ WRITE_NL(); WRITE_STRING("<profile ");
write_char_option(outstr, indent, "input_file", options->color_profile.input_file[i]);
write_char_option(outstr, indent, "input_name", options->color_profile.input_name[i]);
- indent--;
- WRITE_STRING("/>\n");
+ WRITE_STRING("/>");
}
indent--;
- WRITE_STRING("</color_profiles>\n");
+ WRITE_NL(); WRITE_STRING("</color_profiles>");
}
*-----------------------------------------------------------------------------
*/
-gboolean save_options_to(const gchar *utf8_path, ConfOptions *options)
+gboolean save_config_to_file(const gchar *utf8_path, ConfOptions *options)
{
SecureSaveInfo *ssi;
gchar *rc_pathl;
WRITE_SEPARATOR();
WRITE_STRING("-->\n");
WRITE_SEPARATOR();
- WRITE_STRING("<global\n");
+
+ WRITE_STRING("<gq>\n");
+ indent++;
+
+ WRITE_NL(); WRITE_STRING("<global\n");
+ indent++;
write_global_attributes(outstr, indent + 1);
+ indent--;
WRITE_STRING(">\n");
indent++;
filter_write_list(outstr, indent);
WRITE_SEPARATOR();
- WRITE_SUBTITLE("Layout Options - defaults");
- WRITE_STRING("<layout\n");
- layout_write_attributes(&options->layout, outstr, indent + 1);
- WRITE_STRING("/>\n");
-
+ keyword_tree_write_config(outstr, indent);
indent--;
- WRITE_STRING("</global>\n");
+ WRITE_NL(); WRITE_STRING("</global>\n");
WRITE_SEPARATOR();
- WRITE_SUBTITLE("Layout Options");
+ /* Layout Options */
work = layout_window_list;
while (work)
{
LayoutWindow *lw = work->data;
layout_write_config(lw, outstr, indent);
work = work->next;
-
}
-
+ indent--;
+ WRITE_NL(); WRITE_STRING("</gq>\n");
+ WRITE_SEPARATOR();
secure_fputs(ssi, outstr->str);
g_string_free(outstr, TRUE);
const gchar *option = *attribute_names++;
const gchar *value = *attribute_values++;
-
- /* general options */
+ /* General options */
if (READ_BOOL(*options, show_icon_names)) continue;
- if (READ_BOOL(*options, show_copy_path)) continue;
if (READ_BOOL(*options, tree_descend_subdirs)) continue;
if (READ_BOOL(*options, lazy_image_sync)) continue;
if (READ_INT(*options, dnd_icon_size)) continue;
if (READ_BOOL(*options, place_dialogs_under_mouse)) continue;
- /* startup options */
-
- if (READ_BOOL(*options, startup.restore_path)) continue;
-
- if (READ_BOOL(*options, startup.use_last_path)) continue;
+ if (READ_BOOL(*options, save_window_positions)) continue;
+ if (READ_BOOL(*options, tools_restore_state)) continue;
- if (READ_CHAR(*options, startup.path)) continue;
-
-
- /* properties dialog options */
+ /* Properties dialog options */
if (READ_CHAR(*options, properties.tabs_order)) continue;
- /* image options */
+ /* Image options */
if (READ_UINT_CLAMP(*options, image.zoom_mode, 0, ZOOM_RESET_NONE)) continue;
if (READ_BOOL(*options, image.zoom_2pass)) continue;
if (READ_BOOL(*options, image.zoom_to_fit_allow_expand)) continue;
if (READ_INT(*options, image.tile_cache_max)) continue;
if (READ_INT(*options, image.image_cache_max)) continue;
if (READ_UINT_CLAMP(*options, image.zoom_quality, GDK_INTERP_NEAREST, GDK_INTERP_HYPER)) continue;
- if (READ_UINT_CLAMP(*options, image.dither_quality, GDK_RGB_DITHER_NONE, GDK_RGB_DITHER_MAX)) continue;
if (READ_INT(*options, image.zoom_increment)) continue;
if (READ_BOOL(*options, image.enable_read_ahead)) continue;
if (READ_BOOL(*options, image.exif_rotate_enable)) continue;
if (READ_BOOL(*options, image.use_custom_border_color)) continue;
+ if (READ_BOOL(*options, image.use_custom_border_color_in_fullscreen)) continue;
if (READ_COLOR(*options, image.border_color)) continue;
- if (READ_INT_CLAMP(*options, image.read_buffer_size, IMAGE_LOADER_READ_BUFFER_SIZE_MIN, IMAGE_LOADER_READ_BUFFER_SIZE_MAX)) continue;
- if (READ_INT_CLAMP(*options, image.idle_read_loop_count, IMAGE_LOADER_IDLE_READ_LOOP_COUNT_MIN, IMAGE_LOADER_IDLE_READ_LOOP_COUNT_MAX)) continue;
-
+ if (READ_BOOL(*options, image.use_clutter_renderer)) continue;
- /* thumbnails options */
+ /* Thumbnails options */
if (READ_INT_CLAMP(*options, thumbnails.max_width, 16, 512)) continue;
if (READ_INT_CLAMP(*options, thumbnails.max_height, 16, 512)) continue;
if (READ_BOOL(*options, thumbnails.enable_caching)) continue;
if (READ_BOOL(*options, thumbnails.cache_into_dirs)) continue;
- if (READ_BOOL(*options, thumbnails.fast)) continue;
if (READ_BOOL(*options, thumbnails.use_xvpics)) continue;
if (READ_BOOL(*options, thumbnails.spec_standard)) continue;
if (READ_UINT_CLAMP(*options, thumbnails.quality, GDK_INTERP_NEAREST, GDK_INTERP_HYPER)) continue;
if (READ_BOOL(*options, thumbnails.use_exif)) continue;
- /* file sorting options */
+ /* File sorting options */
if (READ_UINT(*options, file_sort.method)) continue;
if (READ_BOOL(*options, file_sort.ascending)) continue;
if (READ_BOOL(*options, file_sort.case_sensitive)) continue;
- /* file operations *options */
+ /* File operations *options */
if (READ_BOOL(*options, file_ops.enable_in_place_rename)) continue;
if (READ_BOOL(*options, file_ops.confirm_delete)) continue;
if (READ_BOOL(*options, file_ops.enable_delete_key)) continue;
if (READ_CHAR(*options, file_ops.safe_delete_path)) continue;
if (READ_INT(*options, file_ops.safe_delete_folder_maxsize)) continue;
- /* fullscreen options */
+ /* Fullscreen options */
if (READ_INT(*options, fullscreen.screen)) continue;
if (READ_BOOL(*options, fullscreen.clean_flip)) continue;
if (READ_BOOL(*options, fullscreen.disable_saver)) continue;
if (READ_BOOL(*options, fullscreen.above)) continue;
- /* image overlay */
+ /* Image overlay */
if (READ_CHAR(*options, image_overlay.template_string)) continue;
if (READ_INT(*options, image_overlay.x)) continue;
if (READ_INT(*options, image_overlay.y)) continue;
-
- /* slideshow options */
+ /* Slideshow options */
if (READ_INT_UNIT(*options, slideshow.delay, SLIDESHOW_SUBSECOND_PRECISION)) continue;
if (READ_BOOL(*options, slideshow.random)) continue;
if (READ_BOOL(*options, slideshow.repeat)) continue;
- /* collection options */
-
+ /* Collection options */
if (READ_BOOL(*options, collections.rectangular_selection)) continue;
- /* filtering options */
-
+ /* Filtering options */
if (READ_BOOL(*options, file_filter.show_hidden_files)) continue;
if (READ_BOOL(*options, file_filter.show_dot_directory)) continue;
if (READ_BOOL(*options, file_filter.disable)) continue;
/* Helpers */
if (READ_CHAR(*options, helpers.html_browser.command_name)) continue;
if (READ_CHAR(*options, helpers.html_browser.command_line)) continue;
- /* Exif */
-/*
- if (0 == g_ascii_strncasecmp(option, "exif.display.", 13))
- {
- for (i = 0; ExifUIList[i].key; i++)
- if (0 == g_ascii_strcasecmp(option + 13, ExifUIList[i].key))
- ExifUIList[i].current = strtol(value, NULL, 10);
- continue;
- }
-*/
- /* metadata */
+
+ /* Metadata */
if (READ_BOOL(*options, metadata.enable_metadata_dirs)) continue;
if (READ_BOOL(*options, metadata.save_in_image_file)) continue;
if (READ_BOOL(*options, metadata.save_legacy_IPTC)) continue;
if (READ_INT(*options, metadata.confirm_timeout)) continue;
if (READ_BOOL(*options, metadata.confirm_on_image_change)) continue;
if (READ_BOOL(*options, metadata.confirm_on_dir_change)) continue;
-
- DEBUG_1("unknown attribute %s = %s", option, value);
+ if (READ_BOOL(*options, metadata.keywords_case_sensitive)) continue;
+ if (READ_BOOL(*options, metadata.write_orientation)) continue;
+
+ if (READ_INT(*options, stereo.mode)) continue;
+ if (READ_INT(*options, stereo.fsmode)) continue;
+ if (READ_BOOL(*options, stereo.enable_fsmode)) continue;
+ if (READ_INT(*options, stereo.fixed_w)) continue;
+ if (READ_INT(*options, stereo.fixed_h)) continue;
+ if (READ_INT(*options, stereo.fixed_x1)) continue;
+ if (READ_INT(*options, stereo.fixed_y1)) continue;
+ if (READ_INT(*options, stereo.fixed_x2)) continue;
+ if (READ_INT(*options, stereo.fixed_y2)) continue;
+
+ /* Dummy options */
+ if (READ_DUMMY(*options, image.dither_quality, "deprecated since 2012-08-13")) continue;
+
+ /* Unknown options */
+ log_printf("unknown attribute %s = %s\n", option, value);
}
return TRUE;
const gchar *option = *attribute_names++;
const gchar *value = *attribute_values++;
-
if (READ_BOOL(options->color_profile, enabled)) continue;
if (READ_BOOL(options->color_profile, use_image)) continue;
if (READ_INT(options->color_profile, input_type)) continue;
- if (READ_INT(options->color_profile, screen_type)) continue;
if (READ_CHAR(options->color_profile, screen_file)) continue;
+ if (READ_BOOL(options->color_profile, use_x11_screen_profile)) continue;
- DEBUG_1("unknown attribute %s = %s", option, value);
+ log_printf("unknown attribute %s = %s\n", option, value);
}
}
if (READ_CHAR_FULL("input_file", options->color_profile.input_file[i])) continue;
if (READ_CHAR_FULL("input_name", options->color_profile.input_name[i])) continue;
-
- DEBUG_1("unknown attribute %s = %s", option, value);
+ log_printf("unknown attribute %s = %s\n", option, value);
}
i++;
options_parse_func_set_data(parser_data, GINT_TO_POINTER(i));
struct _GQParserData
{
GList *parse_func_stack;
- gboolean startup; /* reading config for the first time - add commandline and call init_after_global_options() */
- gboolean global_found;
+ gboolean startup; /* reading config for the first time - add commandline and defaults */
};
+static const gchar *options_get_id(const gchar **attribute_names, const gchar **attribute_values)
+{
+ while (*attribute_names)
+ {
+ const gchar *option = *attribute_names++;
+ const gchar *value = *attribute_values++;
+
+ if (strcmp(option, "id") == 0) return value;
+
+ }
+ return NULL;
+}
+
void options_parse_leaf(GQParserData *parser_data, GMarkupParseContext *context, const gchar *element_name, const gchar **attribute_names, const gchar **attribute_values, gpointer data, GError **error)
{
- DEBUG_1("unexpected: %s", element_name);
+ log_printf("unexpected: %s\n", element_name);
options_parse_func_push(parser_data, options_parse_leaf, NULL, NULL);
}
}
else
{
- DEBUG_1("unexpected profile: %s", element_name);
+ log_printf("unexpected in <profile>: <%s>\n", element_name);
options_parse_func_push(parser_data, options_parse_leaf, NULL, NULL);
}
}
}
else
{
- DEBUG_1("unexpected filter: %s", element_name);
+ log_printf("unexpected in <filter>: <%s>\n", element_name);
options_parse_func_push(parser_data, options_parse_leaf, NULL, NULL);
}
}
static void options_parse_filter_end(GQParserData *parser_data, GMarkupParseContext *context, const gchar *element_name, gpointer data, GError **error)
{
- if (!parser_data->startup) filter_rebuild();
- /* else this is called in init_after_global_options */
+ if (parser_data->startup) filter_add_defaults();
+ filter_rebuild();
+}
+
+static void options_parse_keyword_end(GQParserData *parser_data, GMarkupParseContext *context, const gchar *element_name, gpointer data, GError **error)
+{
+ GtkTreeIter *iter_ptr = data;
+ gtk_tree_iter_free(iter_ptr);
+}
+
+
+static void options_parse_keyword(GQParserData *parser_data, GMarkupParseContext *context, const gchar *element_name, const gchar **attribute_names, const gchar **attribute_values, gpointer data, GError **error)
+{
+ GtkTreeIter *iter_ptr = data;
+ if (g_ascii_strcasecmp(element_name, "keyword") == 0)
+ {
+ GtkTreeIter *child = keyword_add_from_config(keyword_tree, iter_ptr, attribute_names, attribute_values);
+ options_parse_func_push(parser_data, options_parse_keyword, options_parse_keyword_end, child);
+ }
+ else
+ {
+ log_printf("unexpected in <keyword>: <%s>\n", element_name);
+ options_parse_func_push(parser_data, options_parse_leaf, NULL, NULL);
+ }
+}
+
+
+
+static void options_parse_keyword_tree(GQParserData *parser_data, GMarkupParseContext *context, const gchar *element_name, const gchar **attribute_names, const gchar **attribute_values, gpointer data, GError **error)
+{
+ if (g_ascii_strcasecmp(element_name, "keyword") == 0)
+ {
+ GtkTreeIter *iter_ptr = keyword_add_from_config(keyword_tree, NULL, attribute_names, attribute_values);
+ options_parse_func_push(parser_data, options_parse_keyword, options_parse_keyword_end, iter_ptr);
+ }
+ else
+ {
+ log_printf("unexpected in <keyword_tree>: <%s>\n", element_name);
+ options_parse_func_push(parser_data, options_parse_leaf, NULL, NULL);
+ }
}
+
static void options_parse_global(GQParserData *parser_data, GMarkupParseContext *context, const gchar *element_name, const gchar **attribute_names, const gchar **attribute_values, gpointer data, GError **error)
{
if (g_ascii_strcasecmp(element_name, "color_profiles") == 0)
{
options_parse_func_push(parser_data, options_parse_filter, options_parse_filter_end, NULL);
}
- else if (g_ascii_strcasecmp(element_name, "layout") == 0)
+ else if (g_ascii_strcasecmp(element_name, "keyword_tree") == 0)
{
- layout_load_attributes(&options->layout, attribute_names, attribute_values);
- options_parse_func_push(parser_data, options_parse_leaf, NULL, NULL);
+ if (!keyword_tree) keyword_tree_new();
+ options_parse_func_push(parser_data, options_parse_keyword_tree, NULL, NULL);
}
else
{
- DEBUG_1("unexpected global: %s", element_name);
+ log_printf("unexpected in <global>: <%s>\n", element_name);
options_parse_func_push(parser_data, options_parse_leaf, NULL, NULL);
}
}
+static void options_parse_global_end(GQParserData *parser_data, GMarkupParseContext *context, const gchar *element_name, gpointer data, GError **error)
+{
+#ifndef HAVE_EXIV2
+ /* some options do not work without exiv2 */
+ options->metadata.save_in_image_file = FALSE;
+ options->metadata.save_legacy_format = TRUE;
+ options->metadata.write_orientation = FALSE;
+ DEBUG_1("compiled without Exiv2 - disabling XMP write support");
+#endif
+}
+
static void options_parse_pane_exif(GQParserData *parser_data, GMarkupParseContext *context, const gchar *element_name, const gchar **attribute_names, const gchar **attribute_values, gpointer data, GError **error)
{
GtkWidget *pane = data;
}
else
{
- DEBUG_1("unexpected in <pane_exif>: <%s>", element_name);
+ log_printf("unexpected in <pane_exif>: <%s>\n", element_name);
options_parse_func_push(parser_data, options_parse_leaf, NULL, NULL);
}
}
GtkWidget *bar = data;
if (g_ascii_strcasecmp(element_name, "pane_comment") == 0)
{
- GtkWidget *pane = bar_pane_comment_new_from_config(attribute_names, attribute_values);
- bar_add(bar, pane);
+ GtkWidget *pane = bar_find_pane_by_id(bar, PANE_COMMENT, options_get_id(attribute_names, attribute_values));
+ if (pane)
+ {
+ bar_pane_comment_update_from_config(pane, attribute_names, attribute_values);
+ }
+ else
+ {
+ pane = bar_pane_comment_new_from_config(attribute_names, attribute_values);
+ bar_add(bar, pane);
+ }
+ options_parse_func_push(parser_data, options_parse_leaf, NULL, NULL);
+ }
+#ifdef HAVE_LIBCHAMPLAIN
+#ifdef HAVE_LIBCHAMPLAIN_GTK
+ else if (g_ascii_strcasecmp(element_name, "pane_gps") == 0)
+ {
+ GtkWidget *pane = bar_find_pane_by_id(bar, PANE_GPS, options_get_id(attribute_names, attribute_values));
+ if (pane)
+ {
+ bar_pane_gps_update_from_config(pane, attribute_names, attribute_values);
+ }
+ else
+ {
+ pane = bar_pane_gps_new_from_config(attribute_names, attribute_values);
+ bar_add(bar, pane);
+ }
options_parse_func_push(parser_data, options_parse_leaf, NULL, NULL);
}
+#endif
+#endif
else if (g_ascii_strcasecmp(element_name, "pane_exif") == 0)
{
- GtkWidget *pane = bar_pane_exif_new_from_config(attribute_names, attribute_values);
- bar_add(bar, pane);
+ GtkWidget *pane = bar_find_pane_by_id(bar, PANE_EXIF, options_get_id(attribute_names, attribute_values));
+ if (pane)
+ {
+ bar_pane_exif_update_from_config(pane, attribute_names, attribute_values);
+ }
+ else
+ {
+ pane = bar_pane_exif_new_from_config(attribute_names, attribute_values);
+ bar_add(bar, pane);
+ }
options_parse_func_push(parser_data, options_parse_pane_exif, NULL, pane);
}
else if (g_ascii_strcasecmp(element_name, "pane_histogram") == 0)
{
- GtkWidget *pane = bar_pane_histogram_new_from_config(attribute_names, attribute_values);
- bar_add(bar, pane);
+ GtkWidget *pane = bar_find_pane_by_id(bar, PANE_HISTOGRAM, options_get_id(attribute_names, attribute_values));
+ if (pane)
+ {
+ bar_pane_histogram_update_from_config(pane, attribute_names, attribute_values);
+ }
+ else
+ {
+ pane = bar_pane_histogram_new_from_config(attribute_names, attribute_values);
+ bar_add(bar, pane);
+ }
options_parse_func_push(parser_data, options_parse_leaf, NULL, NULL);
}
else if (g_ascii_strcasecmp(element_name, "pane_keywords") == 0)
{
- GtkWidget *pane = bar_pane_keywords_new_from_config(attribute_names, attribute_values);
- bar_add(bar, pane);
+ GtkWidget *pane = bar_find_pane_by_id(bar, PANE_KEYWORDS, options_get_id(attribute_names, attribute_values));
+ if (pane)
+ {
+ bar_pane_keywords_update_from_config(pane, attribute_names, attribute_values);
+ }
+ else
+ {
+ pane = bar_pane_keywords_new_from_config(attribute_names, attribute_values);
+ bar_add(bar, pane);
+ }
+ options_parse_func_push(parser_data, options_parse_leaf, NULL, NULL);
+ }
+ else if (g_ascii_strcasecmp(element_name, "clear") == 0)
+ {
+ bar_clear(bar);
options_parse_func_push(parser_data, options_parse_leaf, NULL, NULL);
}
else
{
- DEBUG_1("unexpected in <bar>: <%s>", element_name);
+ log_printf("unexpected in <bar>: <%s>\n", element_name);
options_parse_func_push(parser_data, options_parse_leaf, NULL, NULL);
}
}
LayoutWindow *lw = data;
if (g_ascii_strcasecmp(element_name, "toolitem") == 0)
{
- layout_toolbar_add_from_config(lw, attribute_names, attribute_values);
+ layout_toolbar_add_from_config(lw, TOOLBAR_MAIN, attribute_names, attribute_values);
+ options_parse_func_push(parser_data, options_parse_leaf, NULL, NULL);
+ }
+ else if (g_ascii_strcasecmp(element_name, "clear") == 0)
+ {
+ layout_toolbar_clear(lw, TOOLBAR_MAIN);
options_parse_func_push(parser_data, options_parse_leaf, NULL, NULL);
}
else
{
- DEBUG_1("unexpected in <toolbar>: <%s>", element_name);
+ log_printf("unexpected in <toolbar>: <%s>\n", element_name);
+ options_parse_func_push(parser_data, options_parse_leaf, NULL, NULL);
+ }
+}
+
+static void options_parse_statusbar(GQParserData *parser_data, GMarkupParseContext *context, const gchar *element_name, const gchar **attribute_names, const gchar **attribute_values, gpointer data, GError **error)
+{
+ LayoutWindow *lw = data;
+ if (g_ascii_strcasecmp(element_name, "toolitem") == 0)
+ {
+ layout_toolbar_add_from_config(lw, TOOLBAR_STATUS, attribute_names, attribute_values);
+ options_parse_func_push(parser_data, options_parse_leaf, NULL, NULL);
+ }
+ else if (g_ascii_strcasecmp(element_name, "clear") == 0)
+ {
+ layout_toolbar_clear(lw, TOOLBAR_STATUS);
+ options_parse_func_push(parser_data, options_parse_leaf, NULL, NULL);
+ }
+ else
+ {
+ log_printf("unexpected in <statusbar>: <%s>\n", element_name);
options_parse_func_push(parser_data, options_parse_leaf, NULL, NULL);
}
}
LayoutWindow *lw = data;
if (g_ascii_strcasecmp(element_name, "bar") == 0)
{
- GtkWidget *bar = bar_new_from_config(lw->utility_box, attribute_names, attribute_values);
- layout_bar_set(lw, bar);
+ if (!lw->bar)
+ {
+ GtkWidget *bar = bar_new_from_config(lw, attribute_names, attribute_values);
+ layout_bar_set(lw, bar);
+ }
+ else
+ {
+ bar_update_from_config(lw->bar, attribute_names, attribute_values);
+ }
+
options_parse_func_push(parser_data, options_parse_bar, NULL, lw->bar);
}
else if (g_ascii_strcasecmp(element_name, "bar_sort") == 0)
}
else if (g_ascii_strcasecmp(element_name, "toolbar") == 0)
{
- layout_toolbar_clear(lw);
options_parse_func_push(parser_data, options_parse_toolbar, NULL, lw);
}
+ else if (g_ascii_strcasecmp(element_name, "statusbar") == 0)
+ {
+ options_parse_func_push(parser_data, options_parse_statusbar, NULL, lw);
+ }
else
{
- DEBUG_1("unexpected in <layout>: <%s>", element_name);
+ log_printf("unexpected in <layout>: <%s>\n", element_name);
options_parse_func_push(parser_data, options_parse_leaf, NULL, NULL);
}
}
static void options_parse_toplevel(GQParserData *parser_data, GMarkupParseContext *context, const gchar *element_name, const gchar **attribute_names, const gchar **attribute_values, gpointer data, GError **error)
{
- if (g_ascii_strcasecmp(element_name, "global") == 0)
+ if (g_ascii_strcasecmp(element_name, "gq") == 0)
{
- load_global_params(attribute_names, attribute_values);
- options_parse_func_push(parser_data, options_parse_global, NULL, NULL);
+ /* optional top-level node */
+ options_parse_func_push(parser_data, options_parse_toplevel, NULL, NULL);
return;
}
-
- if (parser_data->startup && !parser_data->global_found)
+ if (g_ascii_strcasecmp(element_name, "global") == 0)
{
- DEBUG_1(" global end");
- parser_data->global_found = TRUE;
- init_after_global_options();
+ load_global_params(attribute_names, attribute_values);
+ options_parse_func_push(parser_data, options_parse_global, options_parse_global_end, NULL);
+ return;
}
if (g_ascii_strcasecmp(element_name, "layout") == 0)
{
LayoutWindow *lw;
- lw = layout_new_from_config(attribute_names, attribute_values, parser_data->startup);
+ lw = layout_find_by_layout_id(options_get_id(attribute_names, attribute_values));
+ if (lw)
+ {
+ layout_update_from_config(lw, attribute_names, attribute_values);
+ }
+ else
+ {
+ lw = layout_new_from_config(attribute_names, attribute_values, parser_data->startup);
+ }
options_parse_func_push(parser_data, options_parse_layout, options_parse_layout_end, lw);
}
else
{
- DEBUG_1("unexpected in <toplevel>: <%s>", element_name);
+ log_printf("unexpected in <toplevel>: <%s>\n", element_name);
options_parse_func_push(parser_data, options_parse_leaf, NULL, NULL);
}
}
{
GQParserStartFunc start_func;
GQParserEndFunc end_func;
-// GQParserTextFunc text_func;
gpointer data;
};
const gchar **attribute_names,
const gchar **attribute_values,
gpointer user_data,
- GError **error)
+ GError **error)
{
GQParserData *parser_data = user_data;
- GQParserFuncData *func = parser_data->parse_func_stack->data;
- DEBUG_1("start %s", element_name);
+ GQParserFuncData *func = parser_data->parse_func_stack->data;
+ DEBUG_2("start %s", element_name);
if (func->start_func)
func->start_func(parser_data, context, element_name, attribute_names, attribute_values, func->data, error);
static void end_element(GMarkupParseContext *context,
const gchar *element_name,
gpointer user_data,
- GError **error)
+ GError **error)
{
GQParserData *parser_data = user_data;
- GQParserFuncData *func = parser_data->parse_func_stack->data;
- DEBUG_1("end %s", element_name);
+ GQParserFuncData *func = parser_data->parse_func_stack->data;
+ DEBUG_2("end %s", element_name);
if (func->end_func)
func->end_func(parser_data, context, element_name, func->data, error);
*-----------------------------------------------------------------------------
*/
-gboolean load_options_from(const gchar *utf8_path, ConfOptions *options, gboolean startup)
+gboolean load_config_from_buf(const gchar *buf, gsize size, gboolean startup)
{
- gsize size;
- gchar *buf;
GMarkupParseContext *context;
gboolean ret = TRUE;
GQParserData *parser_data;
- if (g_file_get_contents(utf8_path, &buf, &size, NULL) == FALSE)
- {
- return FALSE;
- }
-
parser_data = g_new0(GQParserData, 1);
parser_data->startup = startup;
g_free(parser_data);
- g_free(buf);
g_markup_parse_context_free(context);
return ret;
}
+
+gboolean load_config_from_file(const gchar *utf8_path, gboolean startup)
+{
+ gsize size;
+ gchar *buf;
+ gboolean ret = TRUE;
+
+ if (g_file_get_contents(utf8_path, &buf, &size, NULL) == FALSE)
+ {
+ return FALSE;
+ }
+ ret = load_config_from_buf(buf, size, startup);
+ g_free(buf);
+ return ret;
+}