Browse Source

kivy: use ActionDropdown in ChannelDetailsPopup

patch-4
SomberNight 4 years ago
parent
commit
e15a11a437
No known key found for this signature in database GPG Key ID: B33B5F232C6271E9
  1. 39
      electrum/gui/kivy/uix/dialogs/lightning_channels.py

39
electrum/gui/kivy/uix/dialogs/lightning_channels.py

@ -4,19 +4,20 @@ from typing import TYPE_CHECKING, Optional, Union
from kivy.lang import Builder
from kivy.factory import Factory
from kivy.uix.popup import Popup
from .fee_dialog import FeeDialog
from electrum.util import bh2u
from electrum.logging import Logger
from electrum.lnutil import LOCAL, REMOTE, format_short_channel_id
from electrum.lnchannel import AbstractChannel, Channel, ChannelState
from electrum.gui.kivy.i18n import _
from .question import Question
from electrum.transaction import PartialTxOutput, Transaction
from electrum.util import NotEnoughFunds, NoDynamicFeeEstimates, format_fee_satoshis, quantize_feerate
from electrum.lnutil import ln_dummy_address
from electrum.gui import messages
from ..actiondropdown import ActionButtonOption, ActionDropdown
from .fee_dialog import FeeDialog
from .question import Question
from .qr_dialog import QRDialog
from .choice_dialog import ChoiceDialog
@ -313,29 +314,12 @@ Builder.load_string(r'''
BoxLayout:
size_hint: 1, None
height: '48dp'
Button:
size_hint: 0.5, None
height: '48dp'
text: _('Backup')
on_release: root.export_backup()
Button:
ActionDropdown:
id: action_dropdown
size_hint: 0.5, None
height: '48dp'
text: _('Close')
on_release: root.close()
disabled: root.is_closed
Button:
size_hint: 0.5, None
height: '48dp'
text: _('Force-close')
on_release: root.force_close()
disabled: root.is_closed
Button:
Widget:
size_hint: 0.5, None
height: '48dp'
text: _('Delete')
on_release: root.remove_channel()
disabled: not root.can_be_deleted
<ChannelBackupPopup@Popup>:
id: popuproot
@ -494,6 +478,17 @@ class ChannelDetailsPopup(Popup, Logger):
_("If you want to keep using this channel, you need to disable trampoline routing in your preferences."),
])
self.warning = '' if self.app.wallet.lnworker.channel_db or self.app.wallet.lnworker.is_trampoline_peer(chan.node_id) else _('Warning') + ': ' + msg
self.update_action_dropdown()
def update_action_dropdown(self):
action_dropdown = self.ids.action_dropdown # type: ActionDropdown
options = (
ActionButtonOption(text=_('Backup'), func=lambda btn: self.export_backup()),
ActionButtonOption(text=_('Close channel'), func=lambda btn: self.close(), enabled=not self.is_closed),
ActionButtonOption(text=_('Force-close'), func=lambda btn: self.force_close(), enabled=not self.is_closed),
ActionButtonOption(text=_('Delete'), func=lambda btn: self.remove_channel(), enabled=self.can_be_deleted),
)
action_dropdown.update(options=options)
def close(self):
dialog = ChoiceDialog(

Loading…
Cancel
Save