当前位置: 首页>>代码示例>>Python>>正文


Python notification.NotificationIcon类代码示例

本文整理汇总了Python中jarabe.frame.notification.NotificationIcon的典型用法代码示例。如果您正苦于以下问题:Python NotificationIcon类的具体用法?Python NotificationIcon怎么用?Python NotificationIcon使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了NotificationIcon类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __notification_received_cb

    def __notification_received_cb(self, **kwargs):
        logging.debug('__notification_received_cb')
        icon = NotificationIcon()
        icon.show_badge()
        icon.connect('button-release-event', self.__button_release_event_cb)

        hints = kwargs['hints']

        icon_file_name = hints.get('x-sugar-icon-file-name', '')
        icon_name = hints.get('x-sugar-icon-name', '')
        if icon_file_name:
            icon.props.icon_filename = icon_file_name
        elif icon_name:
            icon.props.icon_name = icon_name
        else:
            icon.props.icon_name = 'application-octet-stream'

        icon_colors = hints.get('x-sugar-icon-colors', '')
        if not icon_colors:
            icon_colors = profile.get_color()
        icon.props.xo_color = icon_colors

        duration = kwargs.get('expire_timeout', -1)
        if duration == -1:
            duration = NOTIFICATION_DURATION

        self.add_notification(icon, Gtk.CornerType.TOP_LEFT, duration)
开发者ID:sugarlabs,项目名称:sugar,代码行数:27,代码来源:frame.py

示例2: show_notification

 def show_notification(self):
     self._notif_icon = NotificationIcon()
     self._notif_icon.props.icon_name = self._icon.props.icon_name
     self._notif_icon.props.xo_color = XoColor(
         "%s,%s" % (self._icon.props.stroke_color, self._icon.props.fill_color)
     )
     frame = jarabe.frame.get_view()
     self._timeout_id = frame.add_notification(self._notif_icon, Gtk.CornerType.BOTTOM_LEFT)
     self._notif_icon.connect("drag_data_get", self._drag_data_get_cb)
     self._notif_icon.connect("drag-begin", self._drag_begin_cb)
     self._notif_icon.drag_source_set(Gdk.ModifierType.BUTTON1_MASK, self._get_targets(), Gdk.DragAction.COPY)
开发者ID:parsoyaarihant,项目名称:sugar,代码行数:11,代码来源:clipboardicon.py

示例3: BaseTransferButton

class BaseTransferButton(ToolButton):
    """Button with a notification attached
    """

    def __init__(self, file_transfer):
        ToolButton.__init__(self)

        self.file_transfer = file_transfer
        file_transfer.connect('notify::state', self.__notify_state_cb)

        icon = Icon()
        self.props.icon_widget = icon
        icon.show()

        self.notif_icon = NotificationIcon()
        self.notif_icon.connect('button-release-event',
                                self.__button_release_event_cb)

        self.connect('clicked', self.__button_clicked_cb)

    def __button_release_event_cb(self, icon, event):
        if self.notif_icon is not None:
            frame = jarabe.frame.get_view()
            frame.remove_notification(self.notif_icon)
            self.notif_icon = None

    def __button_clicked_cb(self, button):
        self.palette.popup(immediate=True, state=Palette.SECONDARY)

    def remove(self):
        frame = jarabe.frame.get_view()
        frame.remove_notification(self.notif_icon)
        self.props.parent.remove(self)

    def __notify_state_cb(self, file_transfer, pspec):
        logging.debug('_update state: %r %r', file_transfer.props.state,
                      file_transfer.reason_last_change)
        if file_transfer.props.state == filetransfer.FT_STATE_CANCELLED:
            if file_transfer.reason_last_change == \
               filetransfer.FT_REASON_LOCAL_STOPPED:
                self.remove()
开发者ID:W3SS,项目名称:sugar,代码行数:41,代码来源:activitiestray.py

示例4: __init__

    def __init__(self, file_transfer):
        ToolButton.__init__(self)

        self.file_transfer = file_transfer
        file_transfer.connect("notify::state", self.__notify_state_cb)

        icon = Icon()
        self.props.icon_widget = icon
        icon.show()

        self.notif_icon = NotificationIcon()
        self.notif_icon.connect("button-release-event", self.__button_release_event_cb)

        self.connect("clicked", self.__button_clicked_cb)
开发者ID:native93,项目名称:bulletinframe,代码行数:14,代码来源:activitiestray.py

示例5: __init__

    def __init__(self, invite):
        ToolButton.__init__(self)

        self._invite = invite

        self.connect('clicked', self.__clicked_cb)
        self.connect('destroy', self.__destroy_cb)

        bundle_registry = bundleregistry.get_registry()
        bundle = bundle_registry.get_bundle(invite.get_bundle_id())

        self._icon = Icon()
        self._icon.props.xo_color = invite.get_color()
        if bundle is not None:
            self._icon.props.file = bundle.get_icon()
        else:
            self._icon.props.icon_name = 'image-missing'
        self.set_icon_widget(self._icon)
        self._icon.show()

        palette = InvitePalette(invite)
        palette.props.invoker = FrameWidgetInvoker(self)
        palette.set_group_id('frame')
        palette.connect('remove-invite', self.__remove_invite_cb)
        self.set_palette(palette)

        self._notif_icon = NotificationIcon()
        self._notif_icon.connect('button-release-event',
                                 self.__button_release_event_cb)

        self._notif_icon.props.xo_color = invite.get_color()
        if bundle is not None:
            self._notif_icon.props.icon_filename = bundle.get_icon()
        else:
            self._notif_icon.props.icon_name = 'image-missing'

        frame = jarabe.frame.get_view()
        frame.add_notification(self._notif_icon, gtk.CORNER_TOP_LEFT)
开发者ID:nemesiscodex,项目名称:JukyOS-sugar,代码行数:38,代码来源:activitiestray.py

示例6: InviteButton

class InviteButton(ToolButton):
    """Invite to shared activity"""

    __gsignals__ = {
        'remove-invite': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ([])),
    }

    def __init__(self, invite):
        ToolButton.__init__(self)

        self._invite = invite

        self.connect('clicked', self.__clicked_cb)
        self.connect('destroy', self.__destroy_cb)

        bundle_registry = bundleregistry.get_registry()
        bundle = bundle_registry.get_bundle(invite.get_bundle_id())

        self._icon = Icon()
        self._icon.props.xo_color = invite.get_color()
        if bundle is not None:
            self._icon.props.file = bundle.get_icon()
        else:
            self._icon.props.icon_name = 'image-missing'
        self.set_icon_widget(self._icon)
        self._icon.show()

        palette = InvitePalette(invite)
        palette.props.invoker = FrameWidgetInvoker(self)
        palette.set_group_id('frame')
        palette.connect('remove-invite', self.__remove_invite_cb)
        self.set_palette(palette)

        self._notif_icon = NotificationIcon()
        self._notif_icon.connect('button-release-event',
                                 self.__button_release_event_cb)

        self._notif_icon.props.xo_color = invite.get_color()
        if bundle is not None:
            self._notif_icon.props.icon_filename = bundle.get_icon()
        else:
            self._notif_icon.props.icon_name = 'image-missing'

        frame = jarabe.frame.get_view()
        frame.add_notification(self._notif_icon, gtk.CORNER_TOP_LEFT)

    def __button_release_event_cb(self, icon, event):
        if self._notif_icon is not None:
            frame = jarabe.frame.get_view()
            frame.remove_notification(self._notif_icon)
            self._notif_icon = None
            self._invite.join()
            self.emit('remove-invite')

    def __clicked_cb(self, button):
        self.palette.popup(immediate=True, state=Palette.SECONDARY)

    def __remove_invite_cb(self, palette):
        self.emit('remove-invite')

    def __destroy_cb(self, button):
        if self._notif_icon is not None:
            frame = jarabe.frame.get_view()
            frame.remove_notification(self._notif_icon)
            self._notif_icon = None
开发者ID:nemesiscodex,项目名称:JukyOS-sugar,代码行数:65,代码来源:activitiestray.py

示例7: ClipboardIcon


#.........这里部分代码省略.........
                    self._clipboard_clear_cb,
                    targets)
            else:
                stored = SugarExt.clipboard_set_with_data(
                    x_clipboard,
                    targets,
                    self._clipboard_data_get_cb,
                    self._clipboard_clear_cb,
                    targets)

            if not stored:
                logging.error('GtkClipboard.set_with_data failed!')
            else:
                self.owns_clipboard = True

    def _clipboard_data_get_cb(self, x_clipboard, selection, info, targets):
        selection_target = selection.get_target()
        entries_targets = [entry.target for entry in targets]
        if not str(selection_target) in entries_targets:
            logging.warning('ClipboardIcon._clipboard_data_get_cb: asked %s'
                            ' but only have %r.', selection_target,
                            entries_targets)
            return
        data = self._cb_object.get_formats()[str(selection_target)].get_data()
        selection.set(selection_target, 8, data)

    def _clipboard_clear_cb(self, x_clipboard, targets):
        logging.debug('ClipboardIcon._clipboard_clear_cb')
        self.owns_clipboard = False

    def _object_state_changed_cb(self, cb_service, cb_object):
        if cb_object != self._cb_object:
            return

        if cb_object.get_icon():
            self._icon.props.icon_name = cb_object.get_icon()
            if self._notif_icon:
                self._notif_icon.props.icon_name = self._icon.props.icon_name
        else:
            self._icon.props.icon_name = 'application-octet-stream'

        child = self.get_child()
        child.connect('drag-begin', self._drag_begin_cb)
        child.drag_source_set(Gdk.ModifierType.BUTTON1_MASK,
                              self._get_targets(),
                              Gdk.DragAction.COPY)

        if cb_object.get_percent() == 100:
            self.props.sensitive = True

        # Clipboard object became complete. Make it the active one.
        if self._current_percent < 100 and cb_object.get_percent() == 100:
            self.props.active = True
            self.show_notification()

        self._current_percent = cb_object.get_percent()

    def _object_selected_cb(self, cb_service, object_id):
        if object_id != self._cb_object.get_id():
            return
        self.props.active = True
        self.show_notification()
        logging.debug('ClipboardIcon: %r was selected', object_id)

    def show_notification(self):
        self._notif_icon = NotificationIcon()
        self._notif_icon.props.icon_name = self._icon.props.icon_name
        self._notif_icon.props.xo_color = \
            XoColor('%s,%s' % (self._icon.props.stroke_color,
                               self._icon.props.fill_color))
        frame = jarabe.frame.get_view()
        self._timeout_id = frame.add_notification(
            self._notif_icon, Gtk.CornerType.BOTTOM_LEFT)
        self._notif_icon.connect('drag_data_get', self._drag_data_get_cb)
        self._notif_icon.connect('drag-begin', self._drag_begin_cb)
        self._notif_icon.drag_source_set(Gdk.ModifierType.BUTTON1_MASK,
                                         self._get_targets(),
                                         Gdk.DragAction.COPY)

    def _drag_begin_cb(self, widget, context):
        # TODO: We should get the pixbuf from the icon, with colors, etc.
        GObject.source_remove(self._timeout_id)
        icon_theme = Gtk.IconTheme.get_default()
        pixbuf = icon_theme.load_icon(self._icon.props.icon_name,
                                      style.STANDARD_ICON_SIZE, 0)
        Gtk.drag_set_icon_pixbuf(context, pixbuf, hot_x=pixbuf.props.width / 2,
                                 hot_y=pixbuf.props.height / 2)

    def _notify_active_cb(self, widget, pspec):
        if self.props.active:
            self._put_in_clipboard()
        else:
            self.owns_clipboard = False

    def _get_targets(self):
        targets = []
        for format_type in self._cb_object.get_formats().keys():
            targets.append(Gtk.TargetEntry.new(format_type,
                                               Gtk.TargetFlags.SAME_APP, 0))
        return targets
开发者ID:icarito,项目名称:sugar,代码行数:101,代码来源:clipboardicon.py

示例8: InviteButton

class InviteButton(ToolButton):
    """Invite to shared activity"""

    __gsignals__ = {"remove-invite": (GObject.SignalFlags.RUN_FIRST, None, ([]))}

    def __init__(self, invite):
        ToolButton.__init__(self)

        self._invite = invite

        self.connect("clicked", self.__clicked_cb)
        self.connect("destroy", self.__destroy_cb)

        bundle_registry = bundleregistry.get_registry()
        bundle = bundle_registry.get_bundle(invite.get_bundle_id())

        self._icon = Icon()
        self._icon.props.xo_color = invite.get_color()
        if bundle is not None:
            self._icon.props.file = bundle.get_icon()
        else:
            self._icon.props.icon_name = "image-missing"
        self.set_icon_widget(self._icon)
        self._icon.show()

        palette = InvitePalette(invite)
        palette.props.invoker = FrameWidgetInvoker(self)
        palette.set_group_id("frame")
        palette.connect("remove-invite", self.__remove_invite_cb)
        self.set_palette(palette)

        self._notif_icon = NotificationIcon()
        self._notif_icon.connect("button-release-event", self.__button_release_event_cb)

        self._notif_icon.props.xo_color = invite.get_color()
        if bundle is not None:
            self._notif_icon.props.icon_filename = bundle.get_icon()
        else:
            self._notif_icon.props.icon_name = "image-missing"

        frame = jarabe.frame.get_view()
        frame.add_notification(self._notif_icon, Gtk.CornerType.TOP_LEFT)

    def __button_release_event_cb(self, icon, event):
        if self._notif_icon is not None:
            frame = jarabe.frame.get_view()
            frame.remove_notification(self._notif_icon)
            self._notif_icon = None
            self._invite.join()
            self.emit("remove-invite")

    def __clicked_cb(self, button):
        self.palette.popup(immediate=True, state=Palette.SECONDARY)

    def __remove_invite_cb(self, palette):
        self.emit("remove-invite")

    def __destroy_cb(self, button):
        if self._notif_icon is not None:
            frame = jarabe.frame.get_view()
            frame.remove_notification(self._notif_icon)
            self._notif_icon = None
开发者ID:native93,项目名称:bulletinframe,代码行数:62,代码来源:activitiestray.py


注:本文中的jarabe.frame.notification.NotificationIcon类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。