]> git.ipfire.org Git - thirdparty/newt.git/commitdiff
- added newtCheckboxTreeGetCurrent() and snack bindings
authorewt <ewt>
Fri, 21 Jan 2000 18:54:53 +0000 (18:54 +0000)
committerewt <ewt>
Fri, 21 Jan 2000 18:54:53 +0000 (18:54 +0000)
- updated snack stuff to allow manual placement of grid wrapped windows

CHANGES
Makefile.in
checkboxtree.c
configure.in
newt.h
newt.spec
popcorn.py
snack.py
snackmodule.c

diff --git a/CHANGES b/CHANGES
index 5a07e73440a08440270c281db4494bbaa8cba33f..ab47d2137539ba0d449a011c98ff47ea336bd2e9 100644 (file)
--- 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
 
index eab67e1ab75ba1d9746d165b656b9ffd4a2f6fe7..d6e516618186b34dc077824aa2767cabaec11cee 100644 (file)
@@ -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)
index c52483c726cd7e9de9067410e2f90f8cb3ce9559..8419f39736c99e06072f2697b355791ae548536d 100644 (file)
@@ -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;
+}
index 1a045b1f9869facff9fba55b821df17b67d16aaf..92bb22f70ff34f8e14def8cf26197850fdcf5fe9 100644 (file)
@@ -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 7f396fbf60976e17b5c77ed38c500b3245e8e40e..6d9b62e7b7d4f413ea9ac6b8bd1b2fbbb15921cc 100644 (file)
--- 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,
index 8f1791060b22e451c9d4fde08718378db098ddcd..6bd0a22980ce8752e163740086bee27cb4b40da0 100644 (file)
--- 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 <ewt@redhat.com>
+- see CHANGES
+
 * Thu Jan 20 2000 Preston Brown <pbrown@redhat.com>
 - fix segfault in newtRadioGetCurrent
 
index 3b3919ba1ba4b745fc59ea567c3ff698ffd492b1..588574cc64b06d69029380dd343d4b7fd8905aac 100755 (executable)
@@ -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()
index a8820e942a2bda228b5be4d3dc541a372254af40..635296d5a5588ff60b25a85baae47dc757c91459 100644 (file)
--- 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' ]):
index ff0392e02c5eeb84016aa28dfa3e1c5c9ed27c39..4622c31614286ab2e398c85136a33b27fc585444 100644 (file)
@@ -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);