[gnome-software] Show an installed tag when there are no buttons showing



commit a3604aadf58e9cbb5e2252dd8824ed14148b3a71
Author: Richard Hughes <richard hughsie com>
Date:   Mon Jul 11 09:39:31 2016 +0100

    Show an installed tag when there are no buttons showing

 src/gs-app-row.c  |   18 ++++++++++++++++++
 src/gs-app-row.ui |   52 +++++++++++++++++++++++++++++++++++++++++-----------
 src/gtk-style.css |   14 ++++++++++++++
 3 files changed, 73 insertions(+), 11 deletions(-)
---
diff --git a/src/gs-app-row.c b/src/gs-app-row.c
index b7f4ced..25d2471 100644
--- a/src/gs-app-row.c
+++ b/src/gs-app-row.c
@@ -48,6 +48,7 @@ typedef struct
        GtkWidget       *checkbox;
        GtkWidget       *label_warning;
        GtkWidget       *label_origin;
+       GtkWidget       *label_installed;
        GtkWidget       *box_sandboxed;
        GtkWidget       *image_sandboxed;
        gboolean         colorful;
@@ -360,6 +361,22 @@ gs_app_row_refresh (GsAppRow *app_row)
                gtk_widget_set_visible (priv->box_sandboxed, FALSE);
        }
 
+       /* installed tag */
+       if (!priv->show_buttons) {
+               switch (gs_app_get_state (priv->app)) {
+               case AS_APP_STATE_UPDATABLE:
+               case AS_APP_STATE_UPDATABLE_LIVE:
+               case AS_APP_STATE_INSTALLED:
+                       gtk_widget_set_visible (priv->label_installed, TRUE);
+                       break;
+               default:
+                       gtk_widget_set_visible (priv->label_installed, FALSE);
+                       break;
+               }
+       } else {
+               gtk_widget_set_visible (priv->label_installed, FALSE);
+       }
+
        gtk_label_set_label (GTK_LABEL (priv->name_label),
                             gs_app_get_name (priv->app));
        if (priv->show_update &&
@@ -649,6 +666,7 @@ gs_app_row_class_init (GsAppRowClass *klass)
        gtk_widget_class_bind_template_child_private (widget_class, GsAppRow, checkbox);
        gtk_widget_class_bind_template_child_private (widget_class, GsAppRow, label_warning);
        gtk_widget_class_bind_template_child_private (widget_class, GsAppRow, label_origin);
+       gtk_widget_class_bind_template_child_private (widget_class, GsAppRow, label_installed);
        gtk_widget_class_bind_template_child_private (widget_class, GsAppRow, box_sandboxed);
        gtk_widget_class_bind_template_child_private (widget_class, GsAppRow, image_sandboxed);
 }
diff --git a/src/gs-app-row.ui b/src/gs-app-row.ui
index dda992a..421e08b 100644
--- a/src/gs-app-row.ui
+++ b/src/gs-app-row.ui
@@ -3,6 +3,9 @@
   <!-- interface-requires gtk+ 3.10 -->
   <template class="GsAppRow" parent="GtkListBoxRow">
     <property name="visible">True</property>
+    <style>
+      <class name="list-box-app-row"/>
+    </style>
     <child>
       <object class="GtkBox" id="box">
         <property name="visible">True</property>
@@ -197,20 +200,47 @@
                   </packing>
                 </child>
                 <child>
-                  <object class="GtkLabel" id="label_origin">
+                  <object class="GtkBox" id="box_desc">
                     <property name="visible">True</property>
-                    <property name="xalign">0.0</property>
-                    <property name="yalign">0.5</property>
-                    <property name="halign">start</property>
-                    <property name="ellipsize">end</property>
-                    <style>
-                      <class name="app-row-origin-text"/>
-                      <class name="dim-label"/>
-                    </style>
+                    <property name="can_focus">False</property>
+                    <property name="orientation">horizontal</property>
+                    <child>
+                      <object class="GtkLabel" id="label_origin">
+                        <property name="visible">True</property>
+                        <property name="xalign">0.0</property>
+                        <property name="yalign">1.0</property>
+                        <property name="halign">start</property>
+                        <property name="ellipsize">end</property>
+                        <style>
+                          <class name="app-row-origin-text"/>
+                          <class name="dim-label"/>
+                        </style>
+                      </object>
+                      <packing>
+                        <property name="expand">True</property>
+                        <property name="fill">True</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="label_installed">
+                        <property name="visible">True</property>
+                        <property name="xalign">1.0</property>
+                        <property name="yalign">0.5</property>
+                        <property name="halign">end</property>
+                        <property name="label" translatable="yes" comments="app state">Installed</property>
+                        <style>
+                          <class name="app-row-installed-label"/>
+                        </style>
+                      </object>
+                      <packing>
+                        <property name="expand">True</property>
+                        <property name="fill">True</property>
+                      </packing>
+                    </child>
                   </object>
                   <packing>
-                    <property name="expand">False</property>
-                    <property name="fill">False</property>
+                    <property name="expand">True</property>
+                    <property name="fill">True</property>
                   </packing>
                 </child>
               </object>
diff --git a/src/gtk-style.css b/src/gtk-style.css
index 3f1552c..bafb598 100644
--- a/src/gtk-style.css
+++ b/src/gtk-style.css
@@ -9,6 +9,7 @@
         color: @theme_selected_fg_color;
   }
 
+
 .popular-installed-overlay-box {
        font-size: 80%;
        background-color: @theme_selected_bg_color;
@@ -25,6 +26,14 @@
        font-size: 14px;
 }
 
+.app-row-installed-label {
+       background-color: @theme_selected_bg_color;
+       border-radius: 0;
+       color: @theme_selected_fg_color;
+       text-shadow: 0 1px 0 rgba(0,0,0,0.5);
+       padding: 4px 12px;
+}
+
 .needs-attention {
        background-image: none;
        background-color: shade(@theme_selected_bg_color, 1.1);
@@ -298,6 +307,11 @@ button.star, .button.star {
 
 .category-sidebar:backdrop:not(.undershoot):not(.overshoot) { background-color: @theme_unfocused_base_color; 
}
 
+/* padding removal */
+.list-box-app-row {
+       padding: 0px;
+}
+
 /* Superfluous borders removal */
 .category-sidebar {
        border-style: none;


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