comparison cagou/plugins/plugin_wid_chat.py @ 261:a579eda31f4f

chat: don't use "force" argument anymore
author Goffi <goffi@goffi.org>
date Mon, 11 Mar 2019 08:39:43 +0100
parents 145c29b5f2b5
children 805c4103dac5
comparison
equal deleted inserted replaced
260:145c29b5f2b5 261:a579eda31f4f
676 log.error(_(u"Unknown OTR state received: {}".format(state))) 676 log.error(_(u"Unknown OTR state received: {}".format(state)))
677 return 677 return
678 self.encryption_btn.symbol = self.encryption_btn.getSymbol() 678 self.encryption_btn.symbol = self.encryption_btn.getSymbol()
679 self.encryption_btn.color = self.encryption_btn.getColor() 679 self.encryption_btn.color = self.encryption_btn.getColor()
680 680
681 def onDelete(self, force=False): 681 def onDelete(self):
682 if force==True: 682 # we always keep one widget, so it's available when swiping
683 return self._onDelete() 683 # TODO: delete all widgets when chat is closed
684 if len(list(G.host.widgets.getWidgets( 684 nb_instances = sum(1 for _ in self.host.widgets.getWidgetInstances(self))
685 self.__class__, self.target, profiles=self.profiles))) > 1: 685 if nb_instances > 1:
686 # we don't keep duplicate widgets 686 self.host.removeListener('progressFinished', self.onProgressFinished)
687 return self._onDelete() 687 self.host.removeListener('progressError', self.onProgressError)
688 return False 688 return super(Chat, self).onDelete()
689 else:
690 return False
689 691
690 692
691 PLUGIN_INFO["factory"] = Chat.factory 693 PLUGIN_INFO["factory"] = Chat.factory
692 quick_widgets.register(quick_chat.QuickChat, Chat) 694 quick_widgets.register(quick_chat.QuickChat, Chat)