Re: [Nautilus-list] emblems in the list view



On 25 Mar 2002, Dave Camp wrote:

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

+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;
+}



Don't you need to free emblem_icons here.



 
 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);

Use g_value_set_pointer here instead.


@@ -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);
 }


I think emblems_to_exclude is leaked here. I'm not sure of the memory 
management issues, but i think you need to free emblems_to_execlude in the 
finalizer for the model.
 
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


In fm_list_view_emblems_changed(), if you could get all the emblems to be 
recalulated and redraw that would be great. 

This is to handle the case where a file in the list is non-writable, and 
the directory changes from writable to non-writable. Non-writable files in 
non-writable directories don't get the non-writable emblem, so the emblem 
list will change.


Other than that it looks fine.

-- 
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 Alexander Larsson                                            Red Hat, Inc 
                   alexl redhat com    alla lysator liu se 
He's a deeply religious devious vagrant on the wrong side of the law. She's a 
brilliant cigar-chomping magician's assistant who don't take no shit from 
nobody. They fight crime! 





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