file-roller r2509 - in trunk: . src



Author: paobac
Date: Mon Sep 22 07:37:45 2008
New Revision: 2509
URL: http://svn.gnome.org/viewvc/file-roller?rev=2509&view=rev

Log:
2008-09-22  Paolo Bacchilega  <paobac svn gnome org>

	* src/gtk-utils.h: 
	* src/fr-window.c: 
	* src/dlg-open-with.c: 
	* src/gtk-utils.c (get_icon_pixbuf): the icon isn't always a 
	themed_icon, it can be a file_icon too.  Load the image from the 
	file if it's a file_icon.
	
	Fixes bug #546799 â file-roller crashed with SIGSEGV in 
	g_str_hash()


Modified:
   trunk/ChangeLog
   trunk/src/dlg-open-with.c
   trunk/src/fr-window.c
   trunk/src/gtk-utils.c
   trunk/src/gtk-utils.h

Modified: trunk/src/dlg-open-with.c
==============================================================================
--- trunk/src/dlg-open-with.c	(original)
+++ trunk/src/dlg-open-with.c	Mon Sep 22 07:37:45 2008
@@ -410,8 +410,7 @@
 	for (scan = data->app_list; scan; scan = scan->next) {
 		gboolean   found;
 		char      *utf8_name;
-		GIcon     *icon;
-		GdkPixbuf *icon_image;
+		GdkPixbuf *icon_image = NULL;
 
 		app = scan->data;
 
@@ -428,16 +427,8 @@
 
 		app_names = g_list_prepend (app_names, (char*) g_app_info_get_executable (app));
 
-		utf8_name = g_locale_to_utf8 (g_app_info_get_name (app), -1, NULL, NULL, NULL);
-		
-		icon = g_app_info_get_icon (app);
-		if (icon != NULL) {
-			icon_image = get_icon_pixbuf (theme, G_THEMED_ICON (icon), icon_size);
-			g_object_unref (icon);
-		}
-		else {
-			icon_image = NULL;
-		}
+		utf8_name = g_locale_to_utf8 (g_app_info_get_name (app), -1, NULL, NULL, NULL);	
+		icon_image = get_icon_pixbuf (g_app_info_get_icon (app), icon_size, theme);
 		
 		gtk_list_store_append (GTK_LIST_STORE (data->app_model),
 				       &iter);

Modified: trunk/src/fr-window.c
==============================================================================
--- trunk/src/fr-window.c	(original)
+++ trunk/src/fr-window.c	Mon Sep 22 07:37:45 2008
@@ -1249,7 +1249,7 @@
 	}
 
 	icon = g_content_type_get_icon (content_type);
-	pixbuf = get_icon_pixbuf (icon_theme, G_THEMED_ICON (icon), file_list_icon_size);
+	pixbuf = get_icon_pixbuf (icon, file_list_icon_size, icon_theme);
 	g_object_unref (icon);
 
 	if (pixbuf == NULL)

Modified: trunk/src/gtk-utils.c
==============================================================================
--- trunk/src/gtk-utils.c	(original)
+++ trunk/src/gtk-utils.c	Mon Sep 22 07:37:45 2008
@@ -652,10 +652,10 @@
 }
 
 
-GdkPixbuf *
-get_icon_pixbuf (GtkIconTheme *icon_theme,
-		 GThemedIcon  *icon,
-		 int           size)
+static GdkPixbuf *
+get_themed_icon_pixbuf (GThemedIcon  *icon,
+		        int           size,
+		        GtkIconTheme *icon_theme)
 {
 	char        **icon_names;
 	GtkIconInfo  *icon_info;
@@ -681,6 +681,39 @@
 }
 
 
+static GdkPixbuf *
+get_file_icon_pixbuf (GFileIcon *icon,
+		      int        size)
+{
+	GFile     *file;
+	char      *filename;
+	GdkPixbuf *pixbuf;
+	
+	file = g_file_icon_get_file (icon);
+	filename = g_file_get_path (file);
+	pixbuf = gdk_pixbuf_new_from_file_at_size (filename, size, -1, NULL);
+	g_free (filename);
+	g_object_unref (file);
+	
+	return pixbuf;
+}
+
+
+GdkPixbuf *
+get_icon_pixbuf (GIcon        *icon,
+		 int           size,
+		 GtkIconTheme *theme)
+{
+	if (icon == NULL)
+		return NULL;
+	if (G_IS_THEMED_ICON (icon))
+		return get_themed_icon_pixbuf (G_THEMED_ICON (icon), size, theme);
+	if (G_IS_FILE_ICON (icon))
+		return get_file_icon_pixbuf (G_FILE_ICON (icon), size);
+	return NULL;
+}
+
+
 GdkPixbuf *
 get_mime_type_pixbuf (const char   *mime_type,
 		      int           icon_size,
@@ -693,7 +726,7 @@
 		icon_theme = gtk_icon_theme_get_default ();
 
 	icon = g_content_type_get_icon (mime_type);
-	pixbuf = get_icon_pixbuf (icon_theme, G_THEMED_ICON (icon), icon_size);
+	pixbuf = get_icon_pixbuf (icon, icon_size, icon_theme);
 	g_object_unref (icon);
 
 	return pixbuf;

Modified: trunk/src/gtk-utils.h
==============================================================================
--- trunk/src/gtk-utils.h	(original)
+++ trunk/src/gtk-utils.h	Mon Sep 22 07:37:45 2008
@@ -70,9 +70,9 @@
 void        _gtk_label_set_filename_text    (GtkLabel   *label,
 					     const char *text);
 char *      _gtk_label_get_filename_text    (GtkLabel   *label);
-GdkPixbuf * get_icon_pixbuf                 (GtkIconTheme *icon_theme,
-		 			     GThemedIcon  *icon,
-		 			     int           size);
+GdkPixbuf * get_icon_pixbuf                 (GIcon        *icon,
+		 			     int           size,
+		 			     GtkIconTheme *icon_theme);
 GdkPixbuf * get_mime_type_pixbuf            (const char   *mime_type,
 		                             int           icon_size,
 		                             GtkIconTheme *icon_theme);



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