[gnome-software] Move featured image rendering to css



commit 026d240778104752b4a2aa79ebbc63cbd0002552
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon Sep 9 20:56:46 2013 -0400

    Move featured image rendering to css
    
    We are constructing custom css for the featured tile anyway,
    and using css for the image lets us use full-size images, and
    rely on css to do the scaling and positioning, instead of manually
    clipping the image.

 src/feature-tile.ui                        |   13 ++++++++++---
 src/gs-feature-tile.c                      |   10 ++++++++--
 src/plugins/gs-plugin-hardcoded-featured.c |   12 +++++++++++-
 3 files changed, 29 insertions(+), 6 deletions(-)
---
diff --git a/src/feature-tile.ui b/src/feature-tile.ui
index 2d8673b..a3566ee 100644
--- a/src/feature-tile.ui
+++ b/src/feature-tile.ui
@@ -11,18 +11,22 @@
           <class name="featured-tile"/>
         </style>
         <child>
-          <object class="GtkBox" id="box">
+          <object class="GsBox" id="box">
             <property name="visible">True</property>
-            <property name="orientation">horizontal</property>
             <property name="hexpand">True</property>
             <child>
-              <object class="GtkImage" id="image">
+              <object class="GtkEventBox" id="image">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
+                <property name="visible_window">True</property>
+                <property name="height_request">240</property>
                 <style>
                   <class name="featured-image"/>
                 </style>
               </object>
+              <packing>
+                <property name="relative_size">1.0</property>
+              </packing>
             </child>
             <child>
               <object class="GtkBox" id="box2">
@@ -53,6 +57,9 @@
                   </object>
                 </child>
               </object>
+              <packing>
+                <property name="relative_size">1.0</property>
+              </packing>
             </child>
           </object>
         </child>
diff --git a/src/gs-feature-tile.c b/src/gs-feature-tile.c
index d281267..2cf730a 100644
--- a/src/gs-feature-tile.c
+++ b/src/gs-feature-tile.c
@@ -70,11 +70,14 @@ gs_feature_tile_set_app (GsFeatureTile *tile, GsApp *app)
         g_clear_object (&priv->app);
        priv->app = g_object_ref (app);
 
-        gtk_image_set_from_pixbuf (GTK_IMAGE (priv->image),
-                                   gs_app_get_featured_pixbuf (priv->app));
         gtk_label_set_label (GTK_LABEL (priv->title), gs_app_get_name (app));
         gtk_label_set_label (GTK_LABEL (priv->subtitle), gs_app_get_summary (app));
         data = g_strdup_printf (
+                ".featured-image {\n"
+                "  background-image: url('%s');\n"
+                "  background-size: %s;\n"
+                "  background-position: %s;\n"
+                "}\n"
                 ".button.featured-tile {\n"
                 "  padding: 0;\n"
                 "  border-radius: 0;\n"
@@ -97,6 +100,9 @@ gs_feature_tile_set_app (GsFeatureTile *tile, GsApp *app)
                 "                       color-stop(0,alpha(%s,0.80)),\n"
                 "                       color-stop(1,alpha(%s,0.80)));\n"
                 "}\n",
+                gs_app_get_metadata_item (app, "Featured::image-path"),
+                gs_app_get_metadata_item (app, "Featured::image-size"),
+                gs_app_get_metadata_item (app, "Featured::image-position"),
                 gs_app_get_metadata_item (app, "Featured::stroke-color"),
                 gs_app_get_metadata_item (app, "Featured::text-color"),
                 gs_app_get_metadata_item (app, "Featured::text-color"),
diff --git a/src/plugins/gs-plugin-hardcoded-featured.c b/src/plugins/gs-plugin-hardcoded-featured.c
index 3410855..a6ad300 100644
--- a/src/plugins/gs-plugin-hardcoded-featured.c
+++ b/src/plugins/gs-plugin-hardcoded-featured.c
@@ -106,9 +106,19 @@ gs_plugin_add_featured (GsPlugin *plugin,
                goto out;
        }
 
-        app = gs_app_new (apps[i]);
+        app = gs_app_new (group);
        gs_app_set_featured_pixbuf (app, pixbuf);
         gs_app_set_metadata (app, "Featured::image-path", path);
+        s = g_key_file_get_string (kf, group, "size", NULL);
+        if (s) {
+                gs_app_set_metadata (app, "Featured::image-size", s);
+                g_free (s);
+        }
+        s = g_key_file_get_string (kf, group, "position", NULL);
+        if (s) {
+                gs_app_set_metadata (app, "Featured::image-position", s);
+                g_free (s);
+        }
         s = g_key_file_get_string (kf, group, "gradient1", NULL);
         if (s) {
                 gs_app_set_metadata (app, "Featured::gradient1-color", s);


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