[Xfce4-commits] <thunarx-python:master> Implemented the preferences interface and added a sample plugin
Adam Plumb
noreply at xfce.org
Thu May 27 18:10:36 CEST 2010
Updating branch refs/heads/master
to 297af9135d1b74baf686e1995bc8c8a84760749a (commit)
from 4f1fcb52204d486219ee5b5fdc3c064228f20ffc (commit)
commit 297af9135d1b74baf686e1995bc8c8a84760749a
Author: Adam Plumb <adamplumb at gmail.com>
Date: Wed Dec 16 10:45:47 2009 -0500
Implemented the preferences interface and added a sample plugin
src/thunarx-python-object.c | 53 +++++++++++++++++++++++++++++++++++-------
src/thunarx-python.c | 3 +-
src/thunarx.defs | 2 +-
3 files changed, 47 insertions(+), 11 deletions(-)
diff --git a/src/thunarx-python-object.c b/src/thunarx-python-object.c
index e18842e..f16e736 100644
--- a/src/thunarx-python-object.c
+++ b/src/thunarx-python-object.c
@@ -55,9 +55,13 @@ static GList *thunarx_python_object_get_dnd_actions (ThunarxMenuProv
GList *files);
-static void thunarx_python_object_property_page_provider_iface_init (ThunarxPropertyPageProviderIface *iface);
-static GList *thunarx_python_object_get_property_pages (ThunarxPropertyPageProvider *provider,
- GList *files);
+static void thunarx_python_object_property_page_provider_iface_init (ThunarxPropertyPageProviderIface *iface);
+static GList *thunarx_python_object_get_property_pages (ThunarxPropertyPageProvider *provider,
+ GList *files);
+
+static void thunarx_python_object_preferences_provider_iface_init (ThunarxPreferencesProviderIface *iface);
+static GList *thunarx_python_object_get_preferences_actions (ThunarxPreferencesProvider *provider,
+ GtkWidget *window);
/* These macros assumes the following things:
* a METHOD_NAME is defined with is a string
@@ -273,15 +277,46 @@ thunarx_python_object_renamer_provider_iface_init (ThunarxRenamerProviderIface *
{
iface->get_renamers = thunarx_python_object_get_renamers;
}
+*/
+
+
+
+#define METHOD_NAME "get_preferences_actions"
+static GList *
+thunarx_python_object_get_preferences_actions (ThunarxPreferencesProvider *provider,
+ GtkWidget *window)
+{
+ 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,
+ "(N)", pygobject_new((GObject *)window));
+
+ 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_preferences_provider_iface_init (ThunarxPreferencesProviderIface *iface)
{
- iface->get_actions = thunarx_python_object_get_actions;
+ iface->get_actions = thunarx_python_object_get_preferences_actions;
}
-*/
+
static void
@@ -344,13 +379,13 @@ thunarx_python_object_get_type (ThunarxProviderPlugin *plugin, PyObject *type)
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);
@@ -387,12 +422,12 @@ thunarx_python_object_get_type (ThunarxProviderPlugin *plugin, PyObject *type)
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.c b/src/thunarx-python.c
index 7d54603..a47a8a3 100644
--- a/src/thunarx-python.c
+++ b/src/thunarx-python.c
@@ -248,7 +248,8 @@ thunarx_python_load_file (ThunarxProviderPlugin *plugin, const gchar *filename)
continue;
if (PyObject_IsSubclass(value, (PyObject*)&PyThunarxMenuProvider_Type) ||
- PyObject_IsSubclass(value, (PyObject*)&PyThunarxPropertyPageProvider_Type)) {
+ PyObject_IsSubclass(value, (PyObject*)&PyThunarxPropertyPageProvider_Type) ||
+ PyObject_IsSubclass(value, (PyObject*)&PyThunarxPreferencesProvider_Type)) {
new_type = thunarx_python_object_get_type(plugin, value);
g_array_append_val(all_types, new_type);
diff --git a/src/thunarx.defs b/src/thunarx.defs
index 9e18e14..01d4bf3 100644
--- a/src/thunarx.defs
+++ b/src/thunarx.defs
@@ -219,7 +219,7 @@
(return-type "GType")
)
-(define-method get_actions
+(define-method get_preferences_actions
(of-object "ThunarxPreferencesProvider")
(c-name "thunarx_preferences_provider_get_actions")
(return-type "GList*")
More information about the Xfce4-commits
mailing list