Fallback to using a generic when requested image isn't found
Use a type specific generic image when the requested icon can't be loaded instead of using an empty texture. https://bugzilla.gnome.org/show_bug.cgi?id=644668
This commit is contained in:
parent
36ce460a39
commit
dd99ed73a9
@ -1208,21 +1208,27 @@ shell_app_info_create_icon_texture (ShellAppInfo *info, float size)
|
||||
GIcon *icon;
|
||||
ClutterActor *ret;
|
||||
|
||||
ret = NULL;
|
||||
|
||||
if (info->type == SHELL_APP_INFO_TYPE_WINDOW)
|
||||
{
|
||||
return st_texture_cache_bind_pixbuf_property (st_texture_cache_get_default (),
|
||||
G_OBJECT (info->window),
|
||||
"icon");
|
||||
}
|
||||
|
||||
icon = shell_app_info_get_icon (info);
|
||||
if (icon == NULL)
|
||||
{
|
||||
ret = clutter_texture_new ();
|
||||
g_object_set (ret, "opacity", 0, "width", size, "height", size, NULL);
|
||||
ret = st_texture_cache_bind_pixbuf_property (st_texture_cache_get_default (),
|
||||
G_OBJECT (info->window),
|
||||
"icon");
|
||||
}
|
||||
else
|
||||
{
|
||||
icon = shell_app_info_get_icon (info);
|
||||
if (icon != NULL)
|
||||
{
|
||||
ret = st_texture_cache_load_gicon (st_texture_cache_get_default (), NULL, icon, (int)size);
|
||||
g_object_unref (icon);
|
||||
}
|
||||
}
|
||||
|
||||
if (ret == NULL)
|
||||
{
|
||||
icon = g_themed_icon_new ("application-x-executable");
|
||||
ret = st_texture_cache_load_gicon (st_texture_cache_get_default (), NULL, icon, (int)size);
|
||||
g_object_unref (icon);
|
||||
}
|
||||
|
@ -141,14 +141,26 @@ shell_app_create_faded_icon_cpu (StTextureCache *cache,
|
||||
app = data->app;
|
||||
size = data->size;
|
||||
|
||||
icon = shell_app_info_get_icon (app->info);
|
||||
if (icon == NULL)
|
||||
return COGL_INVALID_HANDLE;
|
||||
info = NULL;
|
||||
|
||||
icon = shell_app_info_get_icon (app->info);
|
||||
if (icon != NULL)
|
||||
{
|
||||
info = gtk_icon_theme_lookup_by_gicon (gtk_icon_theme_get_default (),
|
||||
icon, (int) (size + 0.5),
|
||||
GTK_ICON_LOOKUP_FORCE_SIZE);
|
||||
g_object_unref (icon);
|
||||
}
|
||||
|
||||
if (info == NULL)
|
||||
{
|
||||
icon = g_themed_icon_new ("application-x-executable");
|
||||
info = gtk_icon_theme_lookup_by_gicon (gtk_icon_theme_get_default (),
|
||||
icon, (int) (size + 0.5),
|
||||
GTK_ICON_LOOKUP_FORCE_SIZE);
|
||||
g_object_unref (icon);
|
||||
}
|
||||
|
||||
info = gtk_icon_theme_lookup_by_gicon (gtk_icon_theme_get_default (),
|
||||
icon, (int) (size + 0.5),
|
||||
GTK_ICON_LOOKUP_FORCE_SIZE);
|
||||
g_object_unref (icon);
|
||||
if (info == NULL)
|
||||
return COGL_INVALID_HANDLE;
|
||||
|
||||
|
@ -1195,6 +1195,8 @@ load_gicon_with_colors (StTextureCache *cache,
|
||||
g_slist_free (request->textures);
|
||||
g_free (request);
|
||||
g_hash_table_remove (cache->priv->outstanding_requests, key);
|
||||
g_object_unref (texture);
|
||||
texture = NULL;
|
||||
}
|
||||
|
||||
g_free (key);
|
||||
@ -1216,7 +1218,7 @@ load_gicon_with_colors (StTextureCache *cache,
|
||||
* This will load @icon as a full-color icon; if you want a symbolic
|
||||
* icon, you must use st_texture_cache_load_icon_name().
|
||||
*
|
||||
* Return Value: (transfer none): A new #ClutterActor for the icon
|
||||
* Return Value: (transfer none): A new #ClutterActor for the icon, or %NULL if not found
|
||||
*/
|
||||
ClutterActor *
|
||||
st_texture_cache_load_gicon (StTextureCache *cache,
|
||||
@ -1461,10 +1463,27 @@ st_texture_cache_load_icon_name (StTextureCache *cache,
|
||||
switch (icon_type)
|
||||
{
|
||||
case ST_ICON_APPLICATION:
|
||||
themed = g_themed_icon_new (name);
|
||||
texture = load_gicon_with_colors (cache, themed, size, NULL);
|
||||
g_object_unref (themed);
|
||||
if (texture == NULL)
|
||||
{
|
||||
themed = g_themed_icon_new ("application-x-executable");
|
||||
texture = load_gicon_with_colors (cache, themed, size, NULL);
|
||||
g_object_unref (themed);
|
||||
}
|
||||
return CLUTTER_ACTOR (texture);
|
||||
break;
|
||||
case ST_ICON_DOCUMENT:
|
||||
themed = g_themed_icon_new (name);
|
||||
texture = load_gicon_with_colors (cache, themed, size, NULL);
|
||||
g_object_unref (themed);
|
||||
if (texture == NULL)
|
||||
{
|
||||
themed = g_themed_icon_new ("x-office-document");
|
||||
texture = load_gicon_with_colors (cache, themed, size, NULL);
|
||||
g_object_unref (themed);
|
||||
}
|
||||
|
||||
return CLUTTER_ACTOR (texture);
|
||||
break;
|
||||
@ -1482,6 +1501,12 @@ st_texture_cache_load_icon_name (StTextureCache *cache,
|
||||
themed = g_themed_icon_new_with_default_fallbacks (name);
|
||||
texture = load_gicon_with_colors (cache, themed, size, NULL);
|
||||
g_object_unref (themed);
|
||||
if (texture == NULL)
|
||||
{
|
||||
themed = g_themed_icon_new ("image-missing");
|
||||
texture = load_gicon_with_colors (cache, themed, size, NULL);
|
||||
g_object_unref (themed);
|
||||
}
|
||||
|
||||
return CLUTTER_ACTOR (texture);
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user