[node-patches] Change in ovirt-node[master]: ui: Adjust colors

fabiand at redhat.com fabiand at redhat.com
Wed Sep 17 13:58:40 UTC 2014


Fabian Deutsch has uploaded a new change for review.

Change subject: ui: Adjust colors
......................................................................

ui: Adjust colors

Previously text and buttons colors could be confusing to users.
Disabled buttons could appear in red, which isn't very intuitive.

Now disabled buttons are displayed in gray on a terminal, and in white
on a pty (ssh).

Change-Id: Iadf93f590efcdeeb41dde4031725adda90293452
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1106918
Signed-off-by: Fabian Deutsch <fabiand at fedoraproject.org>
---
M src/ovirt/node/app.py
M src/ovirt/node/ui/urwid_builder.py
M src/ovirt/node/utils/console.py
3 files changed, 22 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/15/33015/1

diff --git a/src/ovirt/node/app.py b/src/ovirt/node/app.py
index 99ddf03..0c74627 100644
--- a/src/ovirt/node/app.py
+++ b/src/ovirt/node/app.py
@@ -90,8 +90,7 @@
         self.logger.info(("Starting '%s' application " +
                           "with '%s' UI") % (plugin_base, ui_builder))
 
-        if os.ttyname(sys.stdin.fileno()).startswith("/dev/tty") or \
-           os.ttyname(sys.stdin.fileno()) == "/dev/console":
+        if console.is_terminal():
             # We're on a physical console, so explicitly load fonts in
             # case they weren't loaded for some reason
             self.logger.info("Console path is %s" % os.ttyname(
diff --git a/src/ovirt/node/ui/urwid_builder.py b/src/ovirt/node/ui/urwid_builder.py
index aec0264..377fc40 100644
--- a/src/ovirt/node/ui/urwid_builder.py
+++ b/src/ovirt/node/ui/urwid_builder.py
@@ -20,6 +20,7 @@
 # also available at http://www.gnu.org/copyleft/gpl.html.
 from ovirt.node import ui, base, presets
 from ovirt.node.ui import widgets as uw
+from ovirt.node.utils import console
 import os
 import urwid
 
@@ -320,12 +321,12 @@
     with_menu = True
 
     element_styles = {
-        "text": "black",
-        "label": "dark gray",
-        "disabled": "white",
         "background": "light gray",
+        "text": "black",
+        "label": "black",
+        "header": "black",
+        "disabled": "dark gray" if console.is_terminal() else "white",
         "invalid": "dark red",
-        "header": 'black, bold',
     }
 
     palette = [(None, 'default', element_styles["background"], 'bold',
diff --git a/src/ovirt/node/utils/console.py b/src/ovirt/node/utils/console.py
index 8c462dd..238b6c9 100644
--- a/src/ovirt/node/utils/console.py
+++ b/src/ovirt/node/utils/console.py
@@ -22,10 +22,26 @@
 from ovirt.node.utils import Transaction, process
 import StringIO
 import sys
+import os
 import termios
 import tty
 
 
+def is_terminal():
+    """Is true if the terminal is a real one
+    Like the linux terminal console
+    """
+    ttyname = os.ttyname(sys.stdin.fileno())
+    return ttyname.startswith("/dev/tty") or ttyname == "/dev/console"
+
+
+def is_pty():
+    """Is true if the terminal is a pseudo one
+    Like GUI terminals or an ssh session
+    """
+    return not is_terminal()
+
+
 def reset():
     process.call(["reset"])
 


-- 
To view, visit http://gerrit.ovirt.org/33015
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iadf93f590efcdeeb41dde4031725adda90293452
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-node
Gerrit-Branch: master
Gerrit-Owner: Fabian Deutsch <fabiand at redhat.com>



More information about the node-patches mailing list