diff options
author | Alexandru Pandelea <alexandru.pandelea@gmail.com> | 2016-02-24 14:16:31 +0200 |
---|---|---|
committer | Carlos Soriano <csoriano@gnome.org> | 2016-02-24 14:01:14 +0100 |
commit | 9a3f6a9f4c66e527dc3c962ed175fb00d6db8f62 (patch) | |
tree | d9aad781f9a57eceddcb522b44ec9aeb6eea5fb7 /src/nautilus-search-popover.c | |
parent | 0bdd6cd2bb101d2fbe3959eeaa72ccea696bf5f4 (diff) | |
download | nautilus-9a3f6a9f4c66e527dc3c962ed175fb00d6db8f62.tar.gz |
Search popover: limit options to max 5 years
The list displayed too many options for older dates.
In order to limit this, the max_days variable was decreased to
the number of days corresponding to 5 years
The value of the step for months was updated to the proper value, 90.
The days variable contained an unnecessary offset. To prevent it,
for the first occurrence of each timeslice (month, week, year) there
was added an if clause to remove the offset
Due to limiting the max number of years displayed, there was removed
(a now redundant) else from the function get_text_for_date_range.
https://bugzilla.gnome.org/show_bug.cgi?id=762240
Diffstat (limited to 'src/nautilus-search-popover.c')
-rw-r--r-- | src/nautilus-search-popover.c | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/src/nautilus-search-popover.c b/src/nautilus-search-popover.c index 27b284420..e51f01c63 100644 --- a/src/nautilus-search-popover.c +++ b/src/nautilus-search-popover.c @@ -25,6 +25,8 @@ #include <libnautilus-private/nautilus-ui-utilities.h> #include <libnautilus-private/nautilus-global-preferences.h> + #define SEARCH_FILTER_MAX_YEARS 5 + struct _NautilusSearchPopover { GtkPopover parent; @@ -378,7 +380,7 @@ fill_fuzzy_dates_listbox (NautilusSearchPopover *popover) days = 1; maximum_dt = g_date_time_new_from_unix_local (0); now = g_date_time_new_now_local (); - max_days = (g_date_time_get_year (now) - g_date_time_get_year (maximum_dt)) * 365; + max_days = SEARCH_FILTER_MAX_YEARS * 365; current_date = g_date_time_new_now_local (); /* Add the no date filter element first */ @@ -386,10 +388,12 @@ fill_fuzzy_dates_listbox (NautilusSearchPopover *popover) gtk_container_add (GTK_CONTAINER (popover->dates_listbox), row); /* This is a tricky loop. The main intention here is that each - * timeslice (day, week, month) have 2 or 3 entries. Years, - * however, are exceptions and should show many entries. + * timeslice (day, week, month) have 2 or 3 entries. + * + * For the first appearance of each timeslice, there is made a + * check in order to be sure that there is no offset added to days. */ - while (days < max_days) + while (days <= max_days) { gchar *label; gint normalized; @@ -405,26 +409,26 @@ fill_fuzzy_dates_listbox (NautilusSearchPopover *popover) { /* weeks */ normalized = days / 7; + if (normalized == 1) + days = 7; step = 7; } else if (days < 365) { /* months */ normalized = days / 30; - step = 84; + if (normalized == 1) + days = 30; + step = 90; } - else if (days < 1825) + else { /* years */ normalized = days / 365; + if (normalized == 1) + days = 365; step = 365; } - else - { - /* after the first 5 years, jump at a 5-year pace */ - normalized = days / 365; - step = 1825; - } current_date = g_date_time_add_days (now, -days); date_range = g_ptr_array_new_full (2, (GDestroyNotify) g_date_time_unref); |