diff --git a/nomadnet/Conversation.py b/nomadnet/Conversation.py index ee49da0..c3012bb 100644 --- a/nomadnet/Conversation.py +++ b/nomadnet/Conversation.py @@ -13,5 +13,28 @@ class Conversation: lxmessage.write_to_directory(conversation_path) - def __init__(self): - pass \ No newline at end of file + @staticmethod + def conversation_list(app): + conversations = [] + for entry in os.listdir(app.conversationpath): + if os.path.isdir(app.conversationpath + "/" + entry): + try: + conversations.append(Conversation(entry, app)) + except Exception as e: + RNS.log("Error while loading conversation "+str(entry)+", skipping it. The contained exception was: "+str(e), RNS.LOG_ERROR) + + return conversations + + + + def __init__(self, source_hash, app): + self.source_hash = source_hash + self.message_path = app.conversationpath + "/" + source_hash + self.messages_load_time = None + self.messages = [] + self.source_known = False + self.source_trusted = False + self.source_blocked = False + + def __str__(self): + return self.source_hash \ No newline at end of file diff --git a/nomadnet/NomadNetworkApp.py b/nomadnet/NomadNetworkApp.py index 051be56..8d7f20d 100644 --- a/nomadnet/NomadNetworkApp.py +++ b/nomadnet/NomadNetworkApp.py @@ -135,6 +135,8 @@ class NomadNetworkApp: # RNS.log("\t| Message signature : "+signature_string) # RNS.log("\t+---------------------------------------------------------------") + def conversations(self): + return nomadnet.Conversation.conversation_list(self) def createDefaultConfig(self): self.config = ConfigObj(__default_nomadnet_config__) diff --git a/nomadnet/ui/__init__.py b/nomadnet/ui/__init__.py index ac6948a..bfd13b1 100644 --- a/nomadnet/ui/__init__.py +++ b/nomadnet/ui/__init__.py @@ -29,12 +29,14 @@ THEME_LIGHT = 0x02 THEMES = { THEME_DARK: [ - # Style name # 16-color style # Monochrome style # 88, 256 and true-color style - ('heading', 'light gray,underline', 'default', 'underline', 'g93,underline', 'default'), - ('menubar', 'black', 'light gray', 'standout', '#111', '#bbb'), - ('shortcutbar', 'black', 'light gray', 'standout', '#111', '#bbb'), - ('body_text', 'white', 'default', 'default', '#0a0', 'default'), - ('buttons', 'light green,bold', 'default', 'default', '#00a533', 'default') + # Style name # 16-color style # Monochrome style # 88, 256 and true-color style + ('heading', 'light gray,underline', 'default', 'underline', 'g93,underline', 'default'), + ('menubar', 'black', 'light gray', 'standout', '#111', '#bbb'), + ('shortcutbar', 'black', 'light gray', 'standout', '#111', '#bbb'), + ('body_text', 'white', 'default', 'default', '#0a0', 'default'), + ('buttons', 'light green,bold', 'default', 'default', '#00a533', 'default'), + ('msg_editor', 'black', 'light cyan', 'standout', '#111', '#0bb'), + ("list_focus", "black", "light cyan", "standout", "#111", "#0bb"), ] } diff --git a/nomadnet/ui/textui/Conversations.py b/nomadnet/ui/textui/Conversations.py index 9f96bd1..59fd0ac 100644 --- a/nomadnet/ui/textui/Conversations.py +++ b/nomadnet/ui/textui/Conversations.py @@ -8,14 +8,32 @@ class ConversationsDisplayShortcuts(): class ConversationsDisplay(): def __init__(self, app): import urwid + from nomadnet.vendor.additional_urwid_widgets import IndicativeListBox + self.app = app - pile = urwid.Pile([ - urwid.Text(("body_text", "Conversations Display \U0001F332")), - ]) + conversation_list_widgets = [] + for conversation in app.conversations(): + widget = urwid.SelectableIcon(str(conversation), cursor_position=-1) + widget.conversation = conversation + conversation_list_widgets.append(urwid.AttrMap(widget, None, "list_focus")) + + walker = urwid.SimpleFocusListWalker(conversation_list_widgets) + listbox = urwid.LineBox(urwid.Filler(IndicativeListBox(conversation_list_widgets), height=("relative", 100))) + + placeholder = urwid.Text("Conversation Display Area", "left") + + conversation_area = urwid.LineBox( + urwid.Frame( + urwid.Filler(placeholder,"top"), + footer=urwid.AttrMap(urwid.Edit(caption="\u270E", edit_text="Message input"), "msg_editor") + ) + ) + + columns_widget = urwid.Columns([("weight", 0.33, listbox), ("weight", 0.67, conversation_area)], dividechars=0, focus_column=0, box_columns=[0]) self.shortcuts_display = ConversationsDisplayShortcuts(self.app) - self.widget = urwid.Filler(pile, 'top') + self.widget = columns_widget def shortcuts(self): return self.shortcuts_display \ No newline at end of file