def TxHistoryHelperDissociate(helper): if helper and helper.tv: if helper.tv.dataSource: helper.tv.dataSource = None if helper.tv.delegate: helper.tv.delegate = None helper.vc = None # below clears object association -- will auto-release the helper as a side-effect from rubicon.objc.runtime import libobjc theTV = helper.tv helper.tv = None if libobjc.objc_getAssociatedObject( theTV.ptr, helper.ptr).value == helper.ptr.value: libobjc.objc_setAssociatedObject(theTV.ptr, helper.ptr, None, 0x301)
def initWithInputTV_outputTV_timestamp_(self, inputTV: ObjCInstance, outputTV: ObjCInstance, ts: float) -> ObjCInstance: self = ObjCInstance(send_super(__class__, self, 'init')) if self is not None: if not isinstance(utils.nspy_get(self), Transaction): raise ValueError( 'TxInputsOutputsTVC requires an nspy entry on self that is a Transaction subclass!' ) if inputTV.tag == 0: inputTV.tag = 9001 self.tagin = inputTV.tag if outputTV.tag == 0: outputTV.tag = self.tagin + 1 self.tagout = outputTV.tag self.ts = ts if self.tagin == self.tagout or inputTV.ptr.value == outputTV.ptr.value: raise ValueError( "The input and output table views must be different and have different tags!" ) nib = UINib.nibWithNibName_bundle_("TxDetailInOutCell", None) inputTV.registerNib_forCellReuseIdentifier_( nib, "TxDetailInOutCell") outputTV.registerNib_forCellReuseIdentifier_( nib, "TxDetailInOutCell") inputTV.delegate = self outputTV.delegate = self inputTV.dataSource = self outputTV.dataSource = self from rubicon.objc.runtime import libobjc libobjc.objc_setAssociatedObject(inputTV.ptr, self.ptr, self.ptr, 0x301) libobjc.objc_setAssociatedObject(outputTV.ptr, self.ptr, self.ptr, 0x301) def refresh() -> None: inputTV.reloadData() outputTV.reloadData() gui.ElectrumGui.gui.cash_addr_sig.connect(lambda x: refresh(), self) gui.ElectrumGui.gui.sigContacts.connect(lambda: refresh(), self) return self
def NewTxHistoryHelper(tv: ObjCInstance, vc: ObjCInstance, domain: list = None, noRefreshControl=False, cls: ObjCClass = None) -> ObjCInstance: if not cls: cls = TxHistoryHelper helper = cls.new().autorelease() if tv.delegate and tv.dataSource and tv.delegate == tv.dataSource and isinstance( tv.delegate, TxHistoryHelper): TxHistoryHelperDissociate(tv.delegate) tv.dataSource = helper tv.delegate = helper helper.tv = tv helper.vc = vc # optimization to share the same history data with the new helper class we just created for the full mode view # .. hopefully this will keep the UI peppy and responsive! if domain is not None: utils.nspy_put_byname(helper, domain, 'domain') helper.miscSetup() if noRefreshControl: helper.tv.refreshControl = None from rubicon.objc.runtime import libobjc libobjc.objc_setAssociatedObject(tv.ptr, helper.ptr, helper.ptr, 0x301) return helper