nautilus r14593 - in trunk: . libnautilus-private src/file-manager
- From: cneumair svn gnome org
- To: svn-commits-list gnome org
- Subject: nautilus r14593 - in trunk: . libnautilus-private src/file-manager
- Date: Sat, 6 Sep 2008 11:10:00 +0000 (UTC)
Author: cneumair
Date: Sat Sep 6 11:10:00 2008
New Revision: 14593
URL: http://svn.gnome.org/viewvc/nautilus?rev=14593&view=rev
Log:
2008-09-06 Christian Neumair <cneumair gnome org>
* libnautilus-private/nautilus-file.c
(nautilus_file_is_date_sort_attribute_q):
* libnautilus-private/nautilus-file.h:
Add nautilus_file_is_date_sort_attribute_q().
* src/file-manager/fm-list-view.c
(sort_criterion_changes_due_to_user),
(sort_column_changed_callback):
When manually switching to a date column, or to the default column
with âdefault_sort_in_reverse_orderâ active, auto-reverse sort order.
Fixes #533189.
Modified:
trunk/ChangeLog
trunk/libnautilus-private/nautilus-file.c
trunk/libnautilus-private/nautilus-file.h
trunk/src/file-manager/fm-list-view.c
Modified: trunk/libnautilus-private/nautilus-file.c
==============================================================================
--- trunk/libnautilus-private/nautilus-file.c (original)
+++ trunk/libnautilus-private/nautilus-file.c Sat Sep 6 11:10:00 2008
@@ -5508,6 +5508,21 @@
return nautilus_file_get_string_attribute_with_default_q (file, g_quark_from_string (attribute_name));
}
+gboolean
+nautilus_file_is_date_sort_attribute_q (GQuark attribute_q)
+{
+ if (attribute_q == attribute_modification_date_q ||
+ attribute_q == attribute_date_modified_q ||
+ attribute_q == attribute_accessed_date_q ||
+ attribute_q == attribute_date_accessed_q ||
+ attribute_q == attribute_date_changed_q ||
+ attribute_q == attribute_date_permissions_q) {
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
/**
* get_description:
*
Modified: trunk/libnautilus-private/nautilus-file.h
==============================================================================
--- trunk/libnautilus-private/nautilus-file.h (original)
+++ trunk/libnautilus-private/nautilus-file.h Sat Sep 6 11:10:00 2008
@@ -377,6 +377,8 @@
GQuark attribute,
gboolean directories_first,
gboolean reversed);
+gboolean nautilus_file_is_date_sort_attribute_q (GQuark attribute);
+
int nautilus_file_compare_display_name (NautilusFile *file_1,
const char *pattern);
Modified: trunk/src/file-manager/fm-list-view.c
==============================================================================
--- trunk/src/file-manager/fm-list-view.c (original)
+++ trunk/src/file-manager/fm-list-view.c Sat Sep 6 11:10:00 2008
@@ -40,6 +40,7 @@
#include <gtk/gtk.h>
#include <libegg/eggtreemultidnd.h>
#include <glib/gi18n.h>
+#include <glib-object.h>
#include <libgnome/gnome-macros.h>
#include <libnautilus-extension/nautilus-column-provider.h>
#include <libnautilus-private/nautilus-column-chooser.h>
@@ -103,6 +104,8 @@
NautilusFile *renaming_file;
gboolean rename_done;
guint renaming_file_activate_timeout;
+
+ GQuark last_sort_attr;
};
struct SelectionForeachData {
@@ -1005,12 +1008,34 @@
nautilus_file_list_free (selection);
}
+static gboolean
+sort_criterion_changes_due_to_user (GtkTreeView *tree_view)
+{
+ GList *columns, *p;
+ GtkTreeViewColumn *column;
+ GSignalInvocationHint *ihint;
+ unsigned int sort_signal_id;
+
+ sort_signal_id = g_signal_lookup ("clicked", gtk_tree_view_column_get_type ());
+
+ columns = gtk_tree_view_get_columns (tree_view);
+ for (p = columns; p != NULL; p = p->next) {
+ column = p->data;
+ ihint = g_signal_get_invocation_hint (column);
+ if (ihint != NULL) {
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
static void
sort_column_changed_callback (GtkTreeSortable *sortable,
FMListView *view)
{
NautilusFile *file;
- gint sort_column_id;
+ gint sort_column_id, default_sort_column_id;
GtkSortType reversed;
GQuark sort_attr, default_sort_attr;
char *reversed_attr, *default_reversed_attr;
@@ -1018,21 +1043,46 @@
file = fm_directory_view_get_directory_as_file (FM_DIRECTORY_VIEW (view));
gtk_tree_sortable_get_sort_column_id (sortable, &sort_column_id, &reversed);
-
sort_attr = fm_list_model_get_attribute_from_sort_column_id (view->details->model, sort_column_id);
- sort_column_id = fm_list_model_get_sort_column_id_from_attribute (view->details->model,
- g_quark_from_string (default_sort_order_auto_value));
- default_sort_attr = fm_list_model_get_attribute_from_sort_column_id (view->details->model, sort_column_id);
+
+ default_sort_column_id = fm_list_model_get_sort_column_id_from_attribute (view->details->model,
+ g_quark_from_string (default_sort_order_auto_value));
+ default_sort_attr = fm_list_model_get_attribute_from_sort_column_id (view->details->model, default_sort_column_id);
nautilus_file_set_metadata (file, NAUTILUS_METADATA_KEY_LIST_VIEW_SORT_COLUMN,
g_quark_to_string (default_sort_attr), g_quark_to_string (sort_attr));
default_reversed_attr = (default_sort_reversed_auto_value ? "true" : "false");
+
+ if (view->details->last_sort_attr != sort_attr &&
+ sort_criterion_changes_due_to_user (view->details->tree_view)) {
+ /* at this point, the sort order is always GTK_SORT_ASCENDING, if the sort column ID
+ * switched. Invert the sort order, if it's the default criterion with a reversed preference,
+ * or if it makes sense for the attribute (i.e. date). */
+ if (sort_attr == default_sort_attr) {
+ /* use value from preferences */
+ reversed = eel_preferences_get_boolean (NAUTILUS_PREFERENCES_LIST_VIEW_DEFAULT_SORT_IN_REVERSE_ORDER);
+ } else {
+ reversed = nautilus_file_is_date_sort_attribute_q (sort_attr);
+ }
+
+ if (reversed) {
+ g_signal_handlers_block_by_func (sortable, sort_column_changed_callback, view);
+ gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (view->details->model),
+ sort_column_id,
+ GTK_SORT_DESCENDING);
+ g_signal_handlers_unblock_by_func (sortable, sort_column_changed_callback, view);
+ }
+ }
+
+
reversed_attr = (reversed ? "true" : "false");
nautilus_file_set_metadata (file, NAUTILUS_METADATA_KEY_LIST_VIEW_SORT_REVERSED,
default_reversed_attr, reversed_attr);
/* Make sure selected item(s) is visible after sort */
fm_list_view_reveal_selection (FM_DIRECTORY_VIEW (view));
+
+ view->details->last_sort_attr = sort_attr;
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]