[gnome-software] fedora-distro-upgrades: Add fallbacks for the background image
- From: Kalev Lember <klember src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] fedora-distro-upgrades: Add fallbacks for the background image
- Date: Thu, 2 Jun 2016 06:54:23 +0000 (UTC)
commit 0fab09382a2854740de8fe74cebd4e3ea789cce6
Author: Kalev Lember <klember redhat com>
Date: Thu Jun 2 08:44:39 2016 +0200
fedora-distro-upgrades: Add fallbacks for the background image
src/plugins/gs-plugin-fedora-distro-upgrades.c | 25 +++++++++++++++++++++--
1 files changed, 22 insertions(+), 3 deletions(-)
---
diff --git a/src/plugins/gs-plugin-fedora-distro-upgrades.c b/src/plugins/gs-plugin-fedora-distro-upgrades.c
index 262ddf8..6575e55 100644
--- a/src/plugins/gs-plugin-fedora-distro-upgrades.c
+++ b/src/plugins/gs-plugin-fedora-distro-upgrades.c
@@ -284,6 +284,24 @@ parse_pkgdb_collections_data (const gchar *data,
return distros;
}
+static gchar *
+get_upgrade_css_background (guint version)
+{
+ g_autofree gchar *filename1 = NULL;
+ g_autofree gchar *filename2 = NULL;
+
+ filename1 = g_strdup_printf ("/usr/share/backgrounds/f%d/default/standard/f%d.png", version, version);
+ if (g_file_test (filename1, G_FILE_TEST_EXISTS))
+ return g_strdup_printf ("url('%s')", filename1);
+
+ filename2 = g_strdup_printf ("/usr/share/gnome-software/backgrounds/f%d.png", version);
+ if (g_file_test (filename2, G_FILE_TEST_EXISTS))
+ return g_strdup_printf ("url('%s')", filename2);
+
+ /* fall back to solid colour */
+ return g_strdup_printf ("#151E65");
+}
+
gboolean
gs_plugin_add_distro_upgrades (GsPlugin *plugin,
GsAppList *list,
@@ -315,6 +333,7 @@ gs_plugin_add_distro_upgrades (GsPlugin *plugin,
DistroInfo *distro_info = g_ptr_array_index (distros, i);
g_autofree gchar *app_id = NULL;
g_autofree gchar *app_version = NULL;
+ g_autofree gchar *background = NULL;
g_autofree gchar *cache_key = NULL;
g_autofree gchar *url = NULL;
g_autofree gchar *css = NULL;
@@ -382,11 +401,11 @@ gs_plugin_add_distro_upgrades (GsPlugin *plugin,
gs_app_set_url (app, AS_URL_KIND_HOMEPAGE, url);
/* use a fancy background */
- css = g_strdup_printf ("background:
url('/usr/share/backgrounds/f%i/default/standard/f%i.png');"
+ background = get_upgrade_css_background (distro_info->version);
+ css = g_strdup_printf ("background: %s;"
"background-position: center;"
"background-size: cover;",
- distro_info->version,
- distro_info->version);
+ background);
gs_app_set_metadata (app, "GnomeSoftware::UpgradeBanner-css", css);
gs_app_list_add (list, app);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]