comparison frontends/src/quick_frontend/quick_widgets.py @ 2007:19b9d3f8a6c7

plugin XEP-0085, quick_frontends, primitivus: chat states are working again
author Goffi <goffi@goffi.org>
date Sun, 17 Jul 2016 16:47:33 +0200
parents b5ef9b2b995e
children 666b42c957b5
comparison
equal deleted inserted replaced
2006:0ddf3edf643a 2007:19b9d3f8a6c7
77 cls = class_ 77 cls = class_
78 if cls is None: 78 if cls is None:
79 raise exceptions.InternalError("There is not class registered for {}".format(class_)) 79 raise exceptions.InternalError("There is not class registered for {}".format(class_))
80 return cls 80 return cls
81 81
82 def getWidgets(self, class_): 82 def getWidgets(self, class_, profiles=None):
83 """Get all subclassed widgets 83 """Get all subclassed widgets instances
84 84
85 @param class_: subclass of QuickWidget, same parameter as used in [getOrCreateWidget] 85 @param class_: subclass of QuickWidget, same parameter as used in [getOrCreateWidget]
86 @param profiles(iterable, None): if not None, filter on instances linked to these profiles
86 @return: iterator on widgets 87 @return: iterator on widgets
87 """ 88 """
88 class_ = self.getRealClass(class_) 89 class_ = self.getRealClass(class_)
89 try: 90 try:
90 widgets_map = self._widgets[class_.__name__] 91 widgets_map = self._widgets[class_.__name__]
91 except KeyError: 92 except KeyError:
92 return iter([]) 93 return
93 else: 94 else:
94 return widgets_map.itervalues() 95 for w in widgets_map.itervalues():
96 if profiles is None or w.profiles.intersection(profiles):
97 yield w
95 98
96 def getWidget(self, class_, target=None, profiles=None): 99 def getWidget(self, class_, target=None, profiles=None):
97 """Get a widget without creating it if it doesn't exist. 100 """Get a widget without creating it if it doesn't exist.
98 101
99 @param class_(class): class of the widget to create 102 @param class_(class): class of the widget to create