[gnome-software/wip/rancell/permissions] Stub permission dialog
- From: Robert Ancell <rancell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/wip/rancell/permissions] Stub permission dialog
- Date: Mon, 14 Aug 2017 04:29:57 +0000 (UTC)
commit e0486da33e9dac9e202a29a09185cc375dd0fd6e
Author: Robert Ancell <robert ancell canonical com>
Date: Thu Aug 10 22:00:44 2017 +1200
Stub permission dialog
src/gnome-software.gresource.xml | 1 +
src/gs-details-page.c | 31 ++++++++++++++++
src/gs-details-page.ui | 16 ++++++++
src/gs-permission-dialog.c | 73 ++++++++++++++++++++++++++++++++++++++
src/gs-permission-dialog.h | 39 ++++++++++++++++++++
src/gs-permission-dialog.ui | 54 ++++++++++++++++++++++++++++
src/meson.build | 1 +
7 files changed, 215 insertions(+), 0 deletions(-)
---
diff --git a/src/gnome-software.gresource.xml b/src/gnome-software.gresource.xml
index 30e252c..caff29e 100644
--- a/src/gnome-software.gresource.xml
+++ b/src/gnome-software.gresource.xml
@@ -19,6 +19,7 @@
<file preprocess="xml-stripblanks">gs-loading-page.ui</file>
<file preprocess="xml-stripblanks">gs-moderate-page.ui</file>
<file preprocess="xml-stripblanks">gs-overview-page.ui</file>
+ <file preprocess="xml-stripblanks">gs-permission-dialog.ui</file>
<file preprocess="xml-stripblanks">gs-popular-tile.ui</file>
<file preprocess="xml-stripblanks">gs-removal-dialog.ui</file>
<file preprocess="xml-stripblanks">gs-review-dialog.ui</file>
diff --git a/src/gs-details-page.c b/src/gs-details-page.c
index 72f2390..6417acd 100644
--- a/src/gs-details-page.c
+++ b/src/gs-details-page.c
@@ -38,6 +38,7 @@
#include "gs-review-histogram.h"
#include "gs-review-dialog.h"
#include "gs-review-row.h"
+#include "gs-permission-dialog.h"
/* the number of reviews to show before clicking the 'More Reviews' button */
#define SHOW_NR_REVIEWS_INITIAL 4
@@ -84,6 +85,7 @@ struct _GsDetailsPage
GtkWidget *button_install;
GtkWidget *button_remove;
GtkWidget *button_cancel;
+ GtkWidget *button_permissions;
GtkWidget *button_more_reviews;
GtkWidget *infobar_details_app_norepo;
GtkWidget *infobar_details_app_repo;
@@ -396,6 +398,18 @@ gs_details_page_switch_to (GsPage *page, gboolean scroll_up)
}
}
+ /* permissions button */
+ switch (gs_app_get_state (self->app)) {
+ case AS_APP_STATE_INSTALLED:
+ case AS_APP_STATE_UPDATABLE:
+ case AS_APP_STATE_UPDATABLE_LIVE:
+ gtk_widget_set_visible (self->button_permissions, TRUE);
+ break;
+ default:
+ gtk_widget_set_visible (self->button_permissions, FALSE);
+ break;
+ }
+
adj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (self->scrolledwindow_details));
gtk_adjustment_set_value (adj, gtk_adjustment_get_lower (adj));
@@ -1775,6 +1789,19 @@ gs_details_page_app_cancel_button_cb (GtkWidget *widget, GsDetailsPage *self)
}
static void
+gs_details_page_app_permissions_button_cb (GtkWidget *widget, GsDetailsPage *self)
+{
+ GtkWidget *dialog;
+
+ dialog = gs_permission_dialog_new (self->app);
+ gs_shell_modal_dialog_present (self->shell, GTK_DIALOG (dialog));
+
+ /* just destroy */
+ g_signal_connect_swapped (dialog, "response",
+ G_CALLBACK (gtk_widget_destroy), dialog);
+}
+
+static void
gs_details_page_app_install_button_cb (GtkWidget *widget, GsDetailsPage *self)
{
GList *l;
@@ -2202,6 +2229,9 @@ gs_details_page_setup (GsPage *page,
g_signal_connect (self->button_cancel, "clicked",
G_CALLBACK (gs_details_page_app_cancel_button_cb),
self);
+ g_signal_connect (self->button_permissions, "clicked",
+ G_CALLBACK (gs_details_page_app_permissions_button_cb),
+ self);
g_signal_connect (self->button_more_reviews, "clicked",
G_CALLBACK (gs_details_page_more_reviews_button_cb),
self);
@@ -2296,6 +2326,7 @@ gs_details_page_class_init (GsDetailsPageClass *klass)
gtk_widget_class_bind_template_child (widget_class, GsDetailsPage, button_install);
gtk_widget_class_bind_template_child (widget_class, GsDetailsPage, button_remove);
gtk_widget_class_bind_template_child (widget_class, GsDetailsPage, button_cancel);
+ gtk_widget_class_bind_template_child (widget_class, GsDetailsPage, button_permissions);
gtk_widget_class_bind_template_child (widget_class, GsDetailsPage, button_more_reviews);
gtk_widget_class_bind_template_child (widget_class, GsDetailsPage, infobar_details_app_norepo);
gtk_widget_class_bind_template_child (widget_class, GsDetailsPage, infobar_details_app_repo);
diff --git a/src/gs-details-page.ui b/src/gs-details-page.ui
index 888ca7f..9a89f20 100644
--- a/src/gs-details-page.ui
+++ b/src/gs-details-page.ui
@@ -379,6 +379,22 @@
<property name="pack-type">end</property>
</packing>
</child>
+ <child>
+ <object class="GtkButton" id="button_permissions">
+ <property name="use_underline">True</property>
+ <property name="label" translatable="yes">_Permissions</property>
+ <property name="width_request">105</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="halign">start</property>
+ <property name="valign">start</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">9</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="expand">False</property>
diff --git a/src/gs-permission-dialog.c b/src/gs-permission-dialog.c
new file mode 100644
index 0000000..de1fd57
--- /dev/null
+++ b/src/gs-permission-dialog.c
@@ -0,0 +1,73 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2017 Canonical Ltd.
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "config.h"
+
+#include "gs-permission-dialog.h"
+
+struct _GsPermissionDialog
+{
+ GtkDialog parent_instance;
+
+ GsApp *app;
+};
+
+G_DEFINE_TYPE (GsPermissionDialog, gs_permission_dialog, GTK_TYPE_DIALOG)
+
+static void
+gs_permission_dialog_init (GsPermissionDialog *dialog)
+{
+ gtk_widget_init_template (GTK_WIDGET (dialog));
+}
+
+static void
+gs_permission_dialog_dispose (GObject *object)
+{
+ GsPermissionDialog *dialog = GS_PERMISSION_DIALOG (object);
+
+ g_clear_object (&dialog->app);
+
+ G_OBJECT_CLASS (gs_permission_dialog_parent_class)->dispose (object);
+}
+
+static void
+gs_permission_dialog_class_init (GsPermissionDialogClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+ object_class->dispose = gs_permission_dialog_dispose;
+
+ gtk_widget_class_set_template_from_resource (widget_class,
"/org/gnome/Software/gs-permission-dialog.ui");
+}
+
+GtkWidget *
+gs_permission_dialog_new (GsApp *app)
+{
+ GsPermissionDialog *dialog;
+
+ dialog = g_object_new (GS_TYPE_PERMISSION_DIALOG,
+ "use-header-bar", TRUE,
+ NULL);
+ dialog->app = g_object_ref (app);
+
+ return GTK_WIDGET (dialog);
+}
diff --git a/src/gs-permission-dialog.h b/src/gs-permission-dialog.h
new file mode 100644
index 0000000..e13114d
--- /dev/null
+++ b/src/gs-permission-dialog.h
@@ -0,0 +1,39 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2017 Canonical Ltd.
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef GS_PERMISSION_DIALOG_H
+#define GS_PERMISSION_DIALOG_H
+
+#include <gtk/gtk.h>
+
+#include "gnome-software-private.h"
+
+G_BEGIN_DECLS
+
+#define GS_TYPE_PERMISSION_DIALOG (gs_permission_dialog_get_type ())
+
+G_DECLARE_FINAL_TYPE (GsPermissionDialog, gs_permission_dialog, GS, PERMISSION_DIALOG, GtkDialog)
+
+GtkWidget *gs_permission_dialog_new (GsApp *app);
+
+G_END_DECLS
+
+#endif /* GS_PERMISSION_DIALOG_H */
diff --git a/src/gs-permission-dialog.ui b/src/gs-permission-dialog.ui
new file mode 100644
index 0000000..b4c96c7
--- /dev/null
+++ b/src/gs-permission-dialog.ui
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.18.3 -->
+<interface>
+ <requires lib="gtk+" version="3.10"/>
+ <template class="GsPermissionDialog" parent="GtkDialog">
+ <property name="can_focus">False</property>
+ <property name="title" translatable="yes" comments="Translators: Title of the dialog box where app
permissions can be controlled.">Permissions</property>
+ <property name="modal">True</property>
+ <property name="default_width">600</property>
+ <property name="default_height">300</property>
+ <property name="destroy_with_parent">True</property>
+ <property name="type_hint">dialog</property>
+ <property name="use_header_bar">1</property>
+ <child internal-child="headerbar">
+ <object class="GtkHeaderBar">
+ <property name="show_close_button">True</property>
+ </object>
+ </child>
+ <child internal-child="vbox">
+ <object class="GtkBox" id="dialog-vbox">
+ <property name="can_focus">False</property>
+ <property name="margin_start">40</property>
+ <property name="margin_end">40</property>
+ <property name="margin_top">25</property>
+ <property name="margin_bottom">25</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">9</property>
+ <child internal-child="action_area">
+ <object class="GtkButtonBox" id="dialog-action_area1">
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox" id="box1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">20</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </template>
+</interface>
diff --git a/src/meson.build b/src/meson.build
index 4f2c5e9..267880c 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -43,6 +43,7 @@ gnome_software_sources = [
'gs-moderate-page.c',
'gs-overview-page.c',
'gs-page.c',
+ 'gs-permission-dialog.c',
'gs-popular-tile.c',
'gs-progress-button.c',
'gs-removal-dialog.c',
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]