[nautilus/gnome-3-2] places-sidebar: don't crash when not finding the eject symbolic icon
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/gnome-3-2] places-sidebar: don't crash when not finding the eject symbolic icon
- Date: Mon, 17 Oct 2011 21:11:10 +0000 (UTC)
commit 3532c05fb5a2bafadc6de7a8072bcdd4d674ca23
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Wed Sep 28 14:18:40 2011 -0400
places-sidebar: don't crash when not finding the eject symbolic icon
If a theme doesn't have media-eject-symbolic, icon_info can be NULL, and
we would crash trying to load a pixbuf from it anyway.
Fix this and show the stock 'missing image' pixbuf when the theme
doesn't have the specified icons.
https://bugzilla.gnome.org/show_bug.cgi?id=660277
src/nautilus-places-sidebar.c | 34 +++++++++++++++++++++-------------
1 files changed, 21 insertions(+), 13 deletions(-)
---
diff --git a/src/nautilus-places-sidebar.c b/src/nautilus-places-sidebar.c
index 5970c4e..4ebe023 100644
--- a/src/nautilus-places-sidebar.c
+++ b/src/nautilus-places-sidebar.c
@@ -229,26 +229,34 @@ get_eject_icon (NautilusPlacesSidebar *sidebar,
icon_info = gtk_icon_theme_lookup_by_gicon (icon_theme, icon, icon_size, 0);
style = gtk_widget_get_style_context (GTK_WIDGET (sidebar));
- state = gtk_widget_get_state_flags (GTK_WIDGET (sidebar));
-
gtk_style_context_save (style);
- gtk_style_context_add_class (style, GTK_STYLE_CLASS_IMAGE);
- if (highlighted) {
- state |= GTK_STATE_FLAG_PRELIGHT;
- }
+ if (icon_info != NULL) {
+ state = gtk_widget_get_state_flags (GTK_WIDGET (sidebar));
+ gtk_style_context_add_class (style, GTK_STYLE_CLASS_IMAGE);
- gtk_style_context_set_state (style, state);
+ if (highlighted) {
+ state |= GTK_STATE_FLAG_PRELIGHT;
+ }
- eject = gtk_icon_info_load_symbolic_for_context (icon_info,
- style,
- NULL,
- NULL);
+ gtk_style_context_set_state (style, state);
- gtk_style_context_restore (style);
+ eject = gtk_icon_info_load_symbolic_for_context (icon_info,
+ style,
+ NULL,
+ NULL);
+ gtk_icon_info_free (icon_info);
+ } else {
+ GtkIconSet *icon_set;
+
+ gtk_style_context_set_state (style, GTK_STATE_FLAG_NORMAL);
+ icon_set = gtk_style_context_lookup_icon_set (style, GTK_STOCK_MISSING_IMAGE);
+ eject = gtk_icon_set_render_icon_pixbuf (icon_set, style, GTK_ICON_SIZE_MENU);
+ }
+
+ gtk_style_context_restore (style);
g_object_unref (icon);
- gtk_icon_info_free (icon_info);
return eject;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]