Re: [Nautilus-list] [PATCH] fix for bug 73469



here is a new patch with the changes:


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	23 Apr 2002 21:21:32 -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-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	23 Apr 2002 21:21:32 -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 = (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.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	23 Apr 2002 21:21:32 -0000
@@ -55,12 +55,12 @@
 
 static const AttributeEntry attributes[] = {
 	{ "name", FM_LIST_MODEL_NAME_COLUMN },
-	{ "icon", FM_LIST_MODEL_TYPE_COLUMN },
+	{ "type", FM_LIST_MODEL_TYPE_COLUMN },
 #ifdef GNOME2_CONVERSION_COMPLETE
 	{ "emblems", FM_LIST_MODEL_EMBLEMS_COLUMN },
 #endif
 	{ "size", FM_LIST_MODEL_SIZE_COLUMN },
-	{ "type", FM_LIST_MODEL_TYPE_COLUMN },
+	{ "icon", FM_LIST_MODEL_TYPE_COLUMN },
 	{ "date_modified", FM_LIST_MODEL_DATE_MODIFIED_COLUMN },
 };
 
@@ -428,6 +428,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 +702,42 @@
 
 	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)
+{
+	int i;
+
+	for (i = 0; i < G_N_ELEMENTS (attributes); i++) {
+		if (attributes[i].sort_column_id == sort_column_id) {
+			return g_strdup (attributes[i].attribute_name);
+		}
+	}
+
+	g_warning ("unknown sort column id: %d", sort_column_id);
+	return g_strdup ("name");
+
+/*
+	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-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	23 Apr 2002 21:21:32 -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]