[glibmm] Add Gio::Permission
- From: Juan R. Garcia Blanco <juanrgar src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glibmm] Add Gio::Permission
- Date: Sat, 19 Jul 2014 10:42:01 +0000 (UTC)
commit c6092ece126b691078199b1a1c607d4d78f65f8b
Author: Juan R. GarcĂa Blanco <juanrgar gmail com>
Date: Sat Jul 19 12:17:07 2014 +0200
Add Gio::Permission
* gio/giomm.h: Add giomm/permission.h.
* gio/src/filelist.am: Add permission.hg.
* gio/src/gio_signals.defs: Add allowed, can-acquire, and
can-acquire properties.
* gio/src/gio_vfuncs.defs: Add vfuncs.
* gio/src/permission.[hg|ccg]: New files.
* tools/extra_defs_gen/generate_defs_gio.cc: Add
G_TYPE_PERMISSION.
* See https://bugzilla.gnome.org/show_bug.cgi?id=732436
gio/giomm.h | 1 +
gio/src/filelist.am | 1 +
gio/src/gio_signals.defs | 29 +++++++++
gio/src/gio_vfuncs.defs | 58 ++++++++++++++++++
gio/src/permission.ccg | 24 ++++++++
gio/src/permission.hg | 91 +++++++++++++++++++++++++++++
tools/extra_defs_gen/generate_defs_gio.cc | 1 +
7 files changed, 205 insertions(+), 0 deletions(-)
---
diff --git a/gio/giomm.h b/gio/giomm.h
index 1199a2f..c640291 100644
--- a/gio/giomm.h
+++ b/gio/giomm.h
@@ -103,6 +103,7 @@
#include <giomm/networkservice.h>
#include <giomm/notification.h>
#include <giomm/outputstream.h>
+#include <giomm/permission.h>
#include <giomm/pollableinputstream.h>
#include <giomm/pollableoutputstream.h>
#include <giomm/proxy.h>
diff --git a/gio/src/filelist.am b/gio/src/filelist.am
index e2a545f..4fc8aef 100644
--- a/gio/src/filelist.am
+++ b/gio/src/filelist.am
@@ -90,6 +90,7 @@ giomm_files_any_hg = \
networkservice.hg \
notification.hg \
outputstream.hg \
+ permission.hg \
pollableinputstream.hg \
pollableoutputstream.hg \
proxy.hg \
diff --git a/gio/src/gio_signals.defs b/gio/src/gio_signals.defs
index ea5828a..337577c 100644
--- a/gio/src/gio_signals.defs
+++ b/gio/src/gio_signals.defs
@@ -768,6 +768,35 @@
;; From GNotification
+;; From GPermission
+
+(define-property allowed
+ (of-object "GPermission")
+ (prop-type "GParamBoolean")
+ (docs "If the caller is allowed to perform the action")
+ (readable #t)
+ (writable #f)
+ (construct-only #f)
+)
+
+(define-property can-acquire
+ (of-object "GPermission")
+ (prop-type "GParamBoolean")
+ (docs "If calling g_permission_acquire() makes sense")
+ (readable #t)
+ (writable #f)
+ (construct-only #f)
+)
+
+(define-property can-release
+ (of-object "GPermission")
+ (prop-type "GParamBoolean")
+ (docs "If calling g_permission_release() makes sense")
+ (readable #t)
+ (writable #f)
+ (construct-only #f)
+)
+
;; From GPropertyAction
(define-property name
diff --git a/gio/src/gio_vfuncs.defs b/gio/src/gio_vfuncs.defs
index 1917d6c..e9792a9 100644
--- a/gio/src/gio_vfuncs.defs
+++ b/gio/src/gio_vfuncs.defs
@@ -1126,3 +1126,61 @@
'("GMount*" "mount")
)
)
+
+; GPermission
+
+(define-vfunc acquire
+ (of-object "GPermission")
+ (return-type "gboolean")
+ (parameters
+ '("GCancellable*" "cancellable")
+ '("GError**" "error")
+ )
+)
+
+(define-vfunc acquire_async
+ (of-object "GPermission")
+ (return-type "void")
+ (parameters
+ '("GCancellable*" "cancellable")
+ '("GAsyncReadyCallback" "callback")
+ '("gpointer" "user_data")
+ )
+)
+
+(define-vfunc acquire_finish
+ (of-object "GPermission")
+ (return-type "gboolean")
+ (parameters
+ '("GAsyncResult*" "result")
+ '("GError**" "error")
+ )
+)
+
+(define-vfunc release
+ (of-object "GPermission")
+ (return-type "gboolean")
+ (parameters
+ '("GCancellable*" "cancellable")
+ '("GError**" "error")
+ )
+)
+
+(define-vfunc release_async
+ (of-object "GPermission")
+ (return-type "void")
+ (parameters
+ '("GCancellable*" "cancellable")
+ '("GAsyncReadyCallback" "callback")
+ '("gpointer" "user_data")
+ )
+)
+
+(define-vfunc release_finish
+ (of-object "GPermission")
+ (return-type "gboolean")
+ (parameters
+ '("GAsyncResult*" "result")
+ '("GError**" "error")
+ )
+)
diff --git a/gio/src/permission.ccg b/gio/src/permission.ccg
new file mode 100644
index 0000000..c3debd2
--- /dev/null
+++ b/gio/src/permission.ccg
@@ -0,0 +1,24 @@
+/* Copyright (C) 2014 The giomm Development Team
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <gio/gio.h>
+#include "slot_async.h"
+
+
+namespace Gio
+{
+} // namespace Gio
diff --git a/gio/src/permission.hg b/gio/src/permission.hg
new file mode 100644
index 0000000..6405ece
--- /dev/null
+++ b/gio/src/permission.hg
@@ -0,0 +1,91 @@
+/* Copyright (C) 2014 The giomm Development Team
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <glibmm/object.h>
+#include <giomm/cancellable.h>
+#include <giomm/asyncresult.h>
+
+_DEFS(giomm,gio)
+_PINCLUDE(glibmm/private/object_p.h)
+_PINCLUDE(gio/gio.h)
+
+namespace Gio
+{
+
+/** An object representing the permission to perform a certain action.
+ *
+ * A Permission represents the status of the caller's permission to
+ * perform a certain action.
+ *
+ * You can query if the action is currently allowed and if it is
+ * possible to acquire the permission so that the action will be allowed
+ * in the future.
+ *
+ * There is also an API to actually acquire the permission and one to
+ * release it.
+ *
+ * As an example, a Permission might represent the ability for the
+ * user to write to a Settings object. This Permission object could
+ * then be used to decide if it is appropriate to show a "Click here to
+ * unlock" button in a dialog and to provide the mechanism to invoke
+ * when that button is clicked.
+ *
+ * @newin{2,42}
+ */
+class Permission : public Glib::Object
+{
+ _CLASS_GOBJECT(Permission, GPermission, G_PERMISSION, Glib::Object, GObject)
+
+public:
+
+ _WRAP_METHOD(bool acquire(const Glib::RefPtr<Cancellable>& cancellable{?}), g_permission_acquire, errthrow)
+ _WRAP_METHOD(void acquire_async(const SlotAsyncReady& slot{callback}, const Glib::RefPtr<Cancellable>&
cancellable{.?}), g_permission_acquire_async, slot_name slot, slot_callback SignalProxy_async_callback)
+ _WRAP_METHOD(bool acquire_finish(const Glib::RefPtr<AsyncResult>& result), g_permission_acquire_finish,
errthrow)
+
+ _WRAP_METHOD(bool release(const Glib::RefPtr<Cancellable>& cancellable{?}), g_permission_release, errthrow)
+ _WRAP_METHOD(void release_async(const SlotAsyncReady& slot{callback}, const Glib::RefPtr<Cancellable>&
cancellable{.?}), g_permission_release_async, slot_name slot, slot_callback SignalProxy_async_callback)
+ _WRAP_METHOD(bool release_finish(const Glib::RefPtr<AsyncResult>& result), g_permission_release_finish,
errthrow)
+
+ _WRAP_METHOD(bool get_allowed() const, g_permission_get_allowed)
+ _WRAP_METHOD(bool get_can_acquire() const, g_permission_get_can_acquire)
+ _WRAP_METHOD(bool get_can_release() const, g_permission_get_can_release)
+
+ _WRAP_PROPERTY("allowed", bool)
+ _WRAP_PROPERTY("can-acquire", bool)
+ _WRAP_PROPERTY("can-release", bool)
+
+protected:
+
+ _CTOR_DEFAULT
+
+// A copy is needed for vfuncs, i.e. Glib::wrap($3, true)
+#m4 _CONVERSION(`GAsyncResult*',`const Glib::RefPtr<AsyncResult>&',`Glib::wrap($3, true)')
+#m4 _CONVERSION(`GCancellable*',`const Glib::RefPtr<Cancellable>&',`Glib::wrap($3, true)')
+
+ _WRAP_VFUNC(bool acquire(const Glib::RefPtr<Cancellable>& cancellable), acquire, errthrow)
+ _WRAP_VFUNC(void acquire_async(const SlotAsyncReady& slot{callback}, const Glib::RefPtr<Cancellable>&
cancellable{.}), acquire_async, slot_name slot, slot_callback SignalProxy_async_callback)
+ _WRAP_VFUNC(bool acquire_finish(const Glib::RefPtr<AsyncResult>& result), acquire_finish, errthrow)
+
+ _WRAP_VFUNC(bool release(const Glib::RefPtr<Cancellable>& cancellable), release, errthrow)
+ _WRAP_VFUNC(void release_async(const SlotAsyncReady& slot{callback}, const Glib::RefPtr<Cancellable>&
cancellable{.}), release_async, slot_name slot, slot_callback SignalProxy_async_callback)
+ _WRAP_VFUNC(bool release_finish(const Glib::RefPtr<AsyncResult>& result), release_finish, errthrow)
+
+ // You should never call this function except from a Gio::Permission implementation.
+ _WRAP_METHOD(void impl_update(bool allowed, bool can_acquire, bool can_release), g_permission_impl_update)
+};
+
+} // namespace Gio
diff --git a/tools/extra_defs_gen/generate_defs_gio.cc b/tools/extra_defs_gen/generate_defs_gio.cc
index df76459..06069f3 100644
--- a/tools/extra_defs_gen/generate_defs_gio.cc
+++ b/tools/extra_defs_gen/generate_defs_gio.cc
@@ -82,6 +82,7 @@ int main(int, char**)
<< get_defs(G_TYPE_MOUNT)
<< get_defs(G_TYPE_MOUNT_OPERATION)
<< get_defs(G_TYPE_NOTIFICATION)
+ << get_defs(G_TYPE_PERMISSION)
<< get_defs(G_TYPE_PROPERTY_ACTION)
<< get_defs(G_TYPE_PROXY)
<< get_defs(G_TYPE_PROXY_ADDRESS)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]