[Xfce4-commits] <thunarx-python:master> Many changes

Adam Plumb noreply at xfce.org
Thu May 27 18:10:22 CEST 2010


Updating branch refs/heads/master
         to 4b4b00b4f22e7a9b25ec7466882d01cce4e4f04d (commit)
       from 579657bf6ca960a60937e2c2a71678cc7b913cd3 (commit)

commit 4b4b00b4f22e7a9b25ec7466882d01cce4e4f04d
Author: Adam Plumb <adamplumb at gmail.com>
Date:   Fri Dec 11 10:22:32 2009 -0500

    Many changes

 configure.ac.in             |   23 ++
 src/Makefile.am             |   59 +++++-
 src/generate-defs.sh        |   13 +
 src/thunarx-python-object.c |  321 ++++++++++++++++++++++++++
 src/thunarx-python-object.h |   68 ++++++
 src/thunarx-python.c        |  272 ++++++++++++++++++++---
 src/thunarx-python.h        |   70 ++++++
 src/thunarx.defs            |  522 +++++++++++++++++++++++++++++++++++++++++++
 src/thunarx.override        |   39 ++++
 src/thunarxmodule.c         |   60 +++++
 src/txp-provider.c          |  122 ----------
 src/txp-provider.h          |   42 ----
 12 files changed, 1412 insertions(+), 199 deletions(-)

diff --git a/configure.ac.in b/configure.ac.in
index e5a63ef..8cfacad 100644
--- a/configure.ac.in
+++ b/configure.ac.in
@@ -71,6 +71,8 @@ XDT_CHECK_PACKAGE([GTK], [gtk+-2.0], [2.6.0])
 XDT_CHECK_PACKAGE([GLIB], [glib-2.0], [2.6.0])
 XDT_CHECK_PACKAGE([GTHREAD], [gthread-2.0], [2.6.0])
 XDT_CHECK_PACKAGE([GOBJECT], [gobject-2.0], [2.6.0])
+XDT_CHECK_PACKAGE([PYGTK], [pygtk-2.0], [2.6.0])
+XDT_CHECK_PACKAGE([GNOMEPYTHON], [gnome-python-2.0], [2.12.0])
 
 PYTHON_CFLAGS="`python-config --includes`"
 PYTHON_LIBS="`python-config --ldflags`"
@@ -78,6 +80,27 @@ PYTHON_LIBS="`python-config --ldflags`"
 AC_SUBST(PYTHON_CFLAGS)
 AC_SUBST(PYTHON_LIBS)
 
+THUNARX_LIBDIR=`pkg-config --variable=libdir thunarx-2`
+AC_SUBST(THUNARX_LIBDIR)
+AC_DEFINE_UNQUOTED(THUNARX_LIBDIR, "$THUNARX_LIBDIR", [Thunarx libdir])
+
+AC_MSG_CHECKING(for pygtk defs)
+PYGTK_DEFSDIR=`$PKG_CONFIG --variable=defsdir pygtk-2.0`
+AC_SUBST(PYGTK_DEFSDIR)
+AC_MSG_RESULT($PYGTK_DEFSDIR)
+
+AC_MSG_CHECKING(for pygtk codegen)
+PYGTK_CODEGEN="/usr/bin/python `$PKG_CONFIG --variable=codegendir pygobject-2.0`/codegen.py"
+AC_SUBST(PYGTK_CODEGEN)
+AC_MSG_RESULT($PYGTK_CODEGEN)
+
+dnl ---------------------------------
+dnl Get thunar extensions directory
+dnl ---------------------------------
+THUNARX_EXTENSION_DIR=`$PKG_CONFIG --variable=extensionsdir thunarx-2`
+AC_SUBST(THUNARX_EXTENSION_DIR)
+AC_DEFINE_UNQUOTED(THUNARX_EXTENSION_DIR, "$THUNARX_EXTENSION_DIR", [Thunar's extensions directory])
+
 dnl ***********************************
 dnl *** Check for debugging support ***
 dnl ***********************************
diff --git a/src/Makefile.am b/src/Makefile.am
index d465e5a..ba48d6c 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -12,9 +12,10 @@ extensions_LTLIBRARIES =						\
 	thunarx-python.la
 
 thunarx_python_la_SOURCES =						\
-	txp-provider.c							\
-	txp-provider.h							\
-	thunarx-python.c
+	thunarx-python.c						\
+	thunarx-python.h						\
+	thunarx-python-object.c						\
+	thunarx-python-object.h
 
 thunarx_python_la_CPPFLAGS =						\
 	$(AM_CPPFLAGS)
@@ -24,7 +25,9 @@ thunarx_python_la_CFLAGS =						\
 	$(THUNARX_CFLAGS)						\
 	$(EXO_CFLAGS)							\
 	$(LIBXFCE4UTIL_CFLAGS)						\
-	$(PYTHON_CFLAGS)
+	$(PYTHON_CFLAGS)						\
+	$(PYGTK_CFLAGS)							\
+	$(GNOMEPYTHON_CFLAGS)
 
 thunarx_python_la_LDFLAGS =						\
 	-avoid-version							\
@@ -34,6 +37,52 @@ thunarx_python_la_LDFLAGS =						\
 	$(THUNARX_LDFLAGS)						\
 	$(EXO_LDFLAGS)							\
 	$(LIBXFCE4UTIL_LDFLAGS)						\
-	$(PYTHON_LIBS)
+	$(PYTHON_LIBS)							\
+	$(PYGTK_LIBS)							\
+	$(GNOMEPYTHON_LIBS)
+
+pyexec_LTLIBRARIES = thunarx.la
+pyexecdir = $(THUNARX_LIBDIR)/thunarx-python
+
+thunarx_la_LDFLAGS =							\
+	-module								\
+	-avoid-version							\
+	-export-symbols-regex						\
+	initthunarx							\
+	$(PLATFORM_LDFLAGS)						\
+	$(THUNARX_LDFLAGS)						\
+	$(EXO_LDFLAGS)							\
+	$(LIBXFCE4UTIL_LDFLAGS)						\
+	$(PYTHON_LIBS)							\
+	$(PYGTK_LIBS)							\
+	$(GNOMEPYTHON_LIBS)
+
+thunarx_la_LIBADD = $(THUNARX_LIBDIR) $(GNOMEPYTHON_LIBDIR) $(PYGTK_LIBDIR)
+
+thunarx_la_CFLAGS =							\
+	$(PLATFORM_CFLAGS)						\
+	$(THUNARX_CFLAGS)						\
+	$(EXO_CFLAGS)							\
+	$(LIBXFCE4UTIL_CFLAGS)						\
+	$(PYTHON_CFLAGS)						\
+	$(PYGTK_CFLAGS)							\
+	$(GNOMEPYTHON_CFLAGS)
+
+thunarx_la_SOURCES = thunarxmodule.c
+nodist_thunarx_la_SOURCES = thunarx.c
+thunarx.c: thunarx.defs thunarx.override
+CLEANFILES = thunarx.c
+EXTRA_DIST = thunarx.override thunarx.defs
+
+.defs.c:
+	(cd $(srcdir)\
+         && $(PYGTK_CODEGEN) \
+	    --register $(PYGTK_DEFSDIR)/pango-types.defs \
+            --register $(PYGTK_DEFSDIR)/gdk-types.defs \
+            --register $(PYGTK_DEFSDIR)/gtk-types.defs \
+            --override $*.override \
+            --prefix py$* $*.defs) > gen-$*.c \
+        && cp gen-$*.c $*.c \
+        && rm -f gen-$*.c
 
 # vi:set ts=8 sw=8 noet ai nocindent:
diff --git a/src/generate-defs.sh b/src/generate-defs.sh
new file mode 100755
index 0000000..39ee17e
--- /dev/null
+++ b/src/generate-defs.sh
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+THUNAR_INCLUDEDIR=`pkg-config --variable=includedir thunarx-2`/thunarx-2/thunarx
+CODEGEN=`pkg-config --variable=codegendir pygtk-2.0`/h2def.py
+
+python $CODEGEN ${THUNAR_INCLUDEDIR}/*.h >> thunarx.defs
+#python $CODEGEN "${THUNAR_INCLUDEDIR}/thunarx-preferences-provider.h" >> thunarx.defs
+#python $CODEGEN "${THUNAR_INCLUDEDIR}/thunarx-property-page.h" >> thunarx.defs
+#python $CODEGEN "${THUNAR_INCLUDEDIR}/thunarx-property-page-provider.h" >> thunarx.defs
+#python $CODEGEN "${THUNAR_INCLUDEDIR}/thunarx-provider-factory.h" >> thunarx.defs
+#python $CODEGEN "${THUNAR_INCLUDEDIR}/thunarx-provider-plugin.h" >> thunarx.defs
+#python $CODEGEN "${THUNAR_INCLUDEDIR}/thunarx-renamer.h" >> thunarx.defs
+#python $CODEGEN "${THUNAR_INCLUDEDIR}/thunarx-renamer-provider.h" >> thunarx.defs
diff --git a/src/thunarx-python-object.c b/src/thunarx-python-object.c
new file mode 100644
index 0000000..5d42e05
--- /dev/null
+++ b/src/thunarx-python-object.c
@@ -0,0 +1,321 @@
+/*-
+ * Copyright (c) 2006 Peter de Ridder <peter at xfce.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library 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 Library 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.
+ */
+
+#include <config.h>
+
+#include "thunarx-python-object.h"
+#include "thunarx-python.h"
+
+#include <thunarx/thunarx.h>
+
+#include <pygobject.h>
+
+#include <string.h>
+
+#define METHOD_PREFIX ""
+
+static GObjectClass *parent_class;
+
+/* These macros assumes the following things:
+ *   a METHOD_NAME is defined with is a string
+ *   a goto label called beach
+ *   the return value is called ret
+ */
+
+#define CHECK_METHOD_NAME(self)                                         \
+	if (!PyObject_HasAttrString(self, METHOD_NAME))                       \
+		goto beach;
+	
+#define CONVERT_LIST(py_files, files)                                   \
+	{                                                                     \
+		GList *l;                                                           \
+    py_files = PyList_New(0);                                           \
+		for (l = files; l; l = l->next) {                                   \
+      PyObject *obj = pygobject_new((GObject*)l->data);                 \
+			PyList_Append(py_files, obj);							                        \
+			Py_DECREF(obj);                                                   \
+		}                                                                   \
+	}
+
+#define HANDLE_RETVAL(py_ret)                                           \
+  if (!py_ret) {                                                        \
+		PyErr_Print();                                                      \
+		goto beach;                                                         \
+ 	}                                                                     \
+ 	else if (py_ret == Py_None) {                                         \
+ 		goto beach;                                                         \
+	}
+
+#define HANDLE_LIST(py_ret, type, type_name)                            \
+    {                                                                   \
+      Py_ssize_t i = 0;                                                 \
+    	if (!PySequence_Check(py_ret) || PyString_Check(py_ret)) {        \
+    		PyErr_SetString(PyExc_TypeError,                                \
+    						METHOD_NAME " must return a sequence");                 \
+    		goto beach;                                                     \
+    	}                                                                 \
+    	for (i = 0; i < PySequence_Size (py_ret); i++) {                  \
+    		PyGObject *py_item;                                             \
+    		py_item = (PyGObject*)PySequence_GetItem (py_ret, i);           \
+    		if (!pygobject_check(py_item, &Py##type##_Type)) {              \
+    			PyErr_SetString(PyExc_TypeError,                              \
+    							METHOD_NAME                                           \
+    							" must return a sequence of "                         \
+    							type_name);                                           \
+    			goto beach;                                                   \
+    		}                                                               \
+    		ret = g_list_append (ret, (type*) g_object_ref(py_item->obj));  \
+            Py_DECREF(py_item);                                         \
+    	}                                                                 \
+    }
+
+
+static void
+thunarx_python_object_menu_provider_iface_init (ThunarxMenuProviderIface *iface)
+{
+	iface->get_file_actions = thunarx_python_object_get_file_actions;
+	iface->get_folder_actions = thunarx_python_object_get_folder_actions;
+	//iface->get_dnd_actions = thunarx_python_object_get_dnd_actions;
+}
+
+
+
+#define METHOD_NAME "get_file_actions"
+static GList *
+thunarx_python_object_get_file_actions (ThunarxMenuProvider *provider,
+                                        GtkWidget *window,
+                                        GList *files)
+{
+  ThunarxPythonObject *object = (ThunarxPythonObject*)provider;
+  GList *ret = NULL;
+  PyObject *py_ret = NULL, *py_files;
+	PyGILState_STATE state = pyg_gil_state_ensure();
+	
+  debug_enter();
+
+	CHECK_METHOD_NAME(object->instance);
+
+	CONVERT_LIST(py_files, files);
+
+  py_ret = PyObject_CallMethod(object->instance, METHOD_PREFIX METHOD_NAME,
+								 "(NN)", pygobject_new((GObject *)window), py_files);
+
+	HANDLE_RETVAL(py_ret);
+
+	HANDLE_LIST(py_ret, GtkAction, "gtk.Action");
+
+beach:
+  Py_XDECREF(py_ret);
+  pyg_gil_state_release(state);
+  return ret;
+}
+#undef METHOD_NAME
+
+
+
+#define METHOD_NAME "get_folder_actions"
+static GList *
+thunarx_python_object_get_folder_actions (ThunarxMenuProvider *provider,
+ 		  									                  GtkWidget *window,
+	  										                  ThunarxFileInfo *folder)
+{
+	ThunarxPythonObject *object = (ThunarxPythonObject*)provider;
+  GList *ret = NULL;
+  PyObject *py_ret = NULL;
+	PyGILState_STATE state = pyg_gil_state_ensure();
+	
+  debug_enter();
+
+	CHECK_METHOD_NAME(object->instance);
+
+  py_ret = PyObject_CallMethod(object->instance, METHOD_PREFIX METHOD_NAME,
+								 "(NN)",
+								 pygobject_new((GObject *)window),
+								 pygobject_new((GObject *)folder));
+								 
+	HANDLE_RETVAL(py_ret);
+
+	HANDLE_LIST(py_ret, GtkAction, "gtk.Action");
+	
+beach:
+  Py_XDECREF(py_ret);
+  pyg_gil_state_release(state);
+  return ret;
+}
+#undef METHOD_NAME
+
+
+/*
+static void
+thunarx_python_object_property_page_provider_iface_init (ThunarxPropertyPageProviderIface *iface)
+{
+	iface->get_pages = thunarx_python_object_get_property_pages;
+}
+
+
+
+static void
+thunarx_python_object_file_info_iface_init (ThunarxFileInfoIface *iface)
+{
+	iface->file_changed = thunarx_python_object_file_changed;
+	iface->file_renamed = thunarx_python_object_file_renamed;
+}
+
+
+
+static void
+thunarx_python_object_renamer_provider_iface_init (ThunarxRenamerProviderIface *iface)
+{
+	iface->get_renamers = thunarx_python_object_get_renamers;
+}
+
+
+
+static void
+thunarx_python_object_preferences_provider_iface_init (ThunarxPreferencesProviderIface *iface)
+{
+	iface->get_actions = thunarx_python_object_get_actions;
+}
+*/
+
+
+static void 
+thunarx_python_object_instance_init (ThunarxPythonObject *object)
+{
+	ThunarxPythonObjectClass *class;
+  debug_enter();
+
+	class = (ThunarxPythonObjectClass*)(((GTypeInstance*)object)->g_class);
+
+	object->instance = PyObject_CallObject(class->type, NULL);
+	if (object->instance == NULL)
+		PyErr_Print();
+}
+
+static void
+thunarx_python_object_finalize (GObject *object)
+{
+  debug_enter();
+
+	Py_DECREF(((ThunarxPythonObject *)object)->instance);
+}
+
+static void
+thunarx_python_object_class_init (ThunarxPythonObjectClass *klass,
+								                  gpointer class_data)
+{
+	debug_enter();
+
+	parent_class = g_type_class_peek_parent (klass);
+	
+	klass->type = (PyObject*)class_data;
+	
+	G_OBJECT_CLASS (klass)->finalize = thunarx_python_object_finalize;
+}
+
+
+
+GType 
+thunarx_python_object_get_type (ThunarxProviderPlugin *plugin, PyObject *type)
+{
+	GTypeInfo *info;
+	const char *type_name;
+	GType gtype;
+/*
+	static const GInterfaceInfo file_info_iface_info = {
+		(GInterfaceInitFunc) thunarx_python_object_file_info_iface_init,
+		NULL,
+		NULL
+	};
+	  
+	static const GInterfaceInfo property_page_provider_iface_info = {
+		(GInterfaceInitFunc) thunarx_python_object_property_page_provider_iface_init,
+		NULL,
+		NULL
+	};
+*/
+	static const GInterfaceInfo menu_provider_iface_info = {
+		(GInterfaceInitFunc) thunarx_python_object_menu_provider_iface_init,
+		NULL,
+		NULL
+	};
+/*
+	static const GInterfaceInfo renamer_provider_iface_info = {
+		(GInterfaceInitFunc) thunarx_python_object_renamer_provider_iface_init,
+		NULL,
+		NULL
+	};
+
+	static const GInterfaceInfo preferences_provider_iface_info = {
+		(GInterfaceInitFunc) thunarx_python_object_preferences_provider_iface_init,
+		NULL,
+		NULL
+	};
+*/
+	debug_enter_args("type=%s", PyString_AsString(PyObject_GetAttrString(type, "__name__")));
+	info = g_new0 (GTypeInfo, 1);
+	
+	info->class_size = sizeof (ThunarxPythonObjectClass);
+	info->class_init = (GClassInitFunc)thunarx_python_object_class_init;
+	info->instance_size = sizeof (ThunarxPythonObject);
+	info->instance_init = (GInstanceInitFunc)thunarx_python_object_instance_init;
+
+	info->class_data = type;
+	Py_INCREF(type);
+
+	type_name = g_strdup_printf("%s+ThunarxPython",
+								PyString_AsString(PyObject_GetAttrString(type, "__name__")));
+
+	gtype = thunarx_provider_plugin_register_type (plugin, 
+										 G_TYPE_OBJECT,
+										 type_name,
+										 info, 0);
+/*
+	if (PyObject_IsSubclass(type, (PyObject*)&PyThunarxFileInfo_Type)) {
+		thunarx_provider_plugin_add_interface (plugin, gtype, 
+									 THUNARX_TYPE_FILE_INFO,
+									 &file_info_iface_info);
+	}
+
+	if (PyObject_IsSubclass(type, (PyObject*)&PyThunarxPropertyPageProvider_Type)) {
+		thunarx_provider_plugin_add_interface (plugin, gtype, 
+									 THUNARX_TYPE_PROPERTY_PAGE_PROVIDER,
+									 &property_page_provider_iface_info);
+	}
+*/
+	if (PyObject_IsSubclass(type, (PyObject*)&PyThunarxMenuProvider_Type)) {
+		thunarx_provider_plugin_add_interface (plugin, gtype, 
+									 THUNARX_TYPE_MENU_PROVIDER,
+									 &menu_provider_iface_info);
+	}
+/*
+	if (PyObject_IsSubclass(type, (PyObject*)&PyThunarxRenamerProvider_Type)) {
+		thunarx_provider_plugin_add_interface (plugin, gtype, 
+									 THUNARX_TYPE_RENAMER_PROVIDER,
+									 &renamer_provider_iface_info);
+	}
+	
+	if (PyObject_IsSubclass(type, (PyObject*)&PyThunarxPreferencesProvider_Type)) {
+		thunarx_provider_plugin_add_interface (plugin, gtype, 
+									 THUNARX_TYPE_PREFERENCES_PROVIDER,
+									 &preferences_provider_iface_info);
+	}
+*/	
+	return gtype;
+}
diff --git a/src/thunarx-python-object.h b/src/thunarx-python-object.h
new file mode 100644
index 0000000..77de42c
--- /dev/null
+++ b/src/thunarx-python-object.h
@@ -0,0 +1,68 @@
+/*-
+ * Copyright (c) 2006 Peter de Ridder <peter at xfce.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library 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 Library 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.
+ */
+
+#ifndef THUNARX_PYTHON_OBJECT_H
+#define THUNARX_PYTHON_OBJECT_H
+
+#include <Python.h>
+#include <glib-object.h>
+
+#include <thunarx/thunarx.h>
+
+G_BEGIN_DECLS
+
+typedef struct _ThunarxPythonObject       ThunarxPythonObject;
+typedef struct _ThunarxPythonObjectClass  ThunarxPythonObjectClass;
+
+struct _ThunarxPythonObject {
+  GObject parent_slot;
+  PyObject *instance;
+};
+
+struct _ThunarxPythonObjectClass {
+  GObjectClass parent_slot;
+  PyObject *type;
+};
+
+static void
+thunarx_python_object_menu_provider_iface_init (ThunarxMenuProviderIface *iface);
+static GList *
+thunarx_python_object_get_file_actions (ThunarxMenuProvider *provider,
+                                        GtkWidget *window,
+                                        GList *files);
+static GList *
+thunarx_python_object_get_folder_actions (ThunarxMenuProvider *provider,
+ 		  									                  GtkWidget *window,
+	  										                  ThunarxFileInfo *folder);
+
+
+static void 
+thunarx_python_object_instance_init (ThunarxPythonObject *object);
+static void
+thunarx_python_object_finalize (GObject *object);
+static void
+thunarx_python_object_class_init (ThunarxPythonObjectClass *klass,
+								                  gpointer class_data);
+
+GType 
+thunarx_python_object_get_type (ThunarxProviderPlugin *plugin, PyObject *type);
+
+G_END_DECLS
+
+#endif
diff --git a/src/thunarx-python.c b/src/thunarx-python.c
index fed5c3e..8e22ef8 100644
--- a/src/thunarx-python.c
+++ b/src/thunarx-python.c
@@ -22,35 +22,88 @@
 #endif
 
 #include <Python.h>
+#include <pygobject.h>
+#include <pygtk/pygtk.h>
 
-#include <exo/exo.h>
+#include "thunarx-python.h"
+#include "thunarx-python-object.h"
 
-#include <txp-provider.h>
+static GArray *all_types = NULL;
 
-#define DEBUG_ENABLED 1
-#define debug(x) { if (DEBUG_ENABLED) g_print("thunarx-python: " x "\n"); }
-
-static GType type_list[1];
-
-/* delcare it here to make the compiler happy */
 G_MODULE_EXPORT void thunar_extension_initialize (ThunarxProviderPlugin *plugin);
+G_MODULE_EXPORT void thunar_extension_shutdown (void);
+G_MODULE_EXPORT void thunar_extension_list_types (const GType **types, gint *n_types);
 
+static gboolean thunarx_python_init_pygobject (void);
+static gboolean thunarx_python_init_pygtk (void);
 static gboolean thunarx_python_init_python (void);
 
 
+
+static inline gboolean thunarx_python_init_pygobject(void)
+{
+    PyObject *gobject = PyImport_ImportModule("gobject");
+    if (gobject != NULL) {
+        PyObject *mdict = PyModule_GetDict(gobject);
+        PyObject *cobject = PyDict_GetItemString(mdict, "_PyGObject_API");
+        if (PyCObject_Check(cobject))
+            _PyGObject_API = (struct _PyGObject_Functions *)PyCObject_AsVoidPtr(cobject);
+        else {
+            PyErr_SetString(PyExc_RuntimeError,
+                            "could not find _PyGObject_API object");
+			PyErr_Print();
+			return FALSE;
+        }
+    } else {
+        PyErr_Print();
+        g_warning("could not import gobject");
+        return FALSE;
+    }
+	return TRUE;
+}
+
+
+
+static inline gboolean thunarx_python_init_pygtk(void)
+{
+    PyObject *pygtk = PyImport_ImportModule("gtk._gtk");
+    if (pygtk != NULL) {
+		PyObject *module_dict = PyModule_GetDict(pygtk);
+		PyObject *cobject = PyDict_GetItemString(module_dict, "_PyGtk_API");
+		if (PyCObject_Check(cobject))
+			_PyGtk_API = (struct _PyGtk_FunctionStruct*)
+				PyCObject_AsVoidPtr(cobject);
+		else {
+            PyErr_SetString(PyExc_RuntimeError,
+                            "could not find _PyGtk_API object");
+			PyErr_Print();
+			return FALSE;
+        }
+    } else {
+        PyErr_Print();
+        g_warning("could not import gtk._gtk");
+        return FALSE;
+    }
+	return TRUE;
+}
+
+
+
 static gboolean 
 thunarx_python_init_python (void)
 {
+	PyObject *pygtk, *mdict, *require;
+	PyObject *sys_path, *tmp, *thunarx, *gtk, *pygtk_version, *pygtk_required_version;
   GModule *libpython;
   char *argv[] = { "thunarx", NULL };
   
-  debug("thunarx_python_init_python");
+  debug_enter();
 
   if (Py_IsInitialized())
     return TRUE;
 
-  debug ("g_module_open libpython");  
-  libpython = g_module_open ("/usr/lib/libpython2.6.so", 0);
+  debug ("g_module_open libpython " G_MODULE_SUFFIX);  
+  libpython = g_module_open ("/usr/lib/libpython2.6." G_MODULE_SUFFIX, 0);
   if (!libpython)
     g_warning ("g_module_open libpython failed: %s", g_module_error());
   
@@ -69,6 +122,94 @@ thunarx_python_init_python (void)
     PyErr_Print();
     return FALSE;
   }
+
+	/* pygtk.require("2.0") */
+	debug("pygtk.require(\"2.0\")");
+	pygtk = PyImport_ImportModule("pygtk");
+	if (!pygtk) {
+		PyErr_Print();
+		return FALSE;
+	}
+	mdict = PyModule_GetDict(pygtk);
+	require = PyDict_GetItemString(mdict, "require");
+	PyObject_CallObject(require, Py_BuildValue("(S)", PyString_FromString("2.0")));
+	if (PyErr_Occurred()) {
+		PyErr_Print();
+		return FALSE;
+	}
+
+	/* import gobject */
+  debug("init_pygobject");
+	if (!thunarx_python_init_pygobject()) {
+		g_warning("pygobject initialization failed");
+		return FALSE;
+	}
+	/* import gtk */
+	debug("init_pygtk");
+	if (!thunarx_python_init_pygtk()) {
+		g_warning("pygtk initialization failed");
+		return FALSE;
+	}
+
+	/* gobject.threads_init() */
+  debug("pyg_enable_threads");
+	setenv("PYGTK_USE_GIL_STATE_API", "", 0);
+	pyg_enable_threads();
+
+	/* gtk.pygtk_version < (2, 4, 0) */
+	gtk = PyImport_ImportModule("gtk");
+	mdict = PyModule_GetDict(gtk);
+	pygtk_version = PyDict_GetItemString(mdict, "pygtk_version");
+	pygtk_required_version = Py_BuildValue("(iii)", 2, 4, 0);
+	if (PyObject_Compare(pygtk_version, pygtk_required_version) == -1) {
+		g_warning("PyGTK %s required, but %s found.",
+				  PyString_AsString(PyObject_Repr(pygtk_required_version)),
+				  PyString_AsString(PyObject_Repr(pygtk_version)));
+		Py_DECREF(pygtk_required_version);
+		return FALSE;
+	}
+	Py_DECREF(pygtk_required_version);
+  
+  debug("sys.path.insert(0, ...)");
+  sys_path = PySys_GetObject("path");
+  PyList_Insert(sys_path, 0, (tmp = PyString_FromString(THUNARX_LIBDIR "/thunarx-python")));
+  Py_DECREF(tmp);
+  
+  g_setenv("INSIDE_THUNARX_PYTHON", "", FALSE);
+  debug("import thunarx");
+  thunarx = PyImport_ImportModule("thunarx");
+  if (!thunarx)
+  {
+    PyErr_Print();
+    return FALSE;
+  }
+
+	/* Extract types and interfaces from nautilus */
+	mdict = PyModule_GetDict(thunarx);
+	
+	_PyGtkWidget_Type = pygobject_lookup_class(GTK_TYPE_WIDGET);
+	g_assert(_PyGtkWidget_Type != NULL);
+
+	_PyGtkAction_Type = pygobject_lookup_class(GTK_TYPE_ACTION);
+	g_assert(_PyGtkAction_Type != NULL);
+
+#define IMPORT(x, y) \
+    _PyThunarx##x##_Type = (PyTypeObject *)PyDict_GetItemString(mdict, y); \
+	if (_PyThunarx##x##_Type == NULL) { \
+		PyErr_Print(); \
+		return FALSE; \
+	}
+
+	IMPORT(FileInfo, "FileInfo");
+	IMPORT(MenuProvider, "MenuProvider");
+	IMPORT(PreferencesProvider, "PreferencesProvider");
+	IMPORT(PropertyPage, "PropertyPage");
+	IMPORT(PropertyPageProvider, "PropertyPageProvider");
+	IMPORT(ProviderPlugin, "ProviderPlugin");
+	IMPORT(Renamer, "Renamer");
+	IMPORT(RenamerProvider, "RenamerProvider");
+	
+#undef IMPORT
   
   return TRUE;
 }
@@ -76,19 +217,96 @@ thunarx_python_init_python (void)
 
 
 static void
-thunarx_python_load_dir (const gchar *dirname)
+thunarx_python_load_file (ThunarxProviderPlugin *plugin, const gchar *filename)
 {
-  if (thunarx_python_init_python())
+  PyObject *main_module, *main_locals, *locals, *key, *value;
+  PyObject *module;
+  Py_ssize_t pos = 0;
+  GType new_type;
+  
+  main_module = PyImport_AddModule("__main__");
+  if (main_module == NULL)
+  {
+    g_warning ("Could not get __main__");
+    return;
+  }
+  
+  main_locals = PyModule_GetDict(main_module);
+  g_print("Attempting to load module %s\n", filename);
+  module = PyImport_ImportModuleEx((char *) filename, main_locals, main_locals, NULL);
+  if (!module)
   {
-    debug ("python loaded");
+    PyErr_Print();
+    return;
   }
-  else
+  
+  locals = PyModule_GetDict(module);
+  
+  while (PyDict_Next(locals, &pos, &key, &value))
   {
-    debug ("python not loaded");
+    if (!PyType_Check(value))
+      continue;
+      
+		if (PyObject_IsSubclass(value, (PyObject*)&PyThunarxMenuProvider_Type) ||
+			PyObject_IsSubclass(value, (PyObject*)&PyThunarxPropertyPageProvider_Type)) {
+			
+			new_type = thunarx_python_object_get_type(plugin, value);
+			g_array_append_val(all_types, new_type);
+		}
   }
+  
+  debug ("python modules loaded");
 }
 
 
+
+static void
+thunarx_python_load_dir (ThunarxProviderPlugin *plugin, const char *dirname)
+{
+	GDir *dir;
+	const char *name;
+	gboolean initialized = FALSE;
+
+	debug_enter_args("dirname=%s", dirname);
+	
+	dir = g_dir_open(dirname, 0, NULL);
+	if (!dir)
+		return;
+			
+	while ((name = g_dir_read_name(dir)))
+	{
+		if (g_str_has_suffix(name, ".py"))
+		{
+			char *modulename;
+			int len;
+
+			len = strlen(name) - 3;
+			modulename = g_new0(char, len + 1);
+			strncpy(modulename, name, len);
+
+			if (!initialized)
+			{
+				PyObject *sys_path, *py_path;
+				  /* n-p python part is initialized on demand (or not
+				   * at all if no extensions are found) */
+				if (!thunarx_python_init_python())
+				{
+					g_warning("thunarx_python_init_python failed");
+					g_dir_close(dir);
+				}
+				  /* sys.path.insert(0, dirname) */
+				sys_path = PySys_GetObject("path");
+				py_path = PyString_FromString(dirname);
+				PyList_Insert(sys_path, 0, py_path);
+				Py_DECREF(py_path);
+			}
+			thunarx_python_load_file(plugin, modulename);
+		}
+	}
+}
+
+
+
 G_MODULE_EXPORT void
 thunar_extension_initialize (ThunarxProviderPlugin *plugin)
 {
@@ -104,20 +322,13 @@ thunar_extension_initialize (ThunarxProviderPlugin *plugin)
 
   debug ("Initializing thunarx-python extension");
 
-  /* register the types provided by this plugin */
-  txp_provider_register_type (plugin);
-
-  /* setup the plugin provider type list */
-  type_list[0] = TXP_TYPE_PROVIDER;
+  all_types = g_array_new(FALSE, FALSE, sizeof(GType));
   
-  thunarx_python_load_dir("/home/adam/Development/xfce/thunarx-python-modules");
+  thunarx_python_load_dir(plugin, THUNARX_EXTENSION_DIR "/python");
 }
 
 
 
-/* delcare it here to make the compiler happy */
-G_MODULE_EXPORT void thunar_extension_shutdown (void);
-
 G_MODULE_EXPORT void
 thunar_extension_shutdown (void)
 {
@@ -125,18 +336,19 @@ thunar_extension_shutdown (void)
   
   if (Py_IsInitialized())
     Py_Finalize();
+ 
+  g_array_free (all_types, TRUE);
 }
 
 
 
-/* declare it here to make the compiler happy */
-G_MODULE_EXPORT void thunar_extension_list_types (const GType **types, gint *n_types);
-
 G_MODULE_EXPORT void
 thunar_extension_list_types (const GType **types,
                              gint         *n_types)
 {
-  *types = type_list;
-  *n_types = G_N_ELEMENTS (type_list);
+  debug_enter();
+
+  *types = (GType*)all_types->data;
+  *n_types = all_types->len;
 }
 
diff --git a/src/thunarx-python.h b/src/thunarx-python.h
new file mode 100644
index 0000000..30a07a8
--- /dev/null
+++ b/src/thunarx-python.h
@@ -0,0 +1,70 @@
+/*-
+ * Copyright (c) 2009 Adam Plumb <adamplumb at gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library 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 Library 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.
+ */
+ 
+#ifndef THUNARX_PYTHON_H
+#define THUNARX_PYTHON_H
+
+#include <glib-object.h>
+#include <glib/gprintf.h>
+#include <Python.h>
+
+#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN)
+typedef int Py_ssize_t;
+#define PY_SSIZE_T_MAX INT_MAX
+#define PY_SSIZE_T_MIN INT_MIN
+#endif
+
+#define DEBUG_ENABLED 1
+#define debug(x) { if (DEBUG_ENABLED) g_print("thunarx-python: " x "\n"); }
+#define debug_enter()  { if (DEBUG_ENABLED) \
+                             g_printf("%s: entered\n", __FUNCTION__); }
+#define debug_enter_args(x, y) { if (DEBUG_ENABLED) \
+                                     g_printf("%s: entered " x "\n", __FUNCTION__, y); }
+
+PyTypeObject *_PyGtkWidget_Type;
+#define PyGtkWidget_Type (*_PyGtkWidget_Type)
+
+PyTypeObject *_PyGtkAction_Type;
+#define PyGtkAction_Type (*_PyGtkAction_Type)
+
+PyTypeObject *_PyThunarxFileInfo_Type;
+#define PyThunarxFileInfo_Type (*_PyThunarxFileInfo_Type)
+
+PyTypeObject *_PyThunarxMenuProvider_Type;
+#define PyThunarxMenuProvider_Type (*_PyThunarxMenuProvider_Type)
+
+PyTypeObject *_PyThunarxPreferencesProvider_Type;
+#define PyThunarxPreferencesProvider_Type (*_PyThunarxPreferencesProvider_Type)
+
+PyTypeObject *_PyThunarxPropertyPage_Type;
+#define PyThunarxPropertyPage_Type (*_PyThunarxPropertyPage_Type)
+
+PyTypeObject *_PyThunarxPropertyPageProvider_Type;
+#define PyThunarxPropertyPageProvider_Type (*_PyThunarxPropertyPageProvider_Type)
+
+PyTypeObject *_PyThunarxProviderPlugin_Type;
+#define PyThunarxProviderPlugin_Type (*_PyThunarxProviderPlugin_Type)
+
+PyTypeObject *_PyThunarxRenamer_Type;
+#define PyThunarxRenamer_Type (*_PyThunarxRenamer_Type)
+
+PyTypeObject *_PyThunarxRenamerProvider_Type;
+#define PyThunarxRenamerProvider_Type (*_PyThunarxRenamerProvider_Type)
+
+#endif /* THUNARX_PYTHON_H */
diff --git a/src/thunarx.defs b/src/thunarx.defs
new file mode 100644
index 0000000..a7a70b6
--- /dev/null
+++ b/src/thunarx.defs
@@ -0,0 +1,522 @@
+;; -*- scheme -*-
+; object definitions ...
+(define-object FileInfo
+  (in-module "Thunarx")
+  (c-name "ThunarxFileInfo")
+  (gtype-id "THUNARX_TYPE_FILE_INFO")
+)
+
+(define-object MenuProvider
+  (in-module "Thunarx")
+  (c-name "ThunarxMenuProvider")
+  (gtype-id "THUNARX_TYPE_MENU_PROVIDER")
+)
+
+(define-object PreferencesProvider
+  (in-module "Thunarx")
+  (c-name "ThunarxPreferencesProvider")
+  (gtype-id "THUNARX_TYPE_PREFERENCES_PROVIDER")
+)
+
+(define-object PropertyPage
+  (in-module "Thunarx")
+  (parent "GtkBin")
+  (c-name "ThunarxPropertyPage")
+  (gtype-id "THUNARX_TYPE_PROPERTY_PAGE")
+)
+
+(define-object PropertyPageProvider
+  (in-module "Thunarx")
+  (c-name "ThunarxPropertyPageProvider")
+  (gtype-id "THUNARX_TYPE_PROPERTY_PAGE_PROVIDER")
+)
+
+(define-object ProviderPlugin
+  (in-module "Thunarx")
+  (c-name "ThunarxProviderPlugin")
+  (gtype-id "THUNARX_TYPE_PROVIDER_PLUGIN")
+)
+
+(define-object Renamer
+  (in-module "Thunarx")
+  (parent "GtkVBox")
+  (c-name "ThunarxRenamer")
+  (gtype-id "THUNARX_TYPE_RENAMER")
+)
+
+(define-object RenamerProvider
+  (in-module "Thunarx")
+  (c-name "ThunarxRenamerProvider")
+  (gtype-id "THUNARX_TYPE_RENAMER_PROVIDER")
+)
+
+;; Enumerations and flags ...
+
+
+;; From thunarx-config.h
+
+(define-function thunarx_check_version
+  (c-name "thunarx_check_version")
+  (return-type "const-gchar*")
+  (parameters
+    '("guint" "required_major")
+    '("guint" "required_minor")
+    '("guint" "required_micro")
+  )
+)
+
+
+
+;; From thunarx-file-info.h
+
+(define-function thunarx_file_info_get_type
+  (c-name "thunarx_file_info_get_type")
+  (return-type "GType")
+)
+
+(define-method get_name
+  (of-object "ThunarxFileInfo")
+  (c-name "thunarx_file_info_get_name")
+  (return-type "gchar*")
+)
+
+(define-method get_uri
+  (of-object "ThunarxFileInfo")
+  (c-name "thunarx_file_info_get_uri")
+  (return-type "gchar*")
+)
+
+(define-method get_parent_uri
+  (of-object "ThunarxFileInfo")
+  (c-name "thunarx_file_info_get_parent_uri")
+  (return-type "gchar*")
+)
+
+(define-method get_uri_scheme
+  (of-object "ThunarxFileInfo")
+  (c-name "thunarx_file_info_get_uri_scheme")
+  (return-type "gchar*")
+)
+
+(define-method get_mime_type
+  (of-object "ThunarxFileInfo")
+  (c-name "thunarx_file_info_get_mime_type")
+  (return-type "gchar*")
+)
+
+(define-method has_mime_type
+  (of-object "ThunarxFileInfo")
+  (c-name "thunarx_file_info_has_mime_type")
+  (return-type "gboolean")
+  (parameters
+    '("const-gchar*" "mime_type")
+  )
+)
+
+(define-method is_directory
+  (of-object "ThunarxFileInfo")
+  (c-name "thunarx_file_info_is_directory")
+  (return-type "gboolean")
+)
+
+(define-method get_file_info
+  (of-object "ThunarxFileInfo")
+  (c-name "thunarx_file_info_get_file_info")
+  (return-type "GFileInfo*")
+)
+
+(define-method get_filesystem_info
+  (of-object "ThunarxFileInfo")
+  (c-name "thunarx_file_info_get_filesystem_info")
+  (return-type "GFileInfo*")
+)
+
+(define-method get_location
+  (of-object "ThunarxFileInfo")
+  (c-name "thunarx_file_info_get_location")
+  (return-type "GFile*")
+)
+
+(define-method add_emblem
+  (of-object "ThunarxFileInfo")
+  (c-name "thunarx_file_info_add_emblem")
+  (return-type "none")
+  (parameters
+    '("const-gchar*" "emblem_name")
+  )
+)
+
+(define-method remove_emblem
+  (of-object "ThunarxFileInfo")
+  (c-name "thunarx_file_info_remove_emblem")
+  (return-type "none")
+  (parameters
+    '("const-gchar*" "emblem_name")
+  )
+)
+
+(define-method remove_emblems
+  (of-object "ThunarxFileInfo")
+  (c-name "thunarx_file_info_remove_emblems")
+  (return-type "none")
+)
+
+(define-method changed
+  (of-object "ThunarxFileInfo")
+  (c-name "thunarx_file_info_changed")
+  (return-type "none")
+)
+
+(define-method renamed
+  (of-object "ThunarxFileInfo")
+  (c-name "thunarx_file_info_renamed")
+  (return-type "none")
+)
+
+(define-function thunarx_file_info_list_get_type
+  (c-name "thunarx_file_info_list_get_type")
+  (return-type "GType")
+)
+
+(define-function thunarx_file_info_list_copy
+  (c-name "thunarx_file_info_list_copy")
+  (return-type "GList*")
+  (parameters
+    '("GList*" "file_infos")
+  )
+)
+
+(define-function thunarx_file_info_list_free
+  (c-name "thunarx_file_info_list_free")
+  (return-type "none")
+  (parameters
+    '("GList*" "file_infos")
+  )
+)
+
+
+
+;; From thunarx-menu-provider.h
+
+(define-function thunarx_menu_provider_get_type
+  (c-name "thunarx_menu_provider_get_type")
+  (return-type "GType")
+)
+
+(define-method get_file_actions
+  (of-object "ThunarxMenuProvider")
+  (c-name "thunarx_menu_provider_get_file_actions")
+  (return-type "GList*")
+  (parameters
+    '("GtkWidget*" "window")
+    '("GList*" "files")
+  )
+)
+
+(define-method get_folder_actions
+  (of-object "ThunarxMenuProvider")
+  (c-name "thunarx_menu_provider_get_folder_actions")
+  (return-type "GList*")
+  (parameters
+    '("GtkWidget*" "window")
+    '("ThunarxFileInfo*" "folder")
+  )
+)
+
+(define-method get_dnd_actions
+  (of-object "ThunarxMenuProvider")
+  (c-name "thunarx_menu_provider_get_dnd_actions")
+  (return-type "GList*")
+  (parameters
+    '("GtkWidget*" "window")
+    '("ThunarxFileInfo*" "folder")
+    '("GList*" "files")
+  )
+)
+
+
+
+;; From thunarx-preferences-provider.h
+
+(define-function thunarx_preferences_provider_get_type
+  (c-name "thunarx_preferences_provider_get_type")
+  (return-type "GType")
+)
+
+(define-method get_actions
+  (of-object "ThunarxPreferencesProvider")
+  (c-name "thunarx_preferences_provider_get_actions")
+  (return-type "GList*")
+  (parameters
+    '("GtkWidget*" "window")
+  )
+)
+
+
+
+;; From thunarx-property-page-provider.h
+
+(define-function thunarx_property_page_provider_get_type
+  (c-name "thunarx_property_page_provider_get_type")
+  (return-type "GType")
+)
+
+(define-method get_pages
+  (of-object "ThunarxPropertyPageProvider")
+  (c-name "thunarx_property_page_provider_get_pages")
+  (return-type "GList*")
+  (parameters
+    '("GList*" "files")
+  )
+)
+
+
+
+;; From thunarx-property-page.h
+
+(define-function thunarx_property_page_get_type
+  (c-name "thunarx_property_page_get_type")
+  (return-type "GType")
+)
+
+(define-function thunarx_property_page_new
+  (c-name "thunarx_property_page_new")
+  (is-constructor-of "ThunarxPropertyPage")
+  (return-type "GtkWidget*")
+  (parameters
+    '("const-gchar*" "label")
+  )
+)
+
+(define-function thunarx_property_page_new_with_label_widget
+  (c-name "thunarx_property_page_new_with_label_widget")
+  (return-type "GtkWidget*")
+  (parameters
+    '("GtkWidget*" "label_widget")
+  )
+)
+
+(define-method get_label
+  (of-object "ThunarxPropertyPage")
+  (c-name "thunarx_property_page_get_label")
+  (return-type "const-gchar*")
+)
+
+(define-method set_label
+  (of-object "ThunarxPropertyPage")
+  (c-name "thunarx_property_page_set_label")
+  (return-type "none")
+  (parameters
+    '("const-gchar*" "label")
+  )
+)
+
+(define-method get_label_widget
+  (of-object "ThunarxPropertyPage")
+  (c-name "thunarx_property_page_get_label_widget")
+  (return-type "GtkWidget*")
+)
+
+(define-method set_label_widget
+  (of-object "ThunarxPropertyPage")
+  (c-name "thunarx_property_page_set_label_widget")
+  (return-type "none")
+  (parameters
+    '("GtkWidget*" "label_widget")
+  )
+)
+
+
+
+;; From thunarx-provider-factory.h
+
+(define-function thunarx_provider_factory_get_type
+  (c-name "thunarx_provider_factory_get_type")
+  (return-type "GType")
+)
+
+(define-function thunarx_provider_factory_get_default
+  (c-name "thunarx_provider_factory_get_default")
+  (return-type "ThunarxProviderFactory*")
+)
+
+(define-method list_providers
+  (of-object "ThunarxProviderFactory")
+  (c-name "thunarx_provider_factory_list_providers")
+  (return-type "GList*")
+  (parameters
+    '("GType" "type")
+  )
+)
+
+
+
+;; From thunarx-provider-plugin.h
+
+(define-function thunarx_provider_plugin_get_type
+  (c-name "thunarx_provider_plugin_get_type")
+  (return-type "GType")
+)
+
+(define-method get_resident
+  (of-object "ThunarxProviderPlugin")
+  (c-name "thunarx_provider_plugin_get_resident")
+  (return-type "gboolean")
+)
+
+(define-method set_resident
+  (of-object "ThunarxProviderPlugin")
+  (c-name "thunarx_provider_plugin_set_resident")
+  (return-type "none")
+  (parameters
+    '("gboolean" "resident")
+  )
+)
+
+(define-method register_type
+  (of-object "ThunarxProviderPlugin")
+  (c-name "thunarx_provider_plugin_register_type")
+  (return-type "GType")
+  (parameters
+    '("GType" "type_parent")
+    '("const-gchar*" "type_name")
+    '("const-GTypeInfo*" "type_info")
+    '("GTypeFlags" "type_flags")
+  )
+)
+
+(define-method add_interface
+  (of-object "ThunarxProviderPlugin")
+  (c-name "thunarx_provider_plugin_add_interface")
+  (return-type "none")
+  (parameters
+    '("GType" "instance_type")
+    '("GType" "interface_type")
+    '("const-GInterfaceInfo*" "interface_info")
+  )
+)
+
+(define-method register_enum
+  (of-object "ThunarxProviderPlugin")
+  (c-name "thunarx_provider_plugin_register_enum")
+  (return-type "GType")
+  (parameters
+    '("const-gchar*" "name")
+    '("const-GEnumValue*" "const_static_values")
+  )
+)
+
+(define-method register_flags
+  (of-object "ThunarxProviderPlugin")
+  (c-name "thunarx_provider_plugin_register_flags")
+  (return-type "GType")
+  (parameters
+    '("const-gchar*" "name")
+    '("const-GFlagsValue*" "const_static_values")
+  )
+)
+
+
+
+;; From thunarx-renamer-provider.h
+
+(define-function thunarx_renamer_provider_get_type
+  (c-name "thunarx_renamer_provider_get_type")
+  (return-type "GType")
+)
+
+(define-method get_renamers
+  (of-object "ThunarxRenamerProvider")
+  (c-name "thunarx_renamer_provider_get_renamers")
+  (return-type "GList*")
+)
+
+
+
+;; From thunarx-renamer.h
+
+(define-function thunarx_renamer_get_type
+  (c-name "thunarx_renamer_get_type")
+  (return-type "GType")
+)
+
+(define-method get_help_url
+  (of-object "ThunarxRenamer")
+  (c-name "thunarx_renamer_get_help_url")
+  (return-type "const-gchar*")
+)
+
+(define-method set_help_url
+  (of-object "ThunarxRenamer")
+  (c-name "thunarx_renamer_set_help_url")
+  (return-type "none")
+  (parameters
+    '("const-gchar*" "help_url")
+  )
+)
+
+(define-method get_name
+  (of-object "ThunarxRenamer")
+  (c-name "thunarx_renamer_get_name")
+  (return-type "const-gchar*")
+)
+
+(define-method set_name
+  (of-object "ThunarxRenamer")
+  (c-name "thunarx_renamer_set_name")
+  (return-type "none")
+  (parameters
+    '("const-gchar*" "name")
+  )
+)
+
+(define-method process
+  (of-object "ThunarxRenamer")
+  (c-name "thunarx_renamer_process")
+  (return-type "gchar*")
+  (parameters
+    '("ThunarxFileInfo*" "file")
+    '("const-gchar*" "text")
+    '("guint" "index")
+  )
+)
+
+(define-method load
+  (of-object "ThunarxRenamer")
+  (c-name "thunarx_renamer_load")
+  (return-type "none")
+  (parameters
+    '("GHashTable*" "settings")
+  )
+)
+
+(define-method save
+  (of-object "ThunarxRenamer")
+  (c-name "thunarx_renamer_save")
+  (return-type "none")
+  (parameters
+    '("GHashTable*" "settings")
+  )
+)
+
+(define-method get_actions
+  (of-object "ThunarxRenamer")
+  (c-name "thunarx_renamer_get_actions")
+  (return-type "GList*")
+  (parameters
+    '("GtkWindow*" "window")
+    '("GList*" "files")
+  )
+)
+
+(define-method changed
+  (of-object "ThunarxRenamer")
+  (c-name "thunarx_renamer_changed")
+  (return-type "none")
+)
+
+
+
+;; From thunarx.h
+
+
diff --git a/src/thunarx.override b/src/thunarx.override
new file mode 100644
index 0000000..8497bea
--- /dev/null
+++ b/src/thunarx.override
@@ -0,0 +1,39 @@
+/*-
+ * Copyright (c) 2009 Adam Plumb <adamplumb at gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library 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 Library 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.
+ */
+
+%%
+headers
+#define NO_IMOPRT_PYGOBJECT
+#include "pygobject.h"
+
+#include <thunarx/thunarx.h>
+
+%%
+modulename thunarx
+%%
+import gobject.GObject as PyGObject_Type
+import gtk.Bin as PyGtkBin_Type
+import gtk.VBox as PyGtkVBox_Type
+import gtk.Widget as PyGtkWidget_Type
+import gtk.Window as PyGtkWindow_Type
+import gtk.Action as PyGtkAction_Type
+%%
+ignore-glob
+  *_get_type
+%%
diff --git a/src/thunarxmodule.c b/src/thunarxmodule.c
new file mode 100644
index 0000000..e89ed94
--- /dev/null
+++ b/src/thunarxmodule.c
@@ -0,0 +1,60 @@
+/*-
+ * Copyright (c) 2009 Adam Plumb <adamplumb at gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library 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 Library 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+/* include this first, before NO_IMPORT_PYGOBJECT is defined */
+#include <pygobject.h>
+#include <pygtk/pygtk.h>
+
+void pythunarx_register_classes(PyObject *d);
+
+extern PyMethodDef pythunarx_functions[];
+
+DL_EXPORT(void)
+initthunarx(void)
+{
+    PyObject *m, *d;
+    
+    if (!g_getenv("INSIDE_THUNARX_PYTHON"))
+    {
+	    Py_FatalError("This module can only be used from thunarx");
+	    return;
+    }
+	
+    if (!pygobject_init(-1, -1, -1))
+    {
+      PyErr_Print();
+      Py_FatalError("Can't initialize module gobject");
+    }
+    init_pygtk ();
+
+    m = Py_InitModule ("thunarx", pythunarx_functions);
+    d = PyModule_GetDict (m);
+
+    pythunarx_register_classes(d);  
+    
+    if (PyErr_Occurred())
+    {
+      PyErr_Print();
+      Py_FatalError("Can't initialize module thunarx");
+    }
+}
diff --git a/src/txp-provider.c b/src/txp-provider.c
deleted file mode 100644
index e61dc11..0000000
--- a/src/txp-provider.c
+++ /dev/null
@@ -1,122 +0,0 @@
-/*-
- * Copyright (c) 2006 Peter de Ridder <peter at xfce.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library 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 Library 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.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
-#ifdef HAVE_STRING_H
-#include <string.h>
-#endif
-
-#include <libxfce4util/libxfce4util.h>
-
-#include <txp-provider.h>
-
-
-static void   txp_provider_menu_provider_init   (ThunarxMenuProviderIface *iface);
-static void   txp_provider_finalize             (GObject                  *object);
-static GList *txp_provider_get_file_actions     (ThunarxMenuProvider      *menu_provider,
-                                                 GtkWidget                *window,
-                                                 GList                    *files);
-static GList *txp_provider_get_folder_actions   (ThunarxMenuProvider      *menu_provider,
-                                                 GtkWidget                *window,
-                                                 ThunarxFileInfo          *folder);
-
-
-
-struct _TxpProviderClass
-{
-  GObjectClass __parent__;
-};
-
-struct _TxpProvider
-{
-  GObject __parent__;
-
-  gchar          *child_watch_path;
-  gint            child_watch_id;
-};
-
-
-
-THUNARX_DEFINE_TYPE_WITH_CODE (TxpProvider,
-                               txp_provider,
-                               G_TYPE_OBJECT,
-                               THUNARX_IMPLEMENT_INTERFACE (THUNARX_TYPE_MENU_PROVIDER,
-                                                            txp_provider_menu_provider_init));
-
-
-static void
-txp_provider_class_init (TxpProviderClass *klass)
-{
-  GObjectClass *gobject_class;
-
-  gobject_class = G_OBJECT_CLASS (klass);
-  gobject_class->finalize = txp_provider_finalize;
-}
-
-
-
-static void
-txp_provider_menu_provider_init (ThunarxMenuProviderIface *iface)
-{
-  iface->get_file_actions = txp_provider_get_file_actions;
-  iface->get_folder_actions = txp_provider_get_folder_actions;
-}
-
-
-static void
-txp_provider_init (TxpProvider *txp_provider)
-{
-}
-
-
-
-static void
-txp_provider_finalize (GObject *object)
-{
-  (*G_OBJECT_CLASS (txp_provider_parent_class)->finalize) (object);
-}
-
-
-
-static GList*
-txp_provider_get_file_actions (ThunarxMenuProvider *menu_provider,
-                               GtkWidget           *window,
-                               GList               *files)
-{
-  GList              *actions = NULL;
-  return actions;
-}
-
-
-
-static GList*
-txp_provider_get_folder_actions (ThunarxMenuProvider *menu_provider,
-                                 GtkWidget           *window,
-                                 ThunarxFileInfo     *folder)
-{
-  GList              *actions = NULL;
-  return actions;
-}
diff --git a/src/txp-provider.h b/src/txp-provider.h
deleted file mode 100644
index e7f1529..0000000
--- a/src/txp-provider.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*-
- * Copyright (c) 2006 Peter de Ridder <peter at xfce.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library 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 Library 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.
- */
-
-#ifndef __TXP_PROVIDER_H__
-#define __TXP_PROVIDER_H__
-
-#include <thunarx/thunarx.h>
-
-G_BEGIN_DECLS;
-
-typedef struct _TxpProviderClass TxpProviderClass;
-typedef struct _TxpProvider      TxpProvider;
-
-#define TXP_TYPE_PROVIDER             (txp_provider_get_type ())
-#define TXP_PROVIDER(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), TXP_TYPE_PROVIDER, TxpProvider))
-#define TXP_PROVIDER_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass), TXP_TYPE_PROVIDER, TxpProviderClass))
-#define TXP_IS_PROVIDER(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TXP_TYPE_PROVIDER))
-#define TXP_IS_PROVIDER_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), TXP_TYPE_PROVIDER))
-#define TXP_PROVIDER_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), TXP_TYPE_PROVIDER, TxpProviderClass))
-
-GType txp_provider_get_type      (void) G_GNUC_CONST G_GNUC_INTERNAL;
-void  txp_provider_register_type (ThunarxProviderPlugin *plugin) G_GNUC_INTERNAL;
-
-G_END_DECLS;
-
-#endif /* !__TXP_PROVIDER_H__ */



More information about the Xfce4-commits mailing list