URI: 
       tmove set_url to __init__. fixes #672 - electrum - Electrum Bitcoin wallet
  HTML git clone https://git.parazyd.org/electrum
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
       ---
   DIR commit bb88c891dca13fdef9a3d3eb04d188aebb563709
   DIR parent 9196e9feeaa2eb5505edf95d597c49dd34842c79
  HTML Author: ThomasV <thomasv@gitorious>
       Date:   Wed, 30 Apr 2014 07:59:59 +0200
       
       move set_url to __init__. fixes #672
       
       Diffstat:
         M gui/qt/__init__.py                  |      27 ++++++++++++++++++++++++++-
         M gui/qt/main_window.py               |      25 +------------------------
         M lib/util.py                         |       7 ++-----
       
       3 files changed, 29 insertions(+), 30 deletions(-)
       ---
   DIR diff --git a/gui/qt/__init__.py b/gui/qt/__init__.py
       t@@ -147,6 +147,29 @@ class ElectrumGui:
                return int(qtVersion[0]) >= 4 and int(qtVersion[2]) >= 7
        
        
       +    def set_url(self, url):
       +        from electrum import util
       +        from decimal import Decimal
       +        try:
       +            address, amount, label, message, url = util.parse_url(url)
       +        except Exception:
       +            QMessageBox.warning(self.main_window, _('Error'), _('Invalid bitcoin URL'), _('OK'))
       +            return
       +
       +        try:
       +            if amount and self.main_window.base_unit() == 'mBTC': 
       +                amount = str( 1000* Decimal(amount))
       +            elif amount: 
       +                amount = str(Decimal(amount))
       +        except Exception:
       +            amount = "0.0"
       +            QMessageBox.warning(self.main_window, _('Error'), _('Invalid Amount'), _('OK'))
       +
       +            
       +        self.main_window.set_send(address, amount, label, message)
       +        if self.lite_window:
       +            self.lite_window.set_payment_fields(address, amount)
       +
        
            def main(self, url):
        
       t@@ -191,7 +214,9 @@ class ElectrumGui:
                s.start()
        
                self.windows.append(w)
       -        if url: w.set_url(url)
       +        if url: 
       +            self.set_url(url)
       +
                w.app = self.app
                w.connect_slots(s)
                w.update_wallet()
   DIR diff --git a/gui/qt/main_window.py b/gui/qt/main_window.py
       t@@ -880,22 +880,8 @@ class ElectrumWindow(QMainWindow):
        
        
        
       -    def set_url(self, url):
       -        try:
       -            address, amount, label, message, signature, identity, url = util.parse_url(url)
       -        except Exception:
       -            QMessageBox.warning(self, _('Error'), _('Invalid bitcoin URL'), _('OK'))
       -            return
        
       -        try:
       -            if amount and self.base_unit() == 'mBTC': amount = str( 1000* Decimal(amount))
       -            elif amount: amount = str(Decimal(amount))
       -        except Exception:
       -            amount = "0.0"
       -            QMessageBox.warning(self, _('Error'), _('Invalid Amount'), _('OK'))
       -
       -        if self.mini:
       -            self.mini.set_payment_fields(address, amount)
       +    def set_send(self, address, amount, label, message):
        
                if label and self.wallet.labels.get(address) != label:
                    if self.question('Give label "%s" to address %s ?'%(label,address)):
       t@@ -903,8 +889,6 @@ class ElectrumWindow(QMainWindow):
                            self.wallet.addressbook.append(address)
                        self.wallet.set_label(address, label)
        
       -        run_hook('set_url', url, self.show_message, self.question)
       -
                self.tabs.setCurrentIndex(1)
                label = self.wallet.labels.get(address)
                m_addr = label + '  <'+ address +'>' if label else address
       t@@ -914,13 +898,6 @@ class ElectrumWindow(QMainWindow):
                if amount:
                    self.amount_e.setText(amount)
        
       -        if identity:
       -            self.set_frozen(self.payto_e,True)
       -            self.set_frozen(self.amount_e,True)
       -            self.set_frozen(self.message_e,True)
       -            self.payto_sig.setText( '      '+_('The bitcoin URI was signed by')+' ' + identity )
       -        else:
       -            self.payto_sig.setVisible(False)
        
            def do_clear(self):
                self.payto_sig.setVisible(False)
   DIR diff --git a/lib/util.py b/lib/util.py
       t@@ -171,7 +171,7 @@ def parse_url(url):
        
            kv = {}
        
       -    amount = label = message = signature = identity = ''
       +    amount = label = message = ''
            for p in params:
                k,v = p.split('=')
                uv = urldecode(v)
       t@@ -191,11 +191,8 @@ def parse_url(url):
                message = kv['message']
            if 'label' in kv:
                label = kv['label']
       -    if 'signature' in kv:
       -        identity, signature = kv['signature'].split(':')
       -        url = url.replace('&%s=%s'%('signature',kv['signature']),'')
        
       -    return address, amount, label, message, signature, identity, url
       +    return address, amount, label, message, url
        
        
        # Python bug (http://bugs.python.org/issue1927) causes raw_input