[gnome-shell] Fallback to using a generic when requested image isn't found
- From: William Jon McCann <mccann src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] Fallback to using a generic when requested image isn't found
- Date: Thu, 17 Mar 2011 18:11:37 +0000 (UTC)
commit dd99ed73a92e1f9b42bf1afad9591489fde79760
Author: William Jon McCann <jmccann redhat com>
Date: Wed Mar 16 22:27:04 2011 -0400
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
src/shell-app-system.c | 24 +++++++++++++++---------
src/shell-app.c | 24 ++++++++++++++++++------
src/st/st-texture-cache.c | 27 ++++++++++++++++++++++++++-
3 files changed, 59 insertions(+), 16 deletions(-)
---
diff --git a/src/shell-app-system.c b/src/shell-app-system.c
index 9012540..086cfc8 100644
--- a/src/shell-app-system.c
+++ b/src/shell-app-system.c
@@ -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");
+ ret = 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)
+ else
{
- ret = clutter_texture_new ();
- g_object_set (ret, "opacity", 0, "width", size, "height", size, NULL);
+ 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);
+ }
}
- else
+
+ 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);
}
diff --git a/src/shell-app.c b/src/shell-app.c
index b27ebe6..d3b00cf 100644
--- a/src/shell-app.c
+++ b/src/shell-app.c
@@ -141,14 +141,26 @@ shell_app_create_faded_icon_cpu (StTextureCache *cache,
app = data->app;
size = data->size;
+ info = NULL;
+
icon = shell_app_info_get_icon (app->info);
- if (icon == NULL)
- return COGL_INVALID_HANDLE;
+ 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;
diff --git a/src/st/st-texture-cache.c b/src/st/st-texture-cache.c
index 198ddf2..8b46355 100644
--- a/src/st/st-texture-cache.c
+++ b/src/st/st-texture-cache.c
@@ -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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]