[gnome-launch-box] drop libgnomevfs from lb-utils.h



commit a39cd75a8abf1eb2a73bce20fc899e3a174831e8
Author: Sven Herzberg <herzi gnome-de org>
Date:   Tue Feb 9 14:55:59 2010 +0100

    drop libgnomevfs from lb-utils.h
    
    * src/lb-module-bookmarks.c,
    * src/lb-module-files.c,
    * src/lb-module-tracker.c: updated to new API
    * src/lb-utils.c,
    * src/lb-utils.h: drop libgnomevfs by using the new GFile API

 src/lb-module-bookmarks.c |    1 +
 src/lb-module-files.c     |    2 +-
 src/lb-module-tracker.c   |    5 +++
 src/lb-utils.c            |   79 +++++++++++++++++++++++++--------------------
 src/lb-utils.h            |    4 +--
 5 files changed, 52 insertions(+), 39 deletions(-)
---
diff --git a/src/lb-module-bookmarks.c b/src/lb-module-bookmarks.c
index a9aa9bc..8c1295f 100644
--- a/src/lb-module-bookmarks.c
+++ b/src/lb-module-bookmarks.c
@@ -27,6 +27,7 @@
 #include <string.h>
 
 #include <gtk/gtk.h>
+#include <libgnomevfs/gnome-vfs-file-info.h>
 
 #include "lb-action.h"
 #include "lb-bookmark-list.h"
diff --git a/src/lb-module-files.c b/src/lb-module-files.c
index 7795df0..ed640b9 100644
--- a/src/lb-module-files.c
+++ b/src/lb-module-files.c
@@ -198,7 +198,7 @@ module_files_query (LbModule    *module,
 				LbItem    *item;
 				gchar     *icon_name;
 
-				icon_name = lb_get_icon_name_for_uri (uri, info);
+				icon_name = lb_get_icon_name_for_uri (uri);
 
 				item = g_object_new (LB_TYPE_ITEM_FILE,
 						     "name",      name,
diff --git a/src/lb-module-tracker.c b/src/lb-module-tracker.c
index 7349bf5..d9ab509 100644
--- a/src/lb-module-tracker.c
+++ b/src/lb-module-tracker.c
@@ -72,6 +72,11 @@ static void
 lb_module_tracker_add_actions (LbModule* module,
                                LbItem  * item)
 {
+  if (!LB_IS_ITEM_APPLICATION (item))
+    {
+      return;
+    }
+
   lb_item_application_add_actions (LB_ITEM_APPLICATION (item));
 }
 
diff --git a/src/lb-utils.c b/src/lb-utils.c
index b8a8390..67122d9 100644
--- a/src/lb-utils.c
+++ b/src/lb-utils.c
@@ -26,9 +26,10 @@
 
 #include <string.h>
 #include <stdlib.h>
+#include <sys/types.h>
+#include <unistd.h>
 
 #include <gdk-pixbuf/gdk-pixbuf.h>
-#include <libgnomevfs/gnome-vfs.h>
 #include <libgnomeui/gnome-icon-lookup.h>
 #include <gtk/gtkicontheme.h>
 
@@ -208,41 +209,49 @@ lb_string_markup_substring (const gchar *str,
 }
 
 gchar *
-lb_get_icon_name_for_uri (const gchar      *uri,
-			  GnomeVFSFileInfo *info)
+lb_get_icon_name_for_uri (const gchar *uri)
 {
-	gchar                      *name;
-	GnomeIconLookupResultFlags  lookup_result;
-	GnomeVFSFileInfo           *real_info;
-	GnomeVFSResult              result;
-
-	ensure_icon_theme ();
-
-	real_info = info;
-
-	if (!info) {
-		info = gnome_vfs_file_info_new ();
-
-		result = gnome_vfs_get_file_info (
-			uri, info, GNOME_VFS_FILE_INFO_GET_MIME_TYPE);
-		if (result != GNOME_VFS_OK) {
-			gnome_vfs_file_info_unref (info);
-			return NULL;
-		}
-	}
-
-	name = gnome_icon_lookup (icon_theme, thumbnail_factory,
-				  uri, NULL, info, info->mime_type,
-				  GNOME_ICON_LOOKUP_FLAGS_EMBEDDING_TEXT |
-				  GNOME_ICON_LOOKUP_FLAGS_SHOW_SMALL_IMAGES_AS_THEMSELVES |
-				  GNOME_ICON_LOOKUP_FLAGS_ALLOW_SVG_AS_THEMSELVES,
-				  &lookup_result);
-
-	if (real_info != info) {
-		gnome_vfs_file_info_unref (info);
-	}
-
-	return name;
+  GFileInfo* info;
+  GError   * error = NULL;
+  GFile    * file = g_file_new_for_uri (uri);
+  gchar    * result = NULL;
+
+  info = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_ICON,
+                            G_FILE_QUERY_INFO_NONE, NULL,
+                            &error);
+
+  if (!info)
+    {
+      g_printerr ("error reading file info for %s: %s",
+                  uri, error->message);
+      g_error_free (error);
+    }
+  else
+    {
+      GIcon* icon = g_file_info_get_icon (info);
+
+      if (G_IS_THEMED_ICON (icon))
+        {
+          gchar const * const * names = g_themed_icon_get_names (G_THEMED_ICON (icon));
+
+          result = names ? g_strdup (names[g_strv_length ((gchar**)names) - 1]) : NULL;
+
+          /* FIXME: return a GIcon to be more flexible */
+        }
+      else if (G_IS_ICON (icon))
+        {
+          g_printerr ("missing implementation for icon type %s",
+                      G_OBJECT_TYPE_NAME (icon));
+        }
+
+      g_object_unref (info);
+    }
+
+  g_object_unref (file);
+
+  g_print ("%s(%s): %s\n", G_STRFUNC, G_STRLOC, result ? result : "(nil)");
+
+  return result;
 }
 
 gchar *
diff --git a/src/lb-utils.h b/src/lb-utils.h
index 7e39a59..e0050b3 100644
--- a/src/lb-utils.h
+++ b/src/lb-utils.h
@@ -26,7 +26,6 @@
 #define __LB_UTILS_H__
 
 #include <gdk-pixbuf/gdk-pixbuf.h>
-#include <libgnomevfs/gnome-vfs-file-info.h>
 
 #define LB_ICON_SIZE 64
 
@@ -36,8 +35,7 @@ gboolean   lb_string_has_substring        (const gchar      *str,
 gchar     *lb_string_markup_substring     (const gchar      *str,
 					   const gchar      *substr,
 					   const gchar      *tag);
-gchar     *lb_get_icon_name_for_uri       (const gchar      *uri,
-					   GnomeVFSFileInfo *info);
+gchar     *lb_get_icon_name_for_uri       (const gchar      *uri);
 gchar *    lb_get_icon_name_for_mime_type (const gchar      *mime_type);
 GdkPixbuf *lb_get_pixbuf_from_icon_name   (const gchar      *icon_name);
 gchar     *lb_get_firefox_path            (void);



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