def __init__(self, home_activity, group): RadioToolButton.__init__(self, group=group) self.set_palette_invoker(FrameWidgetInvoker(self)) self.palette_invoker.cache_palette = False self._home_activity = home_activity self._notify_launch_hid = None self._icon = NotificationPulsingIcon() self._icon.props.base_color = home_activity.get_icon_color() self._icon.props.pulse_color = \ XoColor('%s,%s' % (style.COLOR_BUTTON_GREY.get_svg(), style.COLOR_TOOLBAR_GREY.get_svg())) if home_activity.get_icon_path(): self._icon.props.file = home_activity.get_icon_path() else: # Let's see if the X11 window can give us an icon. window = home_activity.get_window() if not window.get_icon_is_fallback(): pixbuf = window.get_icon() self._icon.pixbuf = pixbuf else: self._icon.props.icon_name = 'image-missing' self.set_icon_widget(self._icon) self._icon.show() if home_activity.props.launch_status == shell.Activity.LAUNCHING: self._icon.props.pulsing = True self._notify_launch_hid = home_activity.connect( 'notify::launch-status', self.__notify_launch_status_cb) elif home_activity.props.launch_status == shell.Activity.LAUNCH_FAILED: self._on_failed_launch()
def __notification_received_cb(self, **kwargs): logging.debug('ActivitiesTray.__notification_received_cb') name = kwargs.get('app_name') button = self._buttons_by_name.get(name, None) if button is None: hints = kwargs.get('hints') icon = NotificationPulsingIcon( hints.get('x-sugar-icon-file-name', ''), hints.get('x-sugar-icon-name', ''), hints.get('x-sugar-icon-colors', '')) button = NotificationButton(name) button.set_icon(icon) button.show() self.add_item(button) self._buttons_by_name[name] = button if hasattr(button, 'show_badge'): button.show_badge()