[Nautilus-list] [PATCH] fix for bug 73469
- From: Diego González <diego pemas net>
- To: Nautilus List <nautilus-list lists eazel com>
- Subject: [Nautilus-list] [PATCH] fix for bug 73469
- Date: 22 Apr 2002 16:38:54 +0200
hi
the bug is about the list-view not saving the sorting of the columns.
i removed the function the functon get_attribute_from_sort_type from
fm-list-view.c and put a similar one in fm-list-model.c, becuase it
seems like the right place for it, there is a similar function there
that does the reverse mapping.
regards,
Diego
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/nautilus/ChangeLog,v
retrieving revision 1.5232
diff -u -r1.5232 ChangeLog
--- ChangeLog 22 Apr 2002 09:44:46 -0000 1.5232
+++ ChangeLog 22 Apr 2002 12:50:52 -0000
@@ -1,3 +1,17 @@
+2002-04-22 Diego González <diego pemas net>
+
+ * src/file-manager/fm-list-model.[c-h]
+ (fm_list_model_get_sort_column_id_from_attribute): fix typo
+ (fm_list_model_get_attribute_from_sort_column_id): implement
+
+ * src/file-manager/fm-list-view.c
+ (create_and_set_up_tree_view): connect to sort_column_changed signal of
+ the model
+ (rows_reordered_callback): implement, it stores the metadata of the
+ directory that is being viewed
+ (get_attribute_from_sort_type): remove, no longer needed
+ (real_get_default_sort_attribute): remove, no longer needed
+
2002-04-22 Anders Carlsson <andersca gnu org>
* src/nautilus-property-browser.c:
Index: src/file-manager/fm-list-model.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/fm-list-model.c,v
retrieving revision 1.11
diff -u -r1.11 fm-list-model.c
--- src/file-manager/fm-list-model.c 17 Apr 2002 12:38:27 -0000 1.11
+++ src/file-manager/fm-list-model.c 22 Apr 2002 12:50:52 -0000
@@ -22,6 +22,8 @@
Authors: Anders Carlsson <andersca gnu org>
*/
+#include <stdio.h>
+
#include <config.h>
#include "fm-list-model.h"
@@ -428,6 +430,7 @@
path = gtk_tree_path_new ();
iter.stamp = model->details->stamp;
iter.user_data = NULL;
+
gtk_tree_model_rows_reordered (GTK_TREE_MODEL (model),
path, NULL, new_order);
gtk_tree_path_free (path);
@@ -701,11 +704,29 @@
for (i = 0; i < G_N_ELEMENTS (attributes); i++) {
if (strcmp (attributes[i].attribute_name, attribute) == 0) {
- return i;
+ return attributes[i].sort_column_id;
}
}
return -1;
+}
+
+char *
+fm_list_model_get_attribute_from_sort_column_id (int sort_column_id)
+{
+ switch (sort_column_id) {
+ case FM_LIST_MODEL_NAME_COLUMN:
+ return g_strdup ("name");
+ case FM_LIST_MODEL_TYPE_COLUMN:
+ return g_strdup ("type");
+ case FM_LIST_MODEL_SIZE_COLUMN:
+ return g_strdup ("size");
+ case FM_LIST_MODEL_DATE_MODIFIED_COLUMN:
+ return g_strdup ("data_modified");
+ default:
+ g_warning ("unknown sort column id: %d", sort_column_id);
+ return g_strdup ("name");
+ }
}
int
Index: src/file-manager/fm-list-view.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/fm-list-view.c,v
retrieving revision 1.167
diff -u -r1.167 fm-list-view.c
--- src/file-manager/fm-list-view.c 18 Apr 2002 23:51:44 -0000 1.167
+++ src/file-manager/fm-list-view.c 22 Apr 2002 12:50:52 -0000
@@ -67,6 +67,7 @@
static GList * fm_list_view_get_selection (FMDirectoryView *view);
+
GNOME_CLASS_BOILERPLATE (FMListView, fm_list_view,
FMDirectoryView, FM_TYPE_DIRECTORY_VIEW)
@@ -178,6 +179,28 @@
}
static void
+rows_reordered_callback (GtkTreeSortable *sortable,
+ FMListView *view)
+{
+ NautilusFile *file;
+ gint sort_column_id;
+ GtkSortType order;
+ char *attr_column, *attr_order;
+
+ file = fm_directory_view_get_directory_as_file (FM_DIRECTORY_VIEW (view));
+ gtk_tree_sortable_get_sort_column_id (sortable, &sort_column_id, &order);
+
+ attr_column = fm_list_model_get_attribute_from_sort_column_id (sort_column_id);
+ nautilus_file_set_metadata (file, NAUTILUS_METADATA_KEY_LIST_VIEW_SORT_COLUMN, NULL, attr_column);
+
+ attr_order = g_strdup (order ? "true" : "false");
+ nautilus_file_set_metadata (file, NAUTILUS_METADATA_KEY_LIST_VIEW_SORT_REVERSED, NULL, attr_order);
+
+ g_free (attr_order);
+ g_free (attr_column);
+}
+
+static void
cell_renderer_edited (GtkCellRendererText *cell,
const char *path_str,
const char *new_text,
@@ -244,6 +267,10 @@
view->details->model = g_object_new (FM_TYPE_LIST_MODEL, NULL);
gtk_tree_view_set_model (view->details->tree_view, GTK_TREE_MODEL (view->details->model));
+
+ g_signal_connect_object (view->details->model, "sort_column_changed",
+ G_CALLBACK (rows_reordered_callback), view, 0);
+
g_object_unref (view->details->model);
gtk_tree_selection_set_mode (gtk_tree_view_get_selection (view->details->tree_view), GTK_SELECTION_MULTIPLE);
@@ -350,6 +377,7 @@
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (list_view->details->model),
sort_column_id,
sort_reversed ? GTK_SORT_DESCENDING : GTK_SORT_ASCENDING);
+
}
static void
@@ -493,42 +521,6 @@
TRUE);
}
-
-#if GNOME2_CONVERSION_COMPLETE
-
-/* This is needed when writing out the sort to metadata. But we don't
- * need this list here. We can probably do this using the table inside
- * FMListModel.
- */
-
-static char *
-get_attribute_from_sort_type (NautilusFileSortType sort_type)
-{
- switch (sort_type) {
- case NAUTILUS_FILE_SORT_BY_DISPLAY_NAME:
- return g_strdup ("name");
- case NAUTILUS_FILE_SORT_BY_SIZE:
- return g_strdup ("size");
- case NAUTILUS_FILE_SORT_BY_TYPE:
- return g_strdup ("type");
- case NAUTILUS_FILE_SORT_BY_MTIME:
- return g_strdup ("date_modified");
- case NAUTILUS_FILE_SORT_BY_EMBLEMS:
- return g_strdup ("emblems");
- default:
- g_warning ("unknown sort type %d in get_attribute_from_sort_type", sort_type);
- return g_strdup ("name");
- }
-}
-
-static char *
-real_get_default_sort_attribute (FMListView *view)
-{
- return get_attribute_from_sort_type (default_sort_order_auto_value);
-}
-
-#endif
-
static void
fm_list_view_sort_directories_first_changed (FMDirectoryView *view)
{
@@ -566,7 +558,6 @@
*/
#endif
}
-
static void
fm_list_view_class_init (FMListViewClass *class)
Index: src/file-manager/fm-list-model.h
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/fm-list-model.h,v
retrieving revision 1.3
diff -u -r1.3 fm-list-model.h
--- src/file-manager/fm-list-model.h 11 Mar 2002 10:17:49 -0000 1.3
+++ src/file-manager/fm-list-model.h 22 Apr 2002 12:50:52 -0000
@@ -72,5 +72,6 @@
gboolean sort_directories_first);
int fm_list_model_get_sort_column_id_from_attribute (const char *attribute);
int fm_list_model_get_sort_column_id_from_sort_type (NautilusFileSortType sort_type);
+char *fm_list_model_get_attribute_from_sort_column_id (int sort_column_id);
#endif /* FM_LIST_MODEL_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]