URI: 
       tGet URIs working properly for multiple windows - electrum - Electrum Bitcoin wallet
  HTML git clone https://git.parazyd.org/electrum
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
       ---
   DIR commit 27917af2bffd8f79c3fe31db3ccd6d93fe9f01cf
   DIR parent 4655c5f5654097cb4385adcb3c414268b6dbdc9b
  HTML Author: Neil Booth <kyuupichan@gmail.com>
       Date:   Thu,  3 Sep 2015 17:23:43 +0900
       
       Get URIs working properly for multiple windows
       
       Diffstat:
         M electrum                            |      13 +------------
         M gui/qt/__init__.py                  |      28 +++++++++++++++++++---------
       
       2 files changed, 20 insertions(+), 21 deletions(-)
       ---
   DIR diff --git a/electrum b/electrum
       t@@ -20,7 +20,6 @@
        from decimal import Decimal
        import json
        import os
       -import re
        import sys
        import time
        import traceback
       t@@ -298,7 +297,7 @@ class ClientThread(util.DaemonThread):
                    if self.server.gui:
                        if hasattr(server.gui, 'new_window'):
                            path = config.get_wallet_path()
       -                    self.server.gui.new_window(path)
       +                    self.server.gui.new_window(path, config.get('url'))
                            response = "ok"
                        else:
                            response = "error: current GUI does not support multiple windows"
       t@@ -482,16 +481,6 @@ if __name__ == '__main__':
            config = SimpleConfig(config_options)
            cmd_name = config.get('cmd')
        
       -    # check url
       -    url = config.get('url')
       -    if url:
       -        if os.path.exists(url):
       -            # assume this is a payment request
       -            url = "bitcoin:?r=file://"+ os.path.join(os.getcwd(), url)
       -        if not re.match('^bitcoin:', url):
       -            print_stderr('unknown command:', url)
       -            sys.exit(1)
       -
            # initialize plugins.
            plugins = None
            if not is_android:
   DIR diff --git a/gui/qt/__init__.py b/gui/qt/__init__.py
       t@@ -17,7 +17,8 @@
        # along with this program. If not, see <http://www.gnu.org/licenses/>.
        
        import sys
       -import os.path
       +import os
       +import re
        import signal
        
        try:
       t@@ -199,13 +200,13 @@ class ElectrumGui:
                    return
                wallet = wizard.run(action, wallet_type)
                if wallet:
       -            self.start_new_window(full_path)
       +            self.start_new_window(full_path, None)
        
       -    def new_window(self, path):
       +    def new_window(self, path, uri):
                # Use a signal as can be called from daemon thread
       -        self.app.emit(SIGNAL('new_window'), path)
       +        self.app.emit(SIGNAL('new_window'), path, uri)
        
       -    def start_new_window(self, path):
       +    def start_new_window(self, path, uri):
                for w in self.windows:
                    if w.wallet.storage.path == path:
                        w.bring_to_top()
       t@@ -228,9 +229,17 @@ class ElectrumGui:
                    self.windows.append(w)
                    self.build_tray_menu()
        
       -        url = self.config.get('url')
       -        if url:
       -            w.pay_to_URI(url)
       +        if uri:
       +            print "URI: ", uri
       +            if os.path.exists(uri):
       +                # assume this is a payment request
       +                uri = "bitcoin:?r=file://"+ os.path.join(os.getcwd(), uri)
       +            if re.match('^bitcoin:', uri):
       +                w.pay_to_URI(uri)
       +            else:
       +                QMessageBox.critical(None, "Error",
       +                                     _("bad bitcoin URI: %s") % uri)
       +
                return w
        
            def close_window(self, window):
       t@@ -246,7 +255,8 @@ class ElectrumGui:
                        self.config.cmdline_options['default_wallet_path'] = last_wallet
        
                # main window
       -        self.main_window = self.start_new_window(self.config.get_wallet_path())
       +        self.main_window = self.start_new_window(self.config.get_wallet_path(),
       +                                                 self.config.get('url'))
                if not self.main_window:
                    return