summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2014-07-16 13:18:42 +0100
committerRichard Hughes <richard@hughsie.com>2014-07-16 14:28:30 +0100
commit6b3bb0817633954a9e546b58caf8643c0c8ceff4 (patch)
treec45dbe3086d5397ea496e227c1148bcd0c58ebd4
parenta7c1bb82f8c5f6568f26689c19fea961a400f75c (diff)
downloadappstream-glib-6b3bb0817633954a9e546b58caf8643c0c8ceff4.tar.gz
Add oxygen-icon-theme when an application depends on kde-runtime
-rw-r--r--libappstream-builder/asb-task.c32
-rw-r--r--libappstream-builder/plugins/asb-plugin-desktop.c49
2 files changed, 63 insertions, 18 deletions
diff --git a/libappstream-builder/asb-task.c b/libappstream-builder/asb-task.c
index 5522334..8644960 100644
--- a/libappstream-builder/asb-task.c
+++ b/libappstream-builder/asb-task.c
@@ -91,7 +91,9 @@ asb_task_add_suitable_plugins (AsbTask *task)
* asb_task_explode_extra_package:
**/
static gboolean
-asb_task_explode_extra_package (AsbTask *task, const gchar *pkg_name)
+asb_task_explode_extra_package (AsbTask *task,
+ const gchar *pkg_name,
+ gboolean require_same_srpm)
{
AsbTaskPrivate *priv = GET_PRIVATE (task);
AsbPackage *pkg_extra;
@@ -104,8 +106,9 @@ asb_task_explode_extra_package (AsbTask *task, const gchar *pkg_name)
return TRUE;
/* check it's from the same source package */
- if (g_strcmp0 (asb_package_get_source (pkg_extra),
- asb_package_get_source (priv->pkg)) != 0)
+ if (require_same_srpm &&
+ (g_strcmp0 (asb_package_get_source (pkg_extra),
+ asb_package_get_source (priv->pkg)) != 0))
return TRUE;
asb_package_log (priv->pkg,
@@ -138,6 +141,7 @@ asb_task_explode_extra_packages (AsbTask *task)
guint i;
_cleanup_hashtable_unref_ GHashTable *hash;
_cleanup_ptrarray_unref_ GPtrArray *array;
+ _cleanup_ptrarray_unref_ GPtrArray *icon_themes;
/* anything the package requires */
hash = g_hash_table_new (g_str_hash, g_str_equal);
@@ -147,6 +151,7 @@ asb_task_explode_extra_packages (AsbTask *task)
GINT_TO_POINTER (1));
}
array = g_ptr_array_new_with_free_func (g_free);
+ icon_themes = g_ptr_array_new_with_free_func (g_free);
deps = asb_package_get_deps (priv->pkg);
for (i = 0; deps[i] != NULL; i++) {
if (g_strstr_len (deps[i], -1, " ") != NULL)
@@ -157,14 +162,31 @@ asb_task_explode_extra_packages (AsbTask *task)
continue;
if (g_hash_table_lookup (hash, deps[i]) != NULL)
continue;
- g_ptr_array_add (array, g_strdup (deps[i]));
+ /* if an app depends on kde-runtime, that means the
+ * oxygen icon set is available to them */
+ if (g_strcmp0 (deps[i], "oxygen-icon-theme") == 0 ||
+ g_strcmp0 (deps[i], "kde-runtime") == 0) {
+ g_hash_table_insert (hash, (gpointer) "oxygen-icon-theme",
+ GINT_TO_POINTER (1));
+ g_ptr_array_add (icon_themes,
+ g_strdup ("oxygen-icon-theme"));
+ } else {
+ g_ptr_array_add (array, g_strdup (deps[i]));
+ }
g_hash_table_insert (hash, deps[i], GINT_TO_POINTER (1));
}
/* explode any potential packages */
for (i = 0; i < array->len; i++) {
tmp = g_ptr_array_index (array, i);
- if (!asb_task_explode_extra_package (task, tmp))
+ if (!asb_task_explode_extra_package (task, tmp, TRUE))
+ return FALSE;
+ }
+
+ /* explode any icon themes */
+ for (i = 0; i < icon_themes->len; i++) {
+ tmp = g_ptr_array_index (icon_themes, i);
+ if (!asb_task_explode_extra_package (task, tmp, FALSE))
return FALSE;
}
return TRUE;
diff --git a/libappstream-builder/plugins/asb-plugin-desktop.c b/libappstream-builder/plugins/asb-plugin-desktop.c
index aa77faa..0058828 100644
--- a/libappstream-builder/plugins/asb-plugin-desktop.c
+++ b/libappstream-builder/plugins/asb-plugin-desktop.c
@@ -45,7 +45,6 @@ asb_plugin_add_globs (AsbPlugin *plugin, GPtrArray *globs)
{
asb_plugin_add_glob (globs, "/usr/share/applications/*.desktop");
asb_plugin_add_glob (globs, "/usr/share/applications/kde4/*.desktop");
- asb_plugin_add_glob (globs, "/usr/share/icons/hicolor/*/apps/*");
asb_plugin_add_glob (globs, "/usr/share/pixmaps/*");
asb_plugin_add_glob (globs, "/usr/share/icons/*");
asb_plugin_add_glob (globs, "/usr/share/*/icons/*");
@@ -186,7 +185,10 @@ asb_app_find_icon (AsbApp *app,
{
guint i;
guint j;
+ guint k;
+ guint m;
const gchar *pixmap_dirs[] = { "pixmaps", "icons", NULL };
+ const gchar *theme_dirs[] = { "hicolor", "oxygen", NULL };
const gchar *supported_ext[] = { ".png",
".gif",
".svg",
@@ -203,6 +205,20 @@ asb_app_find_icon (AsbApp *app,
"24x24",
"16x16",
NULL };
+ const gchar *types[] = { "actions",
+ "animations",
+ "apps",
+ "categories",
+ "devices",
+ "emblems",
+ "emotes",
+ "filesystems",
+ "intl",
+ "mimetypes",
+ "places",
+ "status",
+ "stock",
+ NULL };
/* is this an absolute path */
if (something[0] == '/') {
@@ -219,18 +235,25 @@ asb_app_find_icon (AsbApp *app,
return asb_app_load_icon (app, tmp, something, error);
}
- /* hicolor apps */
- for (i = 0; sizes[i] != NULL; i++) {
- for (j = 0; supported_ext[j] != NULL; j++) {
- _cleanup_free_ gchar *log;
- _cleanup_free_ gchar *tmp;
- log = g_strdup_printf ("/usr/share/icons/hicolor/%s/apps/%s%s",
- sizes[i],
- something,
- supported_ext[j]);
- tmp = g_build_filename (tmpdir, log, NULL);
- if (g_file_test (tmp, G_FILE_TEST_EXISTS))
- return asb_app_load_icon (app, tmp, log, error);
+ /* icon theme apps */
+ for (k = 0; theme_dirs[k] != NULL; k++) {
+ for (i = 0; sizes[i] != NULL; i++) {
+ for (m = 0; types[m] != NULL; m++) {
+ for (j = 0; supported_ext[j] != NULL; j++) {
+ _cleanup_free_ gchar *log;
+ _cleanup_free_ gchar *tmp;
+ log = g_strdup_printf ("/usr/share/icons/"
+ "%s/%s/%s/%s%s",
+ theme_dirs[k],
+ sizes[i],
+ types[m],
+ something,
+ supported_ext[j]);
+ tmp = g_build_filename (tmpdir, log, NULL);
+ if (g_file_test (tmp, G_FILE_TEST_EXISTS))
+ return asb_app_load_icon (app, tmp, log, error);
+ }
+ }
}
}