Mercurial > libervia-backend
diff frontends/src/primitivus/primitivus @ 1938:011eff37e21d
quick frontend, primitivus: quickContactList refactored to handle several profiles at once
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 18 Apr 2016 18:31:13 +0200 |
parents | 2daf7b4c6756 |
children | 633b5c21aefd |
line wrap: on
line diff
--- a/frontends/src/primitivus/primitivus Sun Apr 17 18:07:55 2016 +0200 +++ b/frontends/src/primitivus/primitivus Mon Apr 18 18:31:13 2016 +0200 @@ -70,7 +70,7 @@ for params, see AdvancedEdit""" nicks = [] for profile, clist in self.host.contact_lists.iteritems(): - for contact in clist.getContacts(): + for contact in clist.selected: chat = self.host.widgets.getWidget(quick_chat.QuickChat, contact, profile) if chat.type != C.CHAT_GROUP: continue @@ -464,11 +464,6 @@ self.main_widget = PrimitivusTopWidget(self.center_part, self.menu_roller, self.notif_bar, self.editBar) return self.main_widget - def addContactList(self, profile): - contact_list = ContactList(self, on_click=self.contactSelected, on_change=lambda w: self.redraw(), profile=profile) - self.contact_lists_pile.contents.append((contact_list, ('weight', 1))) - return contact_list - def plugging_profiles(self): self.loop.widget = self._buildMainWidget() self.redraw() @@ -480,6 +475,12 @@ else: del self._early_popup + def profilePlugged(self, profile): + QuickApp.profilePlugged(self, profile) + contact_list = self.widgets.getOrCreateWidget(ContactList, None, on_new_widget=None, on_click=self.contactSelected, on_change=lambda w: self.redraw(), profile=profile) + self.contact_lists_pile.contents.append((contact_list, ('weight', 1))) + return contact_list + def isHidden(self): """Tells if the frontend window is hidden. @@ -555,10 +556,9 @@ log.debug("No menu to delete") self.selected_widget = widget self._visible_widgets = set([widget]) # XXX: we can only have one widget visible at the time for now - for contact_list in self.contact_lists.itervalues(): - contact_list.unselectAll() + self.contact_lists.select(None) - for wid in self.visible_widgets: + for wid in self.visible_widgets: # FIXME: check if widgets.getWidgets is not more appropriate if isinstance(wid, Chat): contact_list = self.contact_lists[wid.profile] contact_list.select(wid.target) @@ -776,7 +776,11 @@ #MISC CALLBACKS# def setPresenceStatus(self, show='', status=None, profile=C.PROF_KEY_NONE): - self.contact_lists[profile].status_bar.setPresenceStatus(show, status) + contact_list_wid = self.widgets.getWidget(ContactList, profiles=profile) + if contact_list_wid is not None: + contact_list_wid.status_bar.setPresenceStatus(show, status) + else: + log.warning(u"No ContactList widget found for profile {}".format(profile)) sat = PrimitivusApp() sat.start()