[gnome-software] Move the Launch button to the top of the page



commit 392953265eebaab1dd7a3061e7a8c222741d3b5d
Author: Rafal Luzynski <digitalfreak lingonborough com>
Date:   Tue Sep 15 11:18:13 2015 +0200

    Move the Launch button to the top of the page
    
    Some users complained they cannot find the Launch button so here
    it is moved to the top of the page, next to the Remove button.
    
    This patch also removes the "destructive-action" style from the
    Remove button if the Launch is also visible because the designers
    agree that having two styled buttons is shouting.
    
    The launch button show/hide code has been moved from
    gs_shell_details_refresh_all() to gs_shell_details_switch_to()
    because the Launch and Remove buttons styling must be strictly
    synchronized. Also some minor styling fixes to ensure everything
    looks fine.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=738716
    
    Signed-off-by: Richard Hughes <richard hughsie com>

 src/gs-shell-details.c  |   47 ++++++++++++++++++++++++---------------------
 src/gs-shell-details.ui |   48 +++++++++++++++++++++++++---------------------
 2 files changed, 51 insertions(+), 44 deletions(-)
---
diff --git a/src/gs-shell-details.c b/src/gs-shell-details.c
index 3e7240e..21a36ca 100644
--- a/src/gs-shell-details.c
+++ b/src/gs-shell-details.c
@@ -206,6 +206,26 @@ gs_shell_details_switch_to (GsShellDetails *self)
                g_assert_not_reached ();
        }
 
+       /* launch button */
+       switch (gs_app_get_state (self->app)) {
+       case AS_APP_STATE_INSTALLED:
+       case AS_APP_STATE_UPDATABLE:
+               if (gs_app_get_id_kind (self->app) == AS_ID_KIND_DESKTOP ||
+                   gs_app_get_id_kind (self->app) == AS_ID_KIND_WEB_APP) {
+                       gtk_widget_set_visible (self->button_details_launch, TRUE);
+               } else {
+                       gtk_widget_set_visible (self->button_details_launch, FALSE);
+               }
+               break;
+       default:
+               gtk_widget_set_visible (self->button_details_launch, FALSE);
+               break;
+       }
+
+       /* don't show the launch button if the app doesn't have a desktop ID */
+       if (gs_app_get_id (self->app) == NULL)
+               gtk_widget_set_visible (self->button_details_launch, FALSE);
+
        /* remove button */
        if (kind == GS_APP_KIND_SYSTEM) {
                gtk_widget_set_visible (self->button_remove, FALSE);
@@ -215,7 +235,11 @@ gs_shell_details_switch_to (GsShellDetails *self)
                case AS_APP_STATE_UPDATABLE:
                        gtk_widget_set_visible (self->button_remove, TRUE);
                        gtk_widget_set_sensitive (self->button_remove, TRUE);
-                       gtk_style_context_add_class (gtk_widget_get_style_context (self->button_remove), 
"destructive-action");
+                       /* Mark the button as destructive only if Launch is not visible */
+                       if (gtk_widget_get_visible (self->button_details_launch))
+                               gtk_style_context_remove_class (gtk_widget_get_style_context 
(self->button_remove), "destructive-action");
+                       else
+                               gtk_style_context_add_class (gtk_widget_get_style_context 
(self->button_remove), "destructive-action");
                        /* TRANSLATORS: button text in the header when an application can be erased */
                        gtk_button_set_label (GTK_BUTTON (self->button_remove), _("_Remove"));
                        break;
@@ -698,27 +722,6 @@ gs_shell_details_refresh_all (GsShellDetails *self)
        gtk_widget_set_sensitive (self->star,
                                  gs_app_get_state (self->app) == AS_APP_STATE_INSTALLED);
 
-       /* only show launch button when the application is installed */
-       switch (gs_app_get_state (self->app)) {
-       case AS_APP_STATE_INSTALLED:
-       case AS_APP_STATE_UPDATABLE:
-               if (gs_app_get_id_kind (self->app) == AS_ID_KIND_DESKTOP ||
-                   gs_app_get_id_kind (self->app) == AS_ID_KIND_WEB_APP) {
-                       gtk_widget_set_visible (self->button_details_launch, TRUE);
-               } else {
-                       gtk_widget_set_visible (self->button_details_launch, FALSE);
-               }
-               break;
-       default:
-               gtk_widget_set_visible (self->button_details_launch, FALSE);
-               break;
-       }
-
-       /* don't show the launch button if the app doesn't have a desktop ID */
-       tmp = gs_app_get_id (self->app);
-       if (tmp == NULL)
-               gtk_widget_set_visible (self->button_details_launch, FALSE);
-
        /* make history button insensitive if there is none */
        history = gs_app_get_history (self->app);
        switch (gs_app_get_id_kind (self->app)) {
diff --git a/src/gs-shell-details.ui b/src/gs-shell-details.ui
index 0e1511f..7999f35 100644
--- a/src/gs-shell-details.ui
+++ b/src/gs-shell-details.ui
@@ -137,7 +137,7 @@
                               <object class="GtkBox" id="box_install_remove">
                                 <property name="visible">True</property>
                                 <property name="can_focus">False</property>
-                                <property name="spacing">6</property>
+                                <property name="spacing">12</property>
                                 <child>
                                   <object class="GsProgressButton" id="button_install">
                                     <property name="use_underline">True</property>
@@ -166,9 +166,6 @@
                                     <property name="receives_default">True</property>
                                     <property name="halign">start</property>
                                     <property name="valign">start</property>
-                                    <style>
-                                      <class name="destructive-action"/>
-                                    </style>
                                   </object>
                                   <packing>
                                     <property name="expand">False</property>
@@ -197,6 +194,23 @@
                                     <property name="position">3</property>
                                   </packing>
                                 </child>
+                                <child>
+                                  <object class="GtkButton" id="button_details_launch">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="receives_default">False</property>
+                                    <property name="use_underline">True</property>
+                                    <property name="label" translatable="yes" comments="Translators: A label 
for a button to execute the selected application.">_Launch</property>
+                                    <style>
+                                      <class name="suggested-action"/>
+                                    </style>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="fill">False</property>
+                                    <property name="position">4</property>
+                                  </packing>
+                                </child>
                               </object>
                               <packing>
                                 <property name="expand">False</property>
@@ -643,23 +657,6 @@
                             <property name="position">1</property>
                           </packing>
                         </child>
-                        <child>
-                          <object class="GtkButton" id="button_details_launch">
-                            <property name="visible">True</property>
-                            <property name="can_focus">True</property>
-                            <property name="receives_default">False</property>
-                            <property name="use_underline">True</property>
-                            <property name="label" translatable="yes" comments="Translators: A label for a 
button to execute the selected application.">_Launch</property>
-                            <style>
-                              <class name="suggested-action"/>
-                            </style>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">2</property>
-                          </packing>
-                        </child>
                       </object>
                       <packing>
                         <property name="expand">False</property>
@@ -1035,11 +1032,18 @@
       </object>
     </child>
   </template>
+  <object class="GtkSizeGroup" id="sizegroup_install_remove">
+    <property name="ignore_hidden">True</property>
+    <widgets>
+      <widget name="button_install"/>
+      <widget name="button_remove"/>
+      <widget name="button_details_launch"/>
+    </widgets>
+  </object>
   <object class="GtkSizeGroup" id="sizegroup_details_buttons">
     <widgets>
       <widget name="button_details_website"/>
       <widget name="button_history"/>
-      <widget name="button_details_launch"/>
     </widgets>
   </object>
   <object class="GtkSizeGroup" id="sizegroup_details_title">


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