Fix #207: Symlink doesn't show in Sort Manager
authorColin Clark <colin.clark@cclark.uk>
Sat, 30 Sep 2017 09:25:33 +0000 (10:25 +0100)
committerColin Clark <colin.clark@cclark.uk>
Sat, 30 Sep 2017 09:25:33 +0000 (10:25 +0100)
https://github.com/BestImageViewer/geeqie/issues/207

src/bar_sort.c
src/bar_sort.h
src/layout_util.c
src/rcfile.c
src/typedefs.h

index 2b91550..705988e 100644 (file)
@@ -763,6 +763,44 @@ GtkWidget *bar_sort_new_from_config(LayoutWindow *lw, const gchar **attribute_na
        return bar;
 }
 
+/**
+ * @brief Sets the bar_sort_enabled flag
+ * @param lw 
+ * @param attribute_names 
+ * @param attribute_values 
+ * 
+ * Called from rcfile when processing geeqierc.xml on start-up.
+ * It is neccesary to set the bar_sort_enabled flag because
+ * the sort manager and desktop files are set up in the idle loop, and
+ * setup is not yet completed during initialisation.
+ * The flag is checked in layout_editors_reload_idle_cb.
+ * action, mode, selection and filter_key are ignored.
+ */
+void bar_sort_cold_start(LayoutWindow *lw, const gchar **attribute_names, const gchar **attribute_values)
+{
+       gboolean enabled = TRUE;
+       gint action = 0;
+       gint mode = 0;
+       gint selection = 0;
+       gchar *filter_key = NULL;
+
+       while (attribute_names && *attribute_names)
+               {
+               const gchar *option = *attribute_names++;
+               const gchar *value = *attribute_values++;
+
+               if (READ_BOOL_FULL("enabled", enabled)) continue;
+               if (READ_INT_CLAMP_FULL("action", action, 0, BAR_SORT_ACTION_COUNT - 1)) continue;
+               if (READ_INT_CLAMP_FULL("mode", mode, 0, BAR_SORT_MODE_COUNT - 1)) continue;
+               if (READ_INT_CLAMP_FULL("selection", selection, 0, BAR_SORT_SELECTION_COUNT - 1)) continue;
+               if (READ_CHAR_FULL("filter_key", filter_key)) continue;
+
+               log_printf("unknown attribute %s = %s\n", option, value);
+               }
+
+       lw->bar_sort_enabled = enabled;
+}
+
 GtkWidget *bar_sort_new_default(LayoutWindow *lw)
 {
        return bar_sort_new_from_config(lw, NULL, NULL);
index cb3c843..d26d257 100644 (file)
@@ -28,6 +28,6 @@ GtkWidget *bar_sort_new_from_config(LayoutWindow *lw, const gchar **attribute_na
 void bar_sort_close(GtkWidget *bar);
 
 void bar_sort_write_config(GtkWidget *bar, GString *outstr, gint indent);
-
+void bar_sort_cold_start(LayoutWindow *lw, const gchar **attribute_names, const gchar **attribute_values);
 #endif
 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */
index 72e1d6c..4fdd4c1 100644 (file)
@@ -2528,6 +2528,10 @@ static gboolean layout_editors_reload_idle_cb(gpointer data)
                        LayoutWindow *lw = work->data;
                        work = work->next;
                        layout_actions_setup_editors(lw);
+                       if (lw->bar_sort_enabled)
+                               {
+                               layout_bar_sort_toggle(lw);
+                               }
                        }
 
                DEBUG_1("%s layout_editors_reload_idle_cb: setup_editors done", get_exec_time());
index 460a46c..2ac5922 100644 (file)
@@ -1099,17 +1099,11 @@ static void options_parse_layout(GQParserData *parser_data, GMarkupParseContext
 
                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);
+               bar_sort_cold_start(lw, attribute_names, attribute_values);
                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_and_statusbar, NULL, NULL);
index 9327e35..9d78ddd 100644 (file)
@@ -775,7 +775,7 @@ struct _LayoutWindow
        GtkWidget *bar_sort;
        GtkWidget *bar;
 
-//     gint bar_sort_enabled;
+       gboolean bar_sort_enabled; /* Set during start-up, and checked when the editors have loaded */
 //     gint bar_enabled;
 
 //     gint bar_width;