class ActivityView(hippo.CanvasBox): def __init__(self, model): hippo.CanvasBox.__init__(self) self._model = model self._model.connect('current-buddy-added', self.__buddy_added_cb) self._model.connect('current-buddy-removed', self.__buddy_removed_cb) self._icons = {} self._layout = SnowflakeLayout() self.set_layout(self._layout) self._icon = self._create_icon() self._layout.add(self._icon, center=True) self._icon.palette_invoker.cache_palette = False for buddy in self._model.props.current_buddies: self._add_buddy(buddy) def _create_icon(self): icon = _ActivityIcon(self._model, file_name=self._model.bundle.get_icon(), xo_color=self._model.get_color(), size=style.STANDARD_ICON_SIZE) return icon def has_buddy_icon(self, key): return key in self._icons def __buddy_added_cb(self, activity, buddy): self._add_buddy(buddy) def _add_buddy(self, buddy): icon = BuddyIcon(buddy, style.STANDARD_ICON_SIZE) self._icons[buddy.props.key] = icon self._layout.add(icon) def __buddy_removed_cb(self, activity, buddy): icon = self._icons[buddy.props.key] del self._icons[buddy.props.key] icon.destroy() def set_filter(self, query): text_to_check = self._model.bundle.get_name().lower() + \ self._model.bundle.get_bundle_id().lower() self._icon.props.xo_color = self._model.get_color() if text_to_check.find(query) == -1: self._icon.alpha = _FILTERED_ALPHA else: self._icon.alpha = 1.0 for icon in self._icons.itervalues(): if hasattr(icon, 'set_filter'): icon.set_filter(query)
def __init__(self, model): SnowflakeLayout.__init__(self) self._model = model self._model.connect('current-buddy-added', self.__buddy_added_cb) self._model.connect('current-buddy-removed', self.__buddy_removed_cb) self._icons = {} self._icon = self._create_icon() self._icon.show() self.add_icon(self._icon, center=True) self._icon.palette_invoker.cache_palette = False for buddy in self._model.props.current_buddies: self._add_buddy(buddy)