comparison browser_side/panels.py @ 322:971e3812903a

browser_side: scroll to the clicked microblog post and blink it (previous behavior is conserved when the unibox is enabled)
author souliane <souliane@mailoo.org>
date Fri, 03 Jan 2014 22:44:59 +0100
parents 462a0a8894e3
children 0b7934e75e76
comparison
equal deleted inserted replaced
321:bfbd9d6eb901 322:971e3812903a
468 @param new_avatar: path to the new image""" 468 @param new_avatar: path to the new image"""
469 self.avatar.setUrl(new_avatar) 469 self.avatar.setUrl(new_avatar)
470 470
471 def onClick(self, sender): 471 def onClick(self, sender):
472 if sender == self: 472 if sender == self:
473 self._blog_panel.setSelectedEntry(self if self.comments else None) 473 self._blog_panel.setSelectedEntry(self)
474 elif sender == self.delete_label: 474 elif sender == self.delete_label:
475 self._delete() 475 self._delete()
476 elif sender == self.update_label: 476 elif sender == self.update_label:
477 self.setEntryDialog(edit=True) 477 self.setEntryDialog(edit=True)
478 elif sender == self.comment_label: 478 elif sender == self.comment_label:
849 comment.removeFromParent() 849 comment.removeFromParent()
850 self.selected_entry = None 850 self.selected_entry = None
851 break 851 break
852 852
853 def setSelectedEntry(self, entry): 853 def setSelectedEntry(self, entry):
854 try:
855 self.vpanel.getParent().ensureVisible(entry) # scroll to the clicked entry
856 except AttributeError:
857 logging.error("FIXME: MicroblogPanel.vpanel should be wrapped in a ScrollPanel!")
858 removeStyle = lambda entry: entry.removeStyleName('selected_entry')
859 if not self.host.uni_box or not entry.comments:
860 entry.addStyleName('selected_entry') # blink the clicked entry
861 clicked_entry = entry # entry may be None when the timer is done
862 Timer(500, lambda: removeStyle(clicked_entry))
863 if not self.host.uni_box:
864 return # unibox is disabled
865 # from here the previous behavior (toggle main item selection) is conserved
866 entry = entry if entry.comments else None
854 if self.selected_entry == entry: 867 if self.selected_entry == entry:
855 entry = None 868 entry = None
856 if self.selected_entry: 869 if self.selected_entry:
857 self.selected_entry.removeStyleName('selected_entry') 870 removeStyle(self.selected_entry)
858 if entry: 871 if entry:
859 print "microblog entry selected (author=%s)" % entry.author 872 print "microblog entry selected (author=%s)" % entry.author
860 entry.addStyleName('selected_entry') 873 entry.addStyleName('selected_entry')
861 self.selected_entry = entry 874 self.selected_entry = entry
862 875