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

Fixes #417
This commit is contained in:
Robert Ancell 2019-12-16 15:03:32 +13:00 committed by Robert Ancell
parent b31520ae8b
commit dad5cc58b6
2 changed files with 13 additions and 2 deletions

View file

@ -87,6 +87,7 @@ struct _CcApplicationsPanel
GtkStack *stack; GtkStack *stack;
GtkBox *empty_box; GtkBox *empty_box;
GtkBox *settings_box; GtkBox *settings_box;
GtkButton *install_button;
GtkBox *permission_section; GtkBox *permission_section;
GtkListBox *permission_list; GtkListBox *permission_list;
@ -153,6 +154,13 @@ enum
PROP_PARAMETERS PROP_PARAMETERS
}; };
static gboolean
gnome_software_is_installed (void)
{
g_autofree gchar *path = g_find_program_in_path ("gnome-software");
return path != NULL;
}
/* Callbacks */ /* Callbacks */
static gboolean 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_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_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_app_id, g_free);
g_clear_pointer (&self->current_portal_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_section);
gtk_widget_class_bind_template_child (widget_class, CcApplicationsPanel, handler_reset); 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, 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_list);
gtk_widget_class_bind_template_child (widget_class, CcApplicationsPanel, integration_section); gtk_widget_class_bind_template_child (widget_class, CcApplicationsPanel, integration_section);
gtk_widget_class_bind_template_child (widget_class, CcApplicationsPanel, location); 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_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 ()); provider = GTK_STYLE_PROVIDER (gtk_css_provider_new ());
gtk_css_provider_load_from_resource (GTK_CSS_PROVIDER (provider), gtk_css_provider_load_from_resource (GTK_CSS_PROVIDER (provider),
"/org/gnome/control-center/applications/cc-applications-panel.css"); "/org/gnome/control-center/applications/cc-applications-panel.css");

View file

@ -53,7 +53,7 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkButton"> <object class="GtkButton" id="install_button">
<property name="label" translatable="yes">Install some…</property> <property name="label" translatable="yes">Install some…</property>
<property name="visible">1</property> <property name="visible">1</property>
<property name="can-focus">1</property> <property name="can-focus">1</property>