Author: pcman
Date: 2008-06-27 01:10:54 +0000 (Fri, 27 Jun 2008)
New Revision: 27156

Modified:
   xarchiver/trunk/src/mime.c
   xarchiver/trunk/src/mime.h
Log:
Fix invalid pointer in xa_get_stock_mime_icon().
Use "unknown" icon instead of "binary" for better consistency with
other archivers.



Modified: xarchiver/trunk/src/mime.c
===================================================================
--- xarchiver/trunk/src/mime.c  2008-06-26 22:09:16 UTC (rev 27155)
+++ xarchiver/trunk/src/mime.c  2008-06-27 01:10:54 UTC (rev 27156)
@@ -91,15 +91,17 @@
        return type;
 }
 
-const char *xa_get_stock_mime_icon(char *filename)
+const char *xa_get_stock_mime_icon(char *filename, const char *mime)
 {
-       const char *mime;
-       const char *icon_name = "binary";
+       const char *icon_name = NULL;
 
        //g_print ("%s\t%s\n",filename,mime);
        if (strstr(filename,".ogg") || strstr(filename,".flac") )
                icon_name = "sound";
-       else if (strncmp(mime,"image/",6) == 0)
+       else if( NULL == mime )
+               return NULL;
+
+       if (strncmp(mime,"image/",6) == 0)
                icon_name = "image";
        else if (strcmp(mime,"text/html") == 0)
                icon_name = "html";
@@ -131,7 +133,7 @@
                icon_name = "gnome-mime-application-x-perl";
        else if (strcmp(mime,"application/x-font-ttf") == 0)
                icon_name = "gnome-mime-application-x-font-ttf";
-       return icon_name;               
+       return icon_name;
 }
 
 GdkPixbuf *xa_get_pixbuf_icon_from_cache(gchar *filename)
@@ -165,6 +167,7 @@
 #else
                mime_type = xdg_mime_get_mime_type_from_file_name(filename);
 #endif
+
                if( mime_type )
                {
                        mime = lookup_mime_type( mime_type );
@@ -197,8 +200,9 @@
 
                if( G_UNLIKELY( !icon ) )
                {
-                       const char* fallback = xa_get_stock_mime_icon(filename);
-                       icon = gtk_icon_theme_load_icon ( icon_theme, fallback, 
20, 0, NULL );                  
+                       const char* fallback = xa_get_stock_mime_icon(filename, 
mime_type);
+                       if( fallback )
+                               icon = gtk_icon_theme_load_icon ( icon_theme, 
fallback, 20, 0, NULL );                  
                }
                if( G_UNLIKELY( !icon ) )
                {

Modified: xarchiver/trunk/src/mime.h
===================================================================
--- xarchiver/trunk/src/mime.h  2008-06-26 22:09:16 UTC (rev 27155)
+++ xarchiver/trunk/src/mime.h  2008-06-27 01:10:54 UTC (rev 27156)
@@ -34,7 +34,7 @@
        GdkPixbuf *pixbuf;
 };
 
-const char *xa_get_stock_mime_icon(char *filename);
+const char *xa_get_stock_mime_icon(char *filename, const char* mime);
 GdkPixbuf *xa_get_pixbuf_icon_from_cache(gchar *filename);
 gint xa_icon_name_compare_func(pixbuf_cache *a, pixbuf_cache *b);
 void xa_free_icon_cache();

_______________________________________________
Xfce4-commits mailing list
[email protected]
http://foo-projects.org/mailman/listinfo/xfce4-commits

Reply via email to