mirror of
https://github.com/markqvist/NomadNet.git
synced 2025-05-07 08:35:11 -04:00
Work on Conversations UI
This commit is contained in:
parent
f5d263ee31
commit
0c1108f00e
4 changed files with 57 additions and 12 deletions
|
@ -13,5 +13,28 @@ class Conversation:
|
||||||
|
|
||||||
lxmessage.write_to_directory(conversation_path)
|
lxmessage.write_to_directory(conversation_path)
|
||||||
|
|
||||||
def __init__(self):
|
@staticmethod
|
||||||
pass
|
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
|
|
@ -135,6 +135,8 @@ class NomadNetworkApp:
|
||||||
# RNS.log("\t| Message signature : "+signature_string)
|
# RNS.log("\t| Message signature : "+signature_string)
|
||||||
# RNS.log("\t+---------------------------------------------------------------")
|
# RNS.log("\t+---------------------------------------------------------------")
|
||||||
|
|
||||||
|
def conversations(self):
|
||||||
|
return nomadnet.Conversation.conversation_list(self)
|
||||||
|
|
||||||
def createDefaultConfig(self):
|
def createDefaultConfig(self):
|
||||||
self.config = ConfigObj(__default_nomadnet_config__)
|
self.config = ConfigObj(__default_nomadnet_config__)
|
||||||
|
|
|
@ -29,12 +29,14 @@ THEME_LIGHT = 0x02
|
||||||
|
|
||||||
THEMES = {
|
THEMES = {
|
||||||
THEME_DARK: [
|
THEME_DARK: [
|
||||||
# Style name # 16-color style # Monochrome style # 88, 256 and true-color style
|
# Style name # 16-color style # Monochrome style # 88, 256 and true-color style
|
||||||
('heading', 'light gray,underline', 'default', 'underline', 'g93,underline', 'default'),
|
('heading', 'light gray,underline', 'default', 'underline', 'g93,underline', 'default'),
|
||||||
('menubar', 'black', 'light gray', 'standout', '#111', '#bbb'),
|
('menubar', 'black', 'light gray', 'standout', '#111', '#bbb'),
|
||||||
('shortcutbar', 'black', 'light gray', 'standout', '#111', '#bbb'),
|
('shortcutbar', 'black', 'light gray', 'standout', '#111', '#bbb'),
|
||||||
('body_text', 'white', 'default', 'default', '#0a0', 'default'),
|
('body_text', 'white', 'default', 'default', '#0a0', 'default'),
|
||||||
('buttons', 'light green,bold', 'default', 'default', '#00a533', '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"),
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,14 +8,32 @@ class ConversationsDisplayShortcuts():
|
||||||
class ConversationsDisplay():
|
class ConversationsDisplay():
|
||||||
def __init__(self, app):
|
def __init__(self, app):
|
||||||
import urwid
|
import urwid
|
||||||
|
from nomadnet.vendor.additional_urwid_widgets import IndicativeListBox
|
||||||
|
|
||||||
self.app = app
|
self.app = app
|
||||||
|
|
||||||
pile = urwid.Pile([
|
conversation_list_widgets = []
|
||||||
urwid.Text(("body_text", "Conversations Display \U0001F332")),
|
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.shortcuts_display = ConversationsDisplayShortcuts(self.app)
|
||||||
self.widget = urwid.Filler(pile, 'top')
|
self.widget = columns_widget
|
||||||
|
|
||||||
def shortcuts(self):
|
def shortcuts(self):
|
||||||
return self.shortcuts_display
|
return self.shortcuts_display
|
Loading…
Add table
Add a link
Reference in a new issue