]> git.ipfire.org Git - thirdparty/newt.git/commitdiff
- added python binding for newtListboxClear() for Listbox and CListBox
authorkatzj <katzj>
Fri, 8 Jun 2001 14:15:23 +0000 (14:15 +0000)
committerkatzj <katzj>
Fri, 8 Jun 2001 14:15:23 +0000 (14:15 +0000)
- let ButtonBars optionally be made of CompactButtons

newt.spec
snack.py
snackmodule.c

index 32e66d38d26db90451a5889316555ed46e131830..af7736ea1c40a42f26ad52e5efee157968a4b3a2 100644 (file)
--- a/newt.spec
+++ b/newt.spec
@@ -1,6 +1,6 @@
 Summary: A development library for text mode user interfaces.
 Name: newt
-%define version 0.50.24
+%define version 0.50.25
 Version: %{version}
 Release: 1
 Copyright: LGPL
@@ -105,6 +105,10 @@ rm -rf $RPM_BUILD_ROOT
 %endif
 
 %changelog
+* Fri Jun 8 2001 Jeremy Katz <katzj@redhat.com>
+- added python binding for newtListboxClear() for Listbox and CListBox
+- let ButtonBars optionally be made of CompactButtons
+
 * Wed Jun  6 2001 Crutcher Dunnavant <crutcher@redhat.com>
 - added CListBox python convenience class
 
index fe330eafec02857709527e66b45820140dea2ca8..7711af192cb5652d5b25925ea01c78be552d485f 100644 (file)
--- a/snack.py
+++ b/snack.py
@@ -96,6 +96,11 @@ class Listbox(Widget):
     def setCurrent(self, item):
        self.w.listboxSetCurrent(self.item2key[item])
 
+    def clear(self):
+        self.key2item = {}
+        self.item2key = {}        
+        self.w.listboxClear()
+
     def __init__(self, height, scroll = 0, returnExit = 0, width = 0):
        self.w = _snack.listbox(height, scroll, returnExit)
        self.key2item = {}
@@ -355,7 +360,7 @@ class RadioBar(Grid):
 
 class ButtonBar(Grid):
 
-    def __init__(self, screen, buttonlist):
+    def __init__(self, screen, buttonlist, compact = 0):
        self.list = []
        self.hotkeys = {}
        self.item = 0
@@ -370,7 +375,10 @@ class ButtonBar(Grid):
                (title, value, hotkey) = blist
                self.hotkeys[hotkey] = value
 
-           b = Button(title)
+            if compact:
+                b = CompactButton(title)
+            else:
+                b = Button(title)
            self.list.append((b, value))
            self.setField(b, self.item, 0, (1, 0, 1, 0))
            self.item = self.item + 1
@@ -615,9 +623,9 @@ class CListBox(Grid):
                        delta = self.col_widths[i] - len(cstr)
                        if delta > 0:
                                if align == None:
-                                       a = LEFT
-                               else:
-                                       a = align[i]
+                                    a = LEFT
+                                else:
+                                    a = align[i]
 
                                if a == LEFT:
                                        cstr = cstr + (" " * delta)
@@ -664,4 +672,6 @@ class CListBox(Grid):
 
        def setCurrent(self, item):
                self.listbox.setCurrent(item)
-               
+
+        def clear(self):
+            self.listbox.clear()
index ca430ac98267238baf33d1362a4678a615ca47ef..d42d52bb2dc9dcfd8700f1f09955cab9320303c2 100644 (file)
@@ -186,6 +186,7 @@ static PyObject * widgetListboxIns(snackWidget * s, PyObject * args);
 static PyObject * widgetListboxDel(snackWidget * s, PyObject * args);
 static PyObject * widgetListboxGet(snackWidget * s, PyObject * args);
 static PyObject * widgetListboxSet(snackWidget * s, PyObject * args);
+static PyObject * widgetListboxClear(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);
@@ -209,6 +210,7 @@ static PyMethodDef widgetMethods[] = {
     { "listboxSetCurrent", (PyCFunction) widgetListboxSet, METH_VARARGS, NULL },
     { "listboxSetWidth", (PyCFunction) widgetListboxSetW, METH_VARARGS, NULL },
     { "listboxDeleteItem", (PyCFunction) widgetListboxDel, METH_VARARGS, NULL },
+    { "listboxClear", (PyCFunction) widgetListboxClear, METH_VARARGS, NULL },
     { "scaleSet", (PyCFunction) scaleSet, METH_VARARGS, NULL },
     { "checkboxtreeAddItem", (PyCFunction) widgetCheckboxTreeAddItem,
       METH_VARARGS, NULL },
@@ -1016,6 +1018,16 @@ static PyObject * widgetListboxSetW(snackWidget * s, PyObject * args) {
     return Py_None;
 }
 
+static PyObject * widgetListboxClear(snackWidget * s, PyObject * args) {
+  if (!PyArg_ParseTuple(args, ""))
+    return NULL;
+
+  newtListboxClear(s->co);
+
+  Py_INCREF(Py_None);
+  return Py_None;
+}
+
 static void emptyDestructor(PyObject * s) {
 }