tui: Q&D adaptation to new code:
use the new `quick_bridge` adapter and do few changes to make TUI work with new backend. TUI will probably be rewritten at some point, this is just an update to keep it working. `urwid` has been updated to have a version working with Python 3.14.
This commit is contained in:
parent
d3dc59b141
commit
e5ed4e3d7c
1 changed files with 135 additions and 77 deletions
|
|
@ -45,34 +45,44 @@ class StatusBar(urwid.Columns):
|
|||
urwid.connect_signal(self.status, "click", self.on_status_click)
|
||||
|
||||
def on_presence_click(self, sender=None):
|
||||
if not self.host.bridge.is_connected(
|
||||
self.host.current_profile
|
||||
): # FIXME: manage multi-profiles
|
||||
return
|
||||
options = [commonConst.PRESENCE[presence] for presence in commonConst.PRESENCE]
|
||||
list_widget = sat_widgets.GenericList(
|
||||
options=options,
|
||||
option_type=sat_widgets.ClickableText,
|
||||
on_click=self.on_change,
|
||||
def show_presence_popup(connected):
|
||||
if not connected:
|
||||
return
|
||||
options = [
|
||||
commonConst.PRESENCE[presence] for presence in commonConst.PRESENCE
|
||||
]
|
||||
list_widget = sat_widgets.GenericList(
|
||||
options=options,
|
||||
option_type=sat_widgets.ClickableText,
|
||||
on_click=self.on_change,
|
||||
)
|
||||
decorated = sat_widgets.LabelLine(
|
||||
list_widget, sat_widgets.SurroundedText(_("Set your presence"))
|
||||
)
|
||||
self.host.show_pop_up(decorated)
|
||||
|
||||
# FIXME: manage multi-profiles
|
||||
self.host.bridge.is_connected(
|
||||
self.host.current_profile, callback=show_presence_popup
|
||||
)
|
||||
decorated = sat_widgets.LabelLine(
|
||||
list_widget, sat_widgets.SurroundedText(_("Set your presence"))
|
||||
)
|
||||
self.host.show_pop_up(decorated)
|
||||
|
||||
def on_status_click(self, sender=None):
|
||||
if not self.host.bridge.is_connected(
|
||||
self.host.current_profile
|
||||
): # FIXME: manage multi-profiles
|
||||
return
|
||||
pop_up_widget = sat_widgets.InputDialog(
|
||||
_("Set your status"),
|
||||
_("New status"),
|
||||
default_txt=self.status.get_text(),
|
||||
cancel_cb=lambda _: self.host.remove_pop_up(),
|
||||
ok_cb=self.on_change,
|
||||
def show_status_popup(connected):
|
||||
if not connected:
|
||||
return
|
||||
pop_up_widget = sat_widgets.InputDialog(
|
||||
_("Set your status"),
|
||||
_("New status"),
|
||||
default_txt=self.status.get_text(),
|
||||
cancel_cb=lambda _: self.host.remove_pop_up(),
|
||||
ok_cb=self.on_change,
|
||||
)
|
||||
self.host.show_pop_up(pop_up_widget)
|
||||
|
||||
# FIXME: manage multi-profiles
|
||||
self.host.bridge.is_connected(
|
||||
self.host.current_profile, callback=show_status_popup
|
||||
)
|
||||
self.host.show_pop_up(pop_up_widget)
|
||||
|
||||
def on_change(self, sender=None, user_data=None):
|
||||
new_value = user_data.get_text()
|
||||
|
|
|
|||
Loading…
Reference in a new issue