[Xfce4-commits] <thunarx-python:master> Implemented the RenamerProvider interface and added an example. Also, added the preferences plugin for real this time
Adam Plumb
noreply at xfce.org
Thu May 27 18:12:09 CEST 2010
Updating branch refs/heads/master
to 1ec80888a75e3c10c568b71a687d7541b8cbbcb6 (commit)
from 297af9135d1b74baf686e1995bc8c8a84760749a (commit)
commit 1ec80888a75e3c10c568b71a687d7541b8cbbcb6
Author: Adam Plumb <adamplumb at gmail.com>
Date: Wed Dec 16 12:39:27 2009 -0500
Implemented the RenamerProvider interface and added an example. Also, added the preferences plugin for real this time
examples/thunarx-preferences-provider.py | 22 +++++++++++++++
examples/thunarx-renamer-plugin.py | 11 +++++++
src/thunarx-python-object.c | 43 +++++++++++++++++++++++++----
src/thunarx-python.c | 3 +-
4 files changed, 72 insertions(+), 7 deletions(-)
diff --git a/examples/thunarx-preferences-provider.py b/examples/thunarx-preferences-provider.py
new file mode 100644
index 0000000..9c02aa4
--- /dev/null
+++ b/examples/thunarx-preferences-provider.py
@@ -0,0 +1,22 @@
+import thunarx
+import gtk
+
+class ThunarxPreferencesPlugin(thunarx.PreferencesProvider):
+ def __init__(self):
+ pass
+
+ def get_preferences_actions(self, window):
+ action = gtk.Action("TPP:PrefItem", "My Example Preferences", None, None)
+ action.connect("activate", self.__open_preferences, window)
+ return action,
+
+ def __open_preferences(self, action, window):
+ dialog = gtk.Dialog("My dialog",
+ window,
+ gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
+ (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
+ gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))
+
+ dialog.show()
+ dialog.run()
+ dialog.destroy()
diff --git a/examples/thunarx-renamer-plugin.py b/examples/thunarx-renamer-plugin.py
new file mode 100644
index 0000000..6339f9d
--- /dev/null
+++ b/examples/thunarx-renamer-plugin.py
@@ -0,0 +1,11 @@
+import thunarx
+import gtk
+
+class ThunarxPreferencesPlugin(thunarx.RenamerProvider):
+ def __init__(self):
+ pass
+
+ def get_renamers(self):
+ return []
+
+
diff --git a/src/thunarx-python-object.c b/src/thunarx-python-object.c
index f16e736..c8dba4b 100644
--- a/src/thunarx-python-object.c
+++ b/src/thunarx-python-object.c
@@ -63,6 +63,9 @@ static void thunarx_python_object_preferences_provider_iface_init (ThunarxPref
static GList *thunarx_python_object_get_preferences_actions (ThunarxPreferencesProvider *provider,
GtkWidget *window);
+static void thunarx_python_object_renamer_provider_iface_init (ThunarxRenamerProviderIface *iface);
+static GList *thunarx_python_object_get_renamers (ThunarxRenamerProvider *provider);
+
/* These macros assumes the following things:
* a METHOD_NAME is defined with is a string
* a goto label called beach
@@ -262,6 +265,34 @@ beach:
+#define METHOD_NAME "get_renamers"
+static GList *
+thunarx_python_object_get_renamers (ThunarxRenamerProvider *provider)
+{
+ ThunarxPythonObject *object = (ThunarxPythonObject*)provider;
+ PyObject *py_ret = NULL;
+ GList *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, "");
+
+ HANDLE_RETVAL(py_ret);
+
+ HANDLE_LIST(py_ret, ThunarxRenamer, "thunarx.Renamer");
+
+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)
{
@@ -271,13 +302,13 @@ thunarx_python_object_property_page_provider_iface_init (ThunarxPropertyPageProv
-/*
+
static void
thunarx_python_object_renamer_provider_iface_init (ThunarxRenamerProviderIface *iface)
{
iface->get_renamers = thunarx_python_object_get_renamers;
}
-*/
+
@@ -373,13 +404,13 @@ thunarx_python_object_get_type (ThunarxProviderPlugin *plugin, PyObject *type)
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,
@@ -416,13 +447,13 @@ thunarx_python_object_get_type (ThunarxProviderPlugin *plugin, PyObject *type)
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,
diff --git a/src/thunarx-python.c b/src/thunarx-python.c
index a47a8a3..bf7df48 100644
--- a/src/thunarx-python.c
+++ b/src/thunarx-python.c
@@ -249,7 +249,8 @@ thunarx_python_load_file (ThunarxProviderPlugin *plugin, const gchar *filename)
if (PyObject_IsSubclass(value, (PyObject*)&PyThunarxMenuProvider_Type) ||
PyObject_IsSubclass(value, (PyObject*)&PyThunarxPropertyPageProvider_Type) ||
- PyObject_IsSubclass(value, (PyObject*)&PyThunarxPreferencesProvider_Type)) {
+ PyObject_IsSubclass(value, (PyObject*)&PyThunarxPreferencesProvider_Type) ||
+ PyObject_IsSubclass(value, (PyObject*)&PyThunarxRenamerProvider_Type)) {
new_type = thunarx_python_object_get_type(plugin, value);
g_array_append_val(all_types, new_type);
More information about the Xfce4-commits
mailing list