1
From 82a39de7a3c1265ba1a46d1140a084a12b310e32 Mon Sep 17 00:00:00 2001
2
From: Cosimo Cecchi <cosimoc@gnome.org>
3
Date: Wed, 28 Sep 2011 18:18:40 +0000
4
Subject: places-sidebar: don't crash when not finding the eject symbolic icon
6
If a theme doesn't have media-eject-symbolic, icon_info can be NULL, and
7
we would crash trying to load a pixbuf from it anyway.
8
Fix this and show the stock 'missing image' pixbuf when the theme
9
doesn't have the specified icons.
11
https://bugzilla.gnome.org/show_bug.cgi?id=660277
13
diff --git a/src/nautilus-places-sidebar.c b/src/nautilus-places-sidebar.c
14
index 5970c4e..4ebe023 100644
15
--- a/src/nautilus-places-sidebar.c
16
+++ b/src/nautilus-places-sidebar.c
17
@@ -229,26 +229,34 @@ get_eject_icon (NautilusPlacesSidebar *sidebar,
18
icon_info = gtk_icon_theme_lookup_by_gicon (icon_theme, icon, icon_size, 0);
20
style = gtk_widget_get_style_context (GTK_WIDGET (sidebar));
21
- state = gtk_widget_get_state_flags (GTK_WIDGET (sidebar));
23
gtk_style_context_save (style);
24
- gtk_style_context_add_class (style, GTK_STYLE_CLASS_IMAGE);
27
- state |= GTK_STATE_FLAG_PRELIGHT;
29
+ if (icon_info != NULL) {
30
+ state = gtk_widget_get_state_flags (GTK_WIDGET (sidebar));
31
+ gtk_style_context_add_class (style, GTK_STYLE_CLASS_IMAGE);
33
- gtk_style_context_set_state (style, state);
35
+ state |= GTK_STATE_FLAG_PRELIGHT;
38
- eject = gtk_icon_info_load_symbolic_for_context (icon_info,
42
+ gtk_style_context_set_state (style, state);
44
- gtk_style_context_restore (style);
45
+ eject = gtk_icon_info_load_symbolic_for_context (icon_info,
50
+ gtk_icon_info_free (icon_info);
52
+ GtkIconSet *icon_set;
54
+ gtk_style_context_set_state (style, GTK_STATE_FLAG_NORMAL);
55
+ icon_set = gtk_style_context_lookup_icon_set (style, GTK_STOCK_MISSING_IMAGE);
56
+ eject = gtk_icon_set_render_icon_pixbuf (icon_set, style, GTK_ICON_SIZE_MENU);
59
+ gtk_style_context_restore (style);
60
g_object_unref (icon);
61
- gtk_icon_info_free (icon_info);