silence console warnings when fallback icons can't be found

This commit is contained in:
Jordan Lee 2012-12-27 17:49:52 +00:00
parent 144d3b952c
commit ff3a6df7a6
1 changed files with 25 additions and 22 deletions

View File

@ -154,38 +154,41 @@ static const BuiltinIconInfo my_fallback_icons[] =
static void
register_my_icons (void)
{
int i;
const int n = G_N_ELEMENTS (my_fallback_icons);
GtkIconFactory * factory = gtk_icon_factory_new ();
GtkIconTheme * theme = gtk_icon_theme_get_default ();
int i;
const int n = G_N_ELEMENTS (my_fallback_icons);
GtkIconTheme * theme = gtk_icon_theme_get_default ();
GtkIconFactory * factory = gtk_icon_factory_new ();
gtk_icon_factory_add_default (factory);
gtk_icon_factory_add_default (factory);
for (i = 0; i < n; ++i)
for (i=0; i<n; ++i)
{
const char * name = my_fallback_icons[i].name;
const char * name = my_fallback_icons[i].name;
if (!gtk_icon_theme_has_icon (theme, name))
if (!gtk_icon_theme_has_icon (theme, name))
{
int width;
GdkPixbuf * p;
GtkIconSet * icon_set;
GdkPixbuf * p;
p =
gdk_pixbuf_new_from_inline (-1, my_fallback_icons[i].raw,
FALSE,
NULL);
width = gdk_pixbuf_get_width (p);
icon_set = gtk_icon_set_new_from_pixbuf (p);
gtk_icon_theme_add_builtin_icon (name, width, p);
gtk_icon_factory_add (factory, name, icon_set);
p = gdk_pixbuf_new_from_inline (-1, my_fallback_icons[i].raw, FALSE, NULL);
g_object_unref (p);
gtk_icon_set_unref (icon_set);
if (p != NULL)
{
int width;
GtkIconSet * icon_set;
width = gdk_pixbuf_get_width (p);
icon_set = gtk_icon_set_new_from_pixbuf (p);
gtk_icon_theme_add_builtin_icon (name, width, p);
gtk_icon_factory_add (factory, name, icon_set);
g_object_unref (p);
gtk_icon_set_unref (icon_set);
}
}
}
g_object_unref (G_OBJECT (factory));
g_object_unref (G_OBJECT (factory));
}
static GtkUIManager * myUIManager = NULL;