Optionnally display directory's date in list view.
authorLaurent Monin <geeqie@norz.org>
Fri, 13 Jun 2008 11:11:57 +0000 (11:11 +0000)
committerLaurent Monin <geeqie@norz.org>
Fri, 13 Jun 2008 11:11:57 +0000 (11:11 +0000)
It can be set through Preferences > Advanced > Behavior and
is saved to rc file as layout.show_directory_date option.

src/options.c
src/options.h
src/preferences.c
src/rcfile.c
src/view_dir.h
src/view_dir_list.c

index 5442314..3838222 100644 (file)
@@ -107,6 +107,7 @@ ConfOptions *init_options(ConfOptions *options)
        options->layout.properties_window.w = DEF_PROPERTY_WIDTH;
        options->layout.properties_window.h = DEF_PROPERTY_HEIGHT;
        options->layout.save_window_positions = FALSE;
+       options->layout.show_directory_date = FALSE;
        options->layout.show_marks = FALSE;
        options->layout.show_thumbnails = FALSE;
        options->layout.style = 0;
index 142c3a9..34e06db 100644 (file)
@@ -165,6 +165,7 @@ struct _ConfOptions
 
                gint show_thumbnails;
                gint show_marks;
+               gboolean show_directory_date;
 
                struct {
                        gint w;
index 54ac521..c665769 100644 (file)
@@ -360,6 +360,12 @@ static void config_window_apply(void)
        g_free(layout_order);
        }
 
+       if (options->layout.show_directory_date != c_options->layout.show_directory_date)
+               {
+               options->layout.show_directory_date = c_options->layout.show_directory_date;
+               refresh = TRUE;
+               }
+
        image_options_sync();
 
        if (refresh)
@@ -1465,6 +1471,9 @@ static void config_tab_advanced(GtkWidget *notebook)
        pref_checkbox_new_int(group, _("Descend folders in tree view"),
                              options->tree_descend_subdirs, &c_options->tree_descend_subdirs);
 
+       pref_checkbox_new_int(group, _("Show date in directories list view"),
+                             options->layout.show_directory_date, &c_options->layout.show_directory_date);
+
        pref_checkbox_new_int(group, _("In place renaming"),
                              options->file_ops.enable_in_place_rename, &c_options->file_ops.enable_in_place_rename);
 
index 16947f9..b77a6b8 100644 (file)
@@ -376,6 +376,7 @@ static gboolean save_options_to(const gchar *utf8_path, ConfOptions *options)
        WRITE_UINT(layout.file_view_type);
        WRITE_BOOL(layout.show_marks);
        WRITE_BOOL(layout.show_thumbnails);
+       WRITE_BOOL(layout.show_directory_date);
        WRITE_SEPARATOR();
 
        WRITE_BOOL(layout.save_window_positions);
@@ -745,6 +746,7 @@ static gboolean load_options_from(const gchar *utf8_path, ConfOptions *options)
                READ_UINT(layout.file_view_type);
                READ_BOOL(layout.show_marks);
                READ_BOOL(layout.show_thumbnails);
+               READ_BOOL(layout.show_directory_date);
 
                /* window positions */
 
index fb55f95..a4534f6 100644 (file)
@@ -17,6 +17,7 @@ enum {
        DIR_COLUMN_ICON,
        DIR_COLUMN_NAME,
        DIR_COLUMN_COLOR,
+       DIR_COLUMN_DATE,
        DIR_COLUMN_COUNT
 };
 
index 579a6ac..bbc5025 100644 (file)
@@ -157,6 +157,7 @@ static void vdlist_populate(ViewDir *vd)
                FileData *fd;
                GtkTreeIter iter;
                GdkPixbuf *pixbuf;
+               const gchar *date = "";
 
                fd = work->data;
 
@@ -173,6 +174,8 @@ static void vdlist_populate(ViewDir *vd)
                        else
                                {
                                pixbuf = vd->pf->close;
+                               if (options->layout.show_directory_date)
+                                       date = text_from_time(fd->date);
                                }
                        }
                else
@@ -184,7 +187,9 @@ static void vdlist_populate(ViewDir *vd)
                gtk_list_store_set(store, &iter,
                                   DIR_COLUMN_POINTER, fd,
                                   DIR_COLUMN_ICON, pixbuf,
-                                  DIR_COLUMN_NAME, fd->name, -1);
+                                  DIR_COLUMN_NAME, fd->name,
+                                  DIR_COLUMN_DATE, date,
+                                  -1);
 
                work = work->next;
                }
@@ -368,7 +373,7 @@ ViewDir *vdlist_new(ViewDir *vd, FileData *dir_fd)
 
        VDLIST_INFO(vd, list) = NULL;
 
-       store = gtk_list_store_new(4, G_TYPE_POINTER, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_BOOLEAN);
+       store = gtk_list_store_new(5, G_TYPE_POINTER, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_STRING);
        vd->view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
        g_object_unref(store);
 
@@ -391,6 +396,11 @@ ViewDir *vdlist_new(ViewDir *vd, FileData *dir_fd)
        gtk_tree_view_column_add_attribute(column, renderer, "text", DIR_COLUMN_NAME);
        gtk_tree_view_column_set_cell_data_func(column, renderer, vd_color_cb, vd, NULL);
 
+       renderer = gtk_cell_renderer_text_new();
+       gtk_tree_view_column_pack_start(column, renderer, TRUE);
+       gtk_tree_view_column_add_attribute(column, renderer, "text", DIR_COLUMN_DATE);
+       gtk_tree_view_column_set_cell_data_func(column, renderer, vd_color_cb, vd, NULL);
+
        gtk_tree_view_append_column(GTK_TREE_VIEW(vd->view), column);
 
        return vd;