Commit 88a707b4 authored by Johan Dahlin's avatar Johan Dahlin

Wrap.

	* src/nautilus.override
	(_wrap_nautilus_file_info_get_vfs_file_info): Wrap.

	* src/pygnomevfs.h: Add from gnome-python, since it's not installed.

	* src/nautilus-python.c (nautilus_python_init_python): Check
	.nautilus/python-extensions-2.

	* src/nautilus-python-object.c: Thread fixes.
parent 69d9283a
2005-01-08 Johan Dahlin <johan@gnome.org>
* src/nautilus.override
(_wrap_nautilus_file_info_get_vfs_file_info): Wrap.
* src/pygnomevfs.h: Add from gnome-python, since it's not installed.
* src/nautilus-python.c (nautilus_python_init_python): Check
.nautilus/python-extensions-2.
* src/nautilus-python-object.c: Thread fixes.
2004-12-11 Thomas Vander Stichele <thomas at apestaart dot org>
* Makefile.am:
......
......@@ -14,8 +14,8 @@ Requirements
============
Nautilus 2.6.0
PyGtk 2.3.95
Python 2.3
Python 2.3
PyGtk 2.4.0
Problems
========
......
......@@ -36,7 +36,7 @@ nautilus_la_SOURCES = nautilusmodule.c
nodist_nautilus_la_SOURCES = nautilus.c
nautilus.c: nautilus.defs nautilus.override
CLEANFILES = nautilus.c
EXTRA_DIST = nautilus.override nautilus.defs
EXTRA_DIST = nautilus.override nautilus.defs pygnomevfs.h
.defs.c:
(cd $(srcdir)\
......
......@@ -104,9 +104,10 @@ nautilus_python_object_get_property_pages (NautilusPropertyPageProvider *provide
NautilusPythonObject *object = (NautilusPythonObject*)provider;
PyObject *py_files, *py_ret;
GList *ret = NULL;
PyGILState_STATE state = pyg_gil_state_ensure(); \
debug_enter();
CHECK_METHOD_NAME(object->instance);
CONVERT_LIST(py_files, files);
......@@ -118,6 +119,7 @@ nautilus_python_object_get_property_pages (NautilusPropertyPageProvider *provide
HANDLE_LIST(py_ret, NautilusPropertyPage, "nautilus.PropertyPage");
beach:
pyg_gil_state_release(state);
return ret;
}
#undef METHOD_NAME
......@@ -138,6 +140,7 @@ nautilus_python_object_get_file_items (NautilusMenuProvider *provider,
NautilusPythonObject *object = (NautilusPythonObject*)provider;
GList *ret = NULL;
PyObject *py_ret, *py_files;
PyGILState_STATE state = pyg_gil_state_ensure(); \
debug_enter();
......@@ -154,6 +157,7 @@ nautilus_python_object_get_file_items (NautilusMenuProvider *provider,
HANDLE_LIST(py_ret, NautilusMenuItem, "nautilus.MenuItem");
beach:
pyg_gil_state_release(state);
return ret;
}
#undef METHOD_NAME
......@@ -167,6 +171,7 @@ nautilus_python_object_get_background_items (NautilusMenuProvider *provider,
NautilusPythonObject *object = (NautilusPythonObject*)provider;
GList *ret = NULL;
PyObject *py_ret;
PyGILState_STATE state = pyg_gil_state_ensure(); \
debug_enter();
......@@ -195,6 +200,7 @@ nautilus_python_object_get_toolbar_items (NautilusMenuProvider *provider,
NautilusPythonObject *object = (NautilusPythonObject*)provider;
GList *ret = NULL;
PyObject *py_ret;
PyGILState_STATE state = pyg_gil_state_ensure(); \
debug_enter();
......@@ -209,6 +215,7 @@ nautilus_python_object_get_toolbar_items (NautilusMenuProvider *provider,
HANDLE_LIST(py_ret, NautilusMenuItem, "nautilus.MenuItem");
beach:
pyg_gil_state_release(state);
return ret;
}
#undef METHOD_NAME
......@@ -228,6 +235,7 @@ nautilus_python_object_get_columns (NautilusColumnProvider *provider)
NautilusPythonObject *object = (NautilusPythonObject*)provider;
GList *ret = NULL;
PyObject *py_ret;
PyGILState_STATE state = pyg_gil_state_ensure(); \
debug_enter();
......@@ -241,6 +249,7 @@ nautilus_python_object_get_columns (NautilusColumnProvider *provider)
HANDLE_LIST(py_ret, NautilusColumn, "nautilus.Column");
beach:
pyg_gil_state_release(state);
return ret;
}
#undef METHOD_NAME
......@@ -271,6 +280,7 @@ nautilus_python_object_update_file_info (NautilusInfoProvider *provider,
NautilusPythonObject *object = (NautilusPythonObject*)provider;
NautilusOperationResult ret = NAUTILUS_OPERATION_COMPLETE;
PyObject *py_ret;
PyGILState_STATE state = pyg_gil_state_ensure(); \
debug_enter();
......@@ -291,6 +301,7 @@ nautilus_python_object_update_file_info (NautilusInfoProvider *provider,
ret = PyInt_AsLong(py_ret);
beach:
pyg_gil_state_release(state);
return ret;
}
#undef METHOD_NAME
......
......@@ -27,6 +27,7 @@
#include "nautilus-python.h"
#include "nautilus-python-object.h"
#include "pygnomevfs.h"
#include <libnautilus-extension/nautilus-extension-types.h>
......@@ -111,6 +112,7 @@ nautilus_python_init_python (void)
{
PyObject *pygtk, *mdict, *require;
PyObject *sys_path, *nautilus, *gtk, *pygtk_version, *pygtk_required_version;
char *home_dir;
char *argv[] = { "nautilus", NULL };
if (Py_IsInitialized())
......@@ -124,11 +126,18 @@ nautilus_python_init_python (void)
require = PyDict_GetItemString(mdict, "require");
PyObject_CallObject(require, Py_BuildValue("(S)", PyString_FromString("2.0")));
debug("init_pygobject");
debug("init_pygobject");
np_init_pygobject();
debug("init_pygtk");
np_init_pygtk();
debug("init_gnomevfs");
np_init_pygnomevfs();
debug("pyg_enable_threads");
setenv("PYGTK_USE_GIL_STATE_API", "", 0);
putenv("PYGTK_USE_GIL_STATE_API=");
pyg_enable_threads();
gtk = PyImport_ImportModule("gtk");
mdict = PyModule_GetDict(gtk);
pygtk_version = PyDict_GetItemString(mdict, "pygtk_version");
......@@ -144,9 +153,14 @@ nautilus_python_init_python (void)
debug("sys.path.insert(0, ...)");
sys_path = PySys_GetObject("path");
PyList_Insert(sys_path, 0, PyString_FromString(NAUTILUS_LIBDIR "/nautilus-python"));
PyList_Insert(sys_path, 1, PyString_FromString(NAUTILUS_LIBDIR "/nautilus/extensions-1.0/python"));
PyList_Insert(sys_path, 0,
PyString_FromString(NAUTILUS_LIBDIR "/nautilus-python"));
home_dir = g_strdup_printf("%s/.nautilus/python-extensions/",
g_get_home_dir());
PyList_Insert(sys_path, 1, PyString_FromString(home_dir));
PyList_Insert(sys_path, 2,
PyString_FromString(NAUTILUS_LIBDIR "/nautilus/extensions-1.0/python"));
debug("import nautilus");
nautilus = PyImport_ImportModule("nautilus");
if (!nautilus) {
......
/*
* nautilus-python.c - Nautilus Python extension
*
* Copyright (C) 2003, 2004 Novell, Inc.
* Copyright (C) 2004 Johan Dahlin
*
* This library is free software; you can redistribute it and/or
......@@ -18,9 +17,6 @@
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* Author: Calvin Gaisford <cgaisford@novell.com>
* Dave Camp <dave@ximian.com>
*
*/
#ifndef NAUTILUS_PYTHON_H
......@@ -39,9 +35,6 @@
# define debug_enter_args(x, y)
#endif
#define NAUTILUS_TYPE_OBJECT_LIST (nautilus_object_list_get_type ())
GType nautilus_object_list_get_type (void);
/* Macros from PyGTK, changed to return FALSE instead of nothing */
#define np_init_pygobject() { \
PyObject *gobject = PyImport_ImportModule("gobject"); \
......
......@@ -23,6 +23,8 @@ headers
#define NO_IMPORT_PYGOBJECT
#include "pygobject.h"
#include "pygnomevfs.h"
#include <libnautilus-extension/nautilus-file-info.h>
#include <libnautilus-extension/nautilus-info-provider.h>
#include <libnautilus-extension/nautilus-column-provider.h>
......@@ -38,3 +40,18 @@ import gtk.Window as PyGtkWindow_Type
%%
ignore-glob
*_get_type
%%
override nautilus_file_info_get_vfs_file_info noargs
static PyObject *
_wrap_nautilus_file_info_get_vfs_file_info(PyGObject *self)
{
GnomeVFSFileInfo *ret;
ret = nautilus_file_info_get_vfs_file_info(NAUTILUS_FILE_INFO(self->obj));
if (ret) {
return pygnome_vfs_file_info_new(ret);
}
Py_INCREF(Py_None);
return Py_None;
}
/*
* nautilus-python.c - Nautilus Python extension
*
* Copyright (C) 2004 Johan Dahlin
*
* This library 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 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
#ifndef PYGNOME_VFS_H
#define PYGNOME_VFS_H
#include <Python.h>
#include <libgnomevfs/gnome-vfs-init.h>
#include <libgnomevfs/gnome-vfs-uri.h>
#include <libgnomevfs/gnome-vfs-file-info.h>
#include <libgnomevfs/gnome-vfs-directory.h>
#include <libgnomevfs/gnome-vfs-ops.h>
#include <libgnomevfs/gnome-vfs-mime-handlers.h>
#include <libgnomevfs/gnome-vfs-mime-utils.h>
#include <libgnomevfs/gnome-vfs-result.h>
#include <libgnomevfs/gnome-vfs-context.h>
#include <libgnomevfs/gnome-vfs-xfer.h>
typedef struct {
PyObject_HEAD
GnomeVFSURI *uri;
} PyGnomeVFSURI;
typedef struct {
PyObject_HEAD
GnomeVFSFileInfo *finfo;
} PyGnomeVFSFileInfo;
typedef struct {
PyObject_HEAD
GnomeVFSContext *context;
} PyGnomeVFSContext;
#define pygnome_vfs_uri_get(v) (((PyGnomeVFSURI *)(v))->uri)
#define pygnome_vfs_uri_check(v) ((v)->ob_type == _PyGnomeVFS_API->uri_type)
#define pygnome_vfs_file_info_get(v) (((PyGnomeVFSFileInfo *)(v))->finfo)
#define pygnome_vfs_file_info_check(v) ((v)->ob_type == _PyGnomeVFS_API->file_info_type)
#define pygnome_vfs_context_get(v) (((PyGnomeVFSURI *)(v))->context)
#define pygnome_vfs_context_check(v) ((v)->ob_type == _PyGnomeVFS_API->context_type)
struct _PyGnomeVFS_Functions {
GnomeVFSResult (* exception_check)(void);
PyObject *(* uri_new)(GnomeVFSURI *uri);
PyTypeObject *uri_type;
PyObject *(* file_info_new)(GnomeVFSFileInfo *finfo);
PyTypeObject *file_info_type;
PyObject *(* context_new)(GnomeVFSContext *context);
PyTypeObject *context_type;
};
#if defined(NO_IMPORT) || defined(NO_IMPORT_PYGNOMEVFS)
extern struct _PyGnomeVFS_Functions *_PyGnomeVFS_API;
#else
struct _PyGnomeVFS_Functions *_PyGnomeVFS_API;
#endif
#define pygnome_vfs_exception_check (_PyGnomeVFS_API->exception_check)
#define pygnome_vfs_uri_new (_PyGnomeVFS_API->uri_new)
#define PyGnomeVFSURI_Type (*_PyGnomeVFS_API->uri_type)
#define pygnome_vfs_file_info_new (_PyGnomeVFS_API->file_info_new)
#define PyGnomeVFSFileInfo_Type (*_PyGnomeVFS_API->file_info_type)
#define pygnome_vfs_context_new (_PyGnomeVFS_API->context_new)
#define PyGnomeVFSContext_Type (*_PyGnomeVFS_API->context_type)
#define np_init_pygnomevfs() { \
PyObject *gobject = PyImport_ImportModule("gnome.vfs"); \
if (gobject != NULL) { \
PyObject *mdict = PyModule_GetDict(gobject); \
PyObject *cobject = PyDict_GetItemString(mdict, "_PyGnomeVFS_API"); \
if (PyCObject_Check(cobject)) \
_PyGnomeVFS_API = (struct _PyGnomeVFS_Functions *)PyCObject_AsVoidPtr(cobject); \
else { \
Py_FatalError("could not find _PyGnomeVFS_API object"); \
return FALSE; \
} \
} else { \
Py_FatalError("could not import gnome.vfs"); \
return FALSE; \
} \
}
#endif /* PYGNOME_VFS_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment