Skip to content

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

Open
StefanL38 wants to merge 2 commits intolinuxmint:masterfrom
StefanL38:custom-date-format-alternating-rows
Open

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

Conversation

@StefanL38
Copy link

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.
gtk_tree_path_free (path);

g_object_set (renderer,
"cell-background", odd ? "#ebebeb" : NULL,
Copy link
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.

gpointer user_data)
{
gint col_num = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (renderer), "model-column-num"));
gchar *text = NULL;
Copy link
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.

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.

2 participants