[gnome-control-center] applications: Hide buttons that launch gnome-software if it is not available



commit dad5cc58b673cd1d3d06620445ea91852e747b68
Author: Robert Ancell <robert ancell canonical com>
Date:   Mon Dec 16 15:03:32 2019 +1300

    applications: Hide buttons that launch gnome-software if it is not available
    
    Fixes #417

 panels/applications/cc-applications-panel.c  | 13 ++++++++++++-
 panels/applications/cc-applications-panel.ui |  2 +-
 2 files changed, 13 insertions(+), 2 deletions(-)
---
diff --git a/panels/applications/cc-applications-panel.c b/panels/applications/cc-applications-panel.c
index 31570ec4b..19b477cfe 100644
--- a/panels/applications/cc-applications-panel.c
+++ b/panels/applications/cc-applications-panel.c
@@ -87,6 +87,7 @@ struct _CcApplicationsPanel
   GtkStack        *stack;
   GtkBox          *empty_box;
   GtkBox          *settings_box;
+  GtkButton       *install_button;
 
   GtkBox          *permission_section;
   GtkListBox      *permission_list;
@@ -153,6 +154,13 @@ enum
   PROP_PARAMETERS
 };
 
+static gboolean
+gnome_software_is_installed (void)
+{
+  g_autofree gchar *path = g_find_program_in_path ("gnome-software");
+  return path != NULL;
+}
+
 /* Callbacks */
 
 static gboolean
@@ -1659,7 +1667,7 @@ update_panel (CcApplicationsPanel *self,
 
   gtk_label_set_label (self->title_label, g_app_info_get_display_name (info));
   gtk_stack_set_visible_child (self->stack, GTK_WIDGET (self->settings_box));
-  gtk_widget_show (GTK_WIDGET (self->header_button));
+  gtk_widget_set_visible (GTK_WIDGET (self->header_button), gnome_software_is_installed ());
 
   g_clear_pointer (&self->current_app_id, g_free);
   g_clear_pointer (&self->current_portal_app_id, g_free);
@@ -1975,6 +1983,7 @@ cc_applications_panel_class_init (CcApplicationsPanelClass *klass)
   gtk_widget_class_bind_template_child (widget_class, CcApplicationsPanel, handler_section);
   gtk_widget_class_bind_template_child (widget_class, CcApplicationsPanel, handler_reset);
   gtk_widget_class_bind_template_child (widget_class, CcApplicationsPanel, handler_list);
+  gtk_widget_class_bind_template_child (widget_class, CcApplicationsPanel, install_button);
   gtk_widget_class_bind_template_child (widget_class, CcApplicationsPanel, integration_list);
   gtk_widget_class_bind_template_child (widget_class, CcApplicationsPanel, integration_section);
   gtk_widget_class_bind_template_child (widget_class, CcApplicationsPanel, location);
@@ -2043,6 +2052,8 @@ cc_applications_panel_init (CcApplicationsPanel *self)
 
   gtk_widget_init_template (GTK_WIDGET (self));
 
+  gtk_widget_set_visible (GTK_WIDGET (self->install_button), gnome_software_is_installed ());
+
   provider = GTK_STYLE_PROVIDER (gtk_css_provider_new ());
   gtk_css_provider_load_from_resource (GTK_CSS_PROVIDER (provider),
                                        "/org/gnome/control-center/applications/cc-applications-panel.css");
diff --git a/panels/applications/cc-applications-panel.ui b/panels/applications/cc-applications-panel.ui
index 7a08465bf..13f26d457 100644
--- a/panels/applications/cc-applications-panel.ui
+++ b/panels/applications/cc-applications-panel.ui
@@ -53,7 +53,7 @@
                       </packing>
                     </child>
                     <child>
-                      <object class="GtkButton">
+                      <object class="GtkButton" id="install_button">
                         <property name="label" translatable="yes">Install someā€¦</property>
                         <property name="visible">1</property>
                         <property name="can-focus">1</property>


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