Commit ce6b6ef8 authored by Cosimo Cecchi's avatar Cosimo Cecchi

canvas-view: make sure to sort by relevance and select first item

We also need to add a corresponding action/menu item, which is visible
only when we're in a search directory.

https://bugzilla.gnome.org/show_bug.cgi?id=681758
parent 1adea014
......@@ -6795,6 +6795,11 @@ nautilus_canvas_container_select_first (NautilusCanvasContainer *container)
selection_changed = FALSE;
if (container->details->needs_resort) {
resort (container);
container->details->needs_resort = FALSE;
}
icon = g_list_nth_data (container->details->icons, 0);
if (icon) {
selection_changed |= icon_set_selected (container, icon, TRUE);
......
......@@ -129,5 +129,6 @@
#define NAUTILUS_ACTION_UNSTRETCH "Unstretch"
#define NAUTILUS_ACTION_ZOOM_ITEMS "Zoom Items"
#define NAUTILUS_ACTION_SORT_TRASH_TIME "Sort by Trash Time"
#define NAUTILUS_ACTION_SORT_SEARCH_RELEVANCE "Sort by Search Relevance"
#endif /* NAUTILUS_ACTIONS_H */
......@@ -8,6 +8,7 @@
<menuitem name="Sort by Type" action="Sort by Type"/>
<menuitem name="Sort by Modification Date" action="Sort by Modification Date"/>
<menuitem name="Sort by Trash Time" action="Sort by Trash Time"/>
<menuitem name="Sort by Search Relevance" action="Sort by Search Relevance"/>
</placeholder>
<separator name="Layout separator"/>
<menuitem name="Reversed Order" action="Reversed Order"/>
......
......@@ -143,6 +143,11 @@ static const SortCriterion sort_criteria[] = {
NAUTILUS_FILE_SORT_BY_TRASHED_TIME,
"trashed",
NAUTILUS_ACTION_SORT_TRASH_TIME
},
{
NAUTILUS_FILE_SORT_BY_SEARCH_RELEVANCE,
NULL,
NAUTILUS_ACTION_SORT_SEARCH_RELEVANCE,
}
};
......@@ -574,6 +579,15 @@ update_layout_menus (NautilusCanvasView *view)
} else {
gtk_action_set_visible (action, FALSE);
}
action = gtk_action_group_get_action (view->details->canvas_action_group,
NAUTILUS_ACTION_SORT_SEARCH_RELEVANCE);
if (file != NULL && nautilus_file_is_in_search (file)) {
gtk_action_set_visible (action, TRUE);
} else {
gtk_action_set_visible (action, FALSE);
}
}
action = gtk_action_group_get_action (view->details->canvas_action_group,
......@@ -785,7 +799,7 @@ get_sort_criterion_by_metadata_text (const char *metadata_text)
/* Figure out what the new sort setting should be. */
for (i = 0; i < G_N_ELEMENTS (sort_criteria); i++) {
if (strcmp (sort_criteria[i].metadata_text, metadata_text) == 0) {
if (g_strcmp0 (sort_criteria[i].metadata_text, metadata_text) == 0) {
return &sort_criteria[i];
}
}
......@@ -1174,6 +1188,10 @@ static const GtkRadioActionEntry arrange_radio_entries[] = {
N_("By T_rash Time"), NULL,
N_("Keep icons sorted by trash time in rows"),
NAUTILUS_FILE_SORT_BY_TRASHED_TIME },
{ NAUTILUS_ACTION_SORT_SEARCH_RELEVANCE, NULL,
N_("By Search Relevance"), NULL,
N_("Keep icons sorted by search relevance in rows"),
NAUTILUS_FILE_SORT_BY_SEARCH_RELEVANCE },
};
static void
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment