From 0fd0a98369b72d63e923b527c4dbcccefc2b0c83 Mon Sep 17 00:00:00 2001 From: Jeffrey Armstrong Date: Thu, 18 Aug 2011 21:50:32 -0400 Subject: Added an interface to the basic GEM file selection dialog. --- lib/gem.c | 8 +++++++- lib/py_aes.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++- lib/py_aes.h | 2 ++ 3 files changed, 56 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/gem.c b/lib/gem.c index 4b7aaa9..a12e5ea 100644 --- a/lib/gem.c +++ b/lib/gem.c @@ -58,6 +58,9 @@ GemMethods[] = { /* AES Object Library */ {"objc_draw", py_objc_draw, METH_VARARGS, "Draw an AES object to the screen"}, + + /* AES File Selector Library */ + {"fsel_input", py_fsel_input, METH_VARARGS, "Opens a basic file selector"}, /* VDI Functions */ {"v_open_screen", py_v_open_screen, METH_NOARGS, "Open and retrieve a handle to a virtual screen workstation"}, @@ -141,6 +144,9 @@ PROC LibFunc[] = { /* AES Object Library */ "py_objc_draw", "Internal\n", py_objc_draw, + /* AES File Selector Library */ + "fsel_input", "Internal\n", py_fsel_input, + /* VDI Functions */ "py_v_open_screen", "Internal\n", py_v_open_screen, "py_v_clsvwk", "Internal\n", py_v_clsvwk, @@ -153,7 +159,7 @@ PROC LibFunc[] = { }; LDGLIB LibLdg[] = { - 0x0001, 32, LibFunc, "GEM Extensions for Python", 0 + 0x0001, 33, LibFunc, "GEM Extensions for Python", 0 }; int main( void) diff --git a/lib/py_aes.c b/lib/py_aes.c index 2372705..f7e8a3d 100644 --- a/lib/py_aes.c +++ b/lib/py_aes.c @@ -570,4 +570,50 @@ int ret; Py_INCREF(Py_None); return Py_None; -} \ No newline at end of file +} + +/* File Selector Library */ +PyObject* __CDECL py_fsel_input(PyObject *self, PyObject *args) +{ +PyObject *ret; +char *path; +char *default_file; + +char *use_path; +char *use_file; +int result; +int pathlen; + + default_file = NULL; + + if(!PyArg_ParseTuple(args,"s|s",&path,&default_file)) + return NULL; + + pathlen = strlen(path); + if(pathlen < 200) pathlen = 200; + + use_path = (char *)malloc(pathlen*sizeof(char)); + strcpy(use_path,path); + + use_file = (char *)malloc(13*sizeof(char)); + use_file[0] = '\0'; + if(default_file != NULL) { + if(strlen(default_file) <= 12) + strcpy(use_file,default_file); + } + + if(fsel_input(use_path,use_file,&result) == 0) { + PyErr_SetString(GEMError,"Basic File Selector call failed."); + return NULL; + } + + if(result == 0) { + free(use_path); + free(use_file); + Py_INCREF(Py_None); + return Py_None; + } else { + ret = Py_BuildValue("ss",use_path,use_file); + return ret; + } +} diff --git a/lib/py_aes.h b/lib/py_aes.h index a8c6b35..e2e3afd 100644 --- a/lib/py_aes.h +++ b/lib/py_aes.h @@ -35,4 +35,6 @@ PyObject* __CDECL py_objc_draw(PyObject *self, PyObject *args); + PyObject* __CDECL py_fsel_input(PyObject *self, PyObject *args); + #endif /* __PY_AES_HEADERS */ -- cgit v1.2.3