Remember keywords layout
[geeqie.git] / src / rcfile.c
index a62ff7e..52aa2b9 100644 (file)
@@ -1,13 +1,22 @@
 /*
- * Geeqie
- * (C) 2006 John Ellis
- * Copyright (C) 2008 - 2012 The Geeqie Team
+ * Copyright (C) 2006 John Ellis
+ * Copyright (C) 2008 - 2016 The Geeqie Team
  *
  * Author: John Ellis
  *
- * This software is released under the GNU General Public License (GNU GPL).
- * Please read the included file COPYING for more information.
- * This software comes with no warranty of any kind, use at your own risk!
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
 #include <glib/gstdio.h>
@@ -34,6 +43,7 @@
 #include "bar.h"
 #include "metadata.h"
 #include "bar_gps.h"
+#include "dupe.h"
 
 
 /*
@@ -148,6 +158,31 @@ gboolean read_int_option(const gchar *option, const gchar *label, const gchar *v
        return TRUE;
 }
 
+void write_ushort_option(GString *str, gint indent, const gchar *label, guint16 n)
+{
+       g_string_append_printf(str, "%s = \"%uh\" ", label, n);
+}
+
+gboolean read_ushort_option(const gchar *option, const gchar *label, const gchar *value, guint16 *n)
+{
+       if (g_ascii_strcasecmp(option, label) != 0) return FALSE;
+       if (!n) return FALSE;
+
+       if (g_ascii_isdigit(value[0]))
+               {
+               *n = strtoul(value, NULL, 10);
+               }
+       else
+               {
+               if (g_ascii_strcasecmp(value, "true") == 0)
+                       *n = 1;
+               else
+                       *n = 0;
+               }
+
+       return TRUE;
+}
+
 void write_uint_option(GString *str, gint indent, const gchar *label, guint n)
 {
        g_string_append_printf(str, "%s = \"%u\" ", label, n);
@@ -169,7 +204,7 @@ gboolean read_uint_option(const gchar *option, const gchar *label, const gchar *
                else
                        *n = 0;
                }
-       
+
        return TRUE;
 }
 
@@ -239,7 +274,7 @@ gboolean read_int_unit_option(const gchar *option, const gchar *label, const gch
 
        *n = l * subunits + r;
        g_free(buf);
-       
+
        return TRUE;
 }
 
@@ -274,21 +309,29 @@ static void write_global_attributes(GString *outstr, gint indent)
        WRITE_SEPARATOR();
 
        WRITE_NL(); WRITE_BOOL(*options, tree_descend_subdirs);
+       WRITE_NL(); WRITE_BOOL(*options, view_dir_list_single_click_enter);
        WRITE_NL(); WRITE_BOOL(*options, lazy_image_sync);
        WRITE_NL(); WRITE_BOOL(*options, update_on_time_change);
        WRITE_SEPARATOR();
 
        WRITE_NL(); WRITE_BOOL(*options, progressive_key_scrolling);
+       WRITE_NL(); WRITE_UINT(*options, keyboard_scroll_step);
 
        WRITE_NL(); WRITE_UINT(*options, duplicates_similarity_threshold);
+       WRITE_NL(); WRITE_UINT(*options, duplicates_match);
+       WRITE_NL(); WRITE_UINT(*options, duplicates_select_type);
+       WRITE_NL(); WRITE_BOOL(*options, duplicates_thumbnails);
+       WRITE_NL(); WRITE_BOOL(*options, rot_invariant_sim);
        WRITE_SEPARATOR();
 
        WRITE_NL(); WRITE_BOOL(*options, mousewheel_scrolls);
+       WRITE_NL(); WRITE_BOOL(*options, image_lm_click_nav);
        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_NL(); WRITE_BOOL(*options, save_window_positions);
+       WRITE_NL(); WRITE_BOOL(*options, use_saved_window_positions_for_new_windows);
        WRITE_NL(); WRITE_BOOL(*options, tools_restore_state);
 
        /* File operations Options */
@@ -315,6 +358,7 @@ static void write_global_attributes(GString *outstr, gint indent)
        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_INT(*options, image.max_enlargement_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);
@@ -323,6 +367,8 @@ static void write_global_attributes(GString *outstr, gint indent)
        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_COLOR(*options, image.alpha_color_1);
+       WRITE_NL(); WRITE_COLOR(*options, image.alpha_color_2);
        WRITE_NL(); WRITE_BOOL(*options, image.use_clutter_renderer);
 
        /* Thumbnails Options */
@@ -339,6 +385,7 @@ static void write_global_attributes(GString *outstr, gint indent)
        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);
+       WRITE_NL(); WRITE_BOOL(*options, file_sort.natural);
 
        /* Fullscreen Options */
        WRITE_NL(); WRITE_INT(*options, fullscreen.screen);
@@ -353,6 +400,15 @@ static void write_global_attributes(GString *outstr, gint indent)
 
        WRITE_NL(); WRITE_INT(*options, image_overlay.x);
        WRITE_NL(); WRITE_INT(*options, image_overlay.y);
+       WRITE_NL(); WRITE_INT(*options, image_overlay.text_red);
+       WRITE_NL(); WRITE_INT(*options, image_overlay.text_green);
+       WRITE_NL(); WRITE_INT(*options, image_overlay.text_blue);
+       WRITE_NL(); WRITE_INT(*options, image_overlay.text_alpha);
+       WRITE_NL(); WRITE_INT(*options, image_overlay.background_red);
+       WRITE_NL(); WRITE_INT(*options, image_overlay.background_green);
+       WRITE_NL(); WRITE_INT(*options, image_overlay.background_blue);
+       WRITE_NL(); WRITE_INT(*options, image_overlay.background_alpha);
+       WRITE_NL(); WRITE_CHAR(*options, image_overlay.font);
 
        /* Slideshow Options */
        WRITE_NL(); WRITE_INT_UNIT(*options, slideshow.delay, SLIDESHOW_SUBSECOND_PRECISION);
@@ -364,7 +420,9 @@ static void write_global_attributes(GString *outstr, gint indent)
 
        /* Filtering Options */
        WRITE_NL(); WRITE_BOOL(*options, file_filter.show_hidden_files);
+       WRITE_NL(); WRITE_BOOL(*options, file_filter.show_parent_directory);
        WRITE_NL(); WRITE_BOOL(*options, file_filter.show_dot_directory);
+       WRITE_NL(); WRITE_BOOL(*options, file_filter.disable_file_extension_checks);
        WRITE_NL(); WRITE_BOOL(*options, file_filter.disable);
        WRITE_SEPARATOR();
 
@@ -387,6 +445,7 @@ static void write_global_attributes(GString *outstr, gint indent)
        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_BOOL(*options, metadata.sidecar_extended_name);
        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);
@@ -419,6 +478,7 @@ static void write_color_profile(GString *outstr, gint indent)
        WRITE_BOOL(options->color_profile, use_image);
        WRITE_INT(options->color_profile, input_type);
        WRITE_BOOL(options->color_profile, use_x11_screen_profile);
+       WRITE_INT(options->color_profile, render_intent);
        WRITE_STRING(">");
 
        indent++;
@@ -447,7 +507,7 @@ gboolean save_config_to_file(const gchar *utf8_path, ConfOptions *options)
        GString *outstr;
        gint indent = 0;
        GList *work;
-       
+
        rc_pathl = path_from_utf8(utf8_path);
        ssi = secure_open(rc_pathl);
        g_free(rc_pathl);
@@ -472,7 +532,7 @@ gboolean save_config_to_file(const gchar *utf8_path, ConfOptions *options)
 
        WRITE_STRING("<gq>\n");
        indent++;
-       
+
        WRITE_NL(); WRITE_STRING("<global\n");
        indent++;
        write_global_attributes(outstr, indent + 1);
@@ -537,20 +597,28 @@ static gboolean load_global_params(const gchar **attribute_names, const gchar **
                if (READ_BOOL(*options, show_icon_names)) continue;
 
                if (READ_BOOL(*options, tree_descend_subdirs)) continue;
+               if (READ_BOOL(*options, view_dir_list_single_click_enter)) continue;
                if (READ_BOOL(*options, lazy_image_sync)) continue;
                if (READ_BOOL(*options, update_on_time_change)) continue;
 
                if (READ_UINT_CLAMP(*options, duplicates_similarity_threshold, 0, 100)) continue;
+               if (READ_UINT_CLAMP(*options, duplicates_match, 0, DUPE_MATCH_NAME_CI)) continue;
+               if (READ_UINT_CLAMP(*options, duplicates_select_type, 0, DUPE_SELECT_GROUP2)) continue;
+               if (READ_BOOL(*options, duplicates_thumbnails)) continue;
+               if (READ_BOOL(*options, rot_invariant_sim)) continue;
 
                if (READ_BOOL(*options, progressive_key_scrolling)) continue;
+               if (READ_UINT_CLAMP(*options, keyboard_scroll_step, 1, 32)) continue;
 
                if (READ_BOOL(*options, mousewheel_scrolls)) continue;
+               if (READ_BOOL(*options, image_lm_click_nav)) continue;
 
                if (READ_INT(*options, open_recent_list_maxsize)) continue;
                if (READ_INT(*options, dnd_icon_size)) continue;
                if (READ_BOOL(*options, place_dialogs_under_mouse)) continue;
 
                if (READ_BOOL(*options, save_window_positions)) continue;
+               if (READ_BOOL(*options, use_saved_window_positions_for_new_windows)) continue;
                if (READ_BOOL(*options, tools_restore_state)) continue;
 
                /* Properties dialog options */
@@ -565,6 +633,7 @@ static gboolean load_global_params(const gchar **attribute_names, const gchar **
                if (READ_INT(*options, image.max_window_size)) continue;
                if (READ_BOOL(*options, image.limit_autofit_size)) continue;
                if (READ_INT(*options, image.max_autofit_size)) continue;
+               if (READ_INT(*options, image.max_enlargement_size)) continue;
                if (READ_UINT_CLAMP(*options, image.scroll_reset_method, 0, PR_SCROLL_RESET_COUNT - 1)) continue;
                if (READ_INT(*options, image.tile_cache_max)) continue;
                if (READ_INT(*options, image.image_cache_max)) continue;
@@ -575,6 +644,8 @@ static gboolean load_global_params(const gchar **attribute_names, const gchar **
                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_COLOR(*options, image.alpha_color_1)) continue;
+               if (READ_COLOR(*options, image.alpha_color_2)) continue;
                if (READ_BOOL(*options, image.use_clutter_renderer)) continue;
 
                /* Thumbnails options */
@@ -592,6 +663,7 @@ static gboolean load_global_params(const gchar **attribute_names, const gchar **
                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;
+               if (READ_BOOL(*options, file_sort.natural)) continue;
 
                /* File operations *options */
                if (READ_BOOL(*options, file_ops.enable_in_place_rename)) continue;
@@ -611,6 +683,15 @@ static gboolean load_global_params(const gchar **attribute_names, const gchar **
                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;
+               if (READ_USHORT(*options, image_overlay.text_red)) continue;
+               if (READ_USHORT(*options, image_overlay.text_green)) continue;
+               if (READ_USHORT(*options, image_overlay.text_blue)) continue;
+               if (READ_USHORT(*options, image_overlay.text_alpha)) continue;
+               if (READ_USHORT(*options, image_overlay.background_red)) continue;
+               if (READ_USHORT(*options, image_overlay.background_green)) continue;
+               if (READ_USHORT(*options, image_overlay.background_blue)) continue;
+               if (READ_USHORT(*options, image_overlay.background_alpha)) continue;
+               if (READ_CHAR(*options, image_overlay.font)) continue;
 
                /* Slideshow options */
                if (READ_INT_UNIT(*options, slideshow.delay, SLIDESHOW_SUBSECOND_PRECISION)) continue;
@@ -622,7 +703,9 @@ static gboolean load_global_params(const gchar **attribute_names, const gchar **
 
                /* Filtering options */
                if (READ_BOOL(*options, file_filter.show_hidden_files)) continue;
+               if (READ_BOOL(*options, file_filter.show_parent_directory)) continue;
                if (READ_BOOL(*options, file_filter.show_dot_directory)) continue;
+               if (READ_BOOL(*options, file_filter.disable_file_extension_checks)) continue;
                if (READ_BOOL(*options, file_filter.disable)) continue;
                if (READ_CHAR(*options, sidecar.ext)) continue;
 
@@ -644,6 +727,7 @@ static gboolean load_global_params(const gchar **attribute_names, const gchar **
                if (READ_BOOL(*options, metadata.save_legacy_format)) continue;
                if (READ_BOOL(*options, metadata.sync_grouped_files)) continue;
                if (READ_BOOL(*options, metadata.confirm_write)) continue;
+               if (READ_BOOL(*options, metadata.sidecar_extended_name)) continue;
                if (READ_BOOL(*options, metadata.confirm_after_timeout)) continue;
                if (READ_INT(*options, metadata.confirm_timeout)) continue;
                if (READ_BOOL(*options, metadata.confirm_on_image_change)) continue;
@@ -683,6 +767,7 @@ static void options_load_color_profiles(GQParserData *parser_data, GMarkupParseC
                if (READ_INT(options->color_profile, input_type)) continue;
                if (READ_CHAR(options->color_profile, screen_file)) continue;
                if (READ_BOOL(options->color_profile, use_x11_screen_profile)) continue;
+               if (READ_INT(options->color_profile, render_intent)) continue;
 
                log_printf("unknown attribute %s = %s\n", option, value);
                }
@@ -727,7 +812,7 @@ static const gchar *options_get_id(const gchar **attribute_names, const gchar **
                {
                const gchar *option = *attribute_names++;
                const gchar *value = *attribute_values++;
-               
+
                if (strcmp(option, "id") == 0) return value;
 
                }
@@ -863,6 +948,22 @@ static void options_parse_pane_exif(GQParserData *parser_data, GMarkupParseConte
                }
 }
 
+static void options_parse_pane_keywords(GQParserData *parser_data, GMarkupParseContext *context, const gchar *element_name, const gchar **attribute_names, const gchar **attribute_values, gpointer data, GError **error)
+{
+       GtkWidget *pane = data;
+
+       if (g_ascii_strcasecmp(element_name, "expanded") == 0)
+               {
+               bar_pane_keywords_entry_add_from_config(pane, attribute_names, attribute_values);
+               options_parse_func_push(parser_data, options_parse_leaf, NULL, NULL);
+               }
+       else
+               {
+               log_printf("unexpected in <pane_keywords>: <%s>\n", element_name);
+               options_parse_func_push(parser_data, options_parse_leaf, NULL, NULL);
+               }
+}
+
 static void options_parse_bar(GQParserData *parser_data, GMarkupParseContext *context, const gchar *element_name, const gchar **attribute_names, const gchar **attribute_values, gpointer data, GError **error)
 {
        GtkWidget *bar = data;
@@ -938,7 +1039,7 @@ static void options_parse_bar(GQParserData *parser_data, GMarkupParseContext *co
                        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);
+               options_parse_func_push(parser_data, options_parse_pane_keywords, NULL, pane);
                }
        else if (g_ascii_strcasecmp(element_name, "clear") == 0)
                {
@@ -952,44 +1053,13 @@ static void options_parse_bar(GQParserData *parser_data, GMarkupParseContext *co
                }
 }
 
-static void options_parse_toolbar(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_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
-               {
-               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)
+/* Just a dummy function to parse out old leftovers
+ *
+ * This function can be cleaned somedays.
+ */
+static void options_parse_toolbar_and_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);
-               }
+       options_parse_func_push(parser_data, options_parse_leaf, NULL, NULL);
 }
 
 static void options_parse_layout(GQParserData *parser_data, GMarkupParseContext *context, const gchar *element_name, const gchar **attribute_names, const gchar **attribute_values, gpointer data, GError **error)
@@ -1006,22 +1076,27 @@ static void options_parse_layout(GQParserData *parser_data, GMarkupParseContext
                        {
                        bar_update_from_config(lw->bar, attribute_names, attribute_values);
                        }
-                       
+
                options_parse_func_push(parser_data, options_parse_bar, NULL, lw->bar);
                }
+#if 0
+/* FIXME: The sort manager and desktop files are set up in the idle loop.
+ * Setup is not yet completed when the layout is first displayed.
+ */
        else if (g_ascii_strcasecmp(element_name, "bar_sort") == 0)
                {
                GtkWidget *bar = bar_sort_new_from_config(lw, attribute_names, attribute_values);
                layout_bar_sort_set(lw, bar);
                options_parse_func_push(parser_data, options_parse_leaf, NULL, NULL);
                }
+#endif
        else if (g_ascii_strcasecmp(element_name, "toolbar") == 0)
                {
-               options_parse_func_push(parser_data, options_parse_toolbar, NULL, lw);
+               options_parse_func_push(parser_data, options_parse_toolbar_and_statusbar, NULL, NULL);
                }
        else if (g_ascii_strcasecmp(element_name, "statusbar") == 0)
                {
-               options_parse_func_push(parser_data, options_parse_statusbar, NULL, lw);
+               options_parse_func_push(parser_data, options_parse_toolbar_and_statusbar, NULL, NULL);
                }
        else
                {
@@ -1050,7 +1125,7 @@ static void options_parse_toplevel(GQParserData *parser_data, GMarkupParseContex
                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;
@@ -1096,7 +1171,7 @@ void options_parse_func_push(GQParserData *parser_data, GQParserStartFunc start_
        func_data->start_func = start_func;
        func_data->end_func = end_func;
        func_data->data = data;
-       
+
        parser_data->parse_func_stack = g_list_prepend(parser_data->parse_func_stack, func_data);
 }
 
@@ -1123,7 +1198,7 @@ static void start_element(GMarkupParseContext *context,
        GQParserData *parser_data = user_data;
        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);
 }
@@ -1164,10 +1239,10 @@ gboolean load_config_from_buf(const gchar *buf, gsize size, gboolean startup)
        GQParserData *parser_data;
 
        parser_data = g_new0(GQParserData, 1);
-       
+
        parser_data->startup = startup;
        options_parse_func_push(parser_data, options_parse_toplevel, NULL, NULL);
-       
+
        context = g_markup_parse_context_new(&parser, 0, parser_data, NULL);
 
        if (g_markup_parse_context_parse(context, buf, size, NULL) == FALSE)
@@ -1175,7 +1250,7 @@ gboolean load_config_from_buf(const gchar *buf, gsize size, gboolean startup)
                ret = FALSE;
                DEBUG_1("Parse failed");
                }
-               
+
        g_free(parser_data);
 
        g_markup_parse_context_free(context);
@@ -1196,7 +1271,7 @@ gboolean load_config_from_file(const gchar *utf8_path, gboolean startup)
        g_free(buf);
        return ret;
 }
-       
+
 
 
 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */