Mercurial > libervia-backend
comparison 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 |
comparison
equal
deleted
inserted
replaced
1937:14a33c2b1b2a | 1938:011eff37e21d |
---|---|
68 def _nick_completion(self, text, completion_data): | 68 def _nick_completion(self, text, completion_data): |
69 """Completion method which complete pseudo in group chat | 69 """Completion method which complete pseudo in group chat |
70 for params, see AdvancedEdit""" | 70 for params, see AdvancedEdit""" |
71 nicks = [] | 71 nicks = [] |
72 for profile, clist in self.host.contact_lists.iteritems(): | 72 for profile, clist in self.host.contact_lists.iteritems(): |
73 for contact in clist.getContacts(): | 73 for contact in clist.selected: |
74 chat = self.host.widgets.getWidget(quick_chat.QuickChat, contact, profile) | 74 chat = self.host.widgets.getWidget(quick_chat.QuickChat, contact, profile) |
75 if chat.type != C.CHAT_GROUP: | 75 if chat.type != C.CHAT_GROUP: |
76 continue | 76 continue |
77 space = text.rfind(" ") | 77 space = text.rfind(" ") |
78 start = text[space + 1:] | 78 start = text[space + 1:] |
462 self.editBar = EditBar(self) | 462 self.editBar = EditBar(self) |
463 self.menu_roller = self._buildMenuRoller() | 463 self.menu_roller = self._buildMenuRoller() |
464 self.main_widget = PrimitivusTopWidget(self.center_part, self.menu_roller, self.notif_bar, self.editBar) | 464 self.main_widget = PrimitivusTopWidget(self.center_part, self.menu_roller, self.notif_bar, self.editBar) |
465 return self.main_widget | 465 return self.main_widget |
466 | 466 |
467 def addContactList(self, profile): | |
468 contact_list = ContactList(self, on_click=self.contactSelected, on_change=lambda w: self.redraw(), profile=profile) | |
469 self.contact_lists_pile.contents.append((contact_list, ('weight', 1))) | |
470 return contact_list | |
471 | |
472 def plugging_profiles(self): | 467 def plugging_profiles(self): |
473 self.loop.widget = self._buildMainWidget() | 468 self.loop.widget = self._buildMainWidget() |
474 self.redraw() | 469 self.redraw() |
475 try: | 470 try: |
476 # if a popup arrived before main widget is build, we need to show it now | 471 # if a popup arrived before main widget is build, we need to show it now |
477 self.showPopUp(self._early_popup) | 472 self.showPopUp(self._early_popup) |
478 except AttributeError: | 473 except AttributeError: |
479 pass | 474 pass |
480 else: | 475 else: |
481 del self._early_popup | 476 del self._early_popup |
477 | |
478 def profilePlugged(self, profile): | |
479 QuickApp.profilePlugged(self, profile) | |
480 contact_list = self.widgets.getOrCreateWidget(ContactList, None, on_new_widget=None, on_click=self.contactSelected, on_change=lambda w: self.redraw(), profile=profile) | |
481 self.contact_lists_pile.contents.append((contact_list, ('weight', 1))) | |
482 return contact_list | |
482 | 483 |
483 def isHidden(self): | 484 def isHidden(self): |
484 """Tells if the frontend window is hidden. | 485 """Tells if the frontend window is hidden. |
485 | 486 |
486 @return bool | 487 @return bool |
553 self.menu_roller.removeMenu(C.MENU_ID_WIDGET) | 554 self.menu_roller.removeMenu(C.MENU_ID_WIDGET) |
554 except KeyError: | 555 except KeyError: |
555 log.debug("No menu to delete") | 556 log.debug("No menu to delete") |
556 self.selected_widget = widget | 557 self.selected_widget = widget |
557 self._visible_widgets = set([widget]) # XXX: we can only have one widget visible at the time for now | 558 self._visible_widgets = set([widget]) # XXX: we can only have one widget visible at the time for now |
558 for contact_list in self.contact_lists.itervalues(): | 559 self.contact_lists.select(None) |
559 contact_list.unselectAll() | 560 |
560 | 561 for wid in self.visible_widgets: # FIXME: check if widgets.getWidgets is not more appropriate |
561 for wid in self.visible_widgets: | |
562 if isinstance(wid, Chat): | 562 if isinstance(wid, Chat): |
563 contact_list = self.contact_lists[wid.profile] | 563 contact_list = self.contact_lists[wid.profile] |
564 contact_list.select(wid.target) | 564 contact_list.select(wid.target) |
565 | 565 |
566 self.redraw() | 566 self.redraw() |
774 self.alert(_("About"), C.APP_NAME + " v" + self.bridge.getVersion()) | 774 self.alert(_("About"), C.APP_NAME + " v" + self.bridge.getVersion()) |
775 | 775 |
776 #MISC CALLBACKS# | 776 #MISC CALLBACKS# |
777 | 777 |
778 def setPresenceStatus(self, show='', status=None, profile=C.PROF_KEY_NONE): | 778 def setPresenceStatus(self, show='', status=None, profile=C.PROF_KEY_NONE): |
779 self.contact_lists[profile].status_bar.setPresenceStatus(show, status) | 779 contact_list_wid = self.widgets.getWidget(ContactList, profiles=profile) |
780 if contact_list_wid is not None: | |
781 contact_list_wid.status_bar.setPresenceStatus(show, status) | |
782 else: | |
783 log.warning(u"No ContactList widget found for profile {}".format(profile)) | |
780 | 784 |
781 sat = PrimitivusApp() | 785 sat = PrimitivusApp() |
782 sat.start() | 786 sat.start() |