mirror of
https://github.com/markqvist/NomadNet.git
synced 2024-12-27 16:19:33 -05:00
User interface enhancements
This commit is contained in:
parent
557ddd7d1e
commit
7d5bb8e016
@ -58,6 +58,8 @@ class NomadNetworkApp:
|
|||||||
|
|
||||||
self.firstrun = False
|
self.firstrun = False
|
||||||
|
|
||||||
|
self.peer_announce_at_start = True
|
||||||
|
|
||||||
if not os.path.isdir(self.storagepath):
|
if not os.path.isdir(self.storagepath):
|
||||||
os.makedirs(self.storagepath)
|
os.makedirs(self.storagepath)
|
||||||
|
|
||||||
@ -170,6 +172,9 @@ class NomadNetworkApp:
|
|||||||
RNS.Transport.register_announce_handler(nomadnet.Conversation)
|
RNS.Transport.register_announce_handler(nomadnet.Conversation)
|
||||||
RNS.Transport.register_announce_handler(nomadnet.Directory)
|
RNS.Transport.register_announce_handler(nomadnet.Directory)
|
||||||
|
|
||||||
|
if self.peer_announce_at_start:
|
||||||
|
self.announce_now()
|
||||||
|
|
||||||
nomadnet.ui.spawn(self.uimode)
|
nomadnet.ui.spawn(self.uimode)
|
||||||
|
|
||||||
def set_display_name(self, display_name):
|
def set_display_name(self, display_name):
|
||||||
@ -262,6 +267,10 @@ class NomadNetworkApp:
|
|||||||
value = self.config["client"]["downloads_path"]
|
value = self.config["client"]["downloads_path"]
|
||||||
self.downloads_path = os.path.expanduser(value)
|
self.downloads_path = os.path.expanduser(value)
|
||||||
|
|
||||||
|
if option == "announce_at_start":
|
||||||
|
value = self.config["client"].as_bool(option)
|
||||||
|
self.peer_announce_at_start = value
|
||||||
|
|
||||||
if option == "user_interface":
|
if option == "user_interface":
|
||||||
value = value.lower()
|
value = value.lower()
|
||||||
if value == "none":
|
if value == "none":
|
||||||
@ -347,7 +356,8 @@ class NomadNetworkApp:
|
|||||||
if not "announce_at_start" in self.config["node"]:
|
if not "announce_at_start" in self.config["node"]:
|
||||||
self.node_announce_at_start = False
|
self.node_announce_at_start = False
|
||||||
else:
|
else:
|
||||||
self.node_announce_at_start = self.config["node"]["announce_at_start"]
|
value = self.config["node"].as_bool("announce_at_start")
|
||||||
|
self.node_announce_at_start = value
|
||||||
|
|
||||||
if not "announce_interval" in self.config["node"]:
|
if not "announce_interval" in self.config["node"]:
|
||||||
self.node_announce_interval = 720
|
self.node_announce_interval = 720
|
||||||
@ -401,6 +411,10 @@ enable_client = yes
|
|||||||
user_interface = text
|
user_interface = text
|
||||||
downloads_path = ~/Downloads
|
downloads_path = ~/Downloads
|
||||||
|
|
||||||
|
# By default, the peer is announced at startup
|
||||||
|
# to let other peers reach it immediately.
|
||||||
|
announce_at_start = yes
|
||||||
|
|
||||||
[textui]
|
[textui]
|
||||||
|
|
||||||
# Amount of time to show intro screen
|
# Amount of time to show intro screen
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import RNS
|
import RNS
|
||||||
import importlib
|
import urwid
|
||||||
import time
|
import time
|
||||||
|
import os
|
||||||
|
|
||||||
import nomadnet
|
import nomadnet
|
||||||
from nomadnet.ui.textui import *
|
from nomadnet.ui.textui import *
|
||||||
@ -61,21 +62,22 @@ GLYPHS = {
|
|||||||
("check", "=", "\u2713", "\u2713"),
|
("check", "=", "\u2713", "\u2713"),
|
||||||
("cross", "X", "\u2715", "\u2715"),
|
("cross", "X", "\u2715", "\u2715"),
|
||||||
("unknown", "?", "?", "?"),
|
("unknown", "?", "?", "?"),
|
||||||
("lock", "E", "\U0001f512", "\uf023"),
|
("encrypted", "", "\u26BF", "\uf023"),
|
||||||
("unlock", "!", "\U0001f513", "\uf09c"),
|
("plaintext", "!", "!", "\uf06e "),
|
||||||
("arrow_r", "->", "\u2192", "\u2192"),
|
("arrow_r", "->", "\u2192", "\u2192"),
|
||||||
("arrow_l", "<-", "\u2190", "\u2190"),
|
("arrow_l", "<-", "\u2190", "\u2190"),
|
||||||
("arrow_u", "/\\", "\u2191", "\u2191"),
|
("arrow_u", "/\\", "\u2191", "\u2191"),
|
||||||
("arrow_d", "\\/", "\u2193", "\u2193"),
|
("arrow_d", "\\/", "\u2193", "\u2193"),
|
||||||
("warning", "!", "\u26a0", "\uf12a"),
|
("warning", "!", "\u26a0", "\uf12a"),
|
||||||
("info", "i", "\u2139", "\ufb4d"),
|
("info", "i", "\u2139", "\ufb4d"),
|
||||||
("unread", "N", "\u2709", "\uf003 "),
|
("unread", "[U]", "\u2709", "\uf003 "),
|
||||||
("divider1", "-", "\u2504", "\u2504"),
|
("divider1", "-", "\u2504", "\u2504"),
|
||||||
("peer", "P", "\U0001F464", "\uf415"),
|
("peer", "[P]", "\u24c5 ", "\uf415"),
|
||||||
("node", "N", "\U0001F5A5", "\uf502"),
|
("node", "[N]", "\u24c3 ", "\uf502"),
|
||||||
("page", "", "\U0001F5B9", "\uf719 "),
|
("page", "", "\u25a4", "\uf719 "),
|
||||||
("speed", "", "\U0001F5B9", "\uf9c4"),
|
("speed", "", "\u25F7", "\uf9c4"),
|
||||||
("decoration_menu", "", "", " \uf93a"),
|
("decoration_menu", "", "", " \uf93a"),
|
||||||
|
("globe", "", "", "\uf484"),
|
||||||
}
|
}
|
||||||
|
|
||||||
class TextUI:
|
class TextUI:
|
||||||
@ -85,12 +87,13 @@ class TextUI:
|
|||||||
self.app.ui = self
|
self.app.ui = self
|
||||||
self.loop = None
|
self.loop = None
|
||||||
|
|
||||||
if importlib.util.find_spec("urwid") != None:
|
# TODO: Remove
|
||||||
import urwid
|
# if importlib.util.find_spec("urwid") != None:
|
||||||
else:
|
# import urwid
|
||||||
RNS.log("The text-mode user interface requires Urwid to be installed on your system.", RNS.LOG_ERROR)
|
# else:
|
||||||
RNS.log("You can install it with the command: pip3 install urwid", RNS.LOG_ERROR)
|
# RNS.log("The text-mode user interface requires Urwid to be installed on your system.", RNS.LOG_ERROR)
|
||||||
nomadnet.panic()
|
# RNS.log("You can install it with the command: pip3 install urwid", RNS.LOG_ERROR)
|
||||||
|
# nomadnet.panic()
|
||||||
|
|
||||||
urwid.set_encoding("UTF-8")
|
urwid.set_encoding("UTF-8")
|
||||||
|
|
||||||
@ -130,11 +133,21 @@ class TextUI:
|
|||||||
if intro_timeout > 0:
|
if intro_timeout > 0:
|
||||||
self.loop.set_alarm_in(intro_timeout, self.display_main)
|
self.loop.set_alarm_in(intro_timeout, self.display_main)
|
||||||
|
|
||||||
# TODO: Probably remove this at some point when better terminal
|
if "KONSOLE_VERSION" in os.environ:
|
||||||
# color capability detection has been implemented
|
if colormode > 16:
|
||||||
if colormode > 16:
|
RNS.log("", RNS.LOG_WARNING, _override_destination = True)
|
||||||
RNS.log("Starting Text UI in "+str(colormode)+" color mode. If no UI appears, try adjusting your color settings in "+str(self.app.configdir)+"/config", RNS.LOG_INFO, _override_destination = True)
|
RNS.log("", RNS.LOG_WARNING, _override_destination = True)
|
||||||
|
RNS.log("You are using the terminal emulator Konsole.", RNS.LOG_WARNING, _override_destination = True)
|
||||||
|
RNS.log("If you are not seeing the user interface, it is due to a bug in Konsole/urwid.", RNS.LOG_WARNING, _override_destination = True)
|
||||||
|
RNS.log("", RNS.LOG_WARNING, _override_destination = True)
|
||||||
|
|
||||||
|
RNS.log("To circumvent this, use another terminal emulator, or launch nomadnet within a", RNS.LOG_WARNING, _override_destination = True)
|
||||||
|
RNS.log("screen session, using a command like the following:", RNS.LOG_WARNING, _override_destination = True)
|
||||||
|
RNS.log("", RNS.LOG_WARNING, _override_destination = True)
|
||||||
|
RNS.log("screen nomadnet", RNS.LOG_WARNING, _override_destination = True)
|
||||||
|
RNS.log("", RNS.LOG_WARNING, _override_destination = True)
|
||||||
|
RNS.log("Press ctrl-c to exit now and try again.", RNS.LOG_WARNING, _override_destination = True)
|
||||||
|
|
||||||
self.set_colormode(colormode)
|
self.set_colormode(colormode)
|
||||||
|
|
||||||
self.loop.run()
|
self.loop.run()
|
||||||
|
@ -84,8 +84,9 @@ class Browser:
|
|||||||
|
|
||||||
|
|
||||||
def marked_link(self, link_target):
|
def marked_link(self, link_target):
|
||||||
self.link_target = link_target
|
if self.status == Browser.DONE:
|
||||||
self.app.ui.loop.set_alarm_in(0.1, self.marked_link_job)
|
self.link_target = link_target
|
||||||
|
self.app.ui.loop.set_alarm_in(0.1, self.marked_link_job)
|
||||||
|
|
||||||
def marked_link_job(self, sender, event):
|
def marked_link_job(self, sender, event):
|
||||||
link_target = self.link_target
|
link_target = self.link_target
|
||||||
|
@ -702,9 +702,9 @@ class LXMessageWidget(urwid.WidgetWrap):
|
|||||||
message_time = datetime.fromtimestamp(self.timestamp)
|
message_time = datetime.fromtimestamp(self.timestamp)
|
||||||
encryption_string = ""
|
encryption_string = ""
|
||||||
if message.get_transport_encrypted():
|
if message.get_transport_encrypted():
|
||||||
encryption_string = " ["+g["lock"]+" "+str(message.get_transport_encryption())+"]"
|
encryption_string = " ["+g["encrypted"]+" "+str(message.get_transport_encryption())+"]"
|
||||||
else:
|
else:
|
||||||
encryption_string = " ["+g["unlock"]+" "+str(message.get_transport_encryption())+"]"
|
encryption_string = " ["+g["plaintext"]+" "+str(message.get_transport_encryption())+"]"
|
||||||
|
|
||||||
title_string = message_time.strftime(time_format)+encryption_string
|
title_string = message_time.strftime(time_format)+encryption_string
|
||||||
|
|
||||||
|
@ -67,9 +67,9 @@ class AnnounceInfo(urwid.WidgetWrap):
|
|||||||
is_node = announce[3]
|
is_node = announce[3]
|
||||||
|
|
||||||
if is_node:
|
if is_node:
|
||||||
type_string = g["node"] + " Node"
|
type_string = "Node " + g["node"]
|
||||||
else:
|
else:
|
||||||
type_string = g["peer"] + " Peer"
|
type_string = "Peer " + g["peer"]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
data_str = announce[2].decode("utf-8")
|
data_str = announce[2].decode("utf-8")
|
||||||
@ -461,8 +461,6 @@ class KnownNodes(urwid.WidgetWrap):
|
|||||||
# TODO: Sort list
|
# TODO: Sort list
|
||||||
return widget_list
|
return widget_list
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class NodeEntry(urwid.WidgetWrap):
|
class NodeEntry(urwid.WidgetWrap):
|
||||||
def __init__(self, app, node, delegate):
|
def __init__(self, app, node, delegate):
|
||||||
source_hash = node.source_hash
|
source_hash = node.source_hash
|
||||||
@ -712,8 +710,6 @@ class NetworkStats(urwid.WidgetWrap):
|
|||||||
self.w_heard_peers.start()
|
self.w_heard_peers.start()
|
||||||
self.w_known_nodes.start()
|
self.w_known_nodes.start()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class NetworkLeftPile(urwid.Pile):
|
class NetworkLeftPile(urwid.Pile):
|
||||||
def keypress(self, size, key):
|
def keypress(self, size, key):
|
||||||
if key == "ctrl l":
|
if key == "ctrl l":
|
||||||
|
Loading…
Reference in New Issue
Block a user