From fe0a3b6a3e3c39476e0b87bab10a609049a5d0ea Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Thu, 4 Nov 2021 22:28:35 +0100 Subject: [PATCH] Improved LXMF Peer display --- nomadnet/Directory.py | 7 +++++++ nomadnet/ui/textui/Network.py | 14 ++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/nomadnet/Directory.py b/nomadnet/Directory.py index f37be18..c357b45 100644 --- a/nomadnet/Directory.py +++ b/nomadnet/Directory.py @@ -123,6 +123,13 @@ class Directory: else: return "<"+RNS.hexrep(source_hash, delimit=False)+">" + def alleged_display_str(self, source_hash): + if source_hash in self.directory_entries: + return self.directory_entries[source_hash].display_name + else: + return None + + def trust_level(self, source_hash, announced_display_name=None): if source_hash in self.directory_entries: if announced_display_name == None: diff --git a/nomadnet/ui/textui/Network.py b/nomadnet/ui/textui/Network.py index 4e4ca4b..615cdf6 100644 --- a/nomadnet/ui/textui/Network.py +++ b/nomadnet/ui/textui/Network.py @@ -941,7 +941,7 @@ class NodeInfo(urwid.WidgetWrap): self.t_active_links = NodeInfo.links_timer self.t_active_links.update_stat() - announce_button = urwid.Button("Announce Now", on_press=announce_query) + announce_button = urwid.Button("Announce", on_press=announce_query) connect_button = urwid.Button("Browse", on_press=connect_query) pile = urwid.Pile([ @@ -954,9 +954,9 @@ class NodeInfo(urwid.WidgetWrap): urwid.Columns([ ("weight", 0.3, urwid.Button("Back", on_press=show_peer_info)), ("weight", 0.1, urwid.Text("")), - ("weight", 0.3, connect_button), + ("weight", 0.4, connect_button), ("weight", 0.1, urwid.Text("")), - ("weight", 0.3, announce_button) + ("weight", 0.5, announce_button) ]) ]) else: @@ -1236,13 +1236,19 @@ class LXMFPeerEntry(urwid.WidgetWrap): self.app = app g = self.app.ui.glyphs + node_identity = RNS.Identity.recall(destination_hash) display_str = RNS.prettyhexrep(destination_hash) + if node_identity != None: + node_hash = RNS.Destination.hash_from_name_and_identity("nomadnetwork.node", node_identity) + display_name = self.app.directory.alleged_display_str(node_hash) + if display_name != None: + display_str += "\n "+str(display_name) sym = g["sent"] style = "list_unknown" focus_style = "list_focus" - widget = ListEntry(sym+" "+display_str+"\n Last heard "+pretty_date(int(peer.last_heard))+"\n "+str(len(peer.unhandled_messages))+" unhandled") + widget = ListEntry(sym+" "+display_str+"\n Last heard "+pretty_date(int(peer.last_heard))+"\n "+str(len(peer.unhandled_messages))+" unhandled messages") # urwid.connect_signal(widget, "click", delegate.connect_node, node) self.display_widget = urwid.AttrMap(widget, style, focus_style)