Sort by name and date in folder list view
[geeqie.git] / src / layout.c
index 8f6c51a..6f5e209 100644 (file)
@@ -347,8 +347,8 @@ static GtkWidget *layout_tool_setup(LayoutWindow *lw)
        DEBUG_NAME(box_folders);
        gtk_box_pack_start(GTK_BOX(box), box_folders, TRUE, TRUE, 0);
 
-       lw->vd = vd_new(lw->options.dir_view_type, lw->dir_fd);
-       vd_set_layout(lw->vd, lw);
+       lw->vd = vd_new(lw);
+
        vd_set_select_func(lw->vd, layout_vd_select_cb, lw);
 
        lw->dir_view = lw->vd->widget;
@@ -1344,6 +1344,18 @@ void layout_views_set(LayoutWindow *lw, DirViewType dir_view_type, FileViewType
        layout_style_set(lw, -1, NULL);
 }
 
+void layout_views_set_sort(LayoutWindow *lw, SortType method, gboolean ascend)
+{
+       if (!layout_valid(&lw)) return;
+
+       if (lw->options.dir_view_list_sort.method == method && lw->options.dir_view_list_sort.ascend == ascend) return;
+
+       lw->options.dir_view_list_sort.method = method;
+       lw->options.dir_view_list_sort.ascend = ascend;
+
+       layout_style_set(lw, -1, NULL);
+}
+
 gboolean layout_views_get(LayoutWindow *lw, DirViewType *dir_view_type, FileViewType *file_view_type)
 {
        if (!layout_valid(&lw)) return FALSE;
@@ -2564,6 +2576,8 @@ void layout_write_attributes(LayoutOptions *layout, GString *outstr, gint indent
        WRITE_NL(); WRITE_CHAR(*layout, order);
        WRITE_NL(); WRITE_UINT(*layout, dir_view_type);
        WRITE_NL(); WRITE_UINT(*layout, file_view_type);
+       WRITE_NL(); WRITE_UINT(*layout, dir_view_list_sort.method);
+       WRITE_NL(); WRITE_BOOL(*layout, dir_view_list_sort.ascend);
        WRITE_NL(); WRITE_BOOL(*layout, show_marks);
        WRITE_NL(); WRITE_BOOL(*layout, show_file_filter);
        WRITE_NL(); WRITE_BOOL(*layout, show_thumbnails);
@@ -2663,6 +2677,8 @@ void layout_load_attributes(LayoutOptions *layout, const gchar **attribute_names
 
                if (READ_UINT(*layout, dir_view_type)) continue;
                if (READ_UINT(*layout, file_view_type)) continue;
+               if (READ_UINT(*layout, dir_view_list_sort.method)) continue;
+               if (READ_BOOL(*layout, dir_view_list_sort.ascend)) continue;
                if (READ_BOOL(*layout, show_marks)) continue;
                if (READ_BOOL(*layout, show_file_filter)) continue;
                if (READ_BOOL(*layout, show_thumbnails)) continue;