URI: 
       tuse callback instead of wallet.was_updated - electrum - Electrum Bitcoin wallet
  HTML git clone https://git.parazyd.org/electrum
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
       ---
   DIR commit 6de8a946eb129f051acbf4698b32ca90a4b139c5
   DIR parent 2307323bb7b254aff3512336b17872af9fc53e6e
  HTML Author: ThomasV <thomasv@gitorious>
       Date:   Sat, 27 Oct 2012 19:20:50 +0200
       
       use callback instead of wallet.was_updated
       
       Diffstat:
         M lib/gui.py                          |      12 +++++++++---
         M lib/verifier.py                     |       2 +-
         M lib/wallet.py                       |      18 +++++++++---------
       
       3 files changed, 19 insertions(+), 13 deletions(-)
       ---
   DIR diff --git a/lib/gui.py b/lib/gui.py
       t@@ -669,6 +669,10 @@ class ElectrumWindow:
                self.context_id = self.status_bar.get_context_id("statusbar")
                self.update_status_bar()
        
       +        self.wallet_updated = False
       +        self.wallet.interface.register_callback('updated', self.update_callback)
       +
       +
                def update_status_bar_thread():
                    while True:
                        gobject.idle_add( self.update_status_bar )
       t@@ -700,6 +704,9 @@ class ElectrumWindow:
                    thread.start_new_thread(check_recipient_thread, ())
                self.notebook.set_current_page(0)
        
       +    def update_callback(self):
       +        self.wallet_updated = True
       +
        
            def add_tab(self, page, name):
                tab_label = gtk.Label(name)
       t@@ -1182,13 +1189,12 @@ class ElectrumWindow:
                self.status_bar.pop(self.context_id) 
                self.status_bar.push(self.context_id, text)
        
       -        if self.wallet.was_updated and self.wallet.up_to_date:
       +        if self.wallet.up_to_date and self.wallet_updated:
                    self.update_history_tab()
                    self.update_receiving_tab()
                    # addressbook too...
                    self.info.set_text( self.wallet.banner )
       -            self.wallet.was_updated = False
       -        
       +            self.wallet_updated = False
        
            def update_receiving_tab(self):
                self.recv_list.clear()
   DIR diff --git a/lib/verifier.py b/lib/verifier.py
       t@@ -219,7 +219,7 @@ class WalletVerifier(threading.Thread):
                    return False
        
                self.save_header(header)
       -        print_error("verify header: ok %d"%height)
       +        print_error("verify header:", _hash, height)
                return True
                
        
   DIR diff --git a/lib/wallet.py b/lib/wallet.py
       t@@ -77,7 +77,6 @@ class Wallet:
                # not saved
                self.receipt = None          # next receipt
                self.tx_history = {}
       -        self.was_updated = True
                self.banner = ''
        
                # spv
       t@@ -838,6 +837,7 @@ class WalletSynchronizer(threading.Thread):
                self.interface.register_channel('synchronizer')
                self.wallet.interface.register_callback('connected', self.wallet.init_up_to_date)
                self.wallet.interface.register_callback('connected', lambda: self.interface.send([('server.banner',[])],'synchronizer') )
       +        self.was_updated = True
        
            def synchronize_wallet(self):
                new_addresses = self.wallet.synchronize()
       t@@ -847,12 +847,12 @@ class WalletSynchronizer(threading.Thread):
                if self.interface.is_up_to_date('synchronizer'):
                    if not self.wallet.up_to_date:
                        self.wallet.up_to_date = True
       -                self.wallet.was_updated = True
       +                self.was_updated = True
                        self.wallet.up_to_date_event.set()
                else:
                    if self.wallet.up_to_date:
                        self.wallet.up_to_date = False
       -                self.wallet.was_updated = True
       +                self.was_updated = True
        
        
        
       t@@ -879,9 +879,9 @@ class WalletSynchronizer(threading.Thread):
                    # 1. send new requests
                    self.synchronize_wallet()
        
       -            if self.wallet.was_updated:
       +            if self.was_updated:
                        self.interface.trigger_callback('updated')
       -                self.wallet.was_updated = False
       +                self.was_updated = False
        
                    # 2. get a response
                    r = self.interface.get_response('synchronizer')
       t@@ -900,7 +900,7 @@ class WalletSynchronizer(threading.Thread):
                    elif method == 'blockchain.address.get_history':
                        addr = params[0]
                        self.wallet.receive_history_callback(addr, result)
       -                self.wallet.was_updated = True
       +                self.was_updated = True
        
                    elif method == 'blockchain.transaction.broadcast':
                        self.wallet.tx_result = result
       t@@ -908,13 +908,13 @@ class WalletSynchronizer(threading.Thread):
        
                    elif method == 'server.banner':
                        self.wallet.banner = result
       -                self.wallet.was_updated = True
       +                self.was_updated = True
        
                    else:
                        print_error("Error: Unknown message:" + method + ", " + repr(params) + ", " + repr(result) )
        
       -            if self.wallet.was_updated:
       +            if self.was_updated:
                        self.interface.trigger_callback('updated')
       -                self.wallet.was_updated = False
       +                self.was_updated = False