[nautilus/wip/antoniof/new-list-view-continuation: 19/32] view-icon-controller: Use metadata string as sort parameter
- From: António Fernandes <antoniof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/wip/antoniof/new-list-view-continuation: 19/32] view-icon-controller: Use metadata string as sort parameter
- Date: Thu, 21 Apr 2022 09:57:39 +0000 (UTC)
commit 6628285bc0c2905d45d4648cb7fd14925b27fea7
Author: António Fernandes <antoniof gnome org>
Date: Mon Feb 14 00:49:35 2022 +0000
view-icon-controller: Use metadata string as sort parameter
Except for the search relevance, there is a 1-for-1 correspondence
between each string. And there is no particular reason for search
relevance not to use a metadata string either: saving it doesn't change
the default sort for search directories anyway.
So, use the metadata string directly instead.
src/nautilus-view-icon-controller.c | 33 ++++----------------------
src/resources/ui/nautilus-toolbar-view-menu.ui | 6 ++---
2 files changed, 7 insertions(+), 32 deletions(-)
---
diff --git a/src/nautilus-view-icon-controller.c b/src/nautilus-view-icon-controller.c
index 16b789bca..0e41a045c 100644
--- a/src/nautilus-view-icon-controller.c
+++ b/src/nautilus-view-icon-controller.c
@@ -61,7 +61,6 @@ typedef struct
{
const NautilusFileSortType sort_type;
const gchar *metadata_name;
- const gchar *action_target_name;
} SortConstants;
static const SortConstants sorts_constants[] =
@@ -69,63 +68,39 @@ static const SortConstants sorts_constants[] =
{
NAUTILUS_FILE_SORT_BY_DISPLAY_NAME,
"name",
- "name",
},
{
NAUTILUS_FILE_SORT_BY_SIZE,
"size",
- "size",
},
{
NAUTILUS_FILE_SORT_BY_TYPE,
"type",
- "type",
},
{
NAUTILUS_FILE_SORT_BY_MTIME,
"modification date",
- "modification-date",
},
{
NAUTILUS_FILE_SORT_BY_ATIME,
"access date",
- "access-date",
},
{
NAUTILUS_FILE_SORT_BY_BTIME,
"creation date",
- "creation-date",
},
{
NAUTILUS_FILE_SORT_BY_TRASHED_TIME,
"trashed",
- "trash-time",
},
{
NAUTILUS_FILE_SORT_BY_SEARCH_RELEVANCE,
- NULL,
- "search-relevance",
+ "search_relevance",
}
};
static guint get_icon_size_for_zoom_level (NautilusGridZoomLevel zoom_level);
-static const SortConstants *
-get_sorts_constants_from_action_target_name (const gchar *action_target_name)
-{
- int i;
-
- for (i = 0; i < G_N_ELEMENTS (sorts_constants); i++)
- {
- if (g_strcmp0 (sorts_constants[i].action_target_name, action_target_name) == 0)
- {
- return &sorts_constants[i];
- }
- }
-
- return &sorts_constants[0];
-}
-
static const SortConstants *
get_sorts_constants_from_sort_type (NautilusFileSortType sort_type)
{
@@ -223,7 +198,7 @@ update_sort_order_from_metadata_and_preferences (NautilusViewIconController *sel
g_action_group_change_action_state (view_action_group,
"sort",
g_variant_new ("(sb)",
- default_directory_sort->action_target_name,
+ default_directory_sort->metadata_name,
reversed));
}
@@ -935,7 +910,7 @@ real_compare_files (NautilusFilesView *files_view,
view_action_group = nautilus_files_view_get_action_group (files_view);
action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group), "sort");
g_variant_get (g_action_get_state (action), "(&sb)", &target_name, &reversed);
- sort_constants = get_sorts_constants_from_action_target_name (target_name);
+ sort_constants = get_sorts_constants_from_metadata_text (target_name);
directories_first = nautilus_files_view_should_sort_directories_first (files_view);
return nautilus_file_compare_for_sort (file1, file2,
@@ -1141,7 +1116,7 @@ action_sort_order_changed (GSimpleAction *action,
self = NAUTILUS_VIEW_ICON_CONTROLLER (user_data);
g_variant_get (value, "(&sb)", &target_name, &self->reversed);
- sort_constants = get_sorts_constants_from_action_target_name (target_name);
+ sort_constants = get_sorts_constants_from_metadata_text (target_name);
self->sort_type = sort_constants->sort_type;
self->directories_first = nautilus_files_view_should_sort_directories_first (NAUTILUS_FILES_VIEW (self));
diff --git a/src/resources/ui/nautilus-toolbar-view-menu.ui b/src/resources/ui/nautilus-toolbar-view-menu.ui
index aa174889d..32d0e95cf 100644
--- a/src/resources/ui/nautilus-toolbar-view-menu.ui
+++ b/src/resources/ui/nautilus-toolbar-view-menu.ui
@@ -16,13 +16,13 @@
</item>
<item>
<attribute name="action">view.sort</attribute>
- <attribute name="target" type="(sb)">('modification-date',true)</attribute>
+ <attribute name="target" type="(sb)">('modification date',true)</attribute>
<attribute name="label" translatable="yes">Last _Modified</attribute>
<attribute name="hidden-when">action-disabled</attribute>
</item>
<item>
<attribute name="action">view.sort</attribute>
- <attribute name="target" type="(sb)">('modification-date',false)</attribute>
+ <attribute name="target" type="(sb)">('modification date',false)</attribute>
<attribute name="label" translatable="yes">_First Modified</attribute>
<attribute name="hidden-when">action-disabled</attribute>
</item>
@@ -40,7 +40,7 @@
</item>
<item>
<attribute name="action">view.sort</attribute>
- <attribute name="target" type="(sb)">('trash-time',true)</attribute>
+ <attribute name="target" type="(sb)">('trashed',true)</attribute>
<attribute name="label" translatable="yes">Last _Trashed</attribute>
<attribute name="hidden-when">action-disabled</attribute>
<attribute name="nautilus-menu-item">last_trashed</attribute>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]