Add custom date format and alternating row colors in list view#3741
Add custom date format and alternating row colors in list view#3741StefanL38 wants to merge 2 commits into
Conversation
New features: - Custom date format option in Edit → Preferences → Display - New "Custom…" entry in the Format dropdown - Format tokens: YYYY, YY, MM, DD, HH, hh, mm, SS - Example: YYYY.MM.DD HH:mm → 2026.03.21 11:25 - Changes apply immediately without restart - Auto-fit button: sets all date columns to text width + saved padding - Save padding button: saves current padding as new default - Alternating row colors (white / light gray #ebebeb) in list view - Configurable via Edit → Preferences → Views → List View Defaults - Enabled by default - Implemented via GtkCellRenderer::cell-background (cell data functions) - Full i18n: all new UI strings in English source + German translations in po/de_custom.po Modified files: - libnemo-private/org.nemo.gschema.xml: new keys date-format-custom, date-column-autosize, date-column-padding, list-view-alternating-rows - libnemo-private/nemo-global-preferences.h/.c: new preference constants and cache variable - libnemo-private/nemo-file.h/.c: nemo_custom_date_format_to_strftime(), nemo_file_get_sample_date_string(), NEMO_DATE_FORMAT_CUSTOM case - src/nemo-file-management-properties.c: custom format entry, auto-fit/save-padding buttons, combo change handler - src/nemo-list-view.c: icon_cell_data_func, text_cell_data_func, set_row_background helper; alternating rows via cell-background - gresources/nemo-file-management-properties.glade: new widgets for custom format box and buttons - po/de_custom.po: German translations for all new UI strings
Change checkbox label and tooltip from German to English source strings (following gettext convention: source strings in English, translations in .po files). Add German translations for both strings to de_custom.po.
| gtk_tree_path_free (path); | ||
|
|
||
| g_object_set (renderer, | ||
| "cell-background", odd ? "#ebebeb" : NULL, |
There was a problem hiding this comment.
Hard coding a color is a terrible idea. Ina a dark theme, you would get light text against a light background. This has to be tied to the theme colors to work.
I also wouldn't space your code into columns like you are doing a few places right here. Just use normal spacing.
| gpointer user_data) | ||
| { | ||
| gint col_num = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (renderer), "model-column-num")); | ||
| gchar *text = NULL; |
There was a problem hiding this comment.
Same here. Don't space things this way just so they line up. It's fine for the function arguments, but not really here.
|
Hi, thanks for the submission, but I think we'll pass on this. General observations:
Specific observations: Zebra stripingThis should be left up to the Gtk theme, not hardcoded. This is just adding complexity to the rendering of the view. This is stated in the documentation (for the 'rules-hint' property, which used to provide a programmatic method you're re-implementing here. Custom dateThis is overkill here - if there is another, specific useful format we're not covering in the list, we could add it. It's definitely not worth the added complexity here in the list view (which I'm not sure is necessary in the first place - the column should size to fit). |
Just a quick note. I don't think this has been supported in Gtk themes for quite awhile. |
|
Either way, I don't think it's something that needs to be resurrected. |
Summary
This PR adds two new features to the Nemo list view:
1. Custom Date Format
A new "Custom…" option in the date format dropdown under
Edit → Preferences → Display.
When selected, a text field appears where the user can enter a
format string using the following tokens:
Example:
YYYY.MM.DD HH:mm→2026.03.21 14:35Changes apply immediately without restarting Nemo.
Two additional buttons allow managing date column widths:
2. Alternating Row Colors
A new checkbox "Alternating row colors (white / light gray)" under
Edit → Preferences → Views → List View Defaults.
When enabled, odd rows are displayed with a light gray background (
#ebebeb) and even rows with the default background. This improves readability in long file lists.Enabled by default.
Implementation note: CSS
nth-childselectors are not reliable forGtkTreeViewrows in GTK3 (row nodes are recycled dynamically). The alternating background is therefore implemented viaGtkCellRenderer::cell-backgroundusing cell data functions, which is the only robust approach in GTK3.Changed files
libnemo-private/org.nemo.gschema.xml– new keys:date-format-custom,date-column-autosize,date-column-padding,list-view-alternating-rowslibnemo-private/nemo-global-preferences.h/.c– new preference constants and cached format stringlibnemo-private/nemo-file.h/.c–nemo_custom_date_format_to_strftime(),nemo_file_get_sample_date_string(),NEMO_DATE_FORMAT_CUSTOMcasesrc/nemo-file-management-properties.c– custom format entry widget, Auto-fit and Save padding buttons, combo change handlersrc/nemo-list-view.c–set_row_background(),icon_cell_data_func(),text_cell_data_func()for alternating rowsgresources/nemo-file-management-properties.glade– new widgets for custom format box, buttons, and alternating rows checkboxpo/de_custom.po– German translations for all new UI strings