camera: Make the switches toggleable when disabled
Allow to toggle the applications switches when the main permission is disabled.
This commit is contained in:
parent
8ecdeb2805
commit
fa821608b5
1 changed files with 34 additions and 6 deletions
|
@ -101,14 +101,17 @@ on_camera_app_state_set (GtkSwitch *widget,
|
|||
GVariant *params;
|
||||
const gchar *key;
|
||||
gchar **value;
|
||||
gboolean active_camera;
|
||||
|
||||
self = data->self;
|
||||
|
||||
if (data->changing_state)
|
||||
return TRUE;
|
||||
|
||||
active_camera = !g_settings_get_boolean (self->privacy_settings,
|
||||
"disable-camera");
|
||||
data->changing_state = TRUE;
|
||||
data->pending_state = state;
|
||||
data->pending_state = active_camera && state;
|
||||
|
||||
g_variant_iter_init (&iter, self->camera_apps_perms);
|
||||
g_variant_builder_init (&builder, G_VARIANT_TYPE_ARRAY);
|
||||
|
@ -151,6 +154,25 @@ on_camera_app_state_set (GtkSwitch *widget,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
update_app_switch_state (GValue *value,
|
||||
GVariant *variant,
|
||||
gpointer data)
|
||||
{
|
||||
GtkSwitch *w = GTK_SWITCH (data);
|
||||
gboolean active_camera;
|
||||
gboolean active_app;
|
||||
gboolean state;
|
||||
|
||||
active_camera = !g_variant_get_boolean (variant);
|
||||
active_app = gtk_switch_get_active (w);
|
||||
state = active_camera && active_app;
|
||||
|
||||
g_value_set_boolean (value, state);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
add_camera_app (CcCameraPanel *self,
|
||||
const gchar *app_id,
|
||||
|
@ -190,11 +212,17 @@ add_camera_app (CcCameraPanel *self,
|
|||
gtk_switch_set_active (GTK_SWITCH (w), enabled);
|
||||
gtk_widget_set_valign (w, GTK_ALIGN_CENTER);
|
||||
adw_action_row_add_suffix (ADW_ACTION_ROW (row), w);
|
||||
g_settings_bind (self->privacy_settings,
|
||||
|
||||
g_settings_bind_with_mapping (self->privacy_settings,
|
||||
"disable-camera",
|
||||
w,
|
||||
"sensitive",
|
||||
G_SETTINGS_BIND_INVERT_BOOLEAN);
|
||||
"state",
|
||||
G_SETTINGS_BIND_GET,
|
||||
update_app_switch_state,
|
||||
NULL,
|
||||
g_object_ref (w),
|
||||
g_object_unref);
|
||||
|
||||
g_hash_table_insert (self->camera_app_switches,
|
||||
g_strdup (app_id),
|
||||
g_object_ref (w));
|
||||
|
|
Loading…
Add table
Reference in a new issue