[gnome-shell] Add shell_texture_cache_load_from_name
- From: Colin Walters <walters src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnome-shell] Add shell_texture_cache_load_from_name
- Date: Sun, 9 Aug 2009 13:53:36 +0000 (UTC)
commit 5064d873bb473f99609e48b9b52844c7b3f0d4e0
Author: Colin Walters <walters verbum org>
Date: Thu Jul 30 00:17:25 2009 -0400
Add shell_texture_cache_load_from_name
Utility function to load a texture for a themed icon from a
string name.
src/shell-texture-cache.c | 40 ++++++++++++++++++++++++++++++++++------
src/shell-texture-cache.h | 4 ++++
2 files changed, 38 insertions(+), 6 deletions(-)
---
diff --git a/src/shell-texture-cache.c b/src/shell-texture-cache.c
index 1b3a8d7..60fade1 100644
--- a/src/shell-texture-cache.c
+++ b/src/shell-texture-cache.c
@@ -8,12 +8,12 @@ typedef struct
{
ShellTextureCachePolicy policy;
- /* These 3 are exclusive */
+ /* These are exclusive */
GIcon *icon;
gchar *uri;
gchar *thumbnail_uri;
- /* This one is common to all 3 */
+ /* This one is common to all */
guint size;
} CacheKey;
@@ -32,14 +32,17 @@ static guint
cache_key_hash (gconstpointer a)
{
CacheKey *akey = (CacheKey *)a;
+ guint base_hash;
if (akey->icon)
- return g_icon_hash (akey->icon) + 31*akey->size;
+ base_hash = g_icon_hash (akey->icon);
else if (akey->uri)
- return g_str_hash (akey->uri) + 31*akey->size;
+ base_hash = g_str_hash (akey->uri);
else if (akey->thumbnail_uri)
- return g_str_hash (akey->thumbnail_uri) + 31*akey->size;
- g_assert_not_reached ();
+ base_hash = g_str_hash (akey->thumbnail_uri);
+ else
+ g_assert_not_reached ();
+ return base_hash + 31*akey->size;
}
static gboolean
@@ -773,6 +776,31 @@ shell_texture_cache_load_gicon (ShellTextureCache *cache,
}
/**
+ * shell_texture_cache_load_icon_name:
+ * @cache: The texture cache instance
+ * @name: Name of a themed icon
+ * @size: Size of themed
+ *
+ * Load a themed icon into a texture.
+ *
+ * Return Value: (transfer none): A new #ClutterTexture for the icon
+ */
+ClutterActor *
+shell_texture_cache_load_icon_name (ShellTextureCache *cache,
+ const char *name,
+ gint size)
+{
+ ClutterActor *texture;
+ GIcon *themed;
+
+ themed = g_themed_icon_new (name);
+ texture = shell_texture_cache_load_gicon (cache, themed, size);
+ g_object_unref (themed);
+
+ return CLUTTER_ACTOR (texture);
+}
+
+/**
* shell_texture_cache_load_uri:
*
* @cache: The texture cache instance
diff --git a/src/shell-texture-cache.h b/src/shell-texture-cache.h
index d24a681..a228fba 100644
--- a/src/shell-texture-cache.h
+++ b/src/shell-texture-cache.h
@@ -40,6 +40,10 @@ GType shell_texture_cache_get_type (void) G_GNUC_CONST;
ShellTextureCache* shell_texture_cache_get_default (void);
+ClutterActor *shell_texture_cache_load_icon_name (ShellTextureCache *cache,
+ const char *name,
+ gint size);
+
ClutterActor *shell_texture_cache_load_gicon (ShellTextureCache *cache,
GIcon *icon,
gint size);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]