[gnome-software] Add a separate button style class for install progress



commit 8c5db4f49a587e820cb6bbb417d195d5e28020b5
Author: Kalev Lember <kalevlember gmail com>
Date:   Mon Jun 8 14:47:26 2015 +0200

    Add a separate button style class for install progress
    
    This makes it possible to actually remove the style class when we are
    done with the installing and return to regularly styled buttons.

 src/gs-app-row.c |   15 +++++++++++----
 1 files changed, 11 insertions(+), 4 deletions(-)
---
diff --git a/src/gs-app-row.c b/src/gs-app-row.c
index c024da4..7fea78c 100644
--- a/src/gs-app-row.c
+++ b/src/gs-app-row.c
@@ -118,11 +118,11 @@ static gchar *
 gs_app_row_get_button_css (gint percentage)
 {
        if (percentage == 0)
-               return g_strdup ("* { background: @theme_bg_color; }");
+               return g_strdup (".button.install-progress { background: @theme_bg_color; }");
        else if (percentage == 100)
-               return g_strdup ("* { background: @theme_selected_bg_color; }");
+               return g_strdup (".button.install-progress { background: @theme_selected_bg_color; }");
        else
-               return g_strdup_printf ("* { background: linear-gradient(to right, @theme_selected_bg_color 
%d%%, @theme_bg_color %d%%); }", percentage, percentage + 1);
+               return g_strdup_printf (".button.install-progress { background: linear-gradient(to right, 
@theme_selected_bg_color %d%%, @theme_bg_color %d%%); }", percentage, percentage + 1);
 }
 
 /**
@@ -140,9 +140,16 @@ gs_app_row_refresh (GsAppRow *app_row)
                return;
 
        /* do a fill bar for the current progress */
-       if (gs_app_get_progress (priv->app) > 0) {
+       context = gtk_widget_get_style_context (priv->button);
+       switch (gs_app_get_state (priv->app)) {
+       case AS_APP_STATE_INSTALLING:
                button_css = gs_app_row_get_button_css (gs_app_get_progress (priv->app));
                gtk_css_provider_load_from_data (priv->button_css_provider, button_css, -1, NULL);
+               gtk_style_context_add_class (context, "install-progress");
+               break;
+       default:
+               gtk_style_context_remove_class (context, "install-progress");
+               break;
        }
 
        /* join the lines*/


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