[gnome-software/flatpak-permissions: 3/4] updates page: show new permissions
- From: Kalev Lember <klember src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/flatpak-permissions: 3/4] updates page: show new permissions
- Date: Thu, 10 Jan 2019 21:29:30 +0000 (UTC)
commit 099cd42d615f0065f6b5e788f09882341668e6d5
Author: Matthias Clasen <mclasen redhat com>
Date: Wed Dec 26 16:50:18 2018 -0500
updates page: show new permissions
Add a warning in the list if there are new permissions,
and spell out the permissions in the update dialog.
src/gs-app-row.c | 7 +++++
src/gs-update-dialog.c | 80 +++++++++++++++++++++++++++++++++++++++++++++++++
src/gs-update-dialog.ui | 42 +++++++++++++++++++++-----
3 files changed, 122 insertions(+), 7 deletions(-)
---
diff --git a/src/gs-app-row.c b/src/gs-app-row.c
index 9d0fba98..25d90f85 100644
--- a/src/gs-app-row.c
+++ b/src/gs-app-row.c
@@ -488,6 +488,13 @@ gs_app_row_refresh (GsAppRow *app_row)
} else {
gtk_widget_hide (priv->label_app_size);
}
+
+ /* add warning */
+ if (gs_app_has_quirk (priv->app, GS_APP_QUIRK_NEW_PERMISSIONS)) {
+ gtk_label_set_text (GTK_LABEL (priv->label_warning),
+ _("Requires additional permissions"));
+ gtk_widget_show (priv->label_warning);
+ }
}
static void
diff --git a/src/gs-update-dialog.c b/src/gs-update-dialog.c
index 29a349b9..4bec35d2 100644
--- a/src/gs-update-dialog.c
+++ b/src/gs-update-dialog.c
@@ -64,6 +64,8 @@ struct _GsUpdateDialog
GtkWidget *scrolledwindow_details;
GtkWidget *spinner;
GtkWidget *stack;
+ GtkWidget *permissions_section_title;
+ GtkWidget *permissions_section_content;
};
G_DEFINE_TYPE (GsUpdateDialog, gs_update_dialog, GTK_TYPE_DIALOG)
@@ -96,6 +98,73 @@ back_entry_free (BackEntry *entry)
g_slice_free (BackEntry, entry);
}
+static struct {
+ GsAppPermissions permission;
+ const char *title;
+ const char *subtitle;
+} permission_display_data[] = {
+ { GS_APP_PERMISSIONS_NETWORK, N_("Network"), N_("Can communicate over the network") },
+ { GS_APP_PERMISSIONS_SYSTEM_BUS, N_("System Services"), N_("...") },
+ { GS_APP_PERMISSIONS_SESSION_BUS, N_("Session Services"), N_("...") },
+ { GS_APP_PERMISSIONS_DEVICES, N_("Devices"), N_("Can access system device files") },
+ { GS_APP_PERMISSIONS_HOME_FULL, N_("Home folder"), N_("Can view, edit and create files") },
+ { GS_APP_PERMISSIONS_HOME_READ, N_("Home folder"), N_("Can view files") },
+ { GS_APP_PERMISSIONS_FILESYSTEM_FULL, N_("File system"), N_("Can view, edit and create files") },
+ { GS_APP_PERMISSIONS_FILESYSTEM_READ, N_("File system"), N_("Can view files") },
+ { GS_APP_PERMISSIONS_DOWNLOADS_FULL, N_("Downloads folder"), N_("Can view, edit and create files") },
+ { GS_APP_PERMISSIONS_DOWNLOADS_READ, N_("Downloads folder"), N_("Can view files") },
+ { GS_APP_PERMISSIONS_SETTINGS, N_("Settings"), N_("Can view and change any settings") },
+ { GS_APP_PERMISSIONS_X11, N_("Legacy display system"), N_("Uses an old, insecure display system") },
+};
+
+static void
+populate_permissions_section (GsUpdateDialog *dialog, GsAppPermissions permissions)
+{
+ GList *children;
+
+ children = gtk_container_get_children (GTK_CONTAINER (dialog->permissions_section_content));
+ for (GList *l = children; l != NULL; l = l->next)
+ gtk_widget_destroy (GTK_WIDGET (l->data));
+ g_list_free (children);
+
+ for (gsize i = 0; i < G_N_ELEMENTS (permission_display_data); i++) {
+ GtkWidget *row, *image, *box, *label;
+
+ if ((permissions & permission_display_data[i].permission) == 0)
+ continue;
+
+ row = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
+ gtk_widget_show (row);
+ if ((permission_display_data[i].permission & ~MEDIUM_PERMISSIONS) != 0) {
+ gtk_style_context_add_class (gtk_widget_get_style_context (row),
"permission-row-warning");
+ }
+
+ image = gtk_image_new_from_icon_name ("dialog-warning-symbolic", GTK_ICON_SIZE_MENU);
+ if ((permission_display_data[i].permission & ~MEDIUM_PERMISSIONS) == 0)
+ gtk_widget_set_opacity (image, 0);
+
+ gtk_widget_show (image);
+ gtk_container_add (GTK_CONTAINER (row), image);
+
+ box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
+ gtk_widget_show (box);
+ gtk_container_add (GTK_CONTAINER (row), box);
+
+ label = gtk_label_new (_(permission_display_data[i].title));
+ gtk_label_set_xalign (GTK_LABEL (label), 0);
+ gtk_widget_show (label);
+ gtk_container_add (GTK_CONTAINER (box), label);
+
+ label = gtk_label_new (_(permission_display_data[i].subtitle));
+ gtk_label_set_xalign (GTK_LABEL (label), 0);
+ gtk_style_context_add_class (gtk_widget_get_style_context (label), "dim-label");
+ gtk_widget_show (label);
+ gtk_container_add (GTK_CONTAINER (box), label);
+
+ gtk_container_add (GTK_CONTAINER (dialog->permissions_section_content), row);
+ }
+}
+
static void
set_updates_description_ui (GsUpdateDialog *dialog, GsApp *app)
{
@@ -140,6 +209,15 @@ set_updates_description_ui (GsUpdateDialog *dialog, GsApp *app)
/* show the back button if needed */
gtk_widget_set_visible (dialog->button_back, !g_queue_is_empty (dialog->back_entry_stack));
+
+ if (gs_app_has_quirk (app, GS_APP_QUIRK_NEW_PERMISSIONS)) {
+ gtk_widget_show (dialog->permissions_section_title);
+ gtk_widget_show (dialog->permissions_section_content);
+ populate_permissions_section (dialog, gs_app_get_permissions (app));
+ } else {
+ gtk_widget_hide (dialog->permissions_section_title);
+ gtk_widget_hide (dialog->permissions_section_content);
+ }
}
static void
@@ -758,6 +836,8 @@ gs_update_dialog_class_init (GsUpdateDialogClass *klass)
gtk_widget_class_bind_template_child (widget_class, GsUpdateDialog, scrolledwindow_details);
gtk_widget_class_bind_template_child (widget_class, GsUpdateDialog, spinner);
gtk_widget_class_bind_template_child (widget_class, GsUpdateDialog, stack);
+ gtk_widget_class_bind_template_child (widget_class, GsUpdateDialog, permissions_section_title);
+ gtk_widget_class_bind_template_child (widget_class, GsUpdateDialog, permissions_section_content);
}
GtkWidget *
diff --git a/src/gs-update-dialog.ui b/src/gs-update-dialog.ui
index a9c57d1d..73bb8463 100644
--- a/src/gs-update-dialog.ui
+++ b/src/gs-update-dialog.ui
@@ -175,16 +175,44 @@
<property name="vscrollbar_policy">automatic</property>
<property name="shadow_type">none</property>
<child>
- <object class="GtkLabel" id="label_details">
+ <object class="GtkBox">
<property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="yalign">0</property>
- <property name="margin">6</property>
- <property name="label">New in kmod 14-1
+ <property name="orientation">vertical</property>
+ <property name="spacing">20</property>
+ <child>
+ <object class="GtkLabel" id="label_details">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0</property>
+ <property name="margin">6</property>
+ <property name="label">New in kmod 14-1
* Moo
* bar</property>
- <property name="wrap">True</property>
- <property name="selectable">True</property>
+ <property name="wrap">True</property>
+ <property name="selectable">True</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel" id="permissions_section_title">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="halign">start</property>
+ <property name="margin">6</property>
+ <property name="label" translatable="yes">New System Access</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ </object>
+ </child>
+ <child>
+ <object class="GtkBox" id="permissions_section_content">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">12</property>
+ <property name="margin-start">18</property>
+ <property name="margin-end">18</property>
+ </object>
+ </child>
</object>
</child>
</object>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]