Python plugins

master
Yevgen Muntyan 2005-11-06 12:26:19 +00:00
parent 0603085a28
commit 0dfea470c5
18 changed files with 842 additions and 1978 deletions

View File

@ -26,7 +26,9 @@ static MooPluginParams plugin_name__##_plugin_params = { \
TRUE \
}; \
\
static MooPluginPrefsParams plugin_name__##_plugin_prefs_params = {}; \
static MooPluginPrefsParams plugin_name__##_plugin_prefs_params = { \
TRUE \
}; \
\
static MooPluginInfo plugin_name__##_plugin_info = { \
id__, \

View File

@ -190,12 +190,12 @@ moo_plugin_register (GType type)
}
plugin = g_object_new (type, NULL);
g_return_val_if_fail (plugin != NULL, FALSE);
if (!plugin_info_check (plugin->info))
{
g_warning ("%s: invalid info in plugin %s",
G_STRLOC, g_type_name (type));
g_object_unref (plugin);
return FALSE;
}
@ -560,7 +560,7 @@ moo_doc_plugin_lookup (const char *plugin_id,
static gboolean
plugin_info_check (MooPluginInfo *info)
{
return info->id && info->id[0] &&
return info && info->id && info->id[0] &&
g_utf8_validate (info->id, -1, NULL) &&
info->name && g_utf8_validate (info->name, -1, NULL) &&
info->description && g_utf8_validate (info->description, -1, NULL) &&

View File

@ -20,7 +20,7 @@
G_BEGIN_DECLS
#define MOO_PLUGIN_PREFS_ROOT "Plugins"
#define MOO_PLUGIN_CURRENT_VERSION 14
#define MOO_PLUGIN_CURRENT_VERSION 15
#define MOO_PLUGIN_DIR_BASENAME "plugins"
@ -88,6 +88,8 @@ struct _MooPluginParams
struct _MooPluginPrefsParams
{
/* it's needed to make sizeof() > 0 */
guint dummy : 1;
};
struct _MooPluginInfo

View File

@ -16,7 +16,6 @@ nodist_moopython_sources =
moopython_cleanfiles =
mooedit_defs_files = \
$(moopython_srcdir)/mooeditor.defs \
$(moopython_srcdir)/mooplugin.defs
# mooutils_override_files = \

View File

@ -32,10 +32,10 @@ void moo_app_mod_init (PyObject *moo_mod)
{
PyObject *mod;
mod = Py_InitModule3 ("moo.app", moo_app_functions, moo_app_module_doc);
mod = Py_InitModule3 ((char*) "moo.app", moo_app_functions, moo_app_module_doc);
g_return_if_fail (mod != NULL);
Py_INCREF (mod);
PyModule_AddObject (moo_mod, "app", mod);
PyModule_AddObject (moo_mod, (char*) "app", mod);
// moo_app_add_constants (mod, "MOO_");
moo_app_register_classes (PyModule_GetDict (moo_mod));

View File

@ -32,10 +32,10 @@ void moo_edit_mod_init (PyObject *moo_mod)
{
PyObject *mod;
mod = Py_InitModule3 ("moo.edit", moo_edit_functions, moo_edit_module_doc);
mod = Py_InitModule3 ((char*) "moo.edit", moo_edit_functions, moo_edit_module_doc);
g_return_if_fail (mod != NULL);
Py_INCREF (mod);
PyModule_AddObject (moo_mod, "edit", mod);
PyModule_AddObject (moo_mod, (char*) "edit", mod);
// moo_edit_add_constants (mod, "MOO_");
moo_edit_register_classes (PyModule_GetDict (moo_mod));

File diff suppressed because it is too large Load Diff

View File

@ -62,3 +62,26 @@ _wrap_moo_python_plugin_hook (G_GNUC_UNUSED PyObject *self, PyObject *args)
return result;
}
%%
override moo_python_plugin_register varargs
static PyObject *
_wrap_moo_python_plugin_register (G_GNUC_UNUSED PyObject *self, PyObject *args)
{
PyObject *plugin_type, *win_plugin_type = NULL, *doc_plugin_type = NULL;
const char *id;
if (!PyArg_ParseTuple (args, (char*) "sO|OO:plugin_register", &id, &plugin_type,
win_plugin_type, doc_plugin_type))
return NULL;
if (!PyType_Check (plugin_type))
return_TypeErr ("argument must be a type");
if (win_plugin_type && !PyType_Check (win_plugin_type))
return_TypeErr ("argument must be a type");
if (doc_plugin_type && !PyType_Check (doc_plugin_type))
return_TypeErr ("argument must be a type");
return _moo_python_plugin_register (id, plugin_type, win_plugin_type, doc_plugin_type);
}

View File

@ -1,176 +0,0 @@
(define-object Editor
(in-module "Moo")
(parent "GObject")
(c-name "MooEditor")
(gtype-id "MOO_TYPE_EDITOR")
)
(define-function moo_editor_instance
(c-name "moo_editor_instance")
(return-type "MooEditor*")
)
(define-method new_window
(of-object "MooEditor")
(c-name "moo_editor_new_window")
(return-type "MooEditWindow*")
)
(define-method new_doc
(of-object "MooEditor")
(c-name "moo_editor_new_doc")
(return-type "MooEdit*")
(parameters
'("MooEditWindow*" "window")
)
)
(define-method open
(of-object "MooEditor")
(c-name "moo_editor_open")
(return-type "none")
(parameters
'("MooEditWindow*" "window")
'("GtkWidget*" "parent")
'("GSList*" "files")
)
)
(define-method open_file
(of-object "MooEditor")
(c-name "moo_editor_open_file")
(return-type "none")
(parameters
'("MooEditWindow*" "window")
'("GtkWidget*" "parent")
'("const-char*" "filename")
'("const-char*" "encoding")
)
)
(define-method get_doc
(of-object "MooEditor")
(c-name "moo_editor_get_doc")
(return-type "MooEdit*")
(parameters
'("const-char*" "filename")
)
)
(define-method get_active_doc
(of-object "MooEditor")
(c-name "moo_editor_get_active_doc")
(return-type "MooEdit*")
)
(define-method get_active_window
(of-object "MooEditor")
(c-name "moo_editor_get_active_window")
(return-type "MooEditWindow*")
)
(define-method set_active_window
(of-object "MooEditor")
(c-name "moo_editor_set_active_window")
(return-type "none")
(parameters
'("MooEditWindow*" "window")
)
)
(define-method set_active_doc
(of-object "MooEditor")
(c-name "moo_editor_set_active_doc")
(return-type "none")
(parameters
'("MooEdit*" "doc")
)
)
(define-method list_windows
(of-object "MooEditor")
(c-name "moo_editor_list_windows")
(return-type "GSList*")
)
(define-method close_window
(of-object "MooEditor")
(c-name "moo_editor_close_window")
(return-type "gboolean")
(parameters
'("MooEditWindow*" "window")
)
)
(define-method close_doc
(of-object "MooEditor")
(c-name "moo_editor_close_doc")
(return-type "gboolean")
(parameters
'("MooEdit*" "doc")
)
)
(define-method close_docs
(of-object "MooEditor")
(c-name "moo_editor_close_docs")
(return-type "gboolean")
(parameters
'("GSList*" "list")
)
)
(define-method close_all
(of-object "MooEditor")
(c-name "moo_editor_close_all")
(return-type "gboolean")
)
(define-method set_app_name
(of-object "MooEditor")
(c-name "moo_editor_set_app_name")
(return-type "none")
(parameters
'("const-char*" "name")
)
)
(define-method get_history
(of-object "MooEditor")
(c-name "moo_editor_get_history")
(return-type "MooHistoryList*")
)
(define-method get_filter_mgr
(of-object "MooEditor")
(c-name "moo_editor_get_filter_mgr")
(return-type "MooFilterMgr*")
)
(define-method get_ui_xml
(of-object "MooEditor")
(c-name "moo_editor_get_ui_xml")
(return-type "MooUIXML*")
)
(define-method set_ui_xml
(of-object "MooEditor")
(c-name "moo_editor_set_ui_xml")
(return-type "none")
(parameters
'("MooUIXML*" "xml")
)
)
(define-method get_editor
(of-object "MooEditWindow")
(c-name "moo_edit_window_get_editor")
(return-type "MooEditor*")
)
(define-method get_lang_mgr
(of-object "MooEditor")
(c-name "moo_editor_get_lang_mgr")
(return-type "MooLangMgr*")
)

View File

@ -443,3 +443,528 @@ hook_free (Hook *hook)
g_free (hook);
}
}
/***************************************************************************/
/* Python plugins
*/
#define MOO_PY_PLUGIN(obj_) ((MooPyPlugin*)obj_)
typedef struct _MooPyPlugin MooPyPlugin;
typedef struct _MooPyPluginClass MooPyPluginClass;
typedef struct _MooPyPluginClassData MooPyPluginClassData;
struct _MooPyPluginClassData {
PyObject *py_plugin_type;
PyObject *py_win_plugin_type;
PyObject *py_doc_plugin_type;
GType win_plugin_type;
GType doc_plugin_type;
};
struct _MooPyPlugin {
MooPlugin base;
MooPyPluginClassData *class_data;
PyObject *instance;
};
struct _MooPyPluginClass {
MooPluginClass base_class;
MooPyPluginClassData *data;
};
static gpointer moo_py_plugin_parent_class;
static void moo_py_plugin_class_init (MooPyPluginClass *klass,
MooPyPluginClassData *data);
static void moo_py_plugin_instance_init (MooPyPlugin *plugin,
MooPyPluginClass *klass);
static void moo_py_plugin_finalize (GObject *object);
static gboolean moo_py_plugin_init (MooPlugin *plugin);
static void moo_py_plugin_deinit (MooPlugin *plugin);
static void moo_py_plugin_attach_win (MooPlugin *plugin,
MooEditWindow *window);
static void moo_py_plugin_detach_win (MooPlugin *plugin,
MooEditWindow *window);
static void moo_py_plugin_attach_doc (MooPlugin *plugin,
MooEdit *doc,
MooEditWindow *window);
static void moo_py_plugin_detach_doc (MooPlugin *plugin,
MooEdit *doc,
MooEditWindow *window);
static MooPluginInfo *get_plugin_info (PyObject *object);
static GType generate_win_plugin_type (PyObject *py_type);
static GType generate_doc_plugin_type (PyObject *py_type);
static GtkWidget *moo_py_plugin_create_prefs_page (MooPlugin *plugin);
static void plugin_info_free (MooPluginInfo *info);
static void
moo_py_plugin_class_init (MooPyPluginClass *klass,
MooPyPluginClassData *data)
{
MooPluginClass *plugin_class = MOO_PLUGIN_CLASS (klass);
GObjectClass *gobj_class = G_OBJECT_CLASS (klass);
moo_py_plugin_parent_class = g_type_class_peek_parent (klass);
klass->data = data;
gobj_class->finalize = moo_py_plugin_finalize;
plugin_class->plugin_system_version = MOO_PLUGIN_CURRENT_VERSION;
if (data->py_plugin_type)
{
plugin_class->init = moo_py_plugin_init;
plugin_class->deinit = moo_py_plugin_deinit;
plugin_class->attach_win = moo_py_plugin_attach_win;
plugin_class->detach_win = moo_py_plugin_detach_win;
plugin_class->attach_doc = moo_py_plugin_attach_doc;
plugin_class->detach_doc = moo_py_plugin_detach_doc;
plugin_class->create_prefs_page = moo_py_plugin_create_prefs_page;
}
}
static void
moo_py_plugin_instance_init (MooPyPlugin *plugin,
MooPyPluginClass *klass)
{
PyObject *args;
MooPlugin *moo_plugin = MOO_PLUGIN (plugin);
plugin->class_data = klass->data;
args = PyTuple_New (0);
plugin->instance = PyType_GenericNew ((PyTypeObject*) klass->data->py_plugin_type, args, NULL);
Py_DECREF (args);
g_return_if_fail (plugin->instance != NULL);
moo_plugin->info = get_plugin_info (plugin->instance);
if (klass->data->py_win_plugin_type && !klass->data->win_plugin_type)
klass->data->win_plugin_type = generate_win_plugin_type (klass->data->py_win_plugin_type);
if (klass->data->py_win_plugin_type && !klass->data->doc_plugin_type)
klass->data->doc_plugin_type = generate_doc_plugin_type (klass->data->py_doc_plugin_type);
moo_plugin->win_plugin_type = klass->data->win_plugin_type;
moo_plugin->doc_plugin_type = klass->data->doc_plugin_type;
}
static gboolean
moo_py_plugin_init (MooPlugin *plugin)
{
PyObject *result, *meth;
MooPyPlugin *py_plugin = MOO_PY_PLUGIN (plugin);
gboolean bool_result;
g_return_val_if_fail (py_plugin->instance != NULL, FALSE);
if (!PyObject_HasAttrString (py_plugin->instance, (char*) "init"))
return TRUE;
meth = PyObject_GetAttrString (py_plugin->instance, (char*) "init");
if (!meth)
{
PyErr_Print ();
return FALSE;
}
if (!PyCallable_Check (meth))
{
g_critical ("%s: init is not callable", G_STRLOC);
Py_DECREF (meth);
return FALSE;
}
result = PyObject_CallObject (meth, NULL);
Py_DECREF (meth);
if (!result)
{
PyErr_Print ();
return FALSE;
}
bool_result = PyObject_IsTrue (result);
Py_DECREF (result);
return bool_result;
}
static void
moo_py_plugin_deinit (MooPlugin *plugin)
{
PyObject *result, *meth;
MooPyPlugin *py_plugin = MOO_PY_PLUGIN (plugin);
g_return_if_fail (py_plugin->instance != NULL);
if (!PyObject_HasAttrString (py_plugin->instance, (char*) "deinit"))
return;
meth = PyObject_GetAttrString (py_plugin->instance, (char*) "deinit");
if (!meth)
{
PyErr_Print ();
return;
}
if (!PyCallable_Check (meth))
{
g_critical ("%s: deinit is not callable", G_STRLOC);
Py_DECREF (meth);
return;
}
result = PyObject_CallObject (meth, NULL);
Py_DECREF (meth);
if (!result)
PyErr_Print ();
Py_XDECREF (result);
}
static void
moo_py_plugin_call_meth (MooPlugin *plugin,
MooEdit *doc,
MooEditWindow *window,
const char *meth_name)
{
PyObject *result, *meth, *py_window, *py_doc;
MooPyPlugin *py_plugin = MOO_PY_PLUGIN (plugin);
g_return_if_fail (py_plugin->instance != NULL);
if (!PyObject_HasAttrString (py_plugin->instance, (char*) meth_name))
return;
meth = PyObject_GetAttrString (py_plugin->instance, (char*) meth_name);
if (!meth)
{
PyErr_Print ();
return;
}
if (!PyCallable_Check (meth))
{
g_critical ("%s: %s is not callable", G_STRLOC, meth_name);
Py_DECREF (meth);
return;
}
py_window = pygobject_new (G_OBJECT (window));
py_doc = doc ? pygobject_new (G_OBJECT (doc)) : NULL;
if (doc)
result = PyObject_CallFunction (meth, (char*) "(OO)", py_doc, py_window);
else
result = PyObject_CallFunction (meth, (char*) "(O)", py_window);
Py_XDECREF (meth);
Py_XDECREF (py_window);
Py_XDECREF (py_doc);
if (!result)
PyErr_Print ();
Py_XDECREF (result);
}
static void
moo_py_plugin_attach_win (MooPlugin *plugin,
MooEditWindow *window)
{
moo_py_plugin_call_meth (plugin, NULL, window, "attach_win");
}
static void
moo_py_plugin_detach_win (MooPlugin *plugin,
MooEditWindow *window)
{
moo_py_plugin_call_meth (plugin, NULL, window, "detach_win");
}
static void
moo_py_plugin_attach_doc (MooPlugin *plugin,
MooEdit *doc,
MooEditWindow *window)
{
moo_py_plugin_call_meth (plugin, doc, window, "attach_doc");
}
static void
moo_py_plugin_detach_doc (MooPlugin *plugin,
MooEdit *doc,
MooEditWindow *window)
{
moo_py_plugin_call_meth (plugin, doc, window, "detach_doc");
}
static void
moo_py_plugin_finalize (GObject *object)
{
MooPyPlugin *py_plugin = MOO_PY_PLUGIN (object);
MooPlugin *plugin = MOO_PLUGIN (object);
Py_XDECREF (py_plugin->instance);
plugin_info_free (plugin->info);
G_OBJECT_CLASS(moo_py_plugin_parent_class)->finalize (object);
}
static GtkWidget*
moo_py_plugin_create_prefs_page (MooPlugin *plugin)
{
PyObject *result, *meth;
MooPyPlugin *py_plugin = MOO_PY_PLUGIN (plugin);
g_return_val_if_fail (py_plugin->instance != NULL, NULL);
if (!PyObject_HasAttrString (py_plugin->instance, (char*) "create_prefs_page"))
return NULL;
meth = PyObject_GetAttrString (py_plugin->instance, (char*) "create_prefs_page");
if (!meth)
{
PyErr_Print ();
return NULL;
}
if (!PyCallable_Check (meth))
{
g_critical ("%s: create_prefs_page is not callable", G_STRLOC);
Py_DECREF (meth);
return NULL;
}
result = PyObject_CallObject (meth, NULL);
Py_DECREF (meth);
if (!result)
{
PyErr_Print ();
return NULL;
}
else
{
gpointer page = pygobject_get (result);
g_object_ref (page);
Py_DECREF (result);
return page;
}
}
PyObject*
_moo_python_plugin_register (const char *id,
PyObject *py_plugin_type,
PyObject *py_win_plugin_type,
PyObject *py_doc_plugin_type)
{
GType plugin_type;
char *plugin_type_name = NULL;
static GTypeInfo plugin_type_info;
MooPyPluginClassData *class_data;
int i;
g_return_val_if_fail (id != NULL, NULL);
g_return_val_if_fail (py_plugin_type != NULL, NULL);
g_return_val_if_fail (PyType_Check (py_plugin_type), NULL);
g_return_val_if_fail (!py_win_plugin_type || PyType_Check (py_win_plugin_type), NULL);
g_return_val_if_fail (!py_doc_plugin_type || PyType_Check (py_doc_plugin_type), NULL);
for (i = 0; i < 1000; ++i)
{
plugin_type_name = g_strdup_printf ("MooPyPlugin-%08x", g_random_int ());
if (!g_type_from_name (plugin_type_name))
break;
g_free (plugin_type_name);
plugin_type_name = NULL;
}
if (!plugin_type_name)
return_RuntimeErr ("could not find name for plugin class");
class_data = g_new0 (MooPyPluginClassData, 1);
class_data->py_plugin_type = py_plugin_type;
class_data->py_win_plugin_type = py_win_plugin_type;
class_data->py_doc_plugin_type = py_doc_plugin_type;
Py_XINCREF (py_plugin_type);
Py_XINCREF (py_win_plugin_type);
Py_XINCREF (py_doc_plugin_type);
plugin_type_info.class_size = sizeof (MooPyPluginClass);
plugin_type_info.class_init = (GClassInitFunc) moo_py_plugin_class_init;
plugin_type_info.class_data = class_data;
plugin_type_info.instance_size = sizeof (MooPyPlugin);
plugin_type_info.instance_init = (GInstanceInitFunc) moo_py_plugin_instance_init;
plugin_type = g_type_register_static (MOO_TYPE_PLUGIN, plugin_type_name,
&plugin_type_info, 0);
if (!moo_plugin_register (plugin_type))
{
Py_XDECREF (class_data->py_plugin_type);
Py_XINCREF (class_data->py_win_plugin_type);
Py_XINCREF (class_data->py_doc_plugin_type);
g_free (class_data);
return_RuntimeErr ("could not register plugin");
}
return_None;
}
static void
plugin_info_free (MooPluginInfo *info)
{
if (info)
{
g_free ((char*) info->id);
g_free ((char*) info->name);
g_free ((char*) info->description);
g_free ((char*) info->author);
g_free ((char*) info->version);
g_free (info->params);
g_free (info->prefs_params);
g_free (info);
}
}
static char *
dict_get_string (PyObject *dict,
const char *key)
{
PyObject *val, *strval;
char *result;
val = PyDict_GetItemString (dict, (char*) key);
if (!val)
return NULL;
strval = PyObject_Str (val);
Py_DECREF (val);
if (!strval)
{
PyErr_Print ();
return NULL;
}
result = g_strdup (PyString_AS_STRING (strval));
Py_DECREF (strval);
return result;
}
static gboolean
dict_get_bool (PyObject *dict,
const char *key,
gboolean default_val)
{
PyObject *val;
gboolean result;
val = PyDict_GetItemString (dict, (char*) key);
if (!val)
return default_val;
result = PyObject_IsTrue (val);
Py_DECREF (val);
return result;
}
static MooPluginInfo*
get_plugin_info (PyObject *object)
{
MooPluginInfo *info;
PyObject *result, *meth;
if (!PyObject_HasAttrString (object, (char*) "get_info"))
{
g_critical ("%s: no get_info attribute", G_STRLOC);
return NULL;
}
meth = PyObject_GetAttrString (object, (char*) "get_info");
if (!meth)
{
PyErr_Print ();
return NULL;
}
if (!PyCallable_Check (meth))
{
g_critical ("%s: get_info is not callable", G_STRLOC);
Py_DECREF (meth);
return NULL;
}
result = PyObject_CallObject (meth, NULL);
Py_DECREF (meth);
if (!result)
{
PyErr_Print ();
return NULL;
}
if (!PyDict_Check (result))
{
g_critical ("%s: not a dict", G_STRLOC);
Py_DECREF (result);
return NULL;
}
info = g_new0 (MooPluginInfo, 1);
info->params = g_new0 (MooPluginParams, 1);
info->prefs_params = g_new0 (MooPluginPrefsParams, 1);
info->id = dict_get_string (result, "id");
info->name = dict_get_string (result, "name");
info->description = dict_get_string (result, "description");
info->author = dict_get_string (result, "author");
info->version = dict_get_string (result, "version");
info->params->enabled = dict_get_bool (result, "enabled", TRUE);
info->params->visible = dict_get_bool (result, "visible", TRUE);
return info;
}
static GType
generate_win_plugin_type (PyObject *py_type)
{
return 0;
}
static GType
generate_doc_plugin_type (PyObject *py_type)
{
return 0;
}

View File

@ -21,11 +21,15 @@
G_BEGIN_DECLS
gboolean _moo_python_plugin_init (char **dirs);
gboolean _moo_python_plugin_init (char **dirs);
PyObject *_moo_python_plugin_hook (const char *event,
PyObject *callback,
PyObject *data);
PyObject *_moo_python_plugin_hook (const char *event,
PyObject *callback,
PyObject *data);
PyObject *_moo_python_plugin_register (const char *id,
PyObject *plugin_type,
PyObject *win_plugin_type,
PyObject *doc_plugin_type);
G_END_DECLS

View File

@ -6,3 +6,11 @@
'("const-char*" "dummy")
)
)
(define-function plugin_register
(c-name "moo_python_plugin_register")
(return-type "none")
(parameters
'("const-char*" "dummy")
)
)

View File

@ -32,10 +32,10 @@ void moo_term_mod_init (PyObject *moo_mod)
{
PyObject *mod;
mod = Py_InitModule3 ("moo.term", moo_term_functions, moo_term_module_doc);
mod = Py_InitModule3 ((char*) "moo.term", moo_term_functions, moo_term_module_doc);
g_return_if_fail (mod != NULL);
Py_INCREF (mod);
PyModule_AddObject (moo_mod, "term", mod);
PyModule_AddObject (moo_mod, (char*) "term", mod);
// moo_term_add_constants (mod, "MOO_");
moo_term_register_classes (PyModule_GetDict (moo_mod));

View File

@ -54,12 +54,12 @@ override moo_term_fork_command_line kwargs
static PyObject *
_wrap_moo_term_fork_command_line (PyGObject *self, PyObject *args, PyObject *kwargs)
{
static char *kwlist[] = {"cmd", "working_dir", NULL};
static char *kwlist[] = {(char*) "cmd", (char*) "working_dir", NULL};
const char *cmd = NULL;
const char *working_dir = NULL;
gboolean result;
if (!PyArg_ParseTupleAndKeywords (args, kwargs, "s|s:Term.fork_command",
if (!PyArg_ParseTupleAndKeywords (args, kwargs, (char*) "s|s:Term.fork_command",
kwlist, &cmd, &working_dir))
return NULL;
@ -73,11 +73,11 @@ override moo_term_copy_clipboard kwargs
static PyObject *
_wrap_moo_term_copy_clipboard (PyGObject *self, PyObject *args, PyObject *kwargs)
{
static char *kwlist[] = { "selection", NULL };
static char *kwlist[] = { (char*) "selection", NULL };
PyObject *py_selection = NULL;
GdkAtom selection;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:MooTerm.copy_clipboard", kwlist, &py_selection))
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char*) "O:MooTerm.copy_clipboard", kwlist, &py_selection))
return NULL;
selection = atom_from_pyobject(py_selection);
if (PyErr_Occurred())
@ -91,11 +91,11 @@ override moo_term_paste_clipboard kwargs
static PyObject *
_wrap_moo_term_paste_clipboard(PyGObject *self, PyObject *args, PyObject *kwargs)
{
static char *kwlist[] = { "selection", NULL };
static char *kwlist[] = { (char*) "selection", NULL };
PyObject *py_selection = NULL;
GdkAtom selection;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:MooTerm.paste_clipboard", kwlist, &py_selection))
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char*) "O:MooTerm.paste_clipboard", kwlist, &py_selection))
return NULL;
selection = atom_from_pyobject(py_selection);
if (PyErr_Occurred())

View File

@ -90,13 +90,6 @@
(gtype-id "MOO_TYPE_PREFS_DIALOG_PAGE")
)
(define-object UIXML
(in-module "Moo")
(parent "GObject")
(c-name "MooUIXML")
(gtype-id "MOO_TYPE_UI_XML")
)
(define-object Window
(in-module "Moo")
(parent "GtkWindow")
@ -118,8 +111,37 @@
(gtype-id "MOO_TYPE_CLOSURE")
)
(define-object UIXML
(in-module "Moo")
(parent "GObject")
(c-name "MooUIXML")
(gtype-id "MOO_TYPE_UI_XML")
)
(define-boxed UINode
(in-module "Moo")
(c-name "MooUINode")
(gtype-id "MOO_TYPE_UI_NODE")
(copy-func "moo_ui_node_ref")
(release-func "moo_ui_node_unref")
)
;; Enumerations and flags ...
(define-enum UIWidgetType
(in-module "Moo")
(c-name "MooUIWidgetType")
(gtype-id "MOO_TYPE_UI_WIDGET_TYPE")
(values
'("menubar" "MOO_UI_MENUBAR")
'("menu" "MOO_UI_MENU")
'("toolbar" "MOO_UI_TOOLBAR")
)
)
(define-enum FileDialogType
(in-module "Moo")
(c-name "MooFileDialogType")
@ -1113,231 +1135,6 @@
;; From ../mooutils/moomarkup.h
(define-function MOO_MARKUP_NODE
(c-name "MOO_MARKUP_NODE")
(return-type "MooMarkupNode*")
(parameters
'("gpointer" "node")
)
)
(define-function MOO_MARKUP_DOC
(c-name "MOO_MARKUP_DOC")
(return-type "MooMarkupDoc*")
(parameters
'("gpointer" "node")
)
)
(define-function MOO_MARKUP_ELEMENT
(c-name "MOO_MARKUP_ELEMENT")
(return-type "MooMarkupElement*")
(parameters
'("gpointer" "node")
)
)
(define-function MOO_MARKUP_TEXT
(c-name "MOO_MARKUP_TEXT")
(return-type "MooMarkupText*")
(parameters
'("gpointer" "node")
)
)
(define-function MOO_MARKUP_COMMENT
(c-name "MOO_MARKUP_COMMENT")
(return-type "MooMarkupComment*")
(parameters
'("gpointer" "node")
)
)
(define-function moo_markup_doc_new
(c-name "moo_markup_doc_new")
(is-constructor-of "MooMarkupDoc")
(return-type "MooMarkupDoc*")
(parameters
'("const-char*" "name")
)
)
(define-function moo_markup_parse_file
(c-name "moo_markup_parse_file")
(return-type "MooMarkupDoc*")
(parameters
'("const-char*" "filename")
'("GError**" "error")
)
)
(define-function moo_markup_parse_memory
(c-name "moo_markup_parse_memory")
(return-type "MooMarkupDoc*")
(parameters
'("const-char*" "buffer")
'("int" "size")
'("GError**" "error")
)
)
(define-function moo_markup_save
(c-name "moo_markup_save")
(return-type "gboolean")
(parameters
'("MooMarkupDoc*" "doc")
'("const-char*" "filename")
'("GError**" "error")
)
)
(define-function moo_markup_save_pretty
(c-name "moo_markup_save_pretty")
(return-type "gboolean")
(parameters
'("MooMarkupDoc*" "doc")
'("const-char*" "filename")
'("guint" "indent")
'("GError**" "error")
)
)
(define-method get_string
(of-object "MooMarkupNode")
(c-name "moo_markup_node_get_string")
(return-type "char*")
)
(define-method ref
(of-object "MooMarkupDoc")
(c-name "moo_markup_doc_ref")
(return-type "MooMarkupDoc*")
)
(define-method unref
(of-object "MooMarkupDoc")
(c-name "moo_markup_doc_unref")
(return-type "none")
)
(define-function moo_markup_get_root_element
(c-name "moo_markup_get_root_element")
(return-type "MooMarkupNode*")
(parameters
'("MooMarkupDoc*" "doc")
'("const-char*" "name")
)
)
(define-function moo_markup_get_element
(c-name "moo_markup_get_element")
(return-type "MooMarkupNode*")
(parameters
'("MooMarkupNode*" "node")
'("const-char*" "path")
)
)
(define-function moo_markup_get_prop
(c-name "moo_markup_get_prop")
(return-type "const-char*")
(parameters
'("MooMarkupNode*" "node")
'("const-char*" "prop_name")
)
)
(define-function moo_markup_set_prop
(c-name "moo_markup_set_prop")
(return-type "none")
(parameters
'("MooMarkupNode*" "node")
'("const-char*" "prop_name")
'("const-char*" "val")
)
)
(define-function moo_markup_set_content
(c-name "moo_markup_set_content")
(return-type "none")
(parameters
'("MooMarkupNode*" "node")
'("const-char*" "text")
)
)
(define-function moo_markup_get_content
(c-name "moo_markup_get_content")
(return-type "const-char*")
(parameters
'("MooMarkupNode*" "node")
)
)
(define-method get_path
(of-object "MooMarkupElement")
(c-name "moo_markup_element_get_path")
(return-type "char*")
)
(define-function moo_markup_delete_node
(c-name "moo_markup_delete_node")
(return-type "none")
(parameters
'("MooMarkupNode*" "node")
)
)
(define-function moo_markup_create_root_element
(c-name "moo_markup_create_root_element")
(return-type "MooMarkupNode*")
(parameters
'("MooMarkupDoc*" "doc")
'("const-char*" "name")
)
)
(define-function moo_markup_create_element
(c-name "moo_markup_create_element")
(return-type "MooMarkupNode*")
(parameters
'("MooMarkupNode*" "parent")
'("const-char*" "path")
)
)
(define-function moo_markup_create_text_element
(c-name "moo_markup_create_text_element")
(return-type "MooMarkupNode*")
(parameters
'("MooMarkupNode*" "parent")
'("const-char*" "path")
'("const-char*" "content")
)
)
(define-function moo_markup_create_file_element
(c-name "moo_markup_create_file_element")
(return-type "MooMarkupNode*")
(parameters
'("MooMarkupNode*" "parent")
'("const-char*" "path")
'("const-char*" "filename")
)
)
(define-function moo_markup_get_file_content
(c-name "moo_markup_get_file_content")
(return-type "char*")
(parameters
'("MooMarkupNode*" "node")
)
)
;; From ../mooutils/moomenumgr.h
(define-function moo_menu_mgr_new
@ -1795,180 +1592,6 @@
;; From ../mooutils/moouixml.h
(define-function moo_ui_xml_new
(c-name "moo_ui_xml_new")
(is-constructor-of "MooUiXml")
(return-type "MooUIXML*")
)
(define-method add_ui_from_string
(of-object "MooUIXML")
(c-name "moo_ui_xml_add_ui_from_string")
(return-type "none")
(parameters
'("const-char*" "buffer")
'("gssize" "length")
)
)
(define-method get_node
(of-object "MooUIXML")
(c-name "moo_ui_xml_get_node")
(return-type "MooUINode*")
(parameters
'("const-char*" "path")
)
)
(define-method find_placeholder
(of-object "MooUIXML")
(c-name "moo_ui_xml_find_placeholder")
(return-type "MooUINode*")
(parameters
'("const-char*" "name")
)
)
(define-method get_path
(of-object "MooUINode")
(c-name "moo_ui_node_get_path")
(return-type "char*")
)
(define-method get_child
(of-object "MooUINode")
(c-name "moo_ui_node_get_child")
(return-type "MooUINode*")
(parameters
'("const-char*" "path")
)
)
(define-method create_widget
(of-object "MooUIXML")
(c-name "moo_ui_xml_create_widget")
(return-type "GtkWidget*")
(parameters
'("MooUIWidgetType" "type")
'("const-char*" "path")
'("MooActionGroup*" "actions")
'("GtkAccelGroup*" "accel_group")
)
)
(define-method new_merge_id
(of-object "MooUIXML")
(c-name "moo_ui_xml_new_merge_id")
(return-type "guint")
)
(define-method add_item
(of-object "MooUIXML")
(c-name "moo_ui_xml_add_item")
(return-type "MooUINode*")
(parameters
'("guint" "merge_id")
'("const-char*" "parent_path")
'("const-char*" "name")
'("const-char*" "action")
'("int" "position")
)
)
(define-method insert_after
(of-object "MooUIXML")
(c-name "moo_ui_xml_insert_after")
(return-type "none")
(parameters
'("guint" "merge_id")
'("MooUINode*" "parent")
'("MooUINode*" "after")
'("const-char*" "markup")
)
)
(define-method insert_before
(of-object "MooUIXML")
(c-name "moo_ui_xml_insert_before")
(return-type "none")
(parameters
'("guint" "merge_id")
'("MooUINode*" "parent")
'("MooUINode*" "before")
'("const-char*" "markup")
)
)
(define-method insert
(of-object "MooUIXML")
(c-name "moo_ui_xml_insert")
(return-type "none")
(parameters
'("guint" "merge_id")
'("MooUINode*" "parent")
'("int" "position")
'("const-char*" "markup")
)
)
(define-method insert_markup_after
(of-object "MooUIXML")
(c-name "moo_ui_xml_insert_markup_after")
(return-type "none")
(parameters
'("guint" "merge_id")
'("const-char*" "parent_path")
'("const-char*" "after")
'("const-char*" "markup")
)
)
(define-method insert_markup_before
(of-object "MooUIXML")
(c-name "moo_ui_xml_insert_markup_before")
(return-type "none")
(parameters
'("guint" "merge_id")
'("const-char*" "parent_path")
'("const-char*" "before")
'("const-char*" "markup")
)
)
(define-method insert_markup
(of-object "MooUIXML")
(c-name "moo_ui_xml_insert_markup")
(return-type "none")
(parameters
'("guint" "merge_id")
'("const-char*" "parent_path")
'("int" "position")
'("const-char*" "markup")
)
)
(define-method remove_ui
(of-object "MooUIXML")
(c-name "moo_ui_xml_remove_ui")
(return-type "none")
(parameters
'("guint" "merge_id")
)
)
(define-method remove_node
(of-object "MooUIXML")
(c-name "moo_ui_xml_remove_node")
(return-type "none")
(parameters
'("MooUINode*" "node")
)
)
;; From ../mooutils/moowin.h
(define-function moo_window_is_hidden
@ -2255,3 +1878,177 @@
(c-name "moo_closure_invalidate")
(return-type "none")
)
;; From ./moo/mooutils/moouixml.h
(define-function moo_ui_xml_new
(c-name "moo_ui_xml_new")
(is-constructor-of "MooUiXml")
(return-type "MooUIXML*")
)
(define-method add_ui_from_string
(of-object "MooUIXML")
(c-name "moo_ui_xml_add_ui_from_string")
(return-type "none")
(parameters
'("const-char*" "buffer")
'("gssize" "length")
)
)
(define-method get_node
(of-object "MooUIXML")
(c-name "moo_ui_xml_get_node")
(return-type "MooUINode*")
(parameters
'("const-char*" "path")
)
)
(define-method find_placeholder
(of-object "MooUIXML")
(c-name "moo_ui_xml_find_placeholder")
(return-type "MooUINode*")
(parameters
'("const-char*" "name")
)
)
(define-method get_path
(of-object "MooUINode")
(c-name "moo_ui_node_get_path")
(return-type "char*")
)
(define-method get_child
(of-object "MooUINode")
(c-name "moo_ui_node_get_child")
(return-type "MooUINode*")
(parameters
'("const-char*" "path")
)
)
(define-method create_widget
(of-object "MooUIXML")
(c-name "moo_ui_xml_create_widget")
(return-type "GtkWidget*")
(parameters
'("MooUIWidgetType" "type")
'("const-char*" "path")
'("MooActionGroup*" "actions")
'("GtkAccelGroup*" "accel_group")
)
)
(define-method new_merge_id
(of-object "MooUIXML")
(c-name "moo_ui_xml_new_merge_id")
(return-type "guint")
)
(define-method add_item
(of-object "MooUIXML")
(c-name "moo_ui_xml_add_item")
(return-type "MooUINode*")
(parameters
'("guint" "merge_id")
'("const-char*" "parent_path")
'("const-char*" "name")
'("const-char*" "action")
'("int" "position")
)
)
(define-method insert_after
(of-object "MooUIXML")
(c-name "moo_ui_xml_insert_after")
(return-type "none")
(parameters
'("guint" "merge_id")
'("MooUINode*" "parent")
'("MooUINode*" "after")
'("const-char*" "markup")
)
)
(define-method insert_before
(of-object "MooUIXML")
(c-name "moo_ui_xml_insert_before")
(return-type "none")
(parameters
'("guint" "merge_id")
'("MooUINode*" "parent")
'("MooUINode*" "before")
'("const-char*" "markup")
)
)
(define-method insert
(of-object "MooUIXML")
(c-name "moo_ui_xml_insert")
(return-type "none")
(parameters
'("guint" "merge_id")
'("MooUINode*" "parent")
'("int" "position")
'("const-char*" "markup")
)
)
(define-method insert_markup_after
(of-object "MooUIXML")
(c-name "moo_ui_xml_insert_markup_after")
(return-type "none")
(parameters
'("guint" "merge_id")
'("const-char*" "parent_path")
'("const-char*" "after")
'("const-char*" "markup")
)
)
(define-method insert_markup_before
(of-object "MooUIXML")
(c-name "moo_ui_xml_insert_markup_before")
(return-type "none")
(parameters
'("guint" "merge_id")
'("const-char*" "parent_path")
'("const-char*" "before")
'("const-char*" "markup")
)
)
(define-method insert_markup
(of-object "MooUIXML")
(c-name "moo_ui_xml_insert_markup")
(return-type "none")
(parameters
'("guint" "merge_id")
'("const-char*" "parent_path")
'("int" "position")
'("const-char*" "markup")
)
)
(define-method remove_ui
(of-object "MooUIXML")
(c-name "moo_ui_xml_remove_ui")
(return-type "none")
(parameters
'("guint" "merge_id")
)
)
(define-method remove_node
(of-object "MooUIXML")
(c-name "moo_ui_xml_remove_node")
(return-type "none")
(parameters
'("MooUINode*" "node")
)
)

View File

@ -19,6 +19,7 @@ headers
#include "mooutils/moonotebook.h"
#include "mooutils/mooentry.h"
#include "mooutils/moostock.h"
#include "mooutils/moouixml.h"
#include "mooutils/mooutils-python.h"

View File

@ -2243,3 +2243,45 @@ moo_ui_xml_finalize (GObject *object)
G_OBJECT_CLASS(moo_ui_xml_parent_class)->finalize (object);
}
static gpointer
ptr_copy (gpointer boxed)
{
return boxed;
}
GType
moo_ui_node_get_type (void)
{
static GType type = 0;
if (!type)
type = g_boxed_type_register_static ("MooUINode",
(GBoxedCopyFunc) ptr_copy,
(GBoxedFreeFunc) ptr_copy);
return type;
}
GType
moo_ui_widget_type_get_type (void)
{
static GType type = 0;
if (!type)
{
static const GEnumValue values[] = {
{ MOO_UI_MENUBAR, (char*) "MOO_UI_MENUBAR", (char*) "menubar" },
{ MOO_UI_MENU, (char*) "MOO_UI_MENU", (char*) "menu" },
{ MOO_UI_TOOLBAR, (char*) "MOO_UI_TOOLBAR", (char*) "toolbar" },
{ 0, NULL, NULL }
};
type = g_enum_register_static ("MooUIWidgetType", values);
}
return type;
}

View File

@ -84,6 +84,9 @@ typedef enum {
} MooUIWidgetType;
#define MOO_TYPE_UI_NODE (moo_ui_node_get_type ())
#define MOO_TYPE_UI_WIDGET_TYPE (moo_ui_widget_type_get_type ())
#define MOO_TYPE_UI_XML (moo_ui_xml_get_type ())
#define MOO_UI_XML(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), MOO_TYPE_UI_XML, MooUIXML))
#define MOO_UI_XML_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MOO_TYPE_UI_XML, MooUIXMLClass))
@ -109,6 +112,8 @@ struct _MooUIXMLClass
GType moo_ui_xml_get_type (void) G_GNUC_CONST;
GType moo_ui_node_get_type (void) G_GNUC_CONST;
GType moo_ui_widget_type_get_type (void) G_GNUC_CONST;
MooUIXML *moo_ui_xml_new (void);