[notification-daemon] Rework handling of image-path hints



commit c144b4556691ff61156d2507b7c5b5a44c5a31a0
Author: Jonathan Matthew <jonathan d14n org>
Date:   Sat Oct 9 14:26:05 2010 +1000

    Rework handling of image-path hints
    
    Instead of trying to guess if the path is a URI or absolute file,
    just create a GFile with g_file_new_for_commandline_arg and use
    g_file_is_native to decide whether to try loading from a file.
    If the resulting file object is not native, or loading from the
    file fails, try loading from the icon theme.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=623508

 src/nd-notification.c |   23 +++++++++++------------
 1 files changed, 11 insertions(+), 12 deletions(-)
---
diff --git a/src/nd-notification.c b/src/nd-notification.c
index 255e64b..2e50911 100644
--- a/src/nd-notification.c
+++ b/src/nd-notification.c
@@ -488,16 +488,20 @@ static GdkPixbuf *
 _notify_daemon_pixbuf_from_path (const char *path,
                                  int         size)
 {
+        GFile *file;
         GdkPixbuf *pixbuf = NULL;
 
-        if (!strncmp (path, "file://", 7) || *path == '/') {
-                if (!strncmp (path, "file://", 7)) {
-                        path += 7;
-                }
+        file = g_file_new_for_commandline_arg (path);
+        if (g_file_is_native (file)) {
+                char *realpath;
 
-                /* Load file */
-                pixbuf = gdk_pixbuf_new_from_file_at_size (path, size, size, NULL);
-        } else {
+                realpath = g_file_get_path (file);
+                pixbuf = gdk_pixbuf_new_from_file_at_size (realpath, size, size, NULL);
+                g_free (realpath);
+        }
+        g_object_unref (file);
+
+        if (pixbuf == NULL) {
                 /* Load icon theme icon */
                 GtkIconTheme *theme;
                 GtkIconInfo  *icon_info;
@@ -525,11 +529,6 @@ _notify_daemon_pixbuf_from_path (const char *path,
 
                         gtk_icon_info_free (icon_info);
                 }
-
-                if (pixbuf == NULL) {
-                        /* Well... maybe this is a file afterall. */
-                        pixbuf = gdk_pixbuf_new_from_file_at_size (path, size, size, NULL);
-                }
         }
 
         return pixbuf;



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