applications: Merge permissions and integration sections

As per mockups
This commit is contained in:
Georges Basile Stavracas Neto 2022-01-20 16:08:56 -03:00
parent 25e0605f54
commit 53d3b9a70e
2 changed files with 76 additions and 120 deletions

View file

@ -93,8 +93,14 @@ struct _CcApplicationsPanel
GtkWidget *settings_box;
GtkButton *install_button;
GtkWidget *permission_section;
GtkListBox *permission_list;
GtkWidget *integration_section;
CcToggleRow *notification;
CcToggleRow *background;
CcToggleRow *wallpaper;
CcToggleRow *sound;
CcInfoRow *no_sound;
CcToggleRow *search;
CcInfoRow *no_search;
CcToggleRow *camera;
CcInfoRow *no_camera;
CcToggleRow *location;
@ -107,15 +113,6 @@ struct _CcApplicationsPanel
GtkLabel *builtin_label;
GtkListBox *builtin_list;
GtkWidget *integration_section;
CcToggleRow *notification;
CcToggleRow *background;
CcToggleRow *wallpaper;
CcToggleRow *sound;
CcInfoRow *no_sound;
CcToggleRow *search;
CcInfoRow *no_search;
GtkButton *handler_reset;
GtkDialog *handler_dialog;
CcInfoRow *handler_row;
@ -845,49 +842,6 @@ remove_static_permissions (CcApplicationsPanel *self)
listbox_remove_all (self->builtin_list);
}
static void
update_permission_section (CcApplicationsPanel *self,
GAppInfo *info)
{
g_autofree gchar *portal_app_id = get_portal_app_id (info);
gboolean disabled, allowed, set;
gboolean has_any = FALSE;
if (portal_app_id == NULL)
{
gtk_widget_hide (self->permission_section);
return;
}
disabled = g_settings_get_boolean (self->privacy_settings, "disable-camera");
get_device_allowed (self, "camera", portal_app_id, &set, &allowed);
cc_toggle_row_set_allowed (self->camera, allowed);
gtk_widget_set_visible (GTK_WIDGET (self->camera), set && !disabled);
gtk_widget_set_visible (GTK_WIDGET (self->no_camera), set && disabled);
has_any |= set;
disabled = g_settings_get_boolean (self->privacy_settings, "disable-microphone");
get_device_allowed (self, "microphone", portal_app_id, &set, &allowed);
cc_toggle_row_set_allowed (self->microphone, allowed);
gtk_widget_set_visible (GTK_WIDGET (self->microphone), set && !disabled);
gtk_widget_set_visible (GTK_WIDGET (self->no_microphone), set && disabled);
has_any |= set;
disabled = !g_settings_get_boolean (self->location_settings, "enabled");
get_location_allowed (self, portal_app_id, &set, &allowed);
cc_toggle_row_set_allowed (self->location, allowed);
gtk_widget_set_visible (GTK_WIDGET (self->location), set && !disabled);
gtk_widget_set_visible (GTK_WIDGET (self->no_location), set && disabled);
has_any |= set;
#ifdef HAVE_SNAP
remove_snap_permissions (self);
has_any |= add_snap_permissions (self, info, portal_app_id);
#endif
gtk_widget_set_visible (self->permission_section, has_any);
}
/* --- header section --- */
static void
@ -956,6 +910,32 @@ update_integration_section (CcApplicationsPanel *self,
cc_toggle_row_set_allowed (self->sound, allowed);
gtk_widget_set_visible (GTK_WIDGET (self->sound), set && !disabled);
gtk_widget_set_visible (GTK_WIDGET (self->no_sound), set && disabled);
disabled = g_settings_get_boolean (self->privacy_settings, "disable-camera");
get_device_allowed (self, "camera", portal_app_id, &set, &allowed);
cc_toggle_row_set_allowed (self->camera, allowed);
gtk_widget_set_visible (GTK_WIDGET (self->camera), set && !disabled);
gtk_widget_set_visible (GTK_WIDGET (self->no_camera), set && disabled);
has_any |= set;
disabled = g_settings_get_boolean (self->privacy_settings, "disable-microphone");
get_device_allowed (self, "microphone", portal_app_id, &set, &allowed);
cc_toggle_row_set_allowed (self->microphone, allowed);
gtk_widget_set_visible (GTK_WIDGET (self->microphone), set && !disabled);
gtk_widget_set_visible (GTK_WIDGET (self->no_microphone), set && disabled);
has_any |= set;
disabled = !g_settings_get_boolean (self->location_settings, "enabled");
get_location_allowed (self, portal_app_id, &set, &allowed);
cc_toggle_row_set_allowed (self->location, allowed);
gtk_widget_set_visible (GTK_WIDGET (self->location), set && !disabled);
gtk_widget_set_visible (GTK_WIDGET (self->no_location), set && disabled);
has_any |= set;
#ifdef HAVE_SNAP
remove_snap_permissions (self);
has_any |= add_snap_permissions (self, info, portal_app_id);
#endif
}
else
{
@ -969,6 +949,12 @@ update_integration_section (CcApplicationsPanel *self,
gtk_widget_hide (GTK_WIDGET (self->wallpaper));
gtk_widget_hide (GTK_WIDGET (self->sound));
gtk_widget_hide (GTK_WIDGET (self->no_sound));
gtk_widget_hide (GTK_WIDGET (self->camera));
gtk_widget_hide (GTK_WIDGET (self->no_camera));
gtk_widget_hide (GTK_WIDGET (self->microphone));
gtk_widget_hide (GTK_WIDGET (self->no_microphone));
gtk_widget_hide (GTK_WIDGET (self->location));
gtk_widget_hide (GTK_WIDGET (self->no_location));
}
gtk_widget_set_visible (self->integration_section, has_any);
@ -1416,7 +1402,6 @@ update_panel (CcApplicationsPanel *self,
g_clear_pointer (&self->current_portal_app_id, g_free);
update_header_section (self, info);
update_permission_section (self, info);
update_integration_section (self, info);
update_handler_dialog (self, info);
update_usage_section (self, info);
@ -1769,8 +1754,6 @@ cc_applications_panel_class_init (CcApplicationsPanelClass *klass)
gtk_widget_class_bind_template_child (widget_class, CcApplicationsPanel, background);
gtk_widget_class_bind_template_child (widget_class, CcApplicationsPanel, wallpaper);
gtk_widget_class_bind_template_child (widget_class, CcApplicationsPanel, shortcuts);
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);
gtk_widget_class_bind_template_child (widget_class, CcApplicationsPanel, sidebar_listbox);
gtk_widget_class_bind_template_child (widget_class, CcApplicationsPanel, sidebar_search_entry);

View file

@ -105,69 +105,6 @@
</object>
</child>
<child>
<object class="AdwPreferencesGroup" id="permission_section">
<child>
<object class="GtkListBox" id="permission_list">
<property name="selection-mode">none</property>
<style>
<class name="boxed-list"/>
</style>
<child>
<object class="CcToggleRow" id="camera">
<property name="title" translatable="yes">Camera</property>
<signal name="notify::allowed" handler="camera_cb" object="CcApplicationsPanel" swapped="yes"/>
</object>
</child>
<child>
<object class="CcInfoRow" id="no_camera">
<property name="title" translatable="yes">Camera</property>
<property name="info" translatable="yes">Disabled</property>
</object>
</child>
<child>
<object class="CcToggleRow" id="microphone">
<property name="title" translatable="yes">Microphone</property>
<signal name="notify::allowed" handler="microphone_cb" object="CcApplicationsPanel" swapped="yes"/>
</object>
</child>
<child>
<object class="CcInfoRow" id="no_microphone">
<property name="title" translatable="yes">Microphone</property>
<property name="info" translatable="yes">Disabled</property>
</object>
</child>
<child>
<object class="CcToggleRow" id="location">
<property name="title" translatable="yes">Location Services</property>
<signal name="notify::allowed" handler="location_cb" object="CcApplicationsPanel" swapped="yes"/>
</object>
</child>
<child>
<object class="CcInfoRow" id="no_location">
<property name="title" translatable="yes">Location Services</property>
<property name="info" translatable="yes">Disabled</property>
</object>
</child>
<style>
<class name="boxed-list"/>
</style>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="xalign">0</property>
<property name="wrap">1</property>
<property name="max-width-chars">50</property>
<property name="margin-top">12</property>
<property name="label" translatable="yes">Individual permissions for applications can be reviewed in the &lt;a href=&quot;privacy&quot;&gt;Privacy&lt;/a&gt; Settings.</property>
<property name="use-markup">1</property>
<signal name="activate-link" handler="privacy_link_cb" object="CcApplicationsPanel" swapped="yes"/>
</object>
</child>
</object>
</child>
<child>
<object class="AdwPreferencesGroup" id="integration_section">
<child>
@ -218,6 +155,42 @@
<signal name="notify::allowed" handler="shortcuts_cb" swapped="yes"/>
</object>
</child>
<child>
<object class="CcToggleRow" id="camera">
<property name="title" translatable="yes">Camera</property>
<signal name="notify::allowed" handler="camera_cb" object="CcApplicationsPanel" swapped="yes"/>
</object>
</child>
<child>
<object class="CcInfoRow" id="no_camera">
<property name="title" translatable="yes">Camera</property>
<property name="info" translatable="yes">Disabled</property>
</object>
</child>
<child>
<object class="CcToggleRow" id="microphone">
<property name="title" translatable="yes">Microphone</property>
<signal name="notify::allowed" handler="microphone_cb" object="CcApplicationsPanel" swapped="yes"/>
</object>
</child>
<child>
<object class="CcInfoRow" id="no_microphone">
<property name="title" translatable="yes">Microphone</property>
<property name="info" translatable="yes">Disabled</property>
</object>
</child>
<child>
<object class="CcToggleRow" id="location">
<property name="title" translatable="yes">Location Services</property>
<signal name="notify::allowed" handler="location_cb" object="CcApplicationsPanel" swapped="yes"/>
</object>
</child>
<child>
<object class="CcInfoRow" id="no_location">
<property name="title" translatable="yes">Location Services</property>
<property name="info" translatable="yes">Disabled</property>
</object>
</child>
</object>
</child>