[gnome-software/wip/rancell/featured-snap] Support a banner icon



commit dc9781a0c3cdfb368e5aeb10115a892dc450126b
Author: Robert Ancell <robert ancell canonical com>
Date:   Wed Aug 9 15:28:45 2017 +1200

    Support a banner icon

 plugins/snap/gs-plugin-snap.c |   23 +++++++++++++++--------
 1 files changed, 15 insertions(+), 8 deletions(-)
---
diff --git a/plugins/snap/gs-plugin-snap.c b/plugins/snap/gs-plugin-snap.c
index 62daebb..d9604e7 100644
--- a/plugins/snap/gs-plugin-snap.c
+++ b/plugins/snap/gs-plugin-snap.c
@@ -313,11 +313,12 @@ gs_plugin_add_featured (GsPlugin *plugin,
        g_autoptr(GsApp) app = NULL;
        GPtrArray *screenshots;
        guint i;
-       const gchar *banner_url = NULL;
+       const gchar *banner_url = NULL, *icon_url = NULL;
        g_autofree gchar *background_css = NULL;
        g_autofree gchar *css = NULL;
 
        snaps = find_snaps (plugin, SNAPD_FIND_FLAGS_NONE, "featured", NULL, cancellable, error);
+
        if (snaps == NULL)
                return FALSE;
 
@@ -328,7 +329,7 @@ gs_plugin_add_featured (GsPlugin *plugin,
        snap = snaps->pdata[0];
        app = snap_to_app (plugin, snap);
 
-       /* if has a sceenshot called 'banner.png' then use that as the banner */
+       /* if has a sceenshot called 'banner.png' or 'banner-icon.png' then use them for the banner */
        screenshots = snapd_snap_get_screenshots (snap);
        for (i = 0; i < screenshots->len; i++) {
                SnapdScreenshot *screenshot = screenshots->pdata[i];
@@ -342,15 +343,19 @@ gs_plugin_add_featured (GsPlugin *plugin,
                        banner_url = url;
                        break;
                }
+               if (g_strcmp0 (filename, "banner-icon.png") == 0 ||
+                   g_strcmp0 (filename, "banner-icon.jpg") == 0) {
+                       icon_url = url;
+                       break;
+               }
        }
 
-       background_css = g_strdup_printf ("url('%s') left center / auto no-repeat,"
+       background_css = g_strdup_printf ("url('%s') left center / auto 100%% no-repeat,"
                                          " url('%s') center / cover no-repeat;",
-                                         snapd_snap_get_icon (snap),
-                                         banner_url);
+                                         icon_url, banner_url);
        css = g_strdup_printf ("border-color: #000000;\n"
-                              "text-shadow: 0 1px 1px rgba(0,0,0,0.5);\n"
-                              "color: #ffffff;\n"
+                              "text-shadow: 0 1px 1px rgba(255,255,255,0.5);\n"
+                              "color: #000000;\n"
                               "outline-offset: 0;\n"
                               "outline-color: alpha(#ffffff, 0.75);\n"
                               "outline-style: dashed;\n"
@@ -624,7 +629,9 @@ gs_plugin_refine_app (GsPlugin *plugin,
                                url = snapd_screenshot_get_url (screenshot);
                                filename = g_path_get_basename (url);
                                if (g_strcmp0 (filename, "banner.png") == 0 ||
-                                   g_strcmp0 (filename, "banner.jpg") == 0)
+                                   g_strcmp0 (filename, "banner.jpg") == 0 ||
+                                   g_strcmp0 (filename, "banner-icon.png") == 0 ||
+                                   g_strcmp0 (filename, "banner-icon.jpg") == 0)
                                        continue;
 
                                ss = as_screenshot_new ();


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]