[gnome-software] Add installed overlay to app tiles



commit 436b06b9c1b8a98bb58d0eecd580f3c7c207e269
Author: Matthias Clasen <mclasen redhat com>
Date:   Thu Sep 19 18:30:59 2013 -0400

    Add installed overlay to app tiles
    
    Use the same approach we are using for the picks, placing
    the text 'Installed' on a blue background as an overlay.
    The placement of the overlay still needs some fine-tuning.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=707613

 src/app-tile.ui   |  105 ++++++++++++++++++++++++++++++++++-------------------
 src/gs-app-tile.c |   36 ++++++++++++++++++
 2 files changed, 103 insertions(+), 38 deletions(-)
---
diff --git a/src/app-tile.ui b/src/app-tile.ui
index f3a0295..de92b0d 100644
--- a/src/app-tile.ui
+++ b/src/app-tile.ui
@@ -12,50 +12,79 @@
           <class name="tile"/>
         </style>
         <child>
-          <object class="GtkGrid" id="grid">
+          <object class="GtkOverlay" id="overlay">
             <property name="visible">True</property>
-            <property name="margin">12</property>
-            <property name="row-spacing">6</property>
-            <property name="column-spacing">6</property>
-            <child>
-              <object class="GtkImage" id="image">
-                <property name="visible">True</property>
-              </object>
-              <packing>
-                <property name="left-attach">0</property>
-                <property name="top-attach">0</property>
-                <property name="width">1</property>
-                <property name="height">2</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkLabel" id="name">
-                <property name="visible">True</property>
-                <property name="ellipsize">end</property>
-                <property name="xalign">0.0</property>
-                <attributes>
-                  <attribute name="weight" value="bold"/>
-                </attributes>
+            <property name="halign">fill</property>
+            <property name="valign">fill</property>
+            <child type="overlay">
+              <object class="GtkEventBox" id="eventbox">
+                <property name="no_show_all">True</property>
+                <property name="visible_window">True</property>
+                <property name="halign">start</property>
+                <property name="valign">start</property>
+                <property name="margin-top">35</property>
+                <style>
+                  <class name="installed-overlay-box"/>
+                </style>
+                <child>
+                  <object class="GtkLabel" id="installed-label">
+                    <property name="visible">True</property>
+                    <property name="label" translatable="yes">Installed</property>
+                    <property name="margin-left">16</property>
+                    <property name="margin-right">16</property>
+                    <property name="margin-top">4</property>
+                    <property name="margin-bottom">4</property>
+                  </object>
+                </child>
               </object>
-              <packing>
-                <property name="left-attach">1</property>
-                <property name="top-attach">0</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
-              </packing>
             </child>
             <child>
-              <object class="GtkLabel" id="summary">
+              <object class="GtkGrid" id="grid">
                 <property name="visible">True</property>
-                <property name="ellipsize">end</property>
-                <property name="xalign">0.0</property>
+                <property name="margin">12</property>
+                <property name="row-spacing">6</property>
+                <property name="column-spacing">6</property>
+                <child>
+                  <object class="GtkImage" id="image">
+                    <property name="visible">True</property>
+                  </object>
+                  <packing>
+                    <property name="left-attach">0</property>
+                    <property name="top-attach">0</property>
+                    <property name="width">1</property>
+                    <property name="height">2</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="name">
+                    <property name="visible">True</property>
+                    <property name="ellipsize">end</property>
+                    <property name="xalign">0.0</property>
+                    <attributes>
+                      <attribute name="weight" value="bold"/>
+                    </attributes>
+                  </object>
+                  <packing>
+                    <property name="left-attach">1</property>
+                    <property name="top-attach">0</property>
+                    <property name="width">1</property>
+                    <property name="height">1</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="summary">
+                    <property name="visible">True</property>
+                    <property name="ellipsize">end</property>
+                    <property name="xalign">0.0</property>
+                  </object>
+                  <packing>
+                    <property name="left-attach">1</property>
+                    <property name="top-attach">1</property>
+                    <property name="width">1</property>
+                    <property name="height">1</property>
+                  </packing>
+                </child>
               </object>
-              <packing>
-                <property name="left-attach">1</property>
-                <property name="top-attach">1</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
-              </packing>
             </child>
           </object>
         </child>
diff --git a/src/gs-app-tile.c b/src/gs-app-tile.c
index cd817de..a024846 100644
--- a/src/gs-app-tile.c
+++ b/src/gs-app-tile.c
@@ -33,6 +33,7 @@ struct _GsAppTilePrivate
        GtkWidget       *image;
        GtkWidget       *name;
        GtkWidget       *summary;
+       GtkWidget       *eventbox;
 };
 
 G_DEFINE_TYPE_WITH_PRIVATE (GsAppTile, gs_app_tile, GTK_TYPE_BIN)
@@ -55,6 +56,34 @@ gs_app_tile_get_app (GsAppTile *tile)
        return priv->app;
 }
 
+static gboolean
+transform_state_func (GBinding *binding,
+                      const GValue *source,
+                      GValue *target,
+                      gpointer user_data)
+{
+        GsAppState state;
+        gboolean installed;
+
+        state = g_value_get_uint (source);
+
+        switch (state) {
+        case GS_APP_STATE_INSTALLED:
+        case GS_APP_STATE_INSTALLING:
+        case GS_APP_STATE_REMOVING:
+        case GS_APP_STATE_UPDATABLE:
+                installed = TRUE;
+                break;
+        case GS_APP_STATE_AVAILABLE:
+        default:
+                installed = FALSE;
+                break;
+        }
+        g_value_set_boolean (target, installed);
+
+        return TRUE;
+}
+
 void
 gs_app_tile_set_app (GsAppTile *tile, GsApp *app)
 {
@@ -69,6 +98,12 @@ gs_app_tile_set_app (GsAppTile *tile, GsApp *app)
        g_clear_object (&priv->app);
        priv->app = g_object_ref (app);
 
+        g_object_bind_property_full (priv->app, "state",
+                                     priv->eventbox, "visible",
+                                     G_BINDING_SYNC_CREATE,
+                                     transform_state_func,
+                                     NULL, NULL, NULL);
+
        gtk_image_set_from_pixbuf (GTK_IMAGE (priv->image), gs_app_get_pixbuf (app));
        gtk_label_set_label (GTK_LABEL (priv->name), gs_app_get_name (app));
        summary = gs_app_get_summary (app);
@@ -128,6 +163,7 @@ gs_app_tile_class_init (GsAppTileClass *klass)
        gtk_widget_class_bind_template_child_private (widget_class, GsAppTile, image);
        gtk_widget_class_bind_template_child_private (widget_class, GsAppTile, name);
        gtk_widget_class_bind_template_child_private (widget_class, GsAppTile, summary);
+        gtk_widget_class_bind_template_child_private (widget_class, GsAppTile, eventbox);
 }
 
 GtkWidget *



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