[gnome-software/wip/kalev/extensions] details: Show a settings button for shell extensions



commit 658c5c5ed6139cd3b71586b96f02bdfd84dc95e1
Author: Kalev Lember <klember redhat com>
Date:   Fri Nov 25 18:19:16 2016 +0100

    details: Show a settings button for shell extensions
    
    Instead of 'Launch', show a 'Settings' button for shell extensions which
    launched the preferences tool.

 src/gs-shell-details.c  |   48 ++++++++++++++++++++++++++++++++++++----------
 src/gs-shell-details.ui |   29 +++++++++++++++++++++------
 2 files changed, 59 insertions(+), 18 deletions(-)
---
diff --git a/src/gs-shell-details.c b/src/gs-shell-details.c
index 787afe3..748ec9b 100644
--- a/src/gs-shell-details.c
+++ b/src/gs-shell-details.c
@@ -80,6 +80,7 @@ struct _GsShellDetails
        GtkWidget               *button_details_launch;
        GtkWidget               *button_details_add_shortcut;
        GtkWidget               *button_details_remove_shortcut;
+       GtkWidget               *button_details_settings;
        GtkWidget               *button_details_website;
        GtkWidget               *button_install;
        GtkWidget               *button_remove;
@@ -320,19 +321,40 @@ gs_shell_details_switch_to (GsPage *page, gboolean scroll_up)
        }
 
        /* launch button */
-       switch (gs_app_get_state (self->app)) {
-       case AS_APP_STATE_INSTALLED:
-       case AS_APP_STATE_UPDATABLE:
-       case AS_APP_STATE_UPDATABLE_LIVE:
-               if (!gs_app_has_quirk (self->app, AS_APP_QUIRK_NOT_LAUNCHABLE)) {
-                       gtk_widget_set_visible (self->button_details_launch, TRUE);
-               } else {
+       if (gs_app_get_kind (self->app) == AS_APP_KIND_SHELL_EXTENSION) {
+               gtk_widget_set_visible (self->button_details_launch, FALSE);
+       } else {
+               gtk_widget_set_visible (self->button_details_launch, TRUE);
+               switch (gs_app_get_state (self->app)) {
+               case AS_APP_STATE_INSTALLED:
+               case AS_APP_STATE_UPDATABLE:
+               case AS_APP_STATE_UPDATABLE_LIVE:
+                       if (!gs_app_has_quirk (self->app, AS_APP_QUIRK_NOT_LAUNCHABLE)) {
+                               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;
                }
-               break;
-       default:
-               gtk_widget_set_visible (self->button_details_launch, FALSE);
-               break;
+       }
+
+       /* settings button */
+       if (gs_app_get_kind (self->app) == AS_APP_KIND_SHELL_EXTENSION) {
+               switch (gs_app_get_state (self->app)) {
+               case AS_APP_STATE_INSTALLED:
+               case AS_APP_STATE_UPDATABLE:
+               case AS_APP_STATE_UPDATABLE_LIVE:
+                       gtk_widget_set_visible (self->button_details_settings, TRUE);
+                       break;
+               default:
+                       gtk_widget_set_visible (self->button_details_settings, FALSE);
+                       break;
+               }
+       } else {
+               gtk_widget_set_visible (self->button_details_settings, FALSE);
        }
 
        /* don't show the launch and shortcut buttons if the app doesn't have a desktop ID */
@@ -2032,6 +2054,9 @@ gs_shell_details_setup (GsShellDetails *self,
        g_signal_connect (self->button_details_remove_shortcut, "clicked",
                          G_CALLBACK (gs_shell_details_app_remove_shortcut_button_cb),
                          self);
+       g_signal_connect (self->button_details_settings, "clicked",
+                         G_CALLBACK (gs_shell_details_app_launch_button_cb),
+                         self);
        g_signal_connect (self->button_details_website, "clicked",
                          G_CALLBACK (gs_shell_details_website_cb),
                          self);
@@ -2107,6 +2132,7 @@ gs_shell_details_class_init (GsShellDetailsClass *klass)
        gtk_widget_class_bind_template_child (widget_class, GsShellDetails, button_details_launch);
        gtk_widget_class_bind_template_child (widget_class, GsShellDetails, button_details_add_shortcut);
        gtk_widget_class_bind_template_child (widget_class, GsShellDetails, button_details_remove_shortcut);
+       gtk_widget_class_bind_template_child (widget_class, GsShellDetails, button_details_settings);
        gtk_widget_class_bind_template_child (widget_class, GsShellDetails, button_details_website);
        gtk_widget_class_bind_template_child (widget_class, GsShellDetails, button_install);
        gtk_widget_class_bind_template_child (widget_class, GsShellDetails, button_remove);
diff --git a/src/gs-shell-details.ui b/src/gs-shell-details.ui
index 3b25610..98aeade 100644
--- a/src/gs-shell-details.ui
+++ b/src/gs-shell-details.ui
@@ -237,6 +237,21 @@
                               </packing>
                             </child>
                             <child>
+                              <object class="GtkButton" id="button_details_settings">
+                                <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 show extension settings window.">_Settings</property>
+                                <property name="width_request">105</property>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">False</property>
+                                <property name="position">2</property>
+                              </packing>
+                            </child>
+                            <child>
                               <object class="GtkButton" id="button_remove">
                                 <property name="use_underline">True</property>
                                 <property name="label" translatable="yes">_Remove</property>
@@ -249,7 +264,7 @@
                               <packing>
                                 <property name="expand">False</property>
                                 <property name="fill">False</property>
-                                <property name="position">2</property>
+                                <property name="position">3</property>
                               </packing>
                             </child>
                             <child>
@@ -259,7 +274,7 @@
                               <packing>
                                 <property name="expand">False</property>
                                 <property name="fill">False</property>
-                                <property name="position">3</property>
+                                <property name="position">4</property>
                               </packing>
                             </child>
                             <child>
@@ -321,7 +336,7 @@
                               <packing>
                                 <property name="expand">True</property>
                                 <property name="fill">True</property>
-                                <property name="position">4</property>
+                                <property name="position">5</property>
                               </packing>
                             </child>
                             <child>
@@ -335,7 +350,7 @@
                               <packing>
                                 <property name="expand">False</property>
                                 <property name="fill">False</property>
-                                <property name="position">5</property>
+                                <property name="position">6</property>
                               </packing>
                             </child>
                             <child>
@@ -346,7 +361,7 @@
                               <packing>
                                 <property name="expand">False</property>
                                 <property name="fill">False</property>
-                                <property name="position">6</property>
+                                <property name="position">7</property>
                               </packing>
                             </child>
                             <child>
@@ -360,7 +375,7 @@
                               <packing>
                                 <property name="expand">False</property>
                                 <property name="fill">False</property>
-                                <property name="position">7</property>
+                                <property name="position">8</property>
                                 <property name="pack-type">end</property>
                               </packing>
                             </child>
@@ -375,7 +390,7 @@
                               <packing>
                                 <property name="expand">False</property>
                                 <property name="fill">False</property>
-                                <property name="position">8</property>
+                                <property name="position">9</property>
                                 <property name="pack-type">end</property>
                               </packing>
                             </child>


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