Made moo module behave more like a package

master
Yevgen Muntyan 2006-03-11 14:21:41 -06:00
parent f7ab625767
commit 1a221d9610
7 changed files with 32 additions and 16 deletions

View File

@ -1,10 +1,12 @@
"""moo module"""
if @MOO_BUILD_UTILS@:
import moo_utils as utils
if @MOO_BUILD_TERM@:
import moo_term as term
if @MOO_BUILD_EDIT@:
import moo_edit as edit
if @MOO_BUILD_APP@:
import moo_app as app
from _moo import *
#if @MOO_BUILD_UTILS@:
# import moo_utils as utils
#if @MOO_BUILD_TERM@:
# import moo_term as term
#if @MOO_BUILD_EDIT@:
# import moo_edit as edit
#if @MOO_BUILD_APP@:
# import moo_app as app

View File

@ -60,7 +60,7 @@ func_init_pygobject (void)
gboolean
_moo_pygtk_init (void)
{
PyObject *_moo_module, *code, *moo_mod;
PyObject *_moo_module, *code, *moo_mod, *submod;
func_init_pygobject ();
@ -72,24 +72,34 @@ _moo_pygtk_init (void)
if (PyErr_Occurred ())
return FALSE;
PyImport_AddModule ("moo");
PyModule_AddObject (_moo_module, (char*)"version", moo_version());
PyModule_AddObject (_moo_module, (char*)"detailed_version", moo_detailed_version());
#ifdef MOO_BUILD_UTILS
if (!_moo_utils_mod_init ())
return FALSE;
submod = PyImport_ImportModule ("moo.utils");
PyModule_AddObject (_moo_module, "utils", submod);
#endif
#ifdef MOO_BUILD_TERM
if (!_moo_term_mod_init ())
return FALSE;
submod = PyImport_ImportModule ("moo.term");
PyModule_AddObject (_moo_module, "term", submod);
#endif
#ifdef MOO_BUILD_EDIT
if (!_moo_edit_mod_init ())
return FALSE;
submod = PyImport_ImportModule ("moo.edit");
PyModule_AddObject (_moo_module, "edit", submod);
#endif
#ifdef MOO_BUILD_APP
if (!_moo_app_mod_init ())
return FALSE;
submod = PyImport_ImportModule ("moo.app");
PyModule_AddObject (_moo_module, "app", submod);
#endif
code = Py_CompileString (MOO_PY, "moo/__init__.py", Py_file_input);

View File

@ -28,6 +28,7 @@ _moo_app_mod_init (void)
PyObject *mod;
mod = Py_InitModule3 ((char*) "_moo_app", _moo_app_functions, moo_app_module_doc);
PyImport_AddModule ("moo.app");
if (!mod)
return FALSE;
@ -45,7 +46,7 @@ _moo_app_mod_init (void)
if (!code)
return FALSE;
fake_mod = PyImport_ExecCodeModule ((char*) "moo_app", code);
fake_mod = PyImport_ExecCodeModule ((char*) "moo.app", code);
Py_DECREF (code);
if (!fake_mod)

View File

@ -28,6 +28,7 @@ _moo_edit_mod_init (void)
PyObject *mod;
mod = Py_InitModule3 ((char*) "_moo_edit", _moo_edit_functions, moo_edit_module_doc);
PyImport_AddModule ("moo.edit");
if (!mod)
return FALSE;
@ -44,7 +45,7 @@ _moo_edit_mod_init (void)
if (!code)
return FALSE;
fake_mod = PyImport_ExecCodeModule ((char*) "moo_edit", code);
fake_mod = PyImport_ExecCodeModule ((char*) "moo.edit", code);
Py_DECREF (code);
if (!fake_mod)

View File

@ -28,6 +28,7 @@ _moo_term_mod_init (void)
PyObject *mod;
mod = Py_InitModule3 ((char*) "_moo_term", _moo_term_functions, moo_term_module_doc);
PyImport_AddModule ("moo.term");
if (!mod)
return FALSE;
@ -44,7 +45,7 @@ _moo_term_mod_init (void)
if (!code)
return FALSE;
fake_mod = PyImport_ExecCodeModule ((char*) "moo_term", code);
fake_mod = PyImport_ExecCodeModule ((char*) "moo.term", code);
Py_DECREF (code);
if (!fake_mod)

View File

@ -64,7 +64,7 @@
(gtype-id "MOO_TYPE_TERM_LINE")
)
(define-boxed Attr
(define-boxed TextAttr
(in-module "Moo")
(c-name "MooTermTextAttr")
(gtype-id "MOO_TYPE_TERM_TEXT_ATTR")
@ -734,8 +734,8 @@
(return-type "MooTermTextAttr*")
(parameters
'("MooTermTextAttrMask" "mask")
'("MooTermTextColor" "foreground")
'("MooTermTextColor" "background")
'("MooTermTextColor" "foreground" (null-ok) (default "0"))
'("MooTermTextColor" "background" (null-ok) (default "0"))
)
(docstring "TextAttr(mask, foreground=0, background=0) -> TextAttr.\n"
"\n"

View File

@ -51,6 +51,7 @@ _moo_utils_mod_init (void)
pyg_register_boxed_custom (MOO_TYPE_PY_OBJECT, pyobj_from_gval, gval_from_pyobj);
mod = Py_InitModule3 ((char*) "_moo_utils", _moo_utils_functions, moo_utils_module_doc);
PyImport_AddModule ("moo.utils");
if (!mod)
return FALSE;
@ -98,7 +99,7 @@ _moo_utils_mod_init (void)
if (!code)
return FALSE;
fake_mod = PyImport_ExecCodeModule ((char*) "moo_utils", code);
fake_mod = PyImport_ExecCodeModule ((char*) "moo.utils", code);
Py_DECREF (code);
if (!fake_mod)