[Nautilus-list] emblems in the list view



Here's a patch to add emblems to the list view.

-dave


? INSTALL
? install-sh
? missing
? mkinstalldirs
? nautilus-emblems-column.patch
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/nautilus/ChangeLog,v
retrieving revision 1.5158
diff -u -r1.5158 ChangeLog
--- ChangeLog	25 Mar 2002 06:28:35 -0000	1.5158
+++ ChangeLog	25 Mar 2002 15:53:17 -0000
@@ -1,3 +1,17 @@
+2002-03-25  Dave Camp  <dave ximian com>
+
+	* src/file-manager/fm-list-model.c:
+	(fm_list_model_get_column_type),
+	(fm_list_model_get_value): Add back the emblems column
+	(fm_list_model_set_emblems_to_exclude),
+	(fm_list_model_get_emblem_pixbufs_for_file): New functions.
+	* src/file-manager/fm-list-model.h: Prototype for
+	fm_list_model_set_emblems_to_exclude.
+	* src/file-manager/fm-list-view.c: (create_and_set_up_tree_view):
+	Create the emblems column.
+	(fm_list_view_begin_loading): Pass the emblems_to_exclude to the
+	model.
+
 2002-03-25  Alexander Larsson  <alla lysator liu se>
 
 	* src/nautilus-location-bar.c: (style_set_handler):
Index: src/file-manager/fm-list-model.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/fm-list-model.c,v
retrieving revision 1.7
diff -u -r1.7 fm-list-model.c
--- src/file-manager/fm-list-model.c	11 Mar 2002 10:17:49 -0000	1.7
+++ src/file-manager/fm-list-model.c	25 Mar 2002 15:56:05 -0000
@@ -43,6 +43,8 @@
 	GtkSortType order;
 
 	gboolean sort_directories_first;
+
+	EelStringList *emblems_to_exclude;
 };
 
 typedef struct {
@@ -53,14 +55,13 @@
 static const AttributeEntry attributes[] = {
 	{ "name", FM_LIST_MODEL_NAME_COLUMN },
 	{ "icon", 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 },
 	{ "date_modified", FM_LIST_MODEL_DATE_MODIFIED_COLUMN },
 };
 
+
 static guint
 fm_list_model_get_flags (GtkTreeModel *tree_model)
 {
@@ -86,6 +87,8 @@
 		return G_TYPE_STRING;
 	case FM_LIST_MODEL_ICON_COLUMN:
 		return GDK_TYPE_PIXBUF;
+	case FM_LIST_MODEL_EMBLEMS_COLUMN:
+		return G_TYPE_VALUE_ARRAY;
 	case FM_LIST_MODEL_FILE_NAME_IS_EDITABLE_COLUMN:
 		return G_TYPE_BOOLEAN;
 	default:
@@ -148,6 +151,39 @@
 	return path;
 }
 
+static GValueArray *
+fm_list_model_get_emblem_pixbufs_for_file (FMListModel *list_model,
+					   NautilusFile *file)
+{
+	GList *emblem_icons;
+	GList *p;
+	GValueArray *emblem_pixbufs;
+	GValue emblem_value = { 0, };
+	GdkPixbuf *emblem_pixbuf;
+	
+	emblem_icons = nautilus_icon_factory_get_emblem_icons_for_file
+		(file, list_model->details->emblems_to_exclude);
+	
+	g_value_init (&emblem_value, GDK_TYPE_PIXBUF);
+	emblem_pixbufs = g_value_array_new (g_list_length (emblem_icons));
+
+	for (p = emblem_icons; p != NULL; p = p->next) {
+		emblem_pixbuf = nautilus_icon_factory_get_pixbuf_for_icon 
+			(p->data,
+			 NAUTILUS_ICON_SIZE_SMALLER,
+			 NAUTILUS_ICON_SIZE_SMALLER,
+			 NAUTILUS_ICON_SIZE_SMALLER,
+			 NAUTILUS_ICON_SIZE_SMALLER,
+			 NULL, TRUE);
+		if (emblem_pixbuf) {
+			g_value_set_object (&emblem_value, emblem_pixbuf);
+			g_value_array_prepend (emblem_pixbufs, &emblem_value);
+			g_object_unref (emblem_pixbuf);
+		}
+	}
+
+	return emblem_pixbufs;
+}
 
 static void
 fm_list_model_get_value (GtkTreeModel *tree_model, GtkTreeIter *iter, int column, GValue *value)
@@ -182,6 +218,12 @@
 		g_value_set_object (value, icon);
 		g_object_unref (icon);
 		break;
+	case FM_LIST_MODEL_EMBLEMS_COLUMN:
+		g_value_init (value, G_TYPE_VALUE_ARRAY);
+		
+		value->data[0].v_pointer = fm_list_model_get_emblem_pixbufs_for_file (model, file);
+
+		break;
 	case FM_LIST_MODEL_SIZE_COLUMN:
 		g_value_init (value, G_TYPE_STRING);
 
@@ -686,6 +728,18 @@
 
 	model->details->sort_directories_first = sort_directories_first;
 	fm_list_model_sort (model);
+}
+
+void
+fm_list_model_set_emblems_to_exclude (FMListModel *model, 
+				      const EelStringList *emblems_to_exclude)
+{
+	if (model->details->emblems_to_exclude) {
+		eel_string_list_free (model->details->emblems_to_exclude);
+	}
+	
+	model->details->emblems_to_exclude = 
+		eel_string_list_copy (emblems_to_exclude);
 }
 
 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	25 Mar 2002 15:56:05 -0000
@@ -24,6 +24,7 @@
 
 #include <gtk/gtktreemodel.h>
 #include <libnautilus-private/nautilus-file.h>
+#include <eel/eel-string-list.h>
 
 #ifndef FM_LIST_MODEL_H
 #define FM_LIST_MODEL_H
@@ -38,6 +39,7 @@
 	FM_LIST_MODEL_FILE_COLUMN,
 	FM_LIST_MODEL_ICON_COLUMN,
 	FM_LIST_MODEL_NAME_COLUMN,
+	FM_LIST_MODEL_EMBLEMS_COLUMN,
 	FM_LIST_MODEL_SIZE_COLUMN,
 	FM_LIST_MODEL_TYPE_COLUMN,
 	FM_LIST_MODEL_DATE_MODIFIED_COLUMN,
@@ -72,5 +74,8 @@
 							  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);
+
+void     fm_list_model_set_emblems_to_exclude            (FMListModel          *model,
+							  const EelStringList  *emblems_to_ignore);
 
 #endif /* FM_LIST_MODEL_H */
Index: src/file-manager/fm-list-view.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/fm-list-view.c,v
retrieving revision 1.163
diff -u -r1.163 fm-list-view.c
--- src/file-manager/fm-list-view.c	11 Mar 2002 10:17:49 -0000	1.163
+++ src/file-manager/fm-list-view.c	25 Mar 2002 15:56:05 -0000
@@ -229,6 +229,14 @@
 					     NULL);
 	gtk_tree_view_append_column (view->details->tree_view, view->details->file_name_column);
 
+	/* Create the emblems column */
+	cell = eel_cell_renderer_pixbuf_list_new ();
+	column = gtk_tree_view_column_new_with_attributes (_("Emblems"),
+							   cell, 
+							   "pixbufs", FM_LIST_MODEL_EMBLEMS_COLUMN,
+							   NULL);
+	gtk_tree_view_append_column (view->details->tree_view, column);
+
 	/* Create the size column */
 	cell = gtk_cell_renderer_text_new ();
 	g_object_set (G_OBJECT (cell),
@@ -301,6 +309,7 @@
 fm_list_view_begin_loading (FMDirectoryView *view)
 {
 	FMListView *list_view;
+	EelStringList *emblems_to_exclude;
 
 	list_view = FM_LIST_VIEW (view);
 
@@ -308,6 +317,12 @@
 						      fm_directory_view_get_directory_as_file (view));
 
 	set_sort_order_from_metadata_and_preferences (list_view);
+
+	emblems_to_exclude = fm_directory_view_get_emblem_names_to_exclude (view);
+	fm_list_model_set_emblems_to_exclude (list_view->details->model,
+					      emblems_to_exclude);
+
+	eel_string_list_free (emblems_to_exclude);
 }
 
 static void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]