self.config = config
self.init_plugins()
+ self.create_status_bar()
+
self.wallet.interface.register_callback('updated', lambda: self.emit(QtCore.SIGNAL('update_wallet')))
self.wallet.interface.register_callback('banner', lambda: self.emit(QtCore.SIGNAL('banner_signal')))
self.wallet.interface.register_callback('disconnected', lambda: self.emit(QtCore.SIGNAL('update_status')))
tabs.setMinimumSize(600, 400)
tabs.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
self.setCentralWidget(tabs)
- self.create_status_bar()
g = self.config.get("winpos-qt",[100, 100, 840, 400])
self.setGeometry(g[0], g[1], g[2], g[3])
self.console.showMessage(self.wallet.banner)
# plugins that need to change the GUI do it here
- self.run_hook('init')
+ self.run_hook('init_gui')
# plugins
plugin_names = [name for a, name, b in pkgutil.iter_modules([pathname])]
plugin_names = filter( lambda name: os.path.exists(os.path.join(pathname,name+'.py')), plugin_names)
imp.load_module('electrum_plugins', fp, pathname, description)
- self.plugins = map(lambda name: imp.load_source('electrum_plugins.'+name, os.path.join(pathname,name+'.py')), plugin_names)
+ plugins = map(lambda name: imp.load_source('electrum_plugins.'+name, os.path.join(pathname,name+'.py')), plugin_names)
else:
import electrum_plugins
plugin_names = [name for a, name, b in pkgutil.iter_modules(electrum_plugins.__path__)]
- self.plugins = [ __import__('electrum_plugins.'+name, fromlist=['electrum_plugins']) for name in plugin_names]
+ plugins = [ __import__('electrum_plugins.'+name, fromlist=['electrum_plugins']) for name in plugin_names]
- self.plugin_hooks = {}
- for p in self.plugins:
+ self.plugins = []
+ for p in plugins:
try:
- p.init(self)
+ self.plugins.append( p.Plugin(self) )
except:
print_msg("Error:cannot initialize plugin",p)
traceback.print_exc(file=sys.stdout)
- def set_hook(self, name, callback):
- h = self.plugin_hooks.get(name, [])
- h.append(callback)
- self.plugin_hooks[name] = h
-
- def unset_hook(self, name, callback):
- h = self.plugin_hooks.get(name,[])
- if callback in h: h.remove(callback)
- self.plugin_hooks[name] = h
def run_hook(self, name, *args):
- args = (self,) + args
- for cb in self.plugin_hooks.get(name,[]):
- apply(cb, args)
-
+ for p in self.plugins:
+ if not p.is_enabled():
+ continue
+ try:
+ f = eval('p.'+name)
+ except:
+ continue
+ apply(f, args)
+ return
+
def set_label(self, name, text = None):
changed = False
old_text = self.wallet.labels.get(name)
vbox.addWidget(QLabel("Date: %s"%time_str))
vbox.addWidget(QLabel("Status: %d confirmations"%conf))
if is_mine:
- if fee:
+ if fee is not None:
vbox.addWidget(QLabel("Amount sent: %s"% format_satoshis(v-fee, False)))
vbox.addWidget(QLabel("Transaction fee: %s"% format_satoshis(fee, False)))
else:
def address_label_changed(self, item, column, l, column_addr, column_label):
-
if column == column_label:
addr = unicode( item.text(column_addr) )
text = unicode( item.text(column_label) )
for address in account[is_change]:
h = self.wallet.history.get(address,[])
- if not is_change:
- if h == []:
- gap += 1
- if gap > self.wallet.gap_limit:
- is_red = True
- else:
- gap = 0
+ if h == []:
+ gap += 1
+ if gap > self.wallet.gap_limit:
+ is_red = True
+ else:
+ gap = 0
num_tx = '*' if h == ['*'] else "%d"%len(h)
item = QTreeWidgetItem( [ address, '', '', num_tx] )
for address in self.wallet.addressbook:
label = self.wallet.labels.get(address,'')
- n = 0
- for tx in self.wallet.transactions.values():
- if address in map(lambda x: x[0], tx.outputs): n += 1
-
+ n = self.wallet.get_num_tx(address)
item = QTreeWidgetItem( [ address, label, "%d"%n] )
item.setFont(0, QFont(MONOSPACE_FONT))
# 32 = label can be edited (bool)
if (int(qtVersion[0]) >= 4 and int(qtVersion[2]) >= 7):
sb.addPermanentWidget( StatusBarButton( QIcon(":icons/switchgui.png"), _("Switch to Lite Mode"), self.go_lite ) )
if self.wallet.seed:
- sb.addPermanentWidget( StatusBarButton( QIcon(":icons/lock.png"), _("Password"), lambda: self.change_password_dialog(self.wallet, self) ) )
+ self.lock_icon = QIcon(":icons/lock.png") if self.wallet.use_encryption else QIcon(":icons/unlock.png")
+ self.password_button = StatusBarButton( self.lock_icon, _("Password"), lambda: self.change_password_dialog(self.wallet, self) )
+ sb.addPermanentWidget( self.password_button )
sb.addPermanentWidget( StatusBarButton( QIcon(":icons/preferences.png"), _("Preferences"), self.settings_dialog ) )
if self.wallet.seed:
sb.addPermanentWidget( StatusBarButton( QIcon(":icons/seed.png"), _("Seed"), self.show_seed_dialog ) )
self.status_button = StatusBarButton( QIcon(":icons/status_disconnected.png"), _("Network"), lambda: self.network_dialog(self.wallet, self) )
sb.addPermanentWidget( self.status_button )
+ self.run_hook('create_status_bar', (sb,))
+
self.setStatusBar(sb)
def go_lite(self):
vbox.addLayout(grid)
vbox.addLayout(ok_cancel_buttons(d))
- d.setLayout(vbox)
+ d.setLayout(vbox)
+ self.run_hook('password_dialog', pw, grid, 1)
if not d.exec_(): return
return unicode(pw.text())
return ElectrumWindow.change_password_dialog(wallet, parent) # Retry
wallet.update_password(seed, password, new_password)
+ if parent:
+ icon = QIcon(":icons/lock.png") if wallet.use_encryption else QIcon(":icons/unlock.png")
+ parent.password_button.setIcon( icon )
+
@staticmethod
def seed_dialog(wallet, parent=None):
for key, value in json.loads(data).items():
self.wallet.labels[key] = value
self.wallet.save()
- QMessageBox.information(None, _("Labels imported"), _("Your labels where imported from")+" '%s'" % str(labelsFile))
+ QMessageBox.information(None, _("Labels imported"), _("Your labels were imported from")+" '%s'" % str(labelsFile))
except (IOError, os.error), reason:
QMessageBox.critical(None, _("Unable to import labels"), _("Electrum was unable to import your labels.")+"\n" + str(reason))
@protected
def do_import_privkey(self, password):
if not self.wallet.imported_keys:
- r = QMessageBox.question(None, _('Warning'), _('Warning: Imported keys are not recoverable from seed.') + ' ' \
- + _('If you ever need to restore your wallet from its seed, these keys will be lost.') + '\n\n' \
+ r = QMessageBox.question(None, _('Warning'), '<b>'+_('Warning') +':\n</b><br/>'+ _('Imported keys are not recoverable from seed.') + ' ' \
+ + _('If you ever need to restore your wallet from its seed, these keys will be lost.') + '<p>' \
+ + _('In addition, when you send bitcoins from one of your imported addresses, the "change" will be sent to an address derived from your seed, unless you disabled this option.') + '<p>' \
+ _('Are you sure you understand what you are doing?'), 3, 4)
if r == 4: return
vbox = QVBoxLayout()
tabs = QTabWidget(self)
+ self.settings_tab = tabs
vbox.addWidget(tabs)
tab1 = QWidget()
grid_plugins.setColumnStretch(0,1)
tabs.addTab(tab5, _('Plugins') )
def mk_toggle(cb, p):
- return lambda: cb.setChecked(p.toggle(self))
+ return lambda: cb.setChecked(p.toggle())
for i, p in enumerate(self.plugins):
try:
name, description = p.get_info()
traceback.print_exc(file=sys.stdout)
grid_plugins.setRowStretch(i+1,1)
+ self.run_hook('create_settings_tab', tabs)
+
vbox.addLayout(ok_cancel_buttons(d))
d.setLayout(vbox)
self.config.set_key('currency', cur_request, True)
self.update_wallet()
+ self.run_hook('close_settings_dialog')
+
if need_restart:
QMessageBox.warning(self, _('Success'), _('Please restart Electrum to activate the new GUI settings'), _('OK'))
for p in protocol_letters:
i = protocol_letters.index(p)
j = server_protocol.model().index(i,0)
- if p not in pp.keys():
+ if p not in pp.keys() and interface.is_connected:
server_protocol.model().setData(j, QtCore.QVariant(0), QtCore.Qt.UserRole-1)
else:
server_protocol.model().setData(j, QtCore.QVariant(0,False), QtCore.Qt.UserRole-1)