URI: 
       tdo not use hardcoded tab indexes - electrum - Electrum Bitcoin wallet
  HTML git clone https://git.parazyd.org/electrum
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
       ---
   DIR commit f92807f019db811f6b8a005da200772caa212840
   DIR parent cc852ef6a5731bb9a8e8d5ec3323aff808a42c34
  HTML Author: ThomasV <thomasv@electrum.org>
       Date:   Mon,  6 Mar 2017 13:52:27 +0100
       
       do not use hardcoded tab indexes
       
       Diffstat:
         M gui/qt/main_window.py               |      46 ++++++++++++++++---------------
         M gui/qt/utxo_list.py                 |       1 +
       
       2 files changed, 25 insertions(+), 22 deletions(-)
       ---
   DIR diff --git a/gui/qt/main_window.py b/gui/qt/main_window.py
       t@@ -123,13 +123,15 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
                self.completions = QStringListModel()
        
                self.tabs = tabs = QTabWidget(self)
       -        tabs.addTab(self.create_history_tab(), _('History') )
       -        tabs.addTab(self.create_send_tab(), _('Send') )
       -        tabs.addTab(self.create_receive_tab(), _('Receive') )
       +        self.send_tab = self.create_send_tab()
       +        self.receive_tab = self.create_receive_tab()
                self.addresses_tab = self.create_addresses_tab()
       +        self.utxo_tab = self.create_utxo_tab()
       +        tabs.addTab(self.create_history_tab(), _('History') )
       +        tabs.addTab(self.send_tab, _('Send') )
       +        tabs.addTab(self.receive_tab, _('Receive') )
                if self.config.get('show_addresses_tab', False):
                    tabs.addTab(self.addresses_tab, _('Addresses'))
       -        self.utxo_tab = self.create_utxo_tab()
                if self.config.get('show_utxo_tab', False):
                    tabs.addTab(self.utxo_tab, _('Coins'))
                tabs.addTab(self.create_contacts_tab(), _('Contacts') )
       t@@ -691,6 +693,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
            def create_history_tab(self):
                from history_list import HistoryList
                self.history_list = l = HistoryList(self)
       +        l.searchable_list = l
                return l
        
            def show_address(self, addr):
       t@@ -785,6 +788,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
                hbox.addWidget(self.receive_qr)
        
                w = QWidget()
       +        w.searchable_list = self.request_list
                vbox = QVBoxLayout(w)
                vbox.addLayout(hbox)
                vbox.addStretch(1)
       t@@ -926,11 +930,16 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
                        self.qr_window.setVisible(False)
                self.update_receive_qr()
        
       +    def show_send_tab(self):
       +        self.tabs.setCurrentIndex(self.tabs.indexOf(self.send_tab))
       +
       +    def show_receive_tab(self):
       +        self.tabs.setCurrentIndex(self.tabs.indexOf(self.receive_tab))
        
            def receive_at(self, addr):
                if not bitcoin.is_address(addr):
                    return
       -        self.tabs.setCurrentIndex(2)
       +        self.show_receive_tab()
                self.receive_address_e.setText(addr)
                self.new_request_button.setEnabled(True)
        
       t@@ -1092,6 +1101,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
                vbox.addWidget(self.invoices_label)
                vbox.addWidget(self.invoice_list)
                vbox.setStretchFactor(self.invoice_list, 1000)
       +        w.searchable_list = self.invoice_list
                run_hook('create_send_tab', grid)
                return w
        
       t@@ -1393,7 +1403,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
                self.max_button.setEnabled(not b)
        
            def prepare_for_payment_request(self):
       -        self.tabs.setCurrentIndex(1)
       +        self.show_send_tab()
                self.payto_e.is_pr = True
                for e in [self.payto_e, self.amount_e, self.message_e]:
                    e.setFrozen(True)
       t@@ -1445,7 +1455,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
                except BaseException as e:
                    self.show_error(_('Invalid bitcoin URI:') + '\n' + str(e))
                    return
       -        self.tabs.setCurrentIndex(1)
       +        self.show_send_tab()
                r = out.get('r')
                sig = out.get('sig')
                name = out.get('name')
       t@@ -1489,6 +1499,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
        
            def create_list_tab(self, l):
                w = QWidget()
       +        w.searchable_list = l
                vbox = QVBoxLayout()
                w.setLayout(vbox)
                vbox.setMargin(0)
       t@@ -1528,11 +1539,11 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
        
            def spend_coins(self, coins):
                self.set_pay_from(coins)
       -        self.tabs.setCurrentIndex(1)
       +        self.show_send_tab()
                self.update_fee()
        
            def paytomany(self):
       -        self.tabs.setCurrentIndex(1)
       +        self.show_send_tab()
                self.payto_e.paytomany()
                msg = '\n'.join([
                    _('Enter a list of outputs in the \'Pay to\' field.'),
       t@@ -1544,7 +1555,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
        
            def payto_contacts(self, labels):
                paytos = [self.get_contact_payto(label) for label in labels]
       -        self.tabs.setCurrentIndex(1)
       +        self.show_send_tab()
                if len(paytos) == 1:
                    self.payto_e.setText(paytos[0])
                    self.amount_e.setFocus()
       t@@ -1708,18 +1719,9 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
                    self.do_search('')
        
            def do_search(self, t):
       -        i = self.tabs.currentIndex()
       -        if i == 0:
       -            self.history_list.filter(t)
       -        elif i == 1:
       -            self.invoice_list.filter(t)
       -        elif i == 2:
       -            self.request_list.filter(t)
       -        elif i == 3:
       -            self.address_list.filter(t)
       -        elif i == 4:
       -            self.contact_list.filter(t)
       -
       +        tab = self.tabs.currentWidget()
       +        if hasattr(tab, 'searchable_list'):
       +            tab.searchable_list.filter(t)
        
            def new_contact_dialog(self):
                d = WindowModalDialog(self, _("New Contact"))
   DIR diff --git a/gui/qt/utxo_list.py b/gui/qt/utxo_list.py
       t@@ -29,6 +29,7 @@ from electrum.bitcoin import is_address
        
        
        class UTXOList(MyTreeWidget):
       +    filter_columns = [0, 2]  # Address, Label
        
            def __init__(self, parent=None):
                MyTreeWidget.__init__(self, parent, self.create_menu, [ _('Address'), _('Output point'), _('Label'), _('Amount'), ''], 2)