Browse Source

simplify get_label

283
ThomasV 9 years ago
parent
commit
9d3162b1a1
  1. 2
      gui/android.py
  2. 2
      gui/gtk.py
  3. 13
      gui/kivy/uix/screens.py
  4. 4
      gui/qt/history_widget.py
  5. 2
      gui/qt/main_window.py
  6. 2
      gui/qt/transaction_dialog.py
  7. 6
      gui/qt/util.py
  8. 2
      gui/stdio.py
  9. 2
      gui/text.py
  10. 19
      lib/wallet.py

2
gui/android.py

@ -332,7 +332,7 @@ def get_history_values(n):
except Exception:
time_str = 'pending'
conf_str = 'v' if conf else 'o'
label, is_default_label = wallet.get_label(tx_hash)
label = wallet.get_label(tx_hash)
label = label.replace('<','').replace('>','')
values.append((conf_str, ' ' + time_str, ' ' + format_satoshis(value, True), ' ' + label))

2
gui/gtk.py

@ -1185,7 +1185,7 @@ class ElectrumWindow:
time_str = 'pending'
conf_icon = Gtk.STOCK_EXECUTE
label, is_default_label = self.wallet.get_label(tx_hash)
label = self.wallet.get_label(tx_hash)
tooltip = tx_hash + "\n%d confirmations"%conf if tx_hash else ''
details = self.get_tx_details(tx_hash)

13
gui/kivy/uix/screens.py

@ -98,7 +98,7 @@ class HistoryScreen(CScreen):
def label_dialog(self, obj):
from dialogs.label_dialog import LabelDialog
key = obj.tx_hash
text = self.app.wallet.get_label(key)[0]
text = self.app.wallet.get_label(key)
def callback(text):
self.app.wallet.set_label(key, text)
self.update()
@ -127,12 +127,7 @@ class HistoryScreen(CScreen):
else:
icon = "atlas://gui/kivy/theming/light/confirmed"
if tx_hash:
label, is_default_label = self.app.wallet.get_label(tx_hash)
else:
label = _('Pruned transaction outputs')
is_default_label = False
label = self.app.wallet.get_label(tx_hash) if tx_hash else _('Pruned transaction outputs')
date = timestamp_to_datetime(timestamp)
rate = run_hook('history_rate', date)
if self.app.fiat_unit:
@ -430,9 +425,7 @@ class RequestsScreen(CScreen):
signature = req.get('sig')
ci = Factory.RequestItem()
ci.address = req['address']
label, is_default = self.app.wallet.get_label(address)
if label:
ci.memo = label
ci.memo = self.app.wallet.get_label(address)
status = req.get('status')
if status == PR_PAID:
ci.icon = "atlas://gui/kivy/theming/light/confirmed"

4
gui/qt/history_widget.py

@ -74,7 +74,7 @@ class HistoryWidget(MyTreeWidget):
icon, time_str = self.get_icon(conf, timestamp)
v_str = self.parent.format_amount(value, True, whitespaces=True)
balance_str = self.parent.format_amount(balance, whitespaces=True)
label, is_default_label = self.wallet.get_label(tx_hash)
label = self.wallet.get_label(tx_hash)
entry = ['', tx_hash, time_str, label, v_str, balance_str]
run_hook('history_tab_update', tx, entry)
item = QTreeWidgetItem(entry)
@ -88,8 +88,6 @@ class HistoryWidget(MyTreeWidget):
item.setForeground(4, QBrush(QColor("#BC1E1E")))
if tx_hash:
item.setData(0, Qt.UserRole, tx_hash)
if is_default_label:
item.setForeground(3, QBrush(QColor('grey')))
self.insertTopLevelItem(0, item)
if current_tx == tx_hash:
self.setCurrentItem(item)

2
gui/qt/main_window.py

@ -2435,7 +2435,7 @@ class ElectrumWindow(QMainWindow, PrintError):
value_string = '--'
if tx_hash:
label, is_default_label = wallet.get_label(tx_hash)
label = wallet.get_label(tx_hash)
label = label.encode('utf-8')
else:
label = ""

2
gui/qt/transaction_dialog.py

@ -173,7 +173,7 @@ class TxDialog(QDialog):
status = _("Signed")
if tx_hash in self.wallet.transactions.keys():
desc, is_default = self.wallet.get_label(tx_hash)
desc = self.wallet.get_label(tx_hash)
conf, timestamp = self.wallet.get_confirmations(tx_hash)
if timestamp:
time_str = datetime.datetime.fromtimestamp(timestamp).isoformat(' ')[:-3]

6
gui/qt/util.py

@ -383,12 +383,6 @@ class MyTreeWidget(QTreeWidget):
key = str(item.data(0, Qt.UserRole).toString())
text = unicode(item.text(column))
self.parent.wallet.set_label(key, text)
if text:
item.setForeground(column, QBrush(QColor('black')))
else:
text = self.parent.wallet.get_default_label(key)
item.setText(column, text)
item.setForeground(column, QBrush(QColor('gray')))
self.parent.history_list.update()
self.parent.update_completions()

2
gui/stdio.py

@ -96,7 +96,7 @@ class ElectrumGui:
else:
time_str = 'pending'
label, is_default_label = self.wallet.get_label(tx_hash)
label = self.wallet.get_label(tx_hash)
messages.append( format_str%( time_str, label, format_satoshis(value, whitespaces=True), format_satoshis(balance, whitespaces=True) ) )
self.print_list(messages[::-1], format_str%( _("Date"), _("Description"), _("Amount"), _("Balance")))

2
gui/text.py

@ -116,7 +116,7 @@ class ElectrumGui:
else:
time_str = 'pending'
label, is_default_label = self.wallet.get_label(tx_hash)
label = self.wallet.get_label(tx_hash)
if len(label) > 40:
label = label[0:37] + '...'
self.history.append( format_str%( time_str, label, format_satoshis(value, whitespaces=True), format_satoshis(balance, whitespaces=True) ) )

19
lib/wallet.py

@ -867,24 +867,9 @@ class Abstract_Wallet(PrintError):
return h2
def get_label(self, tx_hash):
label = self.labels.get(tx_hash)
is_default = (label == '') or (label is None)
if is_default:
label = self.get_default_label(tx_hash)
return label, is_default
def get_default_label(self, tx_hash):
if self.txi.get(tx_hash) == {}:
d = self.txo.get(tx_hash, {})
labels = []
for addr in d.keys():
label = self.labels.get(addr)
if label:
labels.append(label)
return ', '.join(labels)
return ''
label = self.labels.get(tx_hash, '')
return label
def fee_per_kb(self, config):
b = config.get('dynamic_fees')

Loading…
Cancel
Save