Browse Source

make gtk gui re-work

283
ThomasV 11 years ago
parent
commit
0099b2a560
  1. 32
      gui/gui_gtk.py
  2. 6
      lib/wallet.py

32
gui/gui_gtk.py

@ -24,9 +24,8 @@ pygtk.require('2.0')
import gtk, gobject import gtk, gobject
from decimal import Decimal from decimal import Decimal
from electrum.util import print_error from electrum.util import print_error
from electrum import is_valid from electrum.bitcoin import is_valid
from electrum import mnemonic from electrum import mnemonic, pyqrnative, WalletStorage, Wallet
import pyqrnative
gtk.gdk.threads_init() gtk.gdk.threads_init()
APP_NAME = "Electrum" APP_NAME = "Electrum"
@ -515,6 +514,7 @@ class ElectrumWindow:
self.config = config self.config = config
self.wallet = wallet self.wallet = wallet
self.funds_error = False # True if not enough funds self.funds_error = False # True if not enough funds
self.num_zeros = int(self.config.get('num_zeros',0))
self.window = MyWindow(gtk.WINDOW_TOPLEVEL) self.window = MyWindow(gtk.WINDOW_TOPLEVEL)
title = 'Electrum ' + self.wallet.electrum_version + ' - ' + self.config.path title = 'Electrum ' + self.wallet.electrum_version + ' - ' + self.config.path
@ -601,7 +601,7 @@ class ElectrumWindow:
self.context_id = self.status_bar.get_context_id("statusbar") self.context_id = self.status_bar.get_context_id("statusbar")
self.update_status_bar() self.update_status_bar()
self.wallet.interface.register_callback('updated', self.update_callback) self.wallet.network.register_callback('updated', self.update_callback)
def update_status_bar_thread(): def update_status_bar_thread():
@ -1111,16 +1111,16 @@ class ElectrumWindow:
if self.funds_error: if self.funds_error:
text = "Not enough funds" text = "Not enough funds"
elif interface and interface.is_connected: elif interface and interface.is_connected:
self.network_button.set_tooltip_text("Connected to %s:%d.\n%d blocks"%(interface.host, interface.port, self.wallet.verifier.height)) self.network_button.set_tooltip_text("Connected to %s:%d.\n%d blocks"%(interface.host, interface.port, self.wallet.network.blockchain.height))
if not self.wallet.up_to_date: if not self.wallet.up_to_date:
self.status_image.set_from_stock(gtk.STOCK_REFRESH, gtk.ICON_SIZE_MENU) self.status_image.set_from_stock(gtk.STOCK_REFRESH, gtk.ICON_SIZE_MENU)
text = "Synchronizing..." text = "Synchronizing..."
else: else:
self.status_image.set_from_stock(gtk.STOCK_YES, gtk.ICON_SIZE_MENU) self.status_image.set_from_stock(gtk.STOCK_YES, gtk.ICON_SIZE_MENU)
self.network_button.set_tooltip_text("Connected to %s:%d.\n%d blocks"%(interface.host, interface.port, self.wallet.verifier.height)) self.network_button.set_tooltip_text("Connected to %s:%d.\n%d blocks"%(interface.host, interface.port, self.wallet.network.blockchain.height))
c, u = self.wallet.get_balance() c, u = self.wallet.get_balance()
text = "Balance: %s "%( format_satoshis(c,False,self.wallet.num_zeros) ) text = "Balance: %s "%( format_satoshis(c,False,self.num_zeros) )
if u: text += "[%s unconfirmed]"%( format_satoshis(u,True,self.wallet.num_zeros).strip() ) if u: text += "[%s unconfirmed]"%( format_satoshis(u,True,self.num_zeros).strip() )
else: else:
self.status_image.set_from_stock(gtk.STOCK_NO, gtk.ICON_SIZE_MENU) self.status_image.set_from_stock(gtk.STOCK_NO, gtk.ICON_SIZE_MENU)
self.network_button.set_tooltip_text("Not connected.") self.network_button.set_tooltip_text("Not connected.")
@ -1183,8 +1183,8 @@ class ElectrumWindow:
details = self.get_tx_details(tx_hash) details = self.get_tx_details(tx_hash)
self.history_list.prepend( [tx_hash, conf_icon, time_str, label, is_default_label, self.history_list.prepend( [tx_hash, conf_icon, time_str, label, is_default_label,
format_satoshis(value,True,self.wallet.num_zeros, whitespaces=True), format_satoshis(value,True,self.num_zeros, whitespaces=True),
format_satoshis(balance,False,self.wallet.num_zeros, whitespaces=True), tooltip, details] ) format_satoshis(balance,False,self.num_zeros, whitespaces=True), tooltip, details] )
if cursor: self.history_treeview.set_cursor( cursor ) if cursor: self.history_treeview.set_cursor( cursor )
@ -1276,9 +1276,17 @@ class ElectrumWindow:
class ElectrumGui(): class ElectrumGui():
def __init__(self, wallet, config): def __init__(self, config, network):
self.wallet = wallet self.network = network
self.config = config self.config = config
storage = WalletStorage(config)
if not storage.file_exists:
print "Wallet not found. try 'electrum create'"
exit()
self.wallet = Wallet(storage)
self.wallet.start_threads(network)
def main(self, url=None): def main(self, url=None):
ew = ElectrumWindow(self.wallet, self.config) ew = ElectrumWindow(self.wallet, self.config)

6
lib/wallet.py

@ -450,6 +450,7 @@ class Wallet:
if not self.is_mine(address): return False if not self.is_mine(address): return False
if address in self.imported_keys.keys(): return False if address in self.imported_keys.keys(): return False
acct, s = self.get_address_index(address) acct, s = self.get_address_index(address)
if s is None: return False
return s[0] == 1 return s[0] == 1
def get_master_public_key(self): def get_master_public_key(self):
@ -474,6 +475,9 @@ class Wallet:
if address in self.imported_keys.keys(): if address in self.imported_keys.keys():
return -1, None return -1, None
if address in self.first_addresses.values():
return -1, None
for account in self.accounts.keys(): for account in self.accounts.keys():
for for_change in [0,1]: for for_change in [0,1]:
addresses = self.accounts[account].get_addresses(for_change) addresses = self.accounts[account].get_addresses(for_change)
@ -481,7 +485,7 @@ class Wallet:
if address == addr: if address == addr:
return account, (for_change, addresses.index(addr)) return account, (for_change, addresses.index(addr))
raise BaseException("not found") raise BaseException("Address not found", address)
def rebase_sequence(self, account, sequence): def rebase_sequence(self, account, sequence):

Loading…
Cancel
Save