[nautilus] canvas-view: make sure to sort by relevance and select first item
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus] canvas-view: make sure to sort by relevance and select first item
- Date: Mon, 10 Sep 2012 04:48:58 +0000 (UTC)
commit ce6b6ef83859e62147a4e047e5e6394c053fb282
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Thu Sep 6 17:22:10 2012 -0400
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
libnautilus-private/nautilus-canvas-container.c | 5 +++++
src/nautilus-actions.h | 1 +
src/nautilus-canvas-view-ui.xml | 1 +
src/nautilus-canvas-view.c | 20 +++++++++++++++++++-
4 files changed, 26 insertions(+), 1 deletions(-)
---
diff --git a/libnautilus-private/nautilus-canvas-container.c b/libnautilus-private/nautilus-canvas-container.c
index 6f5914d..de493d4 100644
--- a/libnautilus-private/nautilus-canvas-container.c
+++ b/libnautilus-private/nautilus-canvas-container.c
@@ -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);
diff --git a/src/nautilus-actions.h b/src/nautilus-actions.h
index 7435741..012589c 100644
--- a/src/nautilus-actions.h
+++ b/src/nautilus-actions.h
@@ -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 */
diff --git a/src/nautilus-canvas-view-ui.xml b/src/nautilus-canvas-view-ui.xml
index 394c0fd..5a3b313 100644
--- a/src/nautilus-canvas-view-ui.xml
+++ b/src/nautilus-canvas-view-ui.xml
@@ -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"/>
diff --git a/src/nautilus-canvas-view.c b/src/nautilus-canvas-view.c
index c978321..d262a4e 100644
--- a/src/nautilus-canvas-view.c
+++ b/src/nautilus-canvas-view.c
@@ -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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]