def onBlockExplorerBut_(self, but: ObjCInstance) -> None: parent = gui.ElectrumGui.gui config = parent.config be = web.BE_sorted_list() if be is None or len(be) <= 0: be = ["None"] def onOk(selIdx : int) -> None: be_str = be[selIdx] if selIdx < len(be) else be[0] b = self.view.viewWithTag_(TAG_BLOCK_EXPLORER) if b is not None: b.setTitle_forState_(be_str,UIControlStateNormal) config.set_key('block_explorer', be_str, True) beprefs = config.get('block_explorer', be[0]) sel = [i for i,v in enumerate(be) if v == beprefs] sel = 0 if len(sel) <= 0 else sel[0] if len(be): utils.present_modal_picker(parentVC = self, items = be, selectedIndex = int(sel), okCallback = onOk, okButtonTitle=_("OK"), cancelButtonTitle=_("Cancel"))
def setupCell_section_row_(self, cell : ObjCInstance, secName_oc : ObjCInstance, row : int) -> None: secName = py_from_ns(secName_oc) parent = gui.ElectrumGui.gui fx = parent.daemon.fx if parent.daemon else None cell.tag = 0 cell.contentView.tag = TAG_CONTENTVIEW if secName == 'Tools': if row == 0: cell.imageView.image = parent.cashaddr_icon() cell.textLabel.text = _("Address Converter") cell.detailTextLabel.text = _("Convert between Legacy and Cashaddr formats") cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator elif row == 1: statusText = self.networkStatusText if self.networkStatusText else _("Offline") cell.imageView.image = UIImage.imageNamed_("network_icon_new") cell.textLabel.text = _("Network Settings") cell.detailTextLabel.text = _("Status:") + " " + statusText cell.accessoryType = UITableViewCellAccessoryNone elif row == 2: cell.imageView.image = UIImage.imageNamed_("password_icon_new") cell.textLabel.text = _("Change or Set Password") cell.detailTextLabel.text = _("Modify wallet password & encryption settings") cell.accessoryType = UITableViewCellAccessoryNone elif row == 3: cell.imageView.image = UIImage.imageNamed_("seed_icon_new") cell.textLabel.text = _("Wallet Recovery Seed") cell.detailTextLabel.text = _("View the wallet seed phrase used for wallet recovery") cell.accessoryType = UITableViewCellAccessoryNone # ensure all of the above icons are the same size: 24x24, centered, unscaled cell.imageView.contentMode = UIViewContentModeCenter f = cell.imageView.frame f.size = CGSizeMake(24,24) cell.imageView.frame = f cell.textLabel.textColor = utils.uicolor_custom('dark') cell.detailTextLabel.textColor = utils.uicolor_custom('dark') cell.textLabel.font = UIFont.systemFontOfSize_weight_(16.0, UIFontWeightRegular) cell.detailTextLabel.font = UIFont.systemFontOfSize_weight_(12.0, UIFontWeightThin) elif secName == 'Fees': if row == 0: l = cell.viewWithTag_(1) tf = cell.viewWithTag_(2) l.text = _('Max static fee') tf.placeholder = parent.base_unit() tf.delegate = self tf.text = get_max_static_fee_str(parent) if tf.allTargets.count <= 0: tf.addTarget_action_forControlEvents_(self, SEL(b'onMaxStaticFee:'), UIControlEventEditingChanged) if isinstance(tf, amountedit.BTCkBEdit): tf.setUseUnitLabel_(True) tf.fixedUnitLabelWidth = 75.0 utils.uitf_redo_attrs(tf) elif row == 1: # 'edit fees manually', a bool cell l = cell.viewWithTag_(1) s = cell.viewWithTag_(2) if s.allTargets.count <= 0: s.addTarget_action_forControlEvents_(self, SEL(b'onShowFee:'), UIControlEventValueChanged) l.text = _('Edit fees manually') s.on = parent.prefs_get_show_fee() elif secName == 'Transactions': l = cell.viewWithTag_(1) s = cell.viewWithTag_(2) if row == 0: l.text = _("Enable Schnorr signatures") b, enabled = parent.prefs_use_schnorr, parent.prefs_is_schnorr_possible s.on = b utils.uiview_set_enabled(cell, enabled) if s.allTargets.count <= 0: s.addTarget_action_forControlEvents_(self, SEL(b'onEnableSchnorr:'), UIControlEventValueChanged) elif row == 1: l.text = _("Use change addresses") b, enabled = parent.prefs_get_use_change() s.on = b utils.uiview_set_enabled(cell, enabled) if s.allTargets.count <= 0: s.addTarget_action_forControlEvents_(self, SEL(b'onUseChange:'), UIControlEventValueChanged) elif row == 2: l.text = _("Use multiple change addresses") cell.contentView.tag = TAG_MULTIPLE_CHANGE_CELL b1, enabled = parent.prefs_get_multiple_change() s.on = b1 utils.uiview_set_enabled(cell.contentView, enabled) if s.allTargets.count <= 0: s.addTarget_action_forControlEvents_(self, SEL(b'onUseMultiple:'), UIControlEventValueChanged) elif row == 3: l.text = _("Spend only confirmed coins") s.on = parent.prefs_get_confirmed_only() if s.allTargets.count <= 0: s.addTarget_action_forControlEvents_(self, SEL(b'onConfirmedOnly:'), UIControlEventValueChanged) elif secName == 'Appearance': if row == 0: l = cell.viewWithTag_(1) s = cell.viewWithTag_(2) l.text = _('Hide download banner') s.on = parent.prefs_get_downloading_notif_hidden() if s.allTargets.count <= 0: s.addTarget_action_forControlEvents_(self, SEL(b'onHideDLBanner:'), UIControlEventValueChanged) elif row == 1: l = cell.viewWithTag_(1) s = cell.viewWithTag_(2) l.text = _('CashAddr address format') s.on = parent.prefs_get_use_cashaddr() if s.allTargets.count <= 0: s.addTarget_action_forControlEvents_(self, SEL(b'onUseCashAddr:'), UIControlEventValueChanged) elif row == 2: l = cell.viewWithTag_(1) b = cell.viewWithTag_(2) b = b if b is not None else cell.viewWithTag_(TAG_NZ) l.text = _('Zeros after decimal point') if b is not None: b.tag = TAG_NZ if b.allTargets.count <= 0: b.addTarget_action_forControlEvents_(self, SEL(b'onNZBut:'), UIControlEventPrimaryActionTriggered) nr = len(self.getNumZerosList()) nz_prefs = parent.prefs_get_num_zeros() if nz_prefs >= nr: nz_prefs = nr-1 b.setTitle_forState_(str(nz_prefs),UIControlStateNormal) elif row == 3: l = cell.viewWithTag_(1) b = cell.viewWithTag_(2) b = b if b is not None else cell.viewWithTag_(TAG_BASE_UNIT) l.text = _('Base unit') if b is not None: b.tag = TAG_BASE_UNIT b.setTitle_forState_(parent.base_unit(),UIControlStateNormal) if b.allTargets.count <= 0: b.addTarget_action_forControlEvents_(self, SEL(b'onBaseUnitBut:'), UIControlEventPrimaryActionTriggered) elif row == 4: l = cell.viewWithTag_(1) b = cell.viewWithTag_(2) b = b if b is not None else cell.viewWithTag_(TAG_BLOCK_EXPLORER) l.text = _('Online Block Explorer') if b is not None: b.tag = TAG_BLOCK_EXPLORER be = web.BE_sorted_list() be = be if be is not None and len(be) > 0 else ["None"] beprefs = web.BE_from_config(parent.config) if beprefs not in be: beprefs = be[0] b.setTitle_forState_(beprefs,UIControlStateNormal) if b.allTargets.count <= 0: b.addTarget_action_forControlEvents_(self, SEL(b'onBlockExplorerBut:'), UIControlEventPrimaryActionTriggered) elif secName == 'Fiat': if row == 0: l = cell.viewWithTag_(1) b = cell.viewWithTag_(2) b = b if b is not None else cell.viewWithTag_(TAG_FIAT_CURRENCY) l.text = _('Fiat currency') if b is not None: b.tag = TAG_FIAT_CURRENCY b.enabled = True curr = fx.get_currency() if fx and fx.is_enabled() else pgettext('Referencing Fiat currency', 'None') b.setTitle_forState_(curr, UIControlStateNormal) if b.allTargets.count <= 0: b.addTarget_action_forControlEvents_(self, SEL(b'onFiatCurrencyBut:'), UIControlEventPrimaryActionTriggered) elif row == 1: l = cell.viewWithTag_(1) s = cell.viewWithTag_(2) l.text = _('Show history rates') s.on = bool(fx and fx.get_history_config()) if s.allTargets.count <= 0: s.addTarget_action_forControlEvents_(self, SEL(b'onFiatHistory:'), UIControlEventValueChanged) enabled = bool(bool(fx) and fx.is_enabled()) utils.uiview_set_enabled(cell.contentView, enabled) elif row == 2: l = cell.viewWithTag_(1) s = cell.viewWithTag_(2) l.text = _('Show Fiat balance for addresses') s.on = bool(fx and fx.get_fiat_address_config()) if s.allTargets.count <= 0: s.addTarget_action_forControlEvents_(self, SEL(b'onFiatBal:'), UIControlEventValueChanged) enabled = bool(bool(fx) and fx.is_enabled()) utils.uiview_set_enabled(cell.contentView, enabled) elif row == 3: l = cell.viewWithTag_(1) b = cell.viewWithTag_(2) b = b if b is not None else cell.viewWithTag_(TAG_FIAT_EXCHANGE) l.text = _('Source') if b is not None: b.tag = TAG_FIAT_EXCHANGE b.setTitle_forState_(pgettext('Referencing Fiat rate source', 'None'), UIControlStateNormal) self.setFiatExchangeButtonText_(b) if b.allTargets.count <= 0: b.addTarget_action_forControlEvents_(self, SEL(b'onFiatExchangeBut:'), UIControlEventPrimaryActionTriggered)