[gthumb] fixed crash when no icon theme is provided to _g_icon_get_pixbuf



commit 054992b70f2682953e4b49221805117c069406f5
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Tue Aug 21 17:19:02 2012 +0200

    fixed crash when no icon theme is provided to _g_icon_get_pixbuf

 extensions/catalogs/gth-organize-task.c            |    2 +-
 extensions/gstreamer_tools/gth-media-viewer-page.c |    2 +-
 extensions/image_viewer/gth-image-viewer-page.c    |    2 +-
 gthumb/gth-overwrite-dialog.c                      |    4 ++--
 gthumb/gtk-utils.c                                 |   16 ++++++++++++++++
 gthumb/gtk-utils.h                                 |    1 +
 6 files changed, 22 insertions(+), 5 deletions(-)
---
diff --git a/extensions/catalogs/gth-organize-task.c b/extensions/catalogs/gth-organize-task.c
index 4bc35c8..126ce78 100644
--- a/extensions/catalogs/gth-organize-task.c
+++ b/extensions/catalogs/gth-organize-task.c
@@ -798,7 +798,7 @@ gth_organize_task_init (GthOrganizeTask *self)
 	icon = g_themed_icon_new ("file-catalog");
 	self->priv->icon_pixbuf = _g_icon_get_pixbuf (icon,
 						      _gtk_widget_lookup_for_size (GET_WIDGET ("organization_treeview"), GTK_ICON_SIZE_MENU),
-						      gtk_icon_theme_get_for_screen (gtk_widget_get_screen (GET_WIDGET ("organization_treeview"))));
+						      _gtk_widget_get_icon_theme (GET_WIDGET ("organization_treeview")));
 	g_object_unref (icon);
 
 	self->priv->file_list = gth_file_list_new (gth_grid_view_new (), GTH_FILE_LIST_TYPE_NORMAL, FALSE);
diff --git a/extensions/gstreamer_tools/gth-media-viewer-page.c b/extensions/gstreamer_tools/gth-media-viewer-page.c
index 4178183..c095317 100644
--- a/extensions/gstreamer_tools/gth-media-viewer-page.c
+++ b/extensions/gstreamer_tools/gth-media-viewer-page.c
@@ -216,7 +216,7 @@ video_area_draw_cb (GtkWidget *widget,
 		if (size > allocation.height)
 			size = allocation.height;
 		size = size / 3;
-		self->priv->icon = _g_icon_get_pixbuf (icon, size, gtk_icon_theme_get_for_screen (gtk_widget_get_screen (widget)));
+		self->priv->icon = _g_icon_get_pixbuf (icon, size, _gtk_widget_get_icon_theme (widget));
 
 		g_object_unref (icon);
 		g_free (type);
diff --git a/extensions/image_viewer/gth-image-viewer-page.c b/extensions/image_viewer/gth-image-viewer-page.c
index fd52656..b872dfb 100644
--- a/extensions/image_viewer/gth-image-viewer-page.c
+++ b/extensions/image_viewer/gth-image-viewer-page.c
@@ -631,7 +631,7 @@ paint_comment_over_image_func (GthImageViewer *image_viewer,
         	GIcon *gicon;
 
         	gicon = g_themed_icon_new (GTK_STOCK_PROPERTIES);
-        	icon = _g_icon_get_pixbuf (gicon, 24, NULL);
+        	icon = _g_icon_get_pixbuf (gicon, 24, _gtk_widget_get_icon_theme (GTK_WIDGET (image_viewer)));
 
         	g_object_unref (gicon);
         }
diff --git a/gthumb/gth-overwrite-dialog.c b/gthumb/gth-overwrite-dialog.c
index 076ab04..33809a8 100644
--- a/gthumb/gth-overwrite-dialog.c
+++ b/gthumb/gth-overwrite-dialog.c
@@ -156,7 +156,7 @@ info_ready_cb (GList    *files,
 		icon = (GIcon*) g_file_info_get_attribute_object (self->priv->source_data->info, "preview::icon");
 		if (icon == NULL)
 			icon = g_content_type_get_icon (g_file_info_get_content_type (self->priv->source_data->info));
-		pixbuf = _g_icon_get_pixbuf (icon, ICON_SIZE, gtk_icon_theme_get_for_screen (gtk_widget_get_screen (GTK_WIDGET (self))));
+		pixbuf = _g_icon_get_pixbuf (icon, ICON_SIZE, _gtk_widget_get_icon_theme (GTK_WIDGET (self)));
 		if (pixbuf != NULL) {
 			gth_image_viewer_set_pixbuf (GTH_IMAGE_VIEWER (self->priv->new_image_viewer), pixbuf, -1, -1);
 			g_object_unref (pixbuf);
@@ -204,7 +204,7 @@ info_ready_cb (GList    *files,
 	icon = (GIcon*) g_file_info_get_attribute_object (self->priv->destination_data->info, "preview::icon");
 	if (icon == NULL)
 		icon = g_content_type_get_icon (g_file_info_get_content_type (self->priv->destination_data->info));
-	pixbuf = _g_icon_get_pixbuf (icon, ICON_SIZE, gtk_icon_theme_get_for_screen (gtk_widget_get_screen (GTK_WIDGET (self))));
+	pixbuf = _g_icon_get_pixbuf (icon, ICON_SIZE, _gtk_widget_get_icon_theme (GTK_WIDGET (self)));
 	if (pixbuf != NULL) {
 		gth_image_viewer_set_pixbuf (GTH_IMAGE_VIEWER (self->priv->old_image_viewer), pixbuf, -1, -1);
 		g_object_unref (pixbuf);
diff --git a/gthumb/gtk-utils.c b/gthumb/gtk-utils.c
index fc8923a..18b540f 100644
--- a/gthumb/gtk-utils.c
+++ b/gthumb/gtk-utils.c
@@ -438,6 +438,9 @@ _g_icon_get_pixbuf (GIcon        *icon,
 	GdkPixbuf   *pixbuf = NULL;
 	GtkIconInfo *icon_info;
 
+	if (icon_theme == NULL)
+		icon_theme = gtk_icon_theme_get_default ();
+
 	icon_info = gtk_icon_theme_lookup_by_gicon (icon_theme,
 						    icon,
 						    icon_size,
@@ -1053,3 +1056,16 @@ _gdk_rgba_lighter (GdkRGBA *color,
 {
 	return _gdk_rgba_shade (color, result, 1.2);
 }
+
+
+GtkIconTheme *
+_gtk_widget_get_icon_theme (GtkWidget *widget)
+{
+	GdkScreen *screen;
+
+	screen = gtk_widget_get_screen (widget);
+	if (screen == NULL)
+		return NULL;
+
+	return gtk_icon_theme_get_for_screen (screen);
+}
diff --git a/gthumb/gtk-utils.h b/gthumb/gtk-utils.h
index 4513306..278896d 100644
--- a/gthumb/gtk-utils.h
+++ b/gthumb/gtk-utils.h
@@ -138,6 +138,7 @@ gboolean        _gdk_rgba_darker                           (GdkRGBA          *co
 		 					    GdkRGBA          *result);
 gboolean        _gdk_rgba_lighter                          (GdkRGBA          *color,
 							    GdkRGBA          *result);
+GtkIconTheme *  _gtk_widget_get_icon_theme                 (GtkWidget        *widget);
 
 G_END_DECLS
 



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