guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

123/197: installer: Add a popup window for forms which have multiple cho


From: Danny Milosavljevic
Subject: 123/197: installer: Add a popup window for forms which have multiple choice fields.
Date: Mon, 3 Jul 2017 20:37:11 -0400 (EDT)

dannym pushed a commit to branch wip-installer-2
in repository guix.

commit 621cfad6360a0cf3da21f7ecc8fb7cbd0fdbea3c
Author: John Darrington <address@hidden>
Date:   Thu Jan 19 15:58:16 2017 +0100

    installer: Add a popup window for forms which have multiple choice fields.
    
    * gnu/system/installer/mount-point.scm (mount-point-page-init): Make all 
windows
    panels.
    * gnu/system/installer/utils.scm (make-boxed-window): Make all windows 
panels.
    * gurses/form.scm (form-set-current-field, form-post, make-form): hide/show
    popup window when the relevant field is selected.
---
 gnu/system/installer/mount-point.scm |  4 ++--
 gnu/system/installer/utils.scm       |  3 +--
 gurses/form.scm                      | 29 ++++++++++++++++++++++++++++-
 3 files changed, 31 insertions(+), 5 deletions(-)

diff --git a/gnu/system/installer/mount-point.scm 
b/gnu/system/installer/mount-point.scm
index 598d9bf..fe060a1 100644
--- a/gnu/system/installer/mount-point.scm
+++ b/gnu/system/installer/mount-point.scm
@@ -102,12 +102,12 @@
              #:title (page-title p)))
        
         (text-window (derwin (inner pr) 3 (getmaxx (inner pr))
-                             0 0 #:panel #f))
+                             0 0 #:panel #t))
        
         (bwin (derwin (inner pr)
                       3 (getmaxx (inner pr))
                       (- (getmaxy (inner pr)) 3) 0
-                      #:panel #f))
+                      #:panel #t))
        
         (nav (make-buttons my-buttons 1))
        
diff --git a/gnu/system/installer/utils.scm b/gnu/system/installer/utils.scm
index 6bd10f3..47b8cd7 100644
--- a/gnu/system/installer/utils.scm
+++ b/gnu/system/installer/utils.scm
@@ -284,8 +284,7 @@ which will process each string before returning it."
 pair whose car is the inner window and whose cdr is the frame."
   (let* ((win  (if orig
                   (derwin orig height width starty startx #:panel #f)
-                  (newwin      height width starty startx #:panel #f)
-              ))
+                  (newwin      height width starty startx #:panel #f)))
         (ystart (if title 3 1))
         (sw (derwin win (- (getmaxy win) ystart 1)
                     (- (getmaxx win) 2)
diff --git a/gurses/form.scm b/gurses/form.scm
index 25ed4ff..2e8c242 100644
--- a/gurses/form.scm
+++ b/gurses/form.scm
@@ -33,6 +33,7 @@
   #:export (get-current-field)
 
   #:use-module (ncurses curses)
+  #:use-module (ncurses panel)
   #:use-module (ice-9 match)
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-9))
@@ -135,7 +136,7 @@ label eq? to N"
                                    (make-field symbol label width things
                                                (let ((p
                                                       (newwin (+ 2 (length 
things))
-                                                              (+ 2 width) 0 0 
#:panel #t)))
+                                                              (+ 2 width) 0 0 
#:panel #f)))
                                                  (box p 0 0)
                                                  (let loop ((ll things)
                                                             (y 0))
@@ -234,10 +235,24 @@ label eq? to N"
 
        (refresh (form-window form)))))
 
+(define (ensure-panel! win)
+  (if (not (panel? win))
+      (make-panel! win)))
+
 (define (form-set-current-field form which)
+  (let* ((old-field  (get-current-field form))
+         (popup (field-popup old-field)))
+    (when popup
+          (hide-panel popup)))
   (form-set-current-item! form which)
+  (let* ((new-field  (array-ref (form-items form) which))
+        (popup (field-popup new-field)))
+    (when popup
+          (ensure-panel! popup)
+          (show-panel popup)))
   (move (form-window form) which (form-tabpos form)))
 
+
 (define (form-next-field form)
   (if (< (form-current-item form) (1- (array-length (form-items form))))
       (begin
@@ -267,6 +282,18 @@ label eq? to N"
 
     (form-set-tabpos! form xpos)
 
+    (let loop ((fields (form-items form))
+               (pos 0))
+      (when (array-in-bounds? fields pos)
+            (let* ((f (array-ref fields pos))
+                  (p (field-popup f)))
+              (when p
+                    (ensure-panel! win)
+                    (mvwin p
+                           (+ (getbegy win) pos)
+                           (+ (form-tabpos form) (getbegx win))))
+              (loop fields (1+ pos)))))
+
     ;; Print the field entry areas
     (let loop ((fields (form-items form))
               (pos 0))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]