1
0

Create a Plugins class

Encapsulates plugin logic and removes global variable ugliness.
This commit is contained in:
Neil Booth
2015-09-03 12:02:03 +09:00
parent 2c67de8f64
commit 49797c3094
10 changed files with 208 additions and 203 deletions

View File

@@ -12,7 +12,7 @@ import sys, getpass, datetime
class ElectrumGui:
def __init__(self, config, network):
def __init__(self, config, network, plugins):
self.network = network
self.config = config
storage = WalletStorage(config.get_wallet_path())
@@ -33,7 +33,7 @@ class ElectrumGui:
self.wallet = Wallet(storage)
self.wallet.start_threads(network)
self.contacts = StoreDict(self.config, 'contacts')
self.wallet.network.register_callback('updated', self.updated)
self.wallet.network.register_callback('connected', self.connected)
self.wallet.network.register_callback('disconnected', self.disconnected)
@@ -97,7 +97,7 @@ class ElectrumGui:
delta = (80 - sum(width) - 4)/3
format_str = "%"+"%d"%width[0]+"s"+"%"+"%d"%(width[1]+delta)+"s"+"%" \
+ "%d"%(width[2]+delta)+"s"+"%"+"%d"%(width[3]+delta)+"s"
b = 0
b = 0
messages = []
for item in self.wallet.get_history():
@@ -123,7 +123,7 @@ class ElectrumGui:
if self.wallet.network.is_connected():
if not self.wallet.up_to_date:
msg = _( "Synchronizing..." )
else:
else:
c, u, x = self.wallet.get_balance()
msg = _("Balance")+": %f "%(Decimal(c) / COIN)
if u:
@@ -132,7 +132,7 @@ class ElectrumGui:
msg += " [%f unmatured]"%(Decimal(x) / COIN)
else:
msg = _( "Not connected" )
return(msg)
@@ -169,7 +169,7 @@ class ElectrumGui:
msg = list[i] if i < len(list) else ""
print(msg)
def main(self):
while self.done == 0: self.main_command()
@@ -205,8 +205,8 @@ class ElectrumGui:
except Exception as e:
print(str(e))
return
if self.str_description:
if self.str_description:
self.wallet.labels[tx.hash()] = self.str_description
h = self.wallet.send_tx(tx)
@@ -232,7 +232,7 @@ class ElectrumGui:
def password_dialog(self):
return getpass.getpass()
# XXX unused
@@ -240,6 +240,6 @@ class ElectrumGui:
#if c == 10:
# out = self.run_popup('Address', ["Edit label", "Freeze", "Prioritize"])
return
def run_contacts_tab(self, c):
pass