From: ewt Date: Fri, 21 Jan 2000 18:54:53 +0000 (+0000) Subject: - added newtCheckboxTreeGetCurrent() and snack bindings X-Git-Tag: r0-50-5~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2b6641b114fee9734a4316f7e29dbdac1debde83;p=thirdparty%2Fnewt.git - added newtCheckboxTreeGetCurrent() and snack bindings - updated snack stuff to allow manual placement of grid wrapped windows --- diff --git a/CHANGES b/CHANGES index 5a07e73..ab47d21 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,11 @@ +0.54 -> 0.55 + - added newtCheckboxTreeGetCurrent() and snack bindings + - updated snack stuff to allow manual placement of grid + wrapped windows + +0.53 -> 0.54 + - fix segfault in newtRadioGetCurrent + 0.52 -> 0.53 - place cursor in checkboxtree's more carefully diff --git a/Makefile.in b/Makefile.in index eab67e1..d6e5166 100644 --- a/Makefile.in +++ b/Makefile.in @@ -116,7 +116,12 @@ install-sh: sharedlib whiptcl.so _snackmodule.so install -m 755 _snackmodule.so $(instroot)/$(pythonbindir) install -m 755 snack.py $(instroot)/$(pythondir) -archive: +configure: configure.in + autoconf + echo "You need to rerun ./configure before continuing" + exit 1 + +archive: configure @cvs tag -F $(CVSTAG) @rm -rf /tmp/newt-$(VERSION) /tmp/newt @cd /tmp; cvs export -r$(CVSTAG) newt; mv newt newt-$(VERSION) diff --git a/checkboxtree.c b/checkboxtree.c index c52483c..8419f39 100644 --- a/checkboxtree.c +++ b/checkboxtree.c @@ -256,7 +256,7 @@ static struct items * findItem(struct items * items, const void * data) { return NULL; } -static void listSelected(struct items * items, int * num, void ** list, int seqindex) { +static void listSelected(struct items * items, int * num, const void ** list, int seqindex) { while (items) { if ((seqindex ? items->selected==seqindex : items->selected) && !items->branch) list[(*num)++] = items->data; @@ -266,15 +266,15 @@ static void listSelected(struct items * items, int * num, void ** list, int seqi } } -void ** newtCheckboxTreeGetSelection(newtComponent co, int *numitems) +const void ** newtCheckboxTreeGetSelection(newtComponent co, int *numitems) { return newtCheckboxTreeGetMultiSelection(co, numitems, 0); } -void ** newtCheckboxTreeGetMultiSelection(newtComponent co, int *numitems, char seqnum) +const void ** newtCheckboxTreeGetMultiSelection(newtComponent co, int *numitems, char seqnum) { struct CheckboxTree * ct; - void **retval; + const void **retval; int seqindex=0; if(!co || !numitems) return NULL; @@ -572,3 +572,10 @@ struct eventResult ctEvent(newtComponent co, struct event ev) { return er; } + +const void * newtCheckboxTreeGetCurrent(newtComponent co) { + struct CheckboxTree * ct = co->data; + + if (!ct->currItem) return NULL; + return (*ct->currItem)->data; +} diff --git a/configure.in b/configure.in index 1a045b1..92bb22f 100644 --- a/configure.in +++ b/configure.in @@ -2,7 +2,7 @@ dnl Process this file with autoconf to produce a configure script. AC_INIT(newt_pr.h) AC_CONFIG_HEADER(config.h) -VERSION=0.50.4 +VERSION=0.50.5 SONAME=0.50 AC_SUBST(VERSION) AC_SUBST(SONAME) diff --git a/newt.h b/newt.h index 7f396fb..6d9b62e 100644 --- a/newt.h +++ b/newt.h @@ -168,8 +168,9 @@ void newtListboxSelectItem(newtComponent co, const void * key, newtComponent newtCheckboxTree(int left, int top, int height, int flags); newtComponent newtCheckboxTreeMulti(int left, int top, int height, char *seq, int flags); -void ** newtCheckboxTreeGetSelection(newtComponent co, int *numitems); -void ** newtCheckboxTreeGetMultiSelection(newtComponent co, int *numitems, char seqnum); +const void ** newtCheckboxTreeGetSelection(newtComponent co, int *numitems); +const void * newtCheckboxTreeGetCurrent(newtComponent co); +const void ** newtCheckboxTreeGetMultiSelection(newtComponent co, int *numitems, char seqnum); /* last item is NEWT_ARG_LAST for all of these */ int newtCheckboxTreeAddItem(newtComponent co, const char * text, const void * data, diff --git a/newt.spec b/newt.spec index 8f17910..6bd0a22 100644 --- a/newt.spec +++ b/newt.spec @@ -55,6 +55,9 @@ rm -rf $RPM_BUILD_ROOT %postun -p /sbin/ldconfig %changelog +* Thu Jan 20 2000 Erik Troan +- see CHANGES + * Thu Jan 20 2000 Preston Brown - fix segfault in newtRadioGetCurrent diff --git a/popcorn.py b/popcorn.py index 3b3919b..588574c 100755 --- a/popcorn.py +++ b/popcorn.py @@ -11,7 +11,7 @@ li.insert("Another", "a", "f") li.delete("a") ct = CheckboxTree(5, scroll = 1) ct.append("Colors") -ct.addItem("Red", (0, snackArgs['append'])) +ct.addItem("Red", (0, snackArgs['append']), "red item key") ct.addItem("Yellow", (0, snackArgs['append'])) ct.addItem("Blue", (0, snackArgs['append'])) ct.append("Flavors") @@ -106,3 +106,5 @@ print res print foo print 'lbcw', lbcw +print "ct selected", ct.getSelection() +print "ct current", ct.getCurrent() diff --git a/snack.py b/snack.py index a8820e9..635296d 100644 --- a/snack.py +++ b/snack.py @@ -267,7 +267,10 @@ class SnackScreen: def centeredWindow(self, width, height, title): return _snack.centeredwindow(width, height, title) - def gridWrappedWindow(self, grid, title): + def gridWrappedWindow(self, grid, title, x = None, y = None): + if x and y: + return _snack.gridwrappedwindow(grid.g, title, x, y) + return _snack.gridwrappedwindow(grid.g, title) def popWindow(self): @@ -378,8 +381,8 @@ class GridForm(Grid): growx, growy); self.childList.append(widget) - def runOnce(self): - result = self.run() + def runOnce(self, x = None, y = None): + result = self.run(x, y) self.screen.popWindow() return result @@ -389,16 +392,16 @@ class GridForm(Grid): def setTimer(self, keyname): self.form.setTimer(keyname) - def create(self): + def create(self, x = None, y = None): if not self.form_created: self.place(1,1) for child in self.childList: self.form.add(child) - self.screen.gridWrappedWindow(self, self.title) + self.screen.gridWrappedWindow(self, self.title, x, y) self.form_created = 1 - def run(self): - self.create() + def run(self, x = None, y = None): + self.create(x, y) return self.form.run() def draw(self): @@ -426,6 +429,10 @@ class CheckboxTree(Widget): self.key2item[key] = item self.item2key[item] = key + def getCurrent(self): + curr = self.w.checkboxtreeGetCurrent() + return self.key2item[curr] + def __init__(self, height, scroll = 0): self.w = _snack.checkboxtree(height, scroll) self.key2item = {} @@ -477,14 +484,14 @@ def ListboxChoiceWindow(screen, title, text, items, def ButtonChoiceWindow(screen, title, text, buttons = [ 'Ok', 'Cancel' ], - width = 40): + width = 40, x = None, y = None): bb = ButtonBar(screen, buttons) t = TextboxReflowed(width, text, maxHeight = screen.height - 12) g = GridForm(screen, title, 1, 2) g.add(t, 0, 0, padding = (0, 0, 0, 1)) g.add(bb, 0, 1, growx = 1) - return bb.buttonPressed(g.runOnce()) + return bb.buttonPressed(g.runOnce(x, y)) def EntryWindow(screen, title, text, prompts, allowCancel = 1, width = 40, entryWidth = 20, buttons = [ 'Ok', 'Cancel' ]): diff --git a/snackmodule.c b/snackmodule.c index ff0392e..4622c31 100644 --- a/snackmodule.c +++ b/snackmodule.c @@ -179,6 +179,7 @@ static PyObject * widgetListboxSet(snackWidget * s, PyObject * args); static PyObject * widgetTextboxText(snackWidget * s, PyObject * args); static PyObject * widgetCheckboxTreeAddItem(snackWidget * s, PyObject * args); static PyObject * widgetCheckboxTreeGetSel(snackWidget * s, PyObject * args); +static PyObject * widgetCheckboxTreeGetCur(snackWidget * s, PyObject * args); static PyObject * widgetEntrySetFlags(snackWidget * s, PyObject * args); static PyObject * widgetCheckboxSetFlags(snackWidget * s, PyObject * args); @@ -196,6 +197,8 @@ static PyMethodDef widgetMethods[] = { { "scaleSet", (PyCFunction) scaleSet, METH_VARARGS, NULL }, { "checkboxtreeAddItem", (PyCFunction) widgetCheckboxTreeAddItem, METH_VARARGS, NULL }, + { "checkboxtreeGetCurrent", (PyCFunction) widgetCheckboxTreeGetCur, + METH_VARARGS, NULL }, { "checkboxtreeGetSelection", (PyCFunction) widgetCheckboxTreeGetSel, METH_VARARGS, NULL }, { "entrySetFlags", (PyCFunction) widgetEntrySetFlags, METH_VARARGS, NULL }, @@ -427,11 +430,16 @@ static PyObject * centeredWindow(PyObject * s, PyObject * args) { static PyObject * gridWrappedWindow(PyObject * s, PyObject * args) { snackGrid * grid; char * title; + int x = -1, y = -1; - if (!PyArg_ParseTuple(args, "O!s", &snackGridType, &grid, &title)) + if (!PyArg_ParseTuple(args, "O!s|ii", &snackGridType, &grid, &title, + &x, &y)) return NULL; - newtGridWrappedWindow(grid->grid, title); + if (y == -1) + newtGridWrappedWindow(grid->grid, title); + else + newtGridWrappedWindowAt(grid->grid, title, x, y); Py_INCREF(Py_None); return Py_None; @@ -959,6 +967,13 @@ static PyObject * widgetCheckboxTreeAddItem(snackWidget * s, PyObject * args) { return PyInt_FromLong(s->anint++); } +static PyObject * widgetCheckboxTreeGetCur(snackWidget * s, PyObject * args) { + if (!PyArg_ParseTuple(args, "")) + return NULL; + + return PyInt_FromLong((int) newtCheckboxTreeGetCurrent(s->co)); +} + static PyObject * widgetCheckboxTreeGetSel(snackWidget * s, PyObject * args) { void ** selection; @@ -966,6 +981,9 @@ static PyObject * widgetCheckboxTreeGetSel(snackWidget * s, int i; PyObject * sel; + if (!PyArg_ParseTuple(args, "")) + return NULL; + selection = newtCheckboxTreeGetSelection(s->co, &numselected); sel = PyList_New(0);