[nautilus] Add lookup and creator functions for NautilusFileInfo objects



commit 881f208b876c6e4386d54a0db3fca26aaa34ff71
Author: Alexander Larsson <alexl redhat com>
Date:   Fri Dec 4 12:39:20 2009 +0100

    Add lookup and creator functions for NautilusFileInfo objects
    
    This has been requested by many extension developers.

 libnautilus-extension/nautilus-file-info.c |   40 ++++++++++++++++++++++++++++
 libnautilus-extension/nautilus-file-info.h |    4 +++
 libnautilus-private/nautilus-file.c        |    5 +++-
 3 files changed, 48 insertions(+), 1 deletions(-)
---
diff --git a/libnautilus-extension/nautilus-file-info.c b/libnautilus-extension/nautilus-file-info.c
index 9426770..38a1e42 100644
--- a/libnautilus-extension/nautilus-file-info.c
+++ b/libnautilus-extension/nautilus-file-info.c
@@ -21,7 +21,9 @@
 
 #include <config.h>
 #include "nautilus-file-info.h"
+#include "nautilus-extension-private.h"
 
+NautilusFileInfo *(*nautilus_file_info_getter) (GFile *location, gboolean create);
 
 GList *
 nautilus_file_info_list_copy (GList *files)
@@ -262,3 +264,41 @@ nautilus_file_info_invalidate_extension_info (NautilusFileInfo *file)
 	
 	NAUTILUS_FILE_INFO_GET_IFACE (file)->invalidate_extension_info (file);
 }
+
+NautilusFileInfo *
+nautilus_file_info_lookup (GFile *location)
+{
+	return nautilus_file_info_getter (location, FALSE);
+}
+
+NautilusFileInfo *
+nautilus_file_info_create (GFile *location)
+{
+	return nautilus_file_info_getter (location, TRUE);
+}
+
+NautilusFileInfo *
+nautilus_file_info_lookup_for_uri (const char *uri)
+{
+	GFile *location;
+	NautilusFile *file;
+
+	location = g_file_new_for_uri (uri);
+	file = nautilus_file_info_lookup (location);
+	g_object_unref (location);
+
+	return file;
+}
+
+NautilusFileInfo *
+nautilus_file_info_create_for_uri (const char *uri)
+{
+	GFile *location;
+	NautilusFile *file;
+
+	location = g_file_new_for_uri (uri);
+	file = nautilus_file_info_create (location);
+	g_object_unref (location);
+
+	return file;
+}
diff --git a/libnautilus-extension/nautilus-file-info.h b/libnautilus-extension/nautilus-file-info.h
index d7a7278..fe2cfe9 100644
--- a/libnautilus-extension/nautilus-file-info.h
+++ b/libnautilus-extension/nautilus-file-info.h
@@ -126,6 +126,10 @@ void              nautilus_file_info_add_string_attribute (NautilusFileInfo *fil
 /* Invalidating file info */
 void              nautilus_file_info_invalidate_extension_info (NautilusFileInfo *file);
 
+NautilusFileInfo *nautilus_file_info_lookup                (GFile *location);
+NautilusFileInfo *nautilus_file_info_create                (GFile *location);
+NautilusFileInfo *nautilus_file_info_lookup_for_uri        (const char *uri);
+NautilusFileInfo *nautilus_file_info_create_for_uri        (const char *uri);
 
 G_END_DECLS
 
diff --git a/libnautilus-private/nautilus-file.c b/libnautilus-private/nautilus-file.c
index 7dd6c94..df16e1f 100644
--- a/libnautilus-private/nautilus-file.c
+++ b/libnautilus-private/nautilus-file.c
@@ -59,6 +59,7 @@
 #include <gio/gio.h>
 #include <glib.h>
 #include <libnautilus-extension/nautilus-file-info.h>
+#include <libnautilus-extension/nautilus-extension-private.h>
 #include <libxml/parser.h>
 #include <pwd.h>
 #include <stdlib.h>
@@ -7828,7 +7829,9 @@ static void
 nautilus_file_class_init (NautilusFileClass *class)
 {
 	GtkIconTheme *icon_theme;
-	
+
+	nautilus_file_info_getter = nautilus_file_get_internal;
+
 	attribute_name_q = g_quark_from_static_string ("name");
 	attribute_size_q = g_quark_from_static_string ("size");
 	attribute_type_q = g_quark_from_static_string ("type");



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