summaryrefslogtreecommitdiff
path: root/gio/src/mount.ccg
diff options
context:
space:
mode:
authorMurray Cumming <murrayc@murrayc.com>2008-01-18 18:31:35 +0000
committerMurray Cumming <murrayc@src.gnome.org>2008-01-18 18:31:35 +0000
commit19c519f63b3dcae9c9e5cbcd44182531833ec3e9 (patch)
tree3a148c7b782a51e6f91b1df7a348ee80c5eee387 /gio/src/mount.ccg
parentbf4116688215b8c5e632d59b102bde3562582969 (diff)
downloadglibmm-19c519f63b3dcae9c9e5cbcd44182531833ec3e9.tar.gz
Added unmount(), remount(), and eject(), based on code from José
2008-01-18 Murray Cumming <murrayc@murrayc.com> * gio/src/mount.ccg: * gio/src/mount.hg: Added unmount(), remount(), and eject(), based on code from José Alburquerque in bug #510080. * gio/src/volume.hg: Added documentation. svn path=/trunk/; revision=523
Diffstat (limited to 'gio/src/mount.ccg')
-rw-r--r--gio/src/mount.ccg151
1 files changed, 150 insertions, 1 deletions
diff --git a/gio/src/mount.ccg b/gio/src/mount.ccg
index 076a4af9..2e2bda04 100644
--- a/gio/src/mount.ccg
+++ b/gio/src/mount.ccg
@@ -1,4 +1,4 @@
-// -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+// -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 2 -*-
/* Copyright (C) 2007 The gtkmm Development Team
*
@@ -21,9 +21,158 @@
#include <giomm/volume.h>
#include <gio/gio.h>
+namespace
+{
+
+static void
+SignalProxy_async_callback(GObject*, GAsyncResult* res, void* data)
+{
+ Gio::SlotAsyncReady* the_slot = static_cast<Gio::SlotAsyncReady*>(data);
+
+ #ifdef GLIBMM_EXCEPTIONS_ENABLED
+ try
+ {
+ #endif //GLIBMM_EXCEPTIONS_ENABLED
+ Glib::RefPtr<Gio::AsyncResult> result = Glib::wrap(res, true /* take copy */);
+ (*the_slot)(result);
+ #ifdef GLIBMM_EXCEPTIONS_ENABLED
+ }
+ catch(...)
+ {
+ Glib::exception_handlers_invoke();
+ }
+ #endif //GLIBMM_EXCEPTIONS_ENABLED
+
+ delete the_slot;
+}
+
+} //anonymous namespace
+
namespace Gio
{
+void Mount::unmount(const SlotAsyncReady& slot, const Glib::RefPtr<Cancellable>& cancellable, MountUnmountFlags flags)
+{
+ // Create a copy of the slot.
+ // A pointer to it will be passed through the callback's data parameter
+ // and deleted in the callback.
+ SlotAsyncReady* slot_copy = new SlotAsyncReady(slot);
+
+ g_mount_unmount(gobj(),
+ GMountUnmountFlags(flags),
+ cancellable->gobj(),
+ &SignalProxy_async_callback,
+ slot_copy);
+}
+
+void Mount::unmount(const SlotAsyncReady& slot, MountUnmountFlags flags)
+{
+ // Create a copy of the slot.
+ // A pointer to it will be passed through the callback's data parameter
+ // and deleted in the callback.
+ SlotAsyncReady* slot_copy = new SlotAsyncReady(slot);
+
+ g_mount_unmount(gobj(),
+ GMountUnmountFlags(flags),
+ NULL,
+ &SignalProxy_async_callback,
+ slot_copy);
+}
+
+void Mount::unmount(MountUnmountFlags flags)
+{
+ g_mount_unmount(gobj(),
+ GMountUnmountFlags(flags),
+ NULL,
+ NULL,
+ NULL);
+}
+
+
+void Mount::remount(const Glib::RefPtr<MountOperation>& operation, SlotAsyncReady& slot, const Glib::RefPtr<Cancellable>& cancellable)
+{
+ // Create a copy of the slot.
+ // A pointer to it will be passed through the callback's data parameter
+ // and deleted in the callback.
+ SlotAsyncReady* slot_copy = new SlotAsyncReady(slot);
+
+ g_mount_remount(gobj(),
+ operation->gobj(),
+ cancellable->gobj(),
+ &SignalProxy_async_callback,
+ slot_copy);
+}
+
+void Mount::remount(const Glib::RefPtr<MountOperation>& operation, SlotAsyncReady& slot)
+{
+ // Create a copy of the slot.
+ // A pointer to it will be passed through the callback's data parameter
+ // and deleted in the callback.
+ SlotAsyncReady* slot_copy = new SlotAsyncReady(slot);
+
+ g_mount_remount(gobj(),
+ operation->gobj(),
+ NULL,
+ &SignalProxy_async_callback,
+ slot_copy);
+}
+
+void Mount::remount(const Glib::RefPtr<MountOperation>& operation)
+{
+ g_mount_remount(gobj(),
+ operation->gobj(),
+ NULL,
+ NULL,
+ NULL);
+}
+
+void Mount::remount()
+{
+ g_mount_remount(gobj(),
+ NULL,
+ NULL,
+ NULL,
+ NULL);
+}
+
+void Mount::eject(const SlotAsyncReady& slot, const Glib::RefPtr<Cancellable>& cancellable, MountUnmountFlags flags)
+{
+ // Create a copy of the slot.
+ // A pointer to it will be passed through the callback's data parameter
+ // and deleted in the callback.
+ SlotAsyncReady* slot_copy = new SlotAsyncReady(slot);
+
+ g_mount_eject(gobj(),
+ GMountUnmountFlags(flags),
+ cancellable->gobj(),
+ &SignalProxy_async_callback,
+ slot_copy);
+}
+
+void Mount::eject(const SlotAsyncReady& slot, MountUnmountFlags flags)
+{
+ // Create a copy of the slot.
+ // A pointer to it will be passed through the callback's data parameter
+ // and deleted in the callback.
+ SlotAsyncReady* slot_copy = new SlotAsyncReady(slot);
+
+ g_mount_eject(gobj(),
+ GMountUnmountFlags(flags),
+ NULL,
+ &SignalProxy_async_callback,
+ slot_copy);
+}
+
+void Mount::eject(MountUnmountFlags flags)
+{
+ g_mount_eject(gobj(),
+ GMountUnmountFlags(flags),
+ NULL,
+ NULL,
+ NULL);
+}
+
+
} // namespace Gio