Skip to content

Add custom date format and alternating row colors in list view#3741

Closed
StefanL38 wants to merge 2 commits into
linuxmint:masterfrom
StefanL38:custom-date-format-alternating-rows
Closed

Add custom date format and alternating row colors in list view#3741
StefanL38 wants to merge 2 commits into
linuxmint:masterfrom
StefanL38:custom-date-format-alternating-rows

Conversation

@StefanL38
Copy link
Copy Markdown

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:

Token Meaning Example
YYYY 4-digit year 2026
YY 2-digit year 26
MM Month 01–12 03
DD Day 01–31 21
HH Hour 00–23 (24h) 14
hh Hour 01–12 (12h) 02
mm Minute 00–59 35
SS Second 00–59 07

Example: YYYY.MM.DD HH:mm2026.03.21 14:35

Changes apply immediately without restarting Nemo.

Two additional buttons allow managing date column widths:

  • Auto-fit: sets all date column widths to text width plus a saved padding value
  • Save padding: saves the current padding as the new default for Auto-fit

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-child selectors are not reliable for GtkTreeView rows in GTK3 (row nodes are recycled dynamically). The alternating background is therefore implemented via GtkCellRenderer::cell-background using 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-rows
  • libnemo-private/nemo-global-preferences.h/.c – new preference constants and cached format string
  • libnemo-private/nemo-file.h/.cnemo_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 widget, Auto-fit and Save padding buttons, combo change handler
  • src/nemo-list-view.cset_row_background(), icon_cell_data_func(), text_cell_data_func() for alternating rows
  • gresources/nemo-file-management-properties.glade – new widgets for custom format box, buttons, and alternating rows checkbox
  • po/de_custom.po – German translations for all new UI strings

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.
Comment thread src/nemo-list-view.c
gtk_tree_path_free (path);

g_object_set (renderer,
"cell-background", odd ? "#ebebeb" : NULL,
Copy link
Copy Markdown
Contributor

@JosephMcc JosephMcc Mar 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/nemo-list-view.c
gpointer user_data)
{
gint col_num = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (renderer), "model-column-num"));
gchar *text = NULL;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here. Don't space things this way just so they line up. It's fine for the function arguments, but not really here.

@mtwebster
Copy link
Copy Markdown
Member

Hi, thanks for the submission, but I think we'll pass on this.

General observations:

  • PRs should be tightly focused on a single improvement, fix or feature. There are at least two to three unrelated sets of changes here.
  • Don't update translations - that gets done via Launchpad imports. Anything changed here will get overwritten before the next major release.

Specific observations:

Zebra striping

This 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 date

This 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).

@mtwebster mtwebster closed this May 29, 2026
@JosephMcc
Copy link
Copy Markdown
Contributor

This should be left up to the Gtk theme, not hardcoded

Just a quick note. I don't think this has been supported in Gtk themes for quite awhile.

@mtwebster
Copy link
Copy Markdown
Member

Either way, I don't think it's something that needs to be resurrected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants