guix-commits
[Top][All Lists]
Advanced

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

185/197: installer: Avoid flicker in network page.


From: Danny Milosavljevic
Subject: 185/197: installer: Avoid flicker in network page.
Date: Mon, 3 Jul 2017 20:37:22 -0400 (EDT)

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

commit d2a38b645b7b682280fcb653d337c8ccf27c6bd7
Author: John Darrington <address@hidden>
Date:   Sun Feb 19 14:19:24 2017 +0100

    installer: Avoid flicker in network page.
    
    * gnu/system/installer/network.scm (network-page-init): Cache the flags
    of all interfaces, and refresh the menu only if they have changed.
---
 gnu/system/installer/network.scm | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/gnu/system/installer/network.scm b/gnu/system/installer/network.scm
index 60ae111..a4ffbff 100644
--- a/gnu/system/installer/network.scm
+++ b/gnu/system/installer/network.scm
@@ -162,8 +162,13 @@
   (refresh* (inner (page-wwin page)))
   (menu-refresh (page-datum page 'menu)))
 
+(define (if-flags ifce)
+  (network-interface-flags
+   (socket SOCK_STREAM AF_INET 0)
+   (assq-ref ifce 'name)))
 
 (define (network-page-init p)
+  (define prev-flags (map-in-order if-flags (interfaces)))
   (let* ((s (page-surface p))
         (pr (make-boxed-window  #f
                                  (- (getmaxy s) 4) (- (getmaxx s) 2)
@@ -196,9 +201,7 @@
                      (format #f "~55a ~a"
                              (name->description (assq-ref datum 'name))
                              (if (zero? (logand IFF_RUNNING
-                                         (network-interface-flags
-                                          (socket SOCK_STREAM AF_INET 0)
-                                          (assq-ref datum 'name))))
+                                                (if-flags datum)))
                                  (gettext "Down")
                                  (gettext "Running")))))))
 
@@ -208,7 +211,15 @@
 
 
     ;; Raise sigalarm every second to refresh the menu
-    (sigaction SIGALRM (lambda (_) (menu-redraw menu)))
+    (sigaction SIGALRM (lambda (_)
+                         (let ((flags
+                                (map-in-order
+                                 if-flags
+                                 (interfaces))))
+
+                           (when (not (equal? prev-flags flags))
+                                 (set! prev-flags flags)
+                                 (menu-redraw menu)))))
     (setitimer ITIMER_REAL 1 0 1 0)
 
     (push-cursor (page-cursor-visibility p))



reply via email to

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