Python stuff for MooTerm

master
Yevgen Muntyan 2005-07-22 09:50:25 +00:00
parent fae94b5226
commit 51c94529d3
8 changed files with 213 additions and 37 deletions

View File

@ -14,24 +14,29 @@ subdirs =
noinst_LTLIBRARIES = libmoo.la
libmoo_la_LIBADD =
libmoo_la_SOURCES = dummy.c
moo_pygtk_flags =
if BUILD_MOOUTILS
subdirs += mooutils
libmoo_la_LIBADD += mooutils/libmooutils.la
moo_pygtk_flags += -DBUILD_MOOUTILS
endif
if BUILD_MOOUI
subdirs += mooui
moo_pygtk_flags += -DBUILD_MOOUI
libmoo_la_LIBADD += mooui/libmooui.la
endif
if BUILD_MOOEDIT
subdirs += mooedit
moo_pygtk_flags += -DBUILD_MOOEDIT
libmoo_la_LIBADD += mooedit/libmooedit.la
endif
if BUILD_MOOTERM
subdirs += mooterm
moo_pygtk_flags += -DBUILD_MOOTERM
if !CYGWIN_BUILD
libmoo_la_LIBADD += mooterm/libmooterm.la
endif !CYGWIN_BUILD
@ -39,6 +44,7 @@ endif
if BUILD_MOOAPP
subdirs += mooapp
moo_pygtk_flags += -DBUILD_MOOAPP
if !CYGWIN_BUILD
libmoo_la_LIBADD += mooapp/libmooapp.la
endif !CYGWIN_BUILD
@ -57,7 +63,8 @@ AM_CFLAGS = \
-DMOO_VERSION=\"$(MOO_VERSION)\" \
-DMOO_VERSION_MAJOR=$(MOO_VERSION_MAJOR)\
-DMOO_VERSION_MINOR=$(MOO_VERSION_MINOR)\
-DMOO_VERSION_MICRO=$(MOO_VERSION_MICRO)
-DMOO_VERSION_MICRO=$(MOO_VERSION_MICRO)\
$(moo_pygtk_flags)
EXTRA_DIST = moo-pygtk.c
@ -75,7 +82,7 @@ if BUILD_PYMOO
pyexec_LTLIBRARIES = moo.la
moo_la_SOURCES = dummy.c moo-pygtk.c
moo_la_SOURCES = moo-pygtk.c
if MINGW_BUILD
mingw_flags = -no-undefined

View File

@ -1 +1 @@
// empty file to make automake happy
/* empty file to make automake happy */

View File

@ -86,8 +86,19 @@ void initmoo (void)
PyModule_AddObject (moo_module, (char*)"version", moo_version());
PyModule_AddObject (moo_module, (char*)"detailed_version", moo_detailed_version());
#ifdef BUILD_MOOUTILS
mod_init (moo_utils);
#endif
#ifdef BUILD_MOOUI
mod_init (moo_ui);
#endif
#ifdef BUILD_MOOEDIT
mod_init (moo_edit);
#endif
#ifdef BUILD_MOOTERM
mod_init (moo_term);
#endif
#ifdef BUILD_MOOAPP
mod_init (moo_app);
#endif
}

View File

@ -54,33 +54,47 @@ EXTRA_DIST = \
$(widget_unix_sources) \
$(widget_win32_sources)
############################################################################
# UNIX
#
if UNIX_BUILD
noinst_LTLIBRARIES = libmooterm.la
libmooterm_la_SOURCES =
BUILT_SOURCES =
libmooterm_la_SOURCES = $(widget_sources) $(widget_unix_sources)
BUILT_SOURCES = mootermparser-yacc.c mootermparser-yacc.h
if UNIX_BUILD
libmooterm_la_SOURCES += $(widget_sources) $(widget_unix_sources)
BUILT_SOURCES += mootermparser-yacc.c mootermparser-yacc.h
endif UNIX_BUILD
############################################################################
# MINGW
#
if MINGW_BUILD
noinst_LTLIBRARIES = libmooterm.la
libmooterm_la_SOURCES = $(widget_sources) $(widget_win32_sources)
BUILT_SOURCES = mootermparser-yacc.c mootermparser-yacc.h
libmooterm_la_SOURCES += $(widget_sources) $(widget_win32_sources)
BUILT_SOURCES += mootermparser-yacc.c mootermparser-yacc.h
endif MINGW_BUILD
##############################################################################
# Pygtk stuff
#
EXTRA_DIST += mooterm-mod.c mooterm-pygtk.defs mooterm-pygtk.override
if USE_PYGTK
libmooterm_la_SOURCES += mooterm-mod.c
nodist_libmooterm_la_SOURCES = mooterm-pygtk.c
BUILT_SOURCES += mooterm-pygtk.c
CLEANFILES = mooterm-pygtk.c
mooterm-pygtk.c: $(srcdir)/mooterm-pygtk.defs $(srcdir)/mooterm-pygtk.override
pygtk-codegen-2.0 --prefix moo_term \
--register $(PYGTK_DEFS_DIR)/gtk-types.defs \
--register $(PYGTK_DEFS_DIR)/gdk-types.defs \
--register $(srcdir)/../mooui/mooui-pygtk.defs \
--override $(srcdir)/mooterm-pygtk.override \
$(srcdir)/mooterm-pygtk.defs > mooterm-pygtk.c
endif USE_PYGTK
############################################################################
# CYGWIN
#

42
moo/mooterm/mooterm-mod.c Normal file
View File

@ -0,0 +1,42 @@
/*
* mooterm/mooterm-mod.c
*
* Copyright (C) 2004-2005 by Yevgen Muntyan <muntyan@math.tamu.edu>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* See COPYING file that comes with this distribution.
*/
#include <Python.h>
#define NO_IMPORT_PYGOBJECT
#include <pygobject.h>
#include <glib.h>
void moo_term_mod_init (PyObject *moo_mod);
void moo_term_register_classes (PyObject *dict);
void moo_term_add_constants (PyObject *module,
const gchar *strip_prefix);
extern PyMethodDef moo_term_functions[];
static char *moo_term_module_doc = (char*)"moo.term module.";
void moo_term_mod_init (PyObject *moo_mod)
{
PyObject *mod;
mod = Py_InitModule3 ("moo.term", moo_term_functions, moo_term_module_doc);
g_return_if_fail (mod != NULL);
Py_INCREF (mod);
PyModule_AddObject (moo_mod, "term", mod);
// moo_term_add_constants (mod, "MOO_");
moo_term_register_classes (PyModule_GetDict (moo_mod));
}

View File

@ -0,0 +1,55 @@
;;
;; mooterm/mooterm-pygtk.defs
;;
; object definitions ...
(define-object Term
(in-module "Moo")
(parent "GtkWidget")
(c-name "MooTerm")
(gtype-id "MOO_TYPE_TERM")
)
;; Enumerations and flags ...
(define-function moo_term_new
(c-name "moo_term_new")
(is-constructor-of "MooTerm")
(return-type "MooTerm*")
(parameters
'("guint" "width")
'("guint" "height")
)
)
(define-method feed
(of-object "MooTerm")
(c-name "moo_term_feed")
(return-type "none")
(parameters
'("const-gchar*" "data")
'("int" "len" (default "-1"))
)
)
(define-method feed_child
(of-object "MooTerm")
(c-name "moo_term_feed_child")
(return-type "none")
(parameters
'("const-gchar*" "data")
'("int" "len" (default "-1"))
)
)
(define-method fork_command
(of-object "MooTerm")
(c-name "moo_term_fork_command")
(return-type "gboolean")
(parameters
'("const-gchar*" "cmd")
'("const-gchar*" "working_dir" (null-ok) (default "NULL"))
'("char**" "envp" (null-ok) (default "NULL"))
)
)

View File

@ -0,0 +1,47 @@
%%
headers
#include <Python.h>
#define NO_IMPORT_PYGOBJECT
#include "pygobject.h"
#include "mooterm/mooterm.h"
%%
modulename moo
%%
import gtk.Widget as PyGtkWidget_Type
import gobject.GObject as PyGObject_Type
%%
ignore-glob
*_get_type
%%
override moo_term_new kwargs
static int
_wrap_moo_term_new (PyGObject *self, PyObject *args, PyObject *kwargs)
{
static char *kwlist[] = {NULL};
if (!PyArg_ParseTupleAndKeywords (args, kwargs, ":Term", kwlist))
return -1;
self->obj = g_object_new (MOO_TYPE_TERM, NULL);
pygobject_register_wrapper (self);
return 0;
}
%%
override moo_term_fork_command kwargs
static PyObject *
_wrap_moo_term_fork_command (PyGObject *self, PyObject *args, PyObject *kwargs)
{
static char *kwlist[] = {"cmd", "working_dir", NULL};
const char *cmd = NULL;
const char *working_dir = NULL;
if (!PyArg_ParseTupleAndKeywords (args, kwargs, "s|s:Term.fork_command",
kwlist, &cmd, &working_dir))
return NULL;
moo_term_fork_command (MOO_TERM (self->obj), cmd, working_dir, NULL);
Py_INCREF(Py_None);
return Py_None;
}

View File

@ -24,7 +24,7 @@
</ignoreparts>
<projectdirectory>.</projectdirectory>
<absoluteprojectpath>false</absoluteprojectpath>
<description/>
<description></description>
<secondaryLanguages>
<language>C</language>
</secondaryLanguages>
@ -39,28 +39,28 @@
<mainprogram>tests/mterm</mainprogram>
<directoryradio>executable</directoryradio>
<customdirectory>/</customdirectory>
<programargs/>
<programargs> --dump-trace</programargs>
<terminal>false</terminal>
<autocompile>true</autocompile>
<envvars/>
</run>
<configurations>
<debug>
<configargs>--enable-debug=full --enable-all-gcc-warnings=fatal --enable-developer-mode --without-mooedit --without-mooapp --without-python</configargs>
<configargs>--enable-debug=full --enable-all-gcc-warnings=fatal --enable-developer-mode --without-mooedit --without-mooapp</configargs>
<builddir>build/mooterm-debug</builddir>
<ccompiler>kdevgccoptions</ccompiler>
<cxxcompiler>kdevgppoptions</cxxcompiler>
<f77compiler>kdevpgf77options</f77compiler>
<f77compiler>kdevg77options</f77compiler>
<cflags>-O0 -g3 -pg</cflags>
<cxxflags>-O0 -g3 -pg</cxxflags>
<envvars/>
<topsourcedir/>
<cppflags/>
<ldflags/>
<ccompilerbinary/>
<cxxcompilerbinary/>
<f77compilerbinary/>
<f77flags/>
<topsourcedir></topsourcedir>
<cppflags></cppflags>
<ldflags></ldflags>
<ccompilerbinary></ccompilerbinary>
<cxxcompilerbinary></cxxcompilerbinary>
<f77compilerbinary></f77compilerbinary>
<f77flags></f77flags>
</debug>
<gcc-4.0>
<configargs>--enable-debug=full --enable-all-gcc-warnings=fatal --enable-developer-mode --without-mooedit --without-mooapp --without-python</configargs>
@ -167,11 +167,11 @@
<kdevdebugger>
<general>
<dbgshell>libtool</dbgshell>
<programargs>--g-fatal-warnings --debug bash</programargs>
<gdbpath/>
<configGdbScript/>
<runShellScript/>
<runGdbScript/>
<programargs>--set-breakpoint bash</programargs>
<gdbpath></gdbpath>
<configGdbScript></configGdbScript>
<runShellScript></runShellScript>
<runGdbScript></runGdbScript>
<breakonloadinglibs>true</breakonloadinglibs>
<separatetty>false</separatetty>
<floatingtoolbar>true</floatingtoolbar>
@ -272,7 +272,7 @@
</codecompletion>
<references/>
<creategettersetter>
<prefixGet/>
<prefixGet></prefixGet>
<prefixSet>set</prefixSet>
<prefixVariable>m_,_</prefixVariable>
<parameterName>theValue</parameterName>