Package: newt Version: 0.52.2-5.1 It is quite possible, although slightly awkward to display multiple windows using newt/snack, and update an arbitrary window. To do so, one must pop windows until the window needing updating is the "current" window, redraw it, and push the popped windows back on the display. Using this technique, it is desirable to hold off a refresh until the entire process has been completed, especially when the user is viewing the UI over a slow-ish network connected shell.
Unfortunately, newt automatically refreshes the screen every time a call to newtPopWindow is made. This is inconsistent with, e.g., newtShowWindow, for which an explicit refresh must be performed. I have a patch to go into debian/patches that allows windows to be popped without forcing a refresh. This patch will not break current programs using newt/snack, but allows new programs to make use of the refresh-less popWindow function. Please save the patch as 9999_pop_window_no_refresh.patch .
diff -Naur newt-0.52.2-old/newt.c newt-0.52.2/newt.c --- newt-0.52.2-old/newt.c 2006-07-30 11:20:03.000000000 -0400 +++ newt-0.52.2/newt.c 2006-07-30 11:20:36.000000000 -0400 @@ -1180,6 +1180,11 @@ * @brief Remove the top window */ void newtPopWindow(void) { + newtPopWindowNoRefresh(); + newtRefresh(); +} + +void newtPopWindowNoRefresh(void) { int j, row, col; int n = 0; @@ -1209,8 +1214,6 @@ SLsmg_set_char_set(0); newtTrashScreen(); - - newtRefresh(); } void newtGetWindowPos(int * x, int * y) { diff -Naur newt-0.52.2-old/newt.h newt-0.52.2/newt.h --- newt-0.52.2-old/newt.h 2006-07-30 11:20:02.000000000 -0400 +++ newt-0.52.2/newt.h 2006-07-30 11:20:36.000000000 -0400 @@ -120,6 +120,7 @@ const char * title); int newtCenteredWindow(unsigned int width,unsigned int height, const char * title); void newtPopWindow(void); +void newtPopWindowNoRefresh(void); void newtSetColors(struct newtColors colors); void newtRefresh(void); void newtSuspend(void); diff -Naur newt-0.52.2-old/snack.py newt-0.52.2/snack.py --- newt-0.52.2-old/snack.py 2006-07-30 11:20:02.000000000 -0400 +++ newt-0.52.2/snack.py 2006-07-30 11:20:36.000000000 -0400 @@ -460,8 +460,10 @@ return _snack.gridwrappedwindow(grid.g, title) - def popWindow(self): - return _snack.popwindow() + def popWindow(self, refresh = True): + if refresh: + return _snack.popwindow() + return _snack.popwindownorefresh() def refresh(self): return _snack.refresh() diff -Naur newt-0.52.2-old/snackmodule.c newt-0.52.2/snackmodule.c --- newt-0.52.2-old/snackmodule.c 2006-07-30 11:20:02.000000000 -0400 +++ newt-0.52.2/snackmodule.c 2006-07-30 11:19:29.000000000 -0400 @@ -53,6 +53,7 @@ static PyObject * openWindow(PyObject * s, PyObject * args); static PyObject * popHelpLine(PyObject * s, PyObject * args); static PyObject * popWindow(PyObject * s, PyObject * args); +static PyObject * popWindowNoRefresh(PyObject * s, PyObject * args); static PyObject * pushHelpLine(PyObject * s, PyObject * args); static snackWidget * radioButtonWidget(PyObject * s, PyObject * args); static PyObject * refreshScreen(PyObject * s, PyObject * args); @@ -87,6 +88,7 @@ { "openwindow", openWindow, METH_VARARGS, NULL }, { "pophelpline", popHelpLine, METH_VARARGS, NULL }, { "popwindow", popWindow, METH_VARARGS, NULL }, + { "popwindownorefresh", popWindowNoRefresh, METH_VARARGS, NULL }, { "pushhelpline", pushHelpLine, METH_VARARGS, NULL }, { "radiobutton", (PyCFunction) radioButtonWidget, METH_VARARGS, NULL }, { "reflow", (PyCFunction) reflowText, METH_VARARGS, NULL }, @@ -530,6 +532,12 @@ return Py_None; } +static PyObject * popWindowNoRefresh(PyObject * s, PyObject * args) { + newtPopWindowNoRefresh(); + Py_INCREF(Py_None); + return Py_None; +} + static PyObject * messageWindow(PyObject * s, PyObject * args) { char * title, * text; char * okbutton = "Ok";