From 889174ae195cacd7902e29ff73695748e6c0f736 Mon Sep 17 00:00:00 2001 From: Neil Booth Date: Tue, 28 Apr 2015 19:32:56 +0900 Subject: [PATCH 1/3] Show wallet basename in tray tooltip for those of us using multiple wallets Move basename (and title) logic to the wallet and use those member functions. --- gui/qt/main_window.py | 6 ++---- lib/wallet.py | 12 ++++++++++++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/gui/qt/main_window.py b/gui/qt/main_window.py index 4ad87cedc..d404c7bd7 100644 --- a/gui/qt/main_window.py +++ b/gui/qt/main_window.py @@ -211,9 +211,7 @@ class ElectrumWindow(QMainWindow): self.dummy_address = a[0] if a else None self.accounts_expanded = self.wallet.storage.get('accounts_expanded',{}) self.current_account = self.wallet.storage.get("current_account", None) - title = 'Electrum ' + self.wallet.electrum_version + ' - ' + os.path.basename(self.wallet.storage.path) - if self.wallet.is_watching_only(): title += ' [%s]' % (_('watching only')) - self.setWindowTitle( title ) + self.setWindowTitle( self.wallet.title() ) self.update_history_tab() self.update_wallet() # Once GUI has been initialized check if we want to announce something since the callback has been called before the GUI was initialized @@ -536,7 +534,7 @@ class ElectrumWindow(QMainWindow): text += "%s"%quote if self.tray: - self.tray.setToolTip(text) + self.tray.setToolTip("%s (%s)" % (text, self.wallet.basename())) icon = QIcon(":icons/status_connected.png") else: text = _("Not connected") diff --git a/lib/wallet.py b/lib/wallet.py index 6bf0af969..a8a9a9621 100644 --- a/lib/wallet.py +++ b/lib/wallet.py @@ -109,6 +109,9 @@ class WalletStorage(object): self.data[key] = value self.file_exists = True + def basename(self): + return os.path.basename(self.path) + def get(self, key, default=None): with self.lock: v = self.data.get(key) @@ -231,6 +234,15 @@ class Abstract_Wallet(object): def get_action(self): pass + def basename(self): + return self.storage.basename() + + def title(self): + s = 'Electrum %s - %s' % (self.electrum_version, self.basename()) + if self.is_watching_only(): + s += ' [%s]' % (_('watching only')) + return s + def convert_imported_keys(self, password): for k, v in self.imported_keys.items(): sec = pw_decode(v, password) From f56413d6024df2e0f6c88a4080f664e5b3c1349a Mon Sep 17 00:00:00 2001 From: Neil Booth Date: Tue, 28 Apr 2015 21:12:25 +0900 Subject: [PATCH 2/3] Put title() member func, with localization, in main_window.py --- gui/qt/main_window.py | 8 +++++++- lib/wallet.py | 6 ------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/gui/qt/main_window.py b/gui/qt/main_window.py index d404c7bd7..2d59e9fde 100644 --- a/gui/qt/main_window.py +++ b/gui/qt/main_window.py @@ -200,6 +200,12 @@ class ElectrumWindow(QMainWindow): self.wallet.stop_threads() run_hook('close_wallet') + def title(self): + s = 'Electrum %s - %s' % (self.wallet.electrum_version, self.wallet.basename()) + if self.wallet.is_watching_only(): + s += ' [%s]' % (_('watching only')) + return s + def load_wallet(self, wallet): import electrum self.wallet = wallet @@ -211,7 +217,7 @@ class ElectrumWindow(QMainWindow): self.dummy_address = a[0] if a else None self.accounts_expanded = self.wallet.storage.get('accounts_expanded',{}) self.current_account = self.wallet.storage.get("current_account", None) - self.setWindowTitle( self.wallet.title() ) + self.setWindowTitle( self.title() ) self.update_history_tab() self.update_wallet() # Once GUI has been initialized check if we want to announce something since the callback has been called before the GUI was initialized diff --git a/lib/wallet.py b/lib/wallet.py index a8a9a9621..20af3edac 100644 --- a/lib/wallet.py +++ b/lib/wallet.py @@ -237,12 +237,6 @@ class Abstract_Wallet(object): def basename(self): return self.storage.basename() - def title(self): - s = 'Electrum %s - %s' % (self.electrum_version, self.basename()) - if self.is_watching_only(): - s += ' [%s]' % (_('watching only')) - return s - def convert_imported_keys(self, password): for k, v in self.imported_keys.items(): sec = pw_decode(v, password) From db2517b9012079c51745838ec48e6feda038b03e Mon Sep 17 00:00:00 2001 From: Neil Booth Date: Thu, 30 Apr 2015 13:32:01 +0900 Subject: [PATCH 3/3] Shrink size of changes; functionality unchanged. --- gui/qt/main_window.py | 11 ++++------- lib/wallet.py | 5 +---- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/gui/qt/main_window.py b/gui/qt/main_window.py index 90c9c9e5c..b4043c804 100644 --- a/gui/qt/main_window.py +++ b/gui/qt/main_window.py @@ -200,12 +200,6 @@ class ElectrumWindow(QMainWindow): self.wallet.stop_threads() run_hook('close_wallet') - def title(self): - s = 'Electrum %s - %s' % (self.wallet.electrum_version, self.wallet.basename()) - if self.wallet.is_watching_only(): - s += ' [%s]' % (_('watching only')) - return s - def load_wallet(self, wallet): import electrum self.wallet = wallet @@ -217,7 +211,10 @@ class ElectrumWindow(QMainWindow): self.dummy_address = a[0] if a else None self.accounts_expanded = self.wallet.storage.get('accounts_expanded',{}) self.current_account = self.wallet.storage.get("current_account", None) - self.setWindowTitle( self.title() ) + title = 'Electrum %s - %s' % (self.wallet.electrum_version, self.wallet.basename()) + if self.wallet.is_watching_only(): + title += ' [%s]' % (_('watching only')) + self.setWindowTitle( title ) self.update_history_tab() self.update_wallet() # Once GUI has been initialized check if we want to announce something since the callback has been called before the GUI was initialized diff --git a/lib/wallet.py b/lib/wallet.py index 20af3edac..527fb6a19 100644 --- a/lib/wallet.py +++ b/lib/wallet.py @@ -109,9 +109,6 @@ class WalletStorage(object): self.data[key] = value self.file_exists = True - def basename(self): - return os.path.basename(self.path) - def get(self, key, default=None): with self.lock: v = self.data.get(key) @@ -235,7 +232,7 @@ class Abstract_Wallet(object): pass def basename(self): - return self.storage.basename() + return os.path.basename(self.storage.path) def convert_imported_keys(self, password): for k, v in self.imported_keys.items():