pygobject r907 - in trunk: . gio



Author: johan
Date: Fri Aug  1 22:07:03 2008
New Revision: 907
URL: http://svn.gnome.org/viewvc/pygobject?rev=907&view=rev

Log:
2008-08-02  Johan Dahlin  <johan gnome org>

    * gio/Makefile.am:
    * gio/gfile.override:
    * gio/gio.defs:
    * gio/gio.override:
    * gio/gvolume.override:
    Wrap gio.Volume.mount and gio.Volume.eject



Added:
   trunk/gio/gvolume.override
Modified:
   trunk/ChangeLog
   trunk/gio/Makefile.am
   trunk/gio/gfile.override
   trunk/gio/gio.defs
   trunk/gio/gio.override

Modified: trunk/gio/Makefile.am
==============================================================================
--- trunk/gio/Makefile.am	(original)
+++ trunk/gio/Makefile.am	Fri Aug  1 22:07:03 2008
@@ -44,6 +44,7 @@
 	gfileinfo.override		\
 	ginputstream.override 		\
 	goutputstream.override 		\
+	gvolume.override		\
 	gvolumemonitor.override
 
 GIO_DEFS = gio.defs gio-types.defs $(GIO_OVERRIDES)

Modified: trunk/gio/gfile.override
==============================================================================
--- trunk/gio/gfile.override	(original)
+++ trunk/gio/gfile.override	Fri Aug  1 22:07:03 2008
@@ -408,7 +408,7 @@
     PyGIONotify *notify;
     PyObject *py_flags = NULL;
     PyGObject *py_cancellable = NULL;
-    GMountMountFlags flags = G_MOUNT_MOUNT_NONE;
+    GMountUnmountFlags flags = G_MOUNT_UNMOUNT_NONE;
     GCancellable *cancellable;
 
     notify = g_slice_new0(PyGIONotify);
@@ -435,7 +435,7 @@
     Py_INCREF(notify->callback);
     Py_XINCREF(notify->data);
 
-    if (py_flags && pyg_flags_get_value(G_TYPE_MOUNT_MOUNT_FLAGS,
+    if (py_flags && pyg_flags_get_value(G_TYPE_MOUNT_UNMOUNT_FLAGS,
 					py_flags, (gpointer)&flags))
         return NULL;
 
@@ -533,7 +533,7 @@
     notify = g_slice_new0(PyGIONotify);
 
     if (!PyArg_ParseTupleAndKeywords(args, kwargs,
-                                     "O!|OOOO:File.unmount_mountable",
+                                     "O!|OOOO:File.copy",
 				     kwlist,
 				     &PyGFile_Type,
 				     &destination,
@@ -581,6 +581,76 @@
     return PyBool_FromLong(ret);
 }
 %%
+override g_file_move kwargs
+static PyObject *
+_wrap_g_file_move(PyGObject *self,
+		  PyObject *args,
+		  PyObject *kwargs)
+{
+    static char *kwlist[] = { "destination", "flags",
+			      "cancellable", "progress_callback",
+			      "user_data", NULL };
+    PyGIONotify *notify;
+    PyObject *py_flags = NULL;
+    PyGObject *destination = NULL;
+    PyGObject *py_cancellable = NULL;
+    GFileCopyFlags flags = G_FILE_COPY_NONE;
+    GCancellable *cancellable;
+    int ret;
+    GError *error = NULL;
+    GFileProgressCallback callback = NULL;
+
+    notify = g_slice_new0(PyGIONotify);
+
+    if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+                                     "O!|OOOO:File.move",
+				     kwlist,
+				     &PyGFile_Type,
+				     &destination,
+				     &notify->callback,
+				     &py_flags,
+				     &py_cancellable,
+				     &notify->data))
+
+    {
+      g_slice_free(PyGIONotify, notify);
+      return NULL;
+    }
+
+    if (notify->callback != NULL)
+    {
+	if (!PyCallable_Check(notify->callback))
+	{
+	    PyErr_SetString(PyExc_TypeError, "callback argument not callable");
+	    g_slice_free(PyGIONotify, notify);
+	    return NULL;
+	}
+	callback = (GFileProgressCallback)file_progress_callback_marshal;
+	Py_INCREF(notify->callback);
+    }
+    Py_XINCREF(notify->data);
+
+    if (py_flags && pyg_flags_get_value(G_TYPE_FILE_COPY_FLAGS,
+					py_flags, (gpointer)&flags))
+        return NULL;
+
+    if (!pygio_check_cancellable(py_cancellable, &cancellable))
+        return NULL;
+
+    ret = g_file_move(G_FILE(self->obj),
+		      G_FILE(destination->obj),
+		      flags,
+		      cancellable,
+		      callback,
+		      notify,
+		      &error);
+
+    if (pyg_error_check(&error))
+        return NULL;
+
+    return PyBool_FromLong(ret);
+}
+%%
 override g_file_set_attribute kwargs
 static PyObject *
 _wrap_g_file_set_attribute(PyGObject *self, PyObject *args, PyObject *kwargs)

Modified: trunk/gio/gio.defs
==============================================================================
--- trunk/gio/gio.defs	(original)
+++ trunk/gio/gio.defs	Fri Aug  1 22:07:03 2008
@@ -2004,7 +2004,7 @@
 "operation was cancelled, the error gio.ERROR_CANCELLED will be returned.\n"
 "\n"
 "When the operation is finished, callback will be called. You can\n"
-"then call g_file_unmount_mountable_finish() to get the\n"
+"then call gio.File.unmount_mountable_finish() to get the\n"
 "result of the operation.\n")
   (of-object "GFile")
   (c-name "g_file_unmount_mountable")
@@ -3589,6 +3589,16 @@
 )
 
 (define-method eject
+  (docstring
+"F.eject(callback, [flags, cancellable, user_data])\n"
+"Ejects a volume.\n"
+"\n"
+"If cancellable is not None, then the operation can be cancelled by\n"
+"triggering the cancellable object from another thread. If the\n"
+"operation was cancelled, the error gio.ERROR_CANCELLED will be returned.\n"
+"\n"
+"When the operation is finished, callback will be called. You can\n"
+"then call gio.Volume.eject_finish() to get the result of the operation.\n")
   (of-object "GMount")
   (c-name "g_mount_eject")
   (return-type "none")
@@ -4397,6 +4407,18 @@
 )
 
 (define-method mount
+  (docstring
+"V.mount(mount_operation, callback, [flags, cancellable, user_data])\n"
+"Mounts a volume. Using mount_operation, you can request callbacks\n"
+"when, for instance, passwords are needed during authentication.\n"
+"\n"
+"If cancellable is not None, then the operation can be cancelled by\n"
+" triggering the cancellable object from another thread. If the\n"
+"operation was cancelled, the error gio.ERROR_CANCELLED will be returned.\n"
+"\n"
+"When the operation is finished, callback will be called. You can then\n"
+"call gio.Volume.mount_finish() to get the result of the operation.\n")
+
   (of-object "GVolume")
   (c-name "g_volume_mount")
   (return-type "none")

Modified: trunk/gio/gio.override
==============================================================================
--- trunk/gio/gio.override	(original)
+++ trunk/gio/gio.override	Fri Aug  1 22:07:03 2008
@@ -2,7 +2,7 @@
  * pygtk- Python bindings for the GTK toolkit.
  * Copyright (C) 2008  Johan Dahlin
  *
- *   giomodule.c: module wrapping the GIO library
+ *   gio.override: module wrapping the GIO library
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -87,6 +87,7 @@
   gfileinfo.override
   ginputstream.override
   goutputstream.override
+  gvolume.override
   gvolumemonitor.override
 %%
 ignore-glob

Added: trunk/gio/gvolume.override
==============================================================================
--- (empty file)
+++ trunk/gio/gvolume.override	Fri Aug  1 22:07:03 2008
@@ -0,0 +1,135 @@
+/* -*- Mode: C; c-basic-offset: 4 -*-
+ * pygobject - Python bindings for GObject
+ * Copyright (C) 2008  Johan Dahlin
+ *
+ *   gvolume.override: module overrides for GVolume
+ *
+ * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA
+ */
+%%
+override g_volume_mount kwargs
+static PyObject *
+_wrap_g_volume_mount(PyGObject *self,
+		     PyObject *args,
+		     PyObject *kwargs)
+{
+    static char *kwlist[] = { "callback", "flags", "mount_operation",
+			      "cancellable", "user_data", NULL };
+    PyGIONotify *notify;
+    PyObject *py_flags = NULL;
+    PyGObject *mount_operation;
+    PyGObject *py_cancellable = NULL;
+    GMountMountFlags flags = G_MOUNT_MOUNT_NONE;
+    GCancellable *cancellable;
+
+    notify = g_slice_new0(PyGIONotify);
+
+    if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+                                     "O!O|OOO:Volume.mount",
+				     kwlist,
+				     &PyGMountOperation_Type,
+				     &mount_operation,
+				     &notify->callback,
+				     &py_flags,
+				     &py_cancellable,
+				     &notify->data))
+
+    {
+      g_slice_free(PyGIONotify, notify);
+      return NULL;
+    }
+
+    if (!PyCallable_Check(notify->callback))
+    {
+	PyErr_SetString(PyExc_TypeError, "callback argument not callable");
+	g_slice_free(PyGIONotify, notify);
+	return NULL;
+    }
+    Py_INCREF(notify->callback);
+    Py_XINCREF(notify->data);
+
+    if (py_flags && pyg_flags_get_value(G_TYPE_MOUNT_MOUNT_FLAGS,
+					py_flags, (gpointer)&flags))
+        return NULL;
+
+    if (!pygio_check_cancellable(py_cancellable, &cancellable))
+        return NULL;
+
+    g_volume_mount(G_VOLUME(self->obj),
+		   flags,
+		   G_MOUNT_OPERATION(mount_operation->obj),
+		   cancellable,
+		   (GAsyncReadyCallback)async_result_callback_marshal,
+		   notify);
+
+    Py_INCREF(Py_None);
+    return Py_None;
+}
+%%
+override g_volume_eject kwargs
+static PyObject *
+_wrap_g_volume_eject(PyGObject *self,
+		     PyObject *args,
+		     PyObject *kwargs)
+{
+    static char *kwlist[] = { "callback", "flags",
+			      "cancellable", "user_data", NULL };
+    PyGIONotify *notify;
+    PyObject *py_flags = NULL;
+    PyGObject *py_cancellable = NULL;
+    GMountUnmountFlags flags = G_MOUNT_UNMOUNT_NONE;
+    GCancellable *cancellable;
+
+    notify = g_slice_new0(PyGIONotify);
+
+    if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+                                     "O|OOO:Volume.eject",
+				     kwlist,
+				     &notify->callback,
+				     &py_flags,
+				     &py_cancellable,
+				     &notify->data))
+
+    {
+      g_slice_free(PyGIONotify, notify);
+      return NULL;
+    }
+
+    if (!PyCallable_Check(notify->callback))
+    {
+	PyErr_SetString(PyExc_TypeError, "callback argument not callable");
+	g_slice_free(PyGIONotify, notify);
+	return NULL;
+    }
+    Py_INCREF(notify->callback);
+    Py_XINCREF(notify->data);
+
+    if (py_flags && pyg_flags_get_value(G_TYPE_MOUNT_UNMOUNT_FLAGS,
+					py_flags, (gpointer)&flags))
+        return NULL;
+
+    if (!pygio_check_cancellable(py_cancellable, &cancellable))
+        return NULL;
+
+    g_volume_eject(G_VOLUME(self->obj),
+		   flags,
+		   cancellable,
+		   (GAsyncReadyCallback)async_result_callback_marshal,
+		   notify);
+
+    Py_INCREF(Py_None);
+    return Py_None;
+}



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