diff options
author | Cosimo Cecchi <cosimoc@gnome.org> | 2011-09-28 14:18:40 -0400 |
---|---|---|
committer | Cosimo Cecchi <cosimoc@gnome.org> | 2011-10-17 09:48:07 -0400 |
commit | 3532c05fb5a2bafadc6de7a8072bcdd4d674ca23 (patch) | |
tree | 29adbbb65132378e65e1a09bc131004746b3653d | |
parent | 856f0f89952427502857291962f9c5c3be3dcf62 (diff) | |
download | nautilus-3532c05fb5a2bafadc6de7a8072bcdd4d674ca23.tar.gz |
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
-rw-r--r-- | 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 5970c4ed6..4ebe02379 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; } |