glibmm r523 - in trunk: . gio/src



Author: murrayc
Date: Fri Jan 18 18:31:35 2008
New Revision: 523
URL: http://svn.gnome.org/viewvc/glibmm?rev=523&view=rev

Log:
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.

Modified:
   trunk/ChangeLog
   trunk/gio/src/mount.ccg
   trunk/gio/src/mount.hg
   trunk/gio/src/volume.hg

Modified: trunk/gio/src/mount.ccg
==============================================================================
--- trunk/gio/src/mount.ccg	(original)
+++ trunk/gio/src/mount.ccg	Fri Jan 18 18:31:35 2008
@@ -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
 

Modified: trunk/gio/src/mount.hg
==============================================================================
--- trunk/gio/src/mount.hg	(original)
+++ trunk/gio/src/mount.hg	Fri Jan 18 18:31:35 2008
@@ -63,38 +63,104 @@
   _WRAP_METHOD(bool can_unmount() const, g_mount_can_unmount)
   _WRAP_METHOD(bool can_eject() const, g_mount_can_eject)
 
-//TODO:
-/*
-  _WRAP_METHOD(void               g_mount_unmount              (GMount              *mount,
-						 GMountUnmountFlags   flags,
-                                                 GCancellable        *cancellable,
-                                                 GAsyncReadyCallback  callback,
-                                                 gpointer             user_data);
-*/
+  /** Unmounts a mount. 
+   * This is an asynchronous operation, and is finished by calling unmount_finish() with the AsyncResult data returned in the callback slot.
+   *
+   * @param slot A callback which will be called when the operation is completed or canceled.
+   * @param cancellable A cancellable object which can be used to cancel the operation.
+   * @param flags Flags affecting the unmount.
+   */
+  void unmount(const SlotAsyncReady& slot, const Glib::RefPtr<Cancellable>& cancellable, MountUnmountFlags flags = MOUNT_UNMOUNT_NONE);
+
+  /** Unmounts a mount. 
+   * This is an asynchronous operation, and is finished by calling unmount_finish() with the AsyncResult data returned in the callback slot.
+   *
+   * @param slot A callback which will be called when the operation is completed or canceled.
+   * @param flags Flags affecting the unmount.
+   */
+  void unmount(const SlotAsyncReady& slot, MountUnmountFlags flags = MOUNT_UNMOUNT_NONE);
+
+  /** Unmounts a mount.
+   *
+   * @param cancellable A cancellable object which can be used to cancel the operation.
+   */
+  void unmount(MountUnmountFlags flags = MOUNT_UNMOUNT_NONE);
+  _IGNORE(g_mount_unmount)
+
   _WRAP_METHOD(bool unmount_finish(const Glib::RefPtr<AsyncResult>& result), g_mount_unmount_finish, errthrow)
 
-//TODO:
-/*
-  _WRAP_METHOD(void               g_mount_eject                (GMount              *mount,
-						 GMountUnmountFlags   flags,
-                                                 GCancellable        *cancellable,
-                                                 GAsyncReadyCallback  callback,
-                                                 gpointer             user_data);
-*/
-  _WRAP_METHOD(bool eject_finish(const Glib::RefPtr<AsyncResult>& result), g_mount_eject_finish, errthrow)
+  /** Remounts a mount.
+   * This is an asynchronous operation, and is finished by calling mount_finish() with the AsyncResult data returned in the callback slot.
+   *
+   * Remounting is useful when some setting affecting the operation of the volume has been changed, as this may need a remount 
+   * to take affect. While this is semantically equivalent with unmounting and then remounting, not all backends might need to 
+   * actually be unmounted.
+   *
+   * @param operation A mount operation.
+   * @param slot A callback which will be called when the operation is completed or canceled.
+   * @param cancellable A cancellable object which can be used to cancel the operation.
+   */
+  void remount(const Glib::RefPtr<MountOperation>& operation, SlotAsyncReady& slot, const Glib::RefPtr<Cancellable>& cancellable);
+
+  /** Remounts a mount.
+   * This is an asynchronous operation, and is finished by calling mount_finish() with the AsyncResult data returned in the callback slot.
+   *
+   * Remounting is useful when some setting affecting the operation of the volume has been changed, as this may need a remount 
+   * to take affect. While this is semantically equivalent with unmounting and then remounting, not all backends might need to 
+   * actually be unmounted.
+   *
+   * @param operation A mount operation.
+   * @param slot A callback which will be called when the operation is completed or canceled.
+   */
+  void remount(const Glib::RefPtr<MountOperation>& operation, SlotAsyncReady& slot);
+
+  /** Remounts a mount.
+   * 
+   * Remounting is useful when some setting affecting the operation of the volume has been changed, as this may need a remount 
+   * to take affect. While this is semantically equivalent with unmounting and then remounting, not all backends might need to 
+   * actually be unmounted.
+   *
+   * @param operation A mount operation.
+   */
+  void remount(const Glib::RefPtr<MountOperation>& operation);
+
+  /** Remounts a mount, without user interaction.
+   * 
+   * Remounting is useful when some setting affecting the operation of the volume has been changed, as this may need a remount 
+   * to take affect. While this is semantically equivalent with unmounting and then remounting, not all backends might need to 
+   * actually be unmounted.
+   */
+  void remount();
+  _IGNORE(g_mount_remount)
 
 
-//TODO:
-/*
-  _WRAP_METHOD(void               g_mount_remount              (GMount              *mount,
-						 GMountOperation     *mount_operation,
-                                                 GCancellable        *cancellable,
-                                                 GAsyncReadyCallback  callback,
-                                                 gpointer             user_data);
-*/
   _WRAP_METHOD(bool remount_finish(const Glib::RefPtr<AsyncResult>& result), g_mount_remount_finish, errthrow)
 
+  /** Ejects a mount. 
+   * This is an asynchronous operation, and is finished by calling eject_finish() with the AsyncResult data returned in the callback slot.
+   *
+   * @param slot A callback which will be called when the operation is completed or canceled.
+   * @param cancellable A cancellable object which can be used to cancel the operation.
+   * @param flags Flags affecting the unmount if required for eject.
+   */
+  void eject(const SlotAsyncReady& slot, const Glib::RefPtr<Cancellable>& cancellable, MountUnmountFlags flags = MOUNT_UNMOUNT_NONE);
+
+  /** Ejects a mount. 
+   * This is an asynchronous operation, and is finished by calling eject_finish() with the AsyncResult data returned in the callback slot.
+   *
+   * @param slot A callback which will be called when the operation is completed or canceled.
+   * @param flags Flags affecting the unmount if required for eject.
+   */
+  void eject(const SlotAsyncReady& slot, MountUnmountFlags flags = MOUNT_UNMOUNT_NONE);
+
+  /** Ejects a mount. 
+   *
+   * @param flags Flags affecting the unmount if required for eject.
+   */
+  void eject(MountUnmountFlags flags = MOUNT_UNMOUNT_NONE);
+  _IGNORE(g_mount_eject)
 
+  _WRAP_METHOD(bool eject_finish(const Glib::RefPtr<AsyncResult>& result), g_mount_eject_finish, errthrow)
 
   _WRAP_SIGNAL(void changed(), changed)
   _WRAP_SIGNAL(void unmounted(), unmounted)

Modified: trunk/gio/src/volume.hg
==============================================================================
--- trunk/gio/src/volume.hg	(original)
+++ trunk/gio/src/volume.hg	Fri Jan 18 18:31:35 2008
@@ -73,14 +73,31 @@
   _WRAP_METHOD(bool can_mount() const, g_volume_can_mount)
   _WRAP_METHOD(bool can_eject() const, g_volume_can_eject)
 
-  //TODO: Documentation.
-
+  /** Mounts a volume.
+   * This is an asynchronous operation, and is finished by calling mount_finish() with the AsyncResult data returned in the callback slot.
+   *
+   * @param slot A callback which will be called when the operation is completed or canceled.
+   * @param cancellable A cancellable object which can be used to cancel the operation.
+   * @param mount_operation A mount operation.
+   */
   void mount(const Glib::RefPtr<MountOperation>& mount_operation, const SlotAsyncReady& slot, const Glib::RefPtr<Cancellable>& cancellable);
 
+  /** Mounts a volume.
+   * This is an asynchronous operation, and is finished by calling mount_finish() with the AsyncResult data returned in the callback slot.
+   *
+   * @param slot A callback which will be called when the operation is completed or canceled.
+   * @param mount_operation A mount operation.
+   */
   void mount(const Glib::RefPtr<MountOperation>& mount_operation, const SlotAsyncReady& slot);
 
+  /** Mounts a volume.
+   * 
+   * @param mount_operation A mount operation.
+   */
   void mount(const Glib::RefPtr<MountOperation>& mount_operation);
 
+  /** Mounts a volume.
+   */
   void mount();
 
   _IGNORE(g_volume_mount)
@@ -89,11 +106,28 @@
                g_volume_mount_finish,
                errthrow)
 
-  //TODO: Documentation.
+  /** Ejects a volume. 
+   * This is an asynchronous operation, and is finished by calling eject_finish() with the AsyncResult data returned in the callback slot.
+   *
+   * @param slot A callback which will be called when the operation is completed or canceled.
+   * @param cancellable A cancellable object which can be used to cancel the operation.
+   * @param flags Flags affecting the unmount if required for eject.
+   */
   void eject(const SlotAsyncReady& slot, const Glib::RefPtr<Cancellable>& cancellable, MountUnmountFlags flags = MOUNT_UNMOUNT_NONE);
 
+  /** Ejects a volume. 
+   * This is an asynchronous operation, and is finished by calling eject_finish() with the AsyncResult data returned in the callback slot.
+   *
+   * @param slot A callback which will be called when the operation is completed or canceled.
+   * @param flags Flags affecting the unmount if required for eject.
+   */
   void eject(const SlotAsyncReady& slot, MountUnmountFlags flags = MOUNT_UNMOUNT_NONE);
 
+  /** Ejects a volume. 
+   * This is an asynchronous operation, and is finished by calling eject_finish() with the AsyncResult data returned in the callback slot.
+   *
+   * @param flags Flags affecting the unmount if required for eject.
+   */
   void eject(MountUnmountFlags flags = MOUNT_UNMOUNT_NONE);
   _IGNORE(g_volume_eject)
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]