summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2019-12-02 15:28:17 -0500
committerRobert Ancell <robert.ancell@gmail.com>2019-12-10 03:09:43 +0000
commitedc4044f84af14b23e4cfbc927831dac72b10b01 (patch)
tree24cd6b12c94b7a75da64386353e615ec2c8c0052
parent62d69fb31399adb351ce7e952733a2d4b7a3a629 (diff)
downloadgnome-control-center-background-permission.tar.gz
applications: Add a 'run in background' switchbackground-permission
This is backed by the 'background' permission that the flatpak portal uses. It would be slightly nicer if we had a separate 'unset' state. For now, we just show 'unset' as 'on'.
-rw-r--r--panels/applications/cc-applications-panel.c40
-rw-r--r--panels/applications/cc-applications-panel.ui6
2 files changed, 46 insertions, 0 deletions
diff --git a/panels/applications/cc-applications-panel.c b/panels/applications/cc-applications-panel.c
index 47803085c..6d7be3398 100644
--- a/panels/applications/cc-applications-panel.c
+++ b/panels/applications/cc-applications-panel.c
@@ -86,6 +86,7 @@ struct _CcApplicationsPanel
GtkWidget *integration_section;
GtkWidget *integration_list;
GtkWidget *notification;
+ GtkWidget *background;
GtkWidget *sound;
GtkWidget *no_sound;
GtkWidget *search;
@@ -419,6 +420,37 @@ get_notification_settings (const gchar *app_id)
return g_settings_new_with_path (APP_SCHEMA, path);
}
+
+/* --- background --- */
+
+static void
+get_background_allowed (CcApplicationsPanel *self,
+ const gchar *app_id,
+ gboolean *set,
+ gboolean *allowed)
+{
+ g_auto(GStrv) perms = get_portal_permissions (self, "background", "background", app_id);
+ *set = TRUE;
+ *allowed = perms == NULL || strcmp (perms[0], "no") != 0;
+}
+
+static void
+set_background_allowed (CcApplicationsPanel *self,
+ gboolean allowed)
+{
+ const gchar *perms[2] = { NULL, NULL };
+
+ perms[0] = allowed ? "yes" : "no";
+ set_portal_permissions (self, "background", "background", self->current_flatpak_id, perms);
+}
+
+static void
+background_cb (CcApplicationsPanel *self)
+{
+ if (self->current_app_id)
+ set_background_allowed (self, cc_toggle_row_get_allowed (CC_TOGGLE_ROW (self->background)));
+}
+
/* --- device (microphone, camera, speaker) permissions (flatpak) --- */
static void
@@ -668,6 +700,11 @@ update_integration_section (CcApplicationsPanel *self,
gtk_widget_set_visible (self->notification, set);
has_any |= set;
+ get_background_allowed (self, flatpak_id, &set, &allowed);
+ cc_toggle_row_set_allowed (CC_TOGGLE_ROW (self->background), allowed);
+ gtk_widget_set_visible (self->background, set);
+ has_any |= set;
+
disabled = g_settings_get_boolean (self->privacy_settings, "disable-sound-output");
get_device_allowed (self, "speakers", flatpak_id, &set, &allowed);
cc_toggle_row_set_allowed (CC_TOGGLE_ROW (self->sound), allowed);
@@ -682,6 +719,7 @@ update_integration_section (CcApplicationsPanel *self,
gtk_widget_set_visible (self->notification, set);
has_any |= set;
+ gtk_widget_hide (self->background);
gtk_widget_hide (self->sound);
gtk_widget_hide (self->no_sound);
}
@@ -1679,6 +1717,7 @@ cc_applications_panel_class_init (CcApplicationsPanelClass *klass)
gtk_widget_class_bind_template_child (widget_class, CcApplicationsPanel, no_search);
gtk_widget_class_bind_template_child (widget_class, CcApplicationsPanel, no_sound);
gtk_widget_class_bind_template_child (widget_class, CcApplicationsPanel, notification);
+ gtk_widget_class_bind_template_child (widget_class, CcApplicationsPanel, background);
gtk_widget_class_bind_template_child (widget_class, CcApplicationsPanel, permission_section);
gtk_widget_class_bind_template_child (widget_class, CcApplicationsPanel, permission_list);
gtk_widget_class_bind_template_child (widget_class, CcApplicationsPanel, sidebar_box);
@@ -1700,6 +1739,7 @@ cc_applications_panel_class_init (CcApplicationsPanelClass *klass)
gtk_widget_class_bind_template_callback (widget_class, microphone_cb);
gtk_widget_class_bind_template_callback (widget_class, search_cb);
gtk_widget_class_bind_template_callback (widget_class, notification_cb);
+ gtk_widget_class_bind_template_callback (widget_class, background_cb);
gtk_widget_class_bind_template_callback (widget_class, privacy_link_cb);
gtk_widget_class_bind_template_callback (widget_class, sound_cb);
gtk_widget_class_bind_template_callback (widget_class, permission_row_activated_cb);
diff --git a/panels/applications/cc-applications-panel.ui b/panels/applications/cc-applications-panel.ui
index a73f08c9b..d90f5cd2b 100644
--- a/panels/applications/cc-applications-panel.ui
+++ b/panels/applications/cc-applications-panel.ui
@@ -244,6 +244,12 @@
</object>
</child>
<child>
+ <object class="CcToggleRow" id="background">
+ <property name="title" translatable="yes">Run in background</property>
+ <signal name="notify::allowed" handler="background_cb" swapped="yes"/>
+ </object>
+ </child>
+ <child>
<object class="CcToggleRow" id="sound">
<property name="title" translatable="yes">Sounds</property>
<signal name="notify::allowed" handler="sound_cb" swapped="yes"/>