Skip to content

Commit

Permalink
Optionnally display directory's date in list view.
Browse files Browse the repository at this point in the history
It can be set through Preferences > Advanced > Behavior and
is saved to rc file as layout.show_directory_date option.
  • Loading branch information
Laurent Monin committed Jun 13, 2008
1 parent 0a1ad21 commit c687f78
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ struct _ConfOptions

gint show_thumbnails;
gint show_marks;
gboolean show_directory_date;

struct {
gint w;
Expand Down
9 changes: 9 additions & 0 deletions src/preferences.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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);

Expand Down
2 changes: 2 additions & 0 deletions src/rcfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 */

Expand Down
1 change: 1 addition & 0 deletions src/view_dir.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ enum {
DIR_COLUMN_ICON,
DIR_COLUMN_NAME,
DIR_COLUMN_COLOR,
DIR_COLUMN_DATE,
DIR_COLUMN_COUNT
};

Expand Down
14 changes: 12 additions & 2 deletions src/view_dir_list.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ static void vdlist_populate(ViewDir *vd)
FileData *fd;
GtkTreeIter iter;
GdkPixbuf *pixbuf;
const gchar *date = "";

fd = work->data;

Expand All @@ -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
Expand All @@ -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;
}
Expand Down Expand Up @@ -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);

Expand All @@ -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;
Expand Down

0 comments on commit c687f78

Please sign in to comment.