Re: [PATCH] Don't use file type in sidebar for "abstract" files



Am Sonntag, den 31.07.2005, 01:22 +0200 schrieb Christian Neumair:
> From bug 168561 [1]:
> 
> "When I open "Computer" in the File Browser, the Information sidebar
> shows "x-directory/normal, 11 items". This is very silly considering
> that my computer is not a directory."
> 
> The proposed patches introduce a concept of "abstract" files which don't
> map to actual inodes, i.e. "computer:///", "network:///",
> "x-nautilus-desktop:///" etc.. All of them should not expose their file
> type to the user, since the information is generally crap. I've just
> noticed that I didn't add "fonts:///" and "burn:///", but this would be
> trivial to add. Maybe you remember any other URIs that are abstract?
> For now I'm just interested in architectural feedback :).
> 
> Note that we can later adapt [2] to this API where appropriate, although
> this is not yet a priority.
> 
> [1] http://bugzilla.gnome.org/show_bug.cgi?id=168561
> [2] http://mail.gnome.org/archives/nautilus-list/2005-July/msg00331.html

Attaching patches is fun. Forgetting to do so not.

-- 
Christian Neumair <chris gnome-de org>
Index: libnautilus-private/nautilus-desktop-directory-file.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-desktop-directory-file.c,v
retrieving revision 1.1
diff -u -p -r1.1 nautilus-desktop-directory-file.c
--- libnautilus-private/nautilus-desktop-directory-file.c	15 May 2003 17:18:42 -0000	1.1
+++ libnautilus-private/nautilus-desktop-directory-file.c	30 Jul 2005 23:10:32 -0000
@@ -442,6 +442,11 @@ desktop_directory_file_get_where_string 
 	return g_strdup (_("on the desktop"));
 }
 
+static gboolean
+desktop_directory_file_is_abstract (NautilusFile *file)
+{
+	return TRUE;
+}
 
 static void
 monitor_destroy (gpointer data)
@@ -546,4 +551,5 @@ nautilus_desktop_directory_file_class_in
 	file_class->get_deep_counts = desktop_directory_file_get_deep_counts;
 	file_class->get_date = desktop_directory_file_get_date;
 	file_class->get_where_string = desktop_directory_file_get_where_string;
+	file_class->is_abstract = desktop_directory_file_is_abstract;
 }
Index: libnautilus-private/nautilus-desktop-icon-file.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-desktop-icon-file.c,v
retrieving revision 1.6
diff -u -p -r1.6 nautilus-desktop-icon-file.c
--- libnautilus-private/nautilus-desktop-icon-file.c	22 Feb 2005 10:41:46 -0000	1.6
+++ libnautilus-private/nautilus-desktop-icon-file.c	30 Jul 2005 23:10:32 -0000
@@ -163,6 +163,12 @@ desktop_icon_file_get_where_string (Naut
 	return g_strdup (_("on the desktop"));
 }
 
+static gboolean
+desktop_icon_file_is_abstract (NautilusFile *file)
+{
+	return TRUE;
+}
+
 static void
 nautilus_desktop_icon_file_init (gpointer object, gpointer klass)
 {
@@ -354,4 +360,5 @@ nautilus_desktop_icon_file_class_init (g
 	file_class->get_deep_counts = desktop_icon_file_get_deep_counts;
 	file_class->get_date = desktop_icon_file_get_date;
 	file_class->get_where_string = desktop_icon_file_get_where_string;
+	file_class->is_abstract = desktop_icon_file_is_abstract;
 }
Index: libnautilus-private/nautilus-file.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-file.c,v
retrieving revision 1.367
diff -u -p -r1.367 nautilus-file.c
--- libnautilus-private/nautilus-file.c	16 Jun 2005 15:18:35 -0000	1.367
+++ libnautilus-private/nautilus-file.c	30 Jul 2005 23:10:37 -0000
@@ -2918,6 +2918,27 @@ nautilus_file_get_where_string (Nautilus
 		 get_where_string, (file));
 }
 
+/**
+ * nautilus_file_is_abstract:
+ * 
+ * Get whether a file represents an abstract concept rather than an actual inode.
+ * @file: NautilusFile representing the file in question.
+ * 
+ * Returns: Whether the file represents an abstract concept.
+ * 
+ **/
+gboolean
+nautilus_file_is_abstract (NautilusFile *file)
+{
+	if (file == NULL) {
+		return FALSE;
+	}
+
+	return EEL_CALL_METHOD_WITH_RETURN_VALUE
+		(NAUTILUS_FILE_CLASS, file,
+		 is_abstract, (file));
+}
+
 const char *TODAY_TIME_FORMATS [] = {
 	/* Today, use special word.
 	 * strftime patterns preceeded with the widest
Index: libnautilus-private/nautilus-file.h
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-file.h,v
retrieving revision 1.105
diff -u -p -r1.105 nautilus-file.h
--- libnautilus-private/nautilus-file.h	11 Oct 2004 12:55:13 -0000	1.105
+++ libnautilus-private/nautilus-file.h	30 Jul 2005 23:10:37 -0000
@@ -165,6 +165,7 @@ NautilusRequestStatus   nautilus_file_ge
 									 guint                          *unreadable_directory_count,
 									 GnomeVFSFileSize               *total_size);
 gboolean                nautilus_file_should_show_directory_item_count  (NautilusFile                   *file);
+gboolean                nautilus_file_is_abstract                       (NautilusFile                   *file);
 GList *                 nautilus_file_get_keywords                      (NautilusFile                   *file);
 void                    nautilus_file_set_keywords                      (NautilusFile                   *file,
 									 GList                          *keywords);
@@ -398,6 +399,7 @@ typedef struct {
 							  NautilusDateType        type,
 							  time_t                 *date);
 	char *                (* get_where_string)       (NautilusFile           *file);
+	gboolean              (* is_abstract)            (NautilusFile           *file);
 } NautilusFileClass;
 
 #endif /* NAUTILUS_FILE_H */
@@ -690,6 +718,11 @@ trash_file_get_where_string (NautilusFil
 	return g_strdup (_("on the desktop"));
 }
 
+static gboolean
+trash_file_is_abstract (NautilusFile *file)
+{
+	return TRUE;
+}
 
 static void
 remove_all_real_files (NautilusTrashFile *trash)
@@ -779,4 +812,5 @@ nautilus_trash_file_class_init (gpointer
 	file_class->get_deep_counts = trash_file_get_deep_counts;
 	file_class->get_date = trash_file_get_date;
 	file_class->get_where_string = trash_file_get_where_string;
+	file_class->is_abstract = trash_file_is_abstract;
 }
Index: libnautilus-private/nautilus-vfs-file.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-vfs-file.c,v
retrieving revision 1.16
diff -u -p -r1.16 nautilus-vfs-file.c
--- libnautilus-private/nautilus-vfs-file.c	2 Apr 2003 11:51:01 -0000	1.16
+++ libnautilus-private/nautilus-vfs-file.c	30 Jul 2005 23:10:39 -0000
@@ -29,6 +29,7 @@
 #include "nautilus-directory-private.h"
 #include "nautilus-file-private.h"
 #include <eel/eel-gtk-macros.h>
+#include <string.h>
 
 static void nautilus_vfs_file_init       (gpointer   object,
 						gpointer   klass);
@@ -228,6 +229,21 @@ vfs_file_get_where_string (NautilusFile 
 	return nautilus_file_get_parent_uri_for_display (file);
 }
 
+static gboolean
+vfs_file_is_abstract (NautilusFile *file)
+{
+	char *uri;
+	gboolean ret;
+
+	uri = nautilus_file_get_uri (file);
+	ret = ((strcmp (uri, "computer:///") == 0)
+		|| (strcmp (uri, "network:///") == 0)
+	        || (strcmp (uri, "smb:///") == 0));
+	g_free (uri);
+
+	return ret;
+}
+
 static void
 nautilus_vfs_file_init (gpointer object, gpointer klass)
 {
@@ -254,4 +270,5 @@ nautilus_vfs_file_class_init (gpointer k
 	file_class->get_deep_counts = vfs_file_get_deep_counts;
 	file_class->get_date = vfs_file_get_date;
 	file_class->get_where_string = vfs_file_get_where_string;
+	file_class->is_abstract = vfs_file_is_abstract;
 }
Index: src/nautilus-sidebar-title.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-sidebar-title.c,v
retrieving revision 1.152
diff -u -p -r1.152 nautilus-sidebar-title.c
--- src/nautilus-sidebar-title.c	15 Jul 2005 13:47:53 -0000	1.152
+++ src/nautilus-sidebar-title.c	30 Jul 2005 23:10:49 -0000
@@ -447,7 +447,10 @@ update_more_info (NautilusSidebarTitle *
 		g_free (component_info);
 	} else {
 		info_string = g_string_new (NULL);
-		type_string = nautilus_file_get_string_attribute (file, "type");
+		type_string = NULL;
+		if (nautilus_file_is_abstract (file)) {
+			type_string = nautilus_file_get_string_attribute (file, "type");
+		}
 		if (type_string != NULL) {
 			append_and_eat (info_string, NULL, type_string);
 			append_and_eat (info_string, ", ",

Attachment: signature.asc
Description: This is a digitally signed message part



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