diff options
author | Richard Hughes <richard@hughsie.com> | 2014-03-26 19:28:59 +0000 |
---|---|---|
committer | Richard Hughes <richard@hughsie.com> | 2014-03-26 19:29:59 +0000 |
commit | ce8c928eb97e62f9d38778e5d39be6c12cbbc79f (patch) | |
tree | 9b703cf5d9e235f14dcc58830254ca0484b9efde /libappstream-glib/as-utils.c | |
parent | 721128cbb2c7c5f361cc71b551890e104b670e5a (diff) | |
download | appstream-glib-ce8c928eb97e62f9d38778e5d39be6c12cbbc79f.tar.gz |
Add as_utils_is_stock_icon_name()
This means we add 8k to the library size as we use an embedded GResource.
Diffstat (limited to 'libappstream-glib/as-utils.c')
-rw-r--r-- | libappstream-glib/as-utils.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/libappstream-glib/as-utils.c b/libappstream-glib/as-utils.c index 37dcc0b..9ef2e90 100644 --- a/libappstream-glib/as-utils.c +++ b/libappstream-glib/as-utils.c @@ -32,6 +32,7 @@ #include "config.h" #include "as-node.h" +#include "as-resources.h" #include "as-utils.h" #include "as-utils-private.h" @@ -192,3 +193,37 @@ as_hash_lookup_by_locale (GHashTable *hash, const gchar *locale) out: return tmp; } + +/** + * as_utils_is_stock_icon_name: + * @name: an icon name + * + * Searches the known list of stock icons. + * + * Returns: %TRUE if the icon is a "stock icon name" and does not need to be + * included in the AppStream icon tarball + * + * Since: 0.1.3 + **/ +gboolean +as_utils_is_stock_icon_name (const gchar *name) +{ + GBytes *data; + gboolean ret = FALSE; + gchar *key = NULL; + + /* load the readonly data section and look for the icon name */ + data = g_resource_lookup_data (as_get_resource (), + "/org/freedesktop/appstream-glib/as-stock-icons.txt", + G_RESOURCE_LOOKUP_FLAGS_NONE, + NULL); + if (data == NULL) + goto out; + key = g_strdup_printf ("\n%s\n", name); + ret = g_strstr_len (g_bytes_get_data (data, NULL), -1, key) != NULL; +out: + if (data != NULL) + g_bytes_unref (data); + g_free (key); + return ret; +} |