update guis for new contacts
This commit is contained in:
@@ -76,11 +76,7 @@ def edit_label(addr):
|
|||||||
def select_from_contacts():
|
def select_from_contacts():
|
||||||
title = 'Contacts:'
|
title = 'Contacts:'
|
||||||
droid.dialogCreateAlert(title)
|
droid.dialogCreateAlert(title)
|
||||||
l = []
|
l = contacts.keys()
|
||||||
for i in range(len(wallet.addressbook)):
|
|
||||||
addr = wallet.addressbook[i]
|
|
||||||
label = wallet.labels.get(addr,addr)
|
|
||||||
l.append( label )
|
|
||||||
droid.dialogSetItems(l)
|
droid.dialogSetItems(l)
|
||||||
droid.dialogSetPositiveButtonText('New contact')
|
droid.dialogSetPositiveButtonText('New contact')
|
||||||
droid.dialogShow()
|
droid.dialogShow()
|
||||||
@@ -92,8 +88,8 @@ def select_from_contacts():
|
|||||||
|
|
||||||
result = response.get('item')
|
result = response.get('item')
|
||||||
if result is not None:
|
if result is not None:
|
||||||
addr = wallet.addressbook[result]
|
t, v = contacts.get(result)
|
||||||
return addr
|
return v
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -483,7 +479,8 @@ def make_new_contact():
|
|||||||
address = None
|
address = None
|
||||||
if address:
|
if address:
|
||||||
if modal_question('Add to contacts?', address):
|
if modal_question('Add to contacts?', address):
|
||||||
wallet.add_contact(address)
|
# fixme: ask for key
|
||||||
|
contacts[address] = ('address', address)
|
||||||
else:
|
else:
|
||||||
modal_dialog('Invalid address', data)
|
modal_dialog('Invalid address', data)
|
||||||
|
|
||||||
@@ -893,17 +890,20 @@ droid = android.Android()
|
|||||||
menu_commands = ["send", "receive", "settings", "contacts", "main"]
|
menu_commands = ["send", "receive", "settings", "contacts", "main"]
|
||||||
wallet = None
|
wallet = None
|
||||||
network = None
|
network = None
|
||||||
|
contacts = None
|
||||||
|
|
||||||
class ElectrumGui:
|
class ElectrumGui:
|
||||||
|
|
||||||
def __init__(self, config, _network):
|
def __init__(self, config, _network):
|
||||||
global wallet, network
|
global wallet, network, contacts
|
||||||
network = _network
|
network = _network
|
||||||
network.register_callback('updated', update_callback)
|
network.register_callback('updated', update_callback)
|
||||||
network.register_callback('connected', update_callback)
|
network.register_callback('connected', update_callback)
|
||||||
network.register_callback('disconnected', update_callback)
|
network.register_callback('disconnected', update_callback)
|
||||||
network.register_callback('disconnecting', update_callback)
|
network.register_callback('disconnecting', update_callback)
|
||||||
|
|
||||||
|
contacts = util.StoreDict(config, 'contacts')
|
||||||
|
|
||||||
storage = WalletStorage(config)
|
storage = WalletStorage(config)
|
||||||
if not storage.file_exists:
|
if not storage.file_exists:
|
||||||
action = self.restore_or_create()
|
action = self.restore_or_create()
|
||||||
|
|||||||
18
gui/gtk.py
18
gui/gtk.py
@@ -466,6 +466,9 @@ class ElectrumWindow:
|
|||||||
self.window.set_default_size(720, 350)
|
self.window.set_default_size(720, 350)
|
||||||
self.wallet_updated = False
|
self.wallet_updated = False
|
||||||
|
|
||||||
|
from electrum.util import StoreDict
|
||||||
|
self.contacts = StoreDict(self.config, 'contacts')
|
||||||
|
|
||||||
vbox = Gtk.VBox()
|
vbox = Gtk.VBox()
|
||||||
|
|
||||||
self.notebook = Gtk.Notebook()
|
self.notebook = Gtk.Notebook()
|
||||||
@@ -1154,17 +1157,10 @@ class ElectrumWindow:
|
|||||||
self.recv_list.append((address, label, tx, format_satoshis(c,False,self.num_zeros), Type ))
|
self.recv_list.append((address, label, tx, format_satoshis(c,False,self.num_zeros), Type ))
|
||||||
|
|
||||||
def update_sending_tab(self):
|
def update_sending_tab(self):
|
||||||
# detect addresses that are not mine in history, add them here...
|
|
||||||
self.addressbook_list.clear()
|
self.addressbook_list.clear()
|
||||||
#for alias, v in self.wallet.aliases.items():
|
for k, v in self.contacts.items():
|
||||||
# s, target = v
|
t, v = v
|
||||||
# label = self.wallet.labels.get(alias)
|
self.addressbook_list.append((k, v, t))
|
||||||
# self.addressbook_list.append((alias, label, '-'))
|
|
||||||
|
|
||||||
for address in self.wallet.addressbook:
|
|
||||||
label = self.wallet.labels.get(address)
|
|
||||||
n = self.wallet.get_num_tx(address)
|
|
||||||
self.addressbook_list.append((address, label, "%d"%n))
|
|
||||||
|
|
||||||
def update_history_tab(self):
|
def update_history_tab(self):
|
||||||
cursor = self.history_treeview.get_cursor()[0]
|
cursor = self.history_treeview.get_cursor()[0]
|
||||||
@@ -1268,7 +1264,7 @@ class ElectrumWindow:
|
|||||||
|
|
||||||
if result == 1:
|
if result == 1:
|
||||||
if is_valid(address):
|
if is_valid(address):
|
||||||
self.wallet.add_contact(address,label)
|
self.contacts[label] = address
|
||||||
self.update_sending_tab()
|
self.update_sending_tab()
|
||||||
else:
|
else:
|
||||||
errorDialog = Gtk.MessageDialog(
|
errorDialog = Gtk.MessageDialog(
|
||||||
|
|||||||
18
gui/stdio.py
18
gui/stdio.py
@@ -2,7 +2,7 @@ from decimal import Decimal
|
|||||||
_ = lambda x:x
|
_ = lambda x:x
|
||||||
#from i18n import _
|
#from i18n import _
|
||||||
from electrum.wallet import WalletStorage, Wallet
|
from electrum.wallet import WalletStorage, Wallet
|
||||||
from electrum.util import format_satoshis, set_verbosity
|
from electrum.util import format_satoshis, set_verbosity, StoreDict
|
||||||
from electrum.bitcoin import is_valid
|
from electrum.bitcoin import is_valid
|
||||||
from electrum.network import filter_protocol
|
from electrum.network import filter_protocol
|
||||||
import sys, getpass, datetime
|
import sys, getpass, datetime
|
||||||
@@ -32,6 +32,7 @@ class ElectrumGui:
|
|||||||
|
|
||||||
self.wallet = Wallet(storage)
|
self.wallet = Wallet(storage)
|
||||||
self.wallet.start_threads(network)
|
self.wallet.start_threads(network)
|
||||||
|
self.contacts = StoreDict(self.config, 'contacts')
|
||||||
|
|
||||||
self.wallet.network.register_callback('updated', self.updated)
|
self.wallet.network.register_callback('updated', self.updated)
|
||||||
self.wallet.network.register_callback('connected', self.connected)
|
self.wallet.network.register_callback('connected', self.connected)
|
||||||
@@ -133,8 +134,8 @@ class ElectrumGui:
|
|||||||
|
|
||||||
|
|
||||||
def print_contacts(self):
|
def print_contacts(self):
|
||||||
messages = map(lambda addr: "%30s %30s "%(addr, self.wallet.labels.get(addr,"")), self.wallet.addressbook)
|
messages = map(lambda x: "%20s %45s "%(x[0], x[1][1]), self.contacts.items())
|
||||||
self.print_list(messages, "%19s %25s "%("Address", "Label"))
|
self.print_list(messages, "%19s %25s "%("Key", "Value"))
|
||||||
|
|
||||||
def print_addresses(self):
|
def print_addresses(self):
|
||||||
messages = map(lambda addr: "%30s %30s "%(addr, self.wallet.labels.get(addr,"")), self.wallet.addresses())
|
messages = map(lambda addr: "%30s %30s "%(addr, self.wallet.labels.get(addr,"")), self.wallet.addresses())
|
||||||
@@ -239,14 +240,3 @@ class ElectrumGui:
|
|||||||
|
|
||||||
def run_contacts_tab(self, c):
|
def run_contacts_tab(self, c):
|
||||||
pass
|
pass
|
||||||
# if c == 10 and self.wallet.addressbook:
|
|
||||||
# out = self.run_popup('Adress', ["Copy", "Pay to", "Edit label", "Delete"]).get('button')
|
|
||||||
# address = self.wallet.addressbook[self.pos%len(self.wallet.addressbook)]
|
|
||||||
# if out == "Pay to":
|
|
||||||
# self.tab = 1
|
|
||||||
# self.str_recipient = address
|
|
||||||
# self.pos = 2
|
|
||||||
# elif out == "Edit label":
|
|
||||||
# s = self.get_string(6 + self.pos, 18)
|
|
||||||
# if s:
|
|
||||||
# self.wallet.labels[address] = s
|
|
||||||
|
|||||||
12
gui/text.py
12
gui/text.py
@@ -3,6 +3,7 @@ from decimal import Decimal
|
|||||||
_ = lambda x:x
|
_ = lambda x:x
|
||||||
#from i18n import _
|
#from i18n import _
|
||||||
from electrum.util import format_satoshis, set_verbosity
|
from electrum.util import format_satoshis, set_verbosity
|
||||||
|
from electrum.util import StoreDict
|
||||||
from electrum.bitcoin import is_valid
|
from electrum.bitcoin import is_valid
|
||||||
|
|
||||||
from electrum import Wallet, WalletStorage
|
from electrum import Wallet, WalletStorage
|
||||||
@@ -23,6 +24,7 @@ class ElectrumGui:
|
|||||||
|
|
||||||
self.wallet = Wallet(storage)
|
self.wallet = Wallet(storage)
|
||||||
self.wallet.start_threads(self.network)
|
self.wallet.start_threads(self.network)
|
||||||
|
self.contacts = StoreDict(self.config, 'contacts')
|
||||||
|
|
||||||
locale.setlocale(locale.LC_ALL, '')
|
locale.setlocale(locale.LC_ALL, '')
|
||||||
self.encoding = locale.getpreferredencoding()
|
self.encoding = locale.getpreferredencoding()
|
||||||
@@ -145,8 +147,8 @@ class ElectrumGui:
|
|||||||
|
|
||||||
|
|
||||||
def print_contacts(self):
|
def print_contacts(self):
|
||||||
messages = map(lambda addr: "%30s %30s "%(addr, self.wallet.labels.get(addr,"")), self.wallet.addressbook)
|
messages = map(lambda x: "%20s %45s "%(x[0], x[1][1]), self.contacts.items())
|
||||||
self.print_list(messages, "%19s %25s "%("Address", "Label"))
|
self.print_list(messages, "%19s %15s "%("Key", "Value"))
|
||||||
|
|
||||||
def print_receive(self):
|
def print_receive(self):
|
||||||
fmt = "%-35s %-30s"
|
fmt = "%-35s %-30s"
|
||||||
@@ -248,12 +250,12 @@ class ElectrumGui:
|
|||||||
out = self.run_popup('Address', ["Edit label", "Freeze", "Prioritize"])
|
out = self.run_popup('Address', ["Edit label", "Freeze", "Prioritize"])
|
||||||
|
|
||||||
def run_contacts_tab(self, c):
|
def run_contacts_tab(self, c):
|
||||||
if c == 10 and self.wallet.addressbook:
|
if c == 10 and self.contacts:
|
||||||
out = self.run_popup('Adress', ["Copy", "Pay to", "Edit label", "Delete"]).get('button')
|
out = self.run_popup('Adress', ["Copy", "Pay to", "Edit label", "Delete"]).get('button')
|
||||||
address = self.wallet.addressbook[self.pos%len(self.wallet.addressbook)]
|
key = self.contacts.keys()[self.pos%len(self.contacts.keys())]
|
||||||
if out == "Pay to":
|
if out == "Pay to":
|
||||||
self.tab = 1
|
self.tab = 1
|
||||||
self.str_recipient = address
|
self.str_recipient = key
|
||||||
self.pos = 2
|
self.pos = 2
|
||||||
elif out == "Edit label":
|
elif out == "Edit label":
|
||||||
s = self.get_string(6 + self.pos, 18)
|
s = self.get_string(6 + self.pos, 18)
|
||||||
|
|||||||
Reference in New Issue
Block a user