gedit r6240 - in branches/jessevdk-plugins: bindings/python gedit/plugins
- From: jessevdk svn gnome org
- To: svn-commits-list gnome org
- Subject: gedit r6240 - in branches/jessevdk-plugins: bindings/python gedit/plugins
- Date: Mon, 7 Apr 2008 01:01:31 +0100 (BST)
Author: jessevdk
Date: Mon Apr 7 01:01:30 2008
New Revision: 6240
URL: http://svn.gnome.org/viewvc/gedit?rev=6240&view=rev
Log:
* bindings/python/geditplugins.override:
* bindings/python/geditplugins.defs:
Implemented bindings for gedit_plugins_engine_get_plugin_list and
gedit_plugins_engine_get_plugin_info. Not yet
implemented are gedit_plugin_info_get_plugin and
gedit_plugins_engine_get_plugin
* gedit/plugins/gedit-plugins-engine.c:
* gedit/plugins/gedit-plugins-engine.h:
Added gedit_plugins_engine_get_plugin_info
Modified:
branches/jessevdk-plugins/bindings/python/geditplugins.defs
branches/jessevdk-plugins/bindings/python/geditplugins.override
branches/jessevdk-plugins/gedit/plugins/gedit-plugins-engine.c
branches/jessevdk-plugins/gedit/plugins/gedit-plugins-engine.h
Modified: branches/jessevdk-plugins/bindings/python/geditplugins.defs
==============================================================================
--- branches/jessevdk-plugins/bindings/python/geditplugins.defs (original)
+++ branches/jessevdk-plugins/bindings/python/geditplugins.defs Mon Apr 7 01:01:30 2008
@@ -158,4 +158,12 @@
)
)
+(define-method get_plugin_info
+ (of-object "GeditPluginsEngine")
+ (c-name "gedit_plugins_engine_get_plugin_info")
+ (return-type "GeditPluginInfo*")
+ (parameters
+ '("const-gchar*" "name")
+ )
+)
Modified: branches/jessevdk-plugins/bindings/python/geditplugins.override
==============================================================================
--- branches/jessevdk-plugins/bindings/python/geditplugins.override (original)
+++ branches/jessevdk-plugins/bindings/python/geditplugins.override Mon Apr 7 01:01:30 2008
@@ -26,8 +26,8 @@
return NULL;
}
- PyList_Append(py_list, item);
- Py_DECREF(item);
+ PyList_Append (py_list, item);
+ Py_DECREF (item);
++list;
}
@@ -35,34 +35,37 @@
}
static PyObject *
-_helper_get_plugin_instance (PyObject *pyinfo)
+_helper_wrap_gboxed_glist (const GList *list)
{
- /*GeditPluginInfo *info;
- GeditPlugin *plugin;
- GeditPythonObject *obj;
-
- info = pyg_boxed_get(pyinfo, GeditPluginInfo);
- plugin = gedit_plugin_info_get_plugin(info);*/
+ PyObject *py_list;
+ const GList *tmp;
+
+ if ((py_list = PyList_New (0)) == NULL) {
+ return NULL;
+ }
- /* There are three different cases to take into consideration:
- 1. The plugin is an actual GeditPythonPlugin (then the instance
- of that plugin is the actual python object)
- 2. The plugin is a C plugin, with python bindings (wrap the
- plugin as the python class)
- 3. The plugin is a C plugin, but doesn't have any bindings,
- in which case we return NULL
- */
-
- /* Determine if this is a python plugin */
- /*if (G_TYPE_FROM_INSTANCE(plugin) != GEDIT_TYPE_PLUGIN)
- {
- obj = (GeditPythonObject *)plugin;
- Py_INCREF(obj->instance);
+ for (tmp = list; tmp != NULL; tmp = tmp->next) {
+ /* CHECKME: not sure if it should also make a copy, but I think
+ it should ... */
+ PyObject *py_obj = pyg_boxed_new(GEDIT_TYPE_PLUGIN_INFO, tmp->data, TRUE, TRUE);
+
+ if (py_obj == NULL) {
+ Py_DECREF (py_list);
+ return NULL;
+ }
- return obj->instance;
- }*/
-
- /* Determine if the plugin has python bindings */
+ PyList_Append (py_list, py_obj);
+ Py_DECREF (py_obj);
+ }
+
+ return py_list;
+}
+
+static PyObject *
+_helper_get_plugin_instance (GeditPlugin *plugin)
+{
+ Py_INCREF (Py_None);
+ return Py_None;
}
%%
@@ -74,7 +77,8 @@
ignore-glob
_*
*_get_type
- gedit_plugins_engine_get_plugin_list
+ gedit_plugin_info_copy
+ gedit_plugin_info_free
%%
override gedit_plugin_info_get_authors
PyObject *
@@ -94,5 +98,36 @@
static PyObject *
_wrap_gedit_plugin_info_get_plugin(PyObject *self)
{
- return _helper_get_plugin_instance(self);
+ GeditPluginInfo *info = pyg_boxed_get(self, GeditPluginInfo);
+
+ return _helper_get_plugin_instance(gedit_plugin_info_get_plugin(info));
+}
+%%
+override gedit_plugins_engine_get_plugin kwargs
+static PyObject *
+_wrap_gedit_plugins_engine_get_plugin(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = {"name", NULL};
+ char *name;
+ GeditPlugin *plugin;
+
+ if (!PyArg_ParseTupleAndKeywords (args,
+ kwargs,
+ "s:GeditPluginsEngine.get_plugin",
+ kwlist,
+ &name))
+ return NULL;
+
+ plugin = gedit_plugins_engine_get_plugin(GEDIT_PLUGINS_ENGINE(self->obj), name);
+ return _helper_get_plugin_instance(plugin);
+}
+%%
+override gedit_plugins_engine_get_plugin_list
+static PyObject *
+_wrap_gedit_plugins_engine_get_plugin_list(PyGObject *self)
+{
+ const GList *list;
+
+ list = gedit_plugins_engine_get_plugin_list (GEDIT_PLUGINS_ENGINE(self->obj));
+ return _helper_wrap_gboxed_glist (list);
}
Modified: branches/jessevdk-plugins/gedit/plugins/gedit-plugins-engine.c
==============================================================================
--- branches/jessevdk-plugins/gedit/plugins/gedit-plugins-engine.c (original)
+++ branches/jessevdk-plugins/gedit/plugins/gedit-plugins-engine.c Mon Apr 7 01:01:30 2008
@@ -326,8 +326,8 @@
}
static gint
-compare_plugin_name (GeditPluginInfo *info,
- const gchar *name)
+compare_plugin_module_name (GeditPluginInfo *info,
+ const gchar *name)
{
return strcmp(gedit_plugin_info_get_module_name(info), name);
}
@@ -339,22 +339,41 @@
GList *item;
GeditPluginInfo *info;
- gedit_debug(DEBUG_PLUGINS);
+ gedit_debug (DEBUG_PLUGINS);
- item = g_list_find_custom(engine->priv->plugin_list,
- name,
- (GCompareFunc)compare_plugin_name);
+ item = g_list_find_custom (engine->priv->plugin_list,
+ name,
+ (GCompareFunc)compare_plugin_module_name);
if (!item)
return NULL;
- info = GEDIT_PLUGIN_INFO(item->data);
+ info = GEDIT_PLUGIN_INFO (item->data);
/* CHECK: is this really what we want? */
- if (!gedit_plugin_info_is_active(info))
+ if (!gedit_plugin_info_is_active (info))
return NULL;
- return gedit_plugin_info_get_plugin(info);
+ return gedit_plugin_info_get_plugin (info);
+}
+
+GeditPluginInfo *
+gedit_plugins_engine_get_plugin_info (GeditPluginsEngine *engine,
+ const gchar *name)
+{
+ GList *item;
+ GeditPluginInfo *info;
+
+ gedit_debug(DEBUG_PLUGINS);
+
+ item = g_list_find_custom(engine->priv->plugin_list,
+ name,
+ (GCompareFunc)compare_plugin_module_name);
+
+ if (!item)
+ return NULL;
+
+ return GEDIT_PLUGIN_INFO (item->data);
}
static gboolean
Modified: branches/jessevdk-plugins/gedit/plugins/gedit-plugins-engine.h
==============================================================================
--- branches/jessevdk-plugins/gedit/plugins/gedit-plugins-engine.h (original)
+++ branches/jessevdk-plugins/gedit/plugins/gedit-plugins-engine.h Mon Apr 7 01:01:30 2008
@@ -84,6 +84,9 @@
GeditPluginInfo *info,
GtkWindow *parent);
+GeditPluginInfo *gedit_plugins_engine_get_plugin_info (GeditPluginsEngine *engine,
+ const gchar *name);
+
GeditPlugin *gedit_plugins_engine_get_plugin (GeditPluginsEngine *engine,
const gchar *name);
/*
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]