[gnome-software/flatpak-permissions: 3/5] details: Show permissions
- From: Kalev Lember <klember src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/flatpak-permissions: 3/5] details: Show permissions
- Date: Thu, 10 Jan 2019 20:59:37 +0000 (UTC)
commit 87ff0d5780a319fc6800b644ef4165ba52762bc1
Author: Matthias Clasen <mclasen redhat com>
Date: Wed Dec 26 08:48:59 2018 -0500
details: Show permissions
Show information about system access of applications.
This is loosely based on mockups in
https://gitlab.gnome.org/GNOME/gnome-software/issues/69
src/gs-details-page.c | 118 +++++++++++++++++++++++++++++++++++++++++++++++++
src/gs-details-page.ui | 67 ++++++++++++++++++++++++++++
src/gtk-style.css | 1 -
3 files changed, 185 insertions(+), 1 deletion(-)
---
diff --git a/src/gs-details-page.c b/src/gs-details-page.c
index 789960c4..7ba0585b 100644
--- a/src/gs-details-page.c
+++ b/src/gs-details-page.c
@@ -117,6 +117,8 @@ struct _GsDetailsPage
GtkWidget *label_details_updated_title;
GtkWidget *label_details_updated_value;
GtkWidget *label_details_version_value;
+ GtkWidget *label_details_permissions_title;
+ GtkWidget *button_details_permissions_value;
GtkWidget *label_failed;
GtkWidget *label_license_nonfree_details;
GtkWidget *label_licenses_intro;
@@ -151,6 +153,8 @@ struct _GsDetailsPage
GtkWidget *label_content_rating_none;
GtkWidget *button_details_rating_value;
GtkWidget *label_details_rating_title;
+ GtkWidget *popover_permissions;
+ GtkWidget *box_permissions_details;
};
G_DEFINE_TYPE (GsDetailsPage, gs_details_page, GS_TYPE_PAGE)
@@ -944,6 +948,90 @@ gs_details_page_refresh_buttons (GsDetailsPage *self)
}
}
+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_permission_details (GsDetailsPage *self, GsAppPermissions permissions)
+{
+ GList *children;
+
+ children = gtk_container_get_children (GTK_CONTAINER (self->box_permissions_details));
+ for (GList *l = children; l != NULL; l = l->next)
+ gtk_widget_destroy (GTK_WIDGET (l->data));
+ g_list_free (children);
+
+ if (permissions == GS_APP_PERMISSIONS_NONE) {
+ GtkWidget *label;
+ label = gtk_label_new (_("This application is fully sandboxed."));
+ gtk_label_set_xalign (GTK_LABEL (label), 0);
+ gtk_label_set_max_width_chars (GTK_LABEL (label), 40);
+ gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+ gtk_widget_show (label);
+ gtk_container_add (GTK_CONTAINER (self->box_permissions_details), label);
+ } else if (permissions == GS_APP_PERMISSIONS_UNKNOWN) {
+ GtkWidget *label;
+ label = gtk_label_new (_("Unable to determine which parts of the system "
+ "this application accesses. This is typical for "
+ "older applications."));
+ gtk_label_set_xalign (GTK_LABEL (label), 0);
+ gtk_label_set_max_width_chars (GTK_LABEL (label), 40);
+ gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+ gtk_widget_show (label);
+ gtk_container_add (GTK_CONTAINER (self->box_permissions_details), label);
+ } else {
+ 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);
+
+ 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 (self->box_permissions_details), row);
+ }
+ }
+}
+
static void
gs_details_page_refresh_all (GsDetailsPage *self)
{
@@ -1152,6 +1240,23 @@ gs_details_page_refresh_all (GsDetailsPage *self)
break;
}
+ if ((kudos & GS_APP_KUDO_SANDBOXED) > 0) {
+ GsAppPermissions permissions = gs_app_get_permissions (self->app);
+
+ populate_permission_details (self, permissions);
+
+ if ((permissions & ~LIMITED_PERMISSIONS) == 0)
+ gtk_button_set_label (GTK_BUTTON (self->button_details_permissions_value), _("Low"));
+ else if ((permissions & ~MEDIUM_PERMISSIONS) == 0)
+ gtk_button_set_label (GTK_BUTTON (self->button_details_permissions_value),
_("Medium"));
+ else
+ gtk_button_set_label (GTK_BUTTON (self->button_details_permissions_value), _("High"));
+ } else {
+ populate_permission_details (self, GS_APP_PERMISSIONS_UNKNOWN);
+
+ gtk_button_set_label (GTK_BUTTON (self->button_details_permissions_value), _("Unknown"));
+ }
+
/* are we trying to replace something in the baseos */
gtk_widget_set_visible (self->infobar_details_package_baseos,
gs_app_has_quirk (self->app, GS_APP_QUIRK_COMPULSORY) &&
@@ -2209,6 +2314,12 @@ gs_details_page_content_rating_button_cb (GtkWidget *widget, GsDetailsPage *self
gtk_widget_show (self->popover_content_rating);
}
+static void
+gs_details_page_permissions_button_cb (GtkWidget *widget, GsDetailsPage *self)
+{
+ gtk_widget_show (self->popover_permissions);
+}
+
static gboolean
gs_details_page_activate_link_cb (GtkLabel *label,
const gchar *uri,
@@ -2415,6 +2526,9 @@ gs_details_page_setup (GsPage *page,
g_signal_connect (self->button_details_rating_value, "clicked",
G_CALLBACK (gs_details_page_content_rating_button_cb),
self);
+ g_signal_connect (self->button_details_permissions_value, "clicked",
+ G_CALLBACK (gs_details_page_permissions_button_cb),
+ self);
g_signal_connect (self->label_details_updated_value, "activate-link",
G_CALLBACK (gs_details_page_history_cb),
self);
@@ -2543,6 +2657,8 @@ gs_details_page_class_init (GsDetailsPageClass *klass)
gtk_widget_class_bind_template_child (widget_class, GsDetailsPage, label_details_updated_title);
gtk_widget_class_bind_template_child (widget_class, GsDetailsPage, label_details_updated_value);
gtk_widget_class_bind_template_child (widget_class, GsDetailsPage, label_details_version_value);
+ gtk_widget_class_bind_template_child (widget_class, GsDetailsPage, label_details_permissions_title);
+ gtk_widget_class_bind_template_child (widget_class, GsDetailsPage, button_details_permissions_value);
gtk_widget_class_bind_template_child (widget_class, GsDetailsPage, label_failed);
gtk_widget_class_bind_template_child (widget_class, GsDetailsPage, list_box_addons);
gtk_widget_class_bind_template_child (widget_class, GsDetailsPage, box_reviews);
@@ -2577,6 +2693,8 @@ gs_details_page_class_init (GsDetailsPageClass *klass)
gtk_widget_class_bind_template_child (widget_class, GsDetailsPage, label_content_rating_none);
gtk_widget_class_bind_template_child (widget_class, GsDetailsPage, button_details_rating_value);
gtk_widget_class_bind_template_child (widget_class, GsDetailsPage, label_details_rating_title);
+ gtk_widget_class_bind_template_child (widget_class, GsDetailsPage, popover_permissions);
+ gtk_widget_class_bind_template_child (widget_class, GsDetailsPage, box_permissions_details);
}
static void
diff --git a/src/gs-details-page.ui b/src/gs-details-page.ui
index 05033864..8273c779 100644
--- a/src/gs-details-page.ui
+++ b/src/gs-details-page.ui
@@ -642,6 +642,44 @@
</packing>
</child>
+ <child>
+ <object class="GtkLabel" id="label_details_permissions_title">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Permissions</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.5</property>
+ <property name="vexpand">True</property>
+ <style>
+ <class name="dim-label"/>
+ </style>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">9</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="button_details_permissions_value">
+ <property name="visible">True</property>
+ <property name="use_underline">True</property>
+ <property name="label">Details</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="vexpand">False</property>
+ <property name="halign">start</property>
+ <style>
+ <class name="content-rating"/>
+ </style>
+ <accessibility>
+ <relation type="labelled-by" target="label_details_permissions_title"/>
+ </accessibility>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">9</property>
+ </packing>
+ </child>
+
<child>
<object class="GtkLabel" id="label_details_updated_title">
<property name="visible">True</property>
@@ -1285,4 +1323,33 @@
</object>
</child>
</object>
+ <object class="GtkPopover" id="popover_permissions">
+ <property name="visible">False</property>
+ <property name="border_width">21</property>
+ <property name="relative_to">button_details_permissions_value</property>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">18</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="halign">center</property>
+ <property name="label" translatable="yes">Permissions</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ </object>
+ </child>
+ <child>
+ <object class="GtkBox" id="box_permissions_details">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">12</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
</interface>
diff --git a/src/gtk-style.css b/src/gtk-style.css
index 283efb9c..01a260d7 100644
--- a/src/gtk-style.css
+++ b/src/gtk-style.css
@@ -134,7 +134,6 @@
border-color: #dbdbdb;
}
-
.kudo-pill {
color: @theme_selected_fg_color;
background-color: shade(@theme_selected_bg_color, 1.1);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]