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


Python PaletteMenuItem.connect方法代码示例

本文整理汇总了Python中sugar3.graphics.palettemenu.PaletteMenuItem.connect方法的典型用法代码示例。如果您正苦于以下问题:Python PaletteMenuItem.connect方法的具体用法?Python PaletteMenuItem.connect怎么用?Python PaletteMenuItem.connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sugar3.graphics.palettemenu.PaletteMenuItem的用法示例。


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

示例1: __init__

# 需要导入模块: from sugar3.graphics.palettemenu import PaletteMenuItem [as 别名]
# 或者: from sugar3.graphics.palettemenu.PaletteMenuItem import connect [as 别名]
    def __init__(self, invite):
        Palette.__init__(self, '')

        self._invite = invite

        self.menu_box = PaletteMenuBox()
        self.set_content(self.menu_box)
        self.menu_box.show()

        menu_item = PaletteMenuItem(_('Join'), icon_name='dialog-ok')
        menu_item.connect('activate', self.__join_activate_cb)
        self.menu_box.append_item(menu_item)
        menu_item.show()

        menu_item = PaletteMenuItem(_('Decline'), icon_name='dialog-cancel')
        menu_item.connect('activate', self.__decline_activate_cb)
        self.menu_box.append_item(menu_item)
        menu_item.show()

        bundle_id = invite.get_bundle_id()

        registry = bundleregistry.get_registry()
        self._bundle = registry.get_bundle(bundle_id)
        if self._bundle:
            name = self._bundle.get_name()
        else:
            name = bundle_id

        self.set_primary_text(name)
开发者ID:icarito,项目名称:sugar,代码行数:31,代码来源:activitiestray.py

示例2: __init__

# 需要导入模块: from sugar3.graphics.palettemenu import PaletteMenuItem [as 别名]
# 或者: from sugar3.graphics.palettemenu.PaletteMenuItem import connect [as 别名]
    def __init__(self, name):
        Gtk.VBox.__init__(self)
        self._name = name

        self._notifications_box = Gtk.VBox()
        self._notifications_box.show()

        self._scrolled_window = Gtk.ScrolledWindow()
        self._scrolled_window.add_with_viewport(self._notifications_box)
        self._scrolled_window.set_policy(Gtk.PolicyType.NEVER,
                                         Gtk.PolicyType.AUTOMATIC)
        self._scrolled_window.show()

        separator = PaletteMenuItemSeparator()
        separator.show()

        clear_item = PaletteMenuItem(_('Clear notifications'), 'dialog-cancel')
        clear_item.connect('activate', self.__clear_cb)
        clear_item.show()

        self.add(self._scrolled_window)
        self.add(separator)
        self.add(clear_item)

        self._service = notifications.get_service()
        entries = self._service.retrieve_by_name(self._name)

        if entries:
            for entry in entries:
                self._add(entry['summary'], entry['body'])

        self._service.notification_received.connect(
            self.__notification_received_cb)

        self.connect('destroy', self.__destroy_cb)
开发者ID:jvonau,项目名称:sugar,代码行数:37,代码来源:notification.py

示例3: add_menu

# 需要导入模块: from sugar3.graphics.palettemenu import PaletteMenuItem [as 别名]
# 或者: from sugar3.graphics.palettemenu.PaletteMenuItem import connect [as 别名]
def add_menu(icon_name, tooltip, tool_name, button, activate_cb):
    menu_item = PaletteMenuItem(icon_name=icon_name, text_label=tooltip)
    menu_item.connect('activate', activate_cb, tool_name)
    menu_item.icon_name = icon_name
    button.menu_box.append_item(menu_item)
    menu_item.show()
    return menu_item
开发者ID:leonardcj,项目名称:paint-activity,代码行数:9,代码来源:toolbox.py

示例4: __init__

# 需要导入模块: from sugar3.graphics.palettemenu import PaletteMenuItem [as 别名]
# 或者: from sugar3.graphics.palettemenu.PaletteMenuItem import connect [as 别名]
    def __init__(self, file_name, document_path, activity_name, title,
                 bundle=False):
        RadioToolButton.__init__(self)

        self._document_path = document_path
        self._title = title
        self._jobject = None
        self._activity_name = activity_name

        self.props.tooltip = _('Instance Source')

        settings = Gio.Settings('org.sugarlabs.user')
        self._color = settings.get_string('color')
        icon = Icon(file=file_name,
                    pixel_size=style.STANDARD_ICON_SIZE,
                    xo_color=XoColor(self._color))
        self.set_icon_widget(icon)
        icon.show()

        box = PaletteMenuBox()
        self.props.palette.set_content(box)
        box.show()

        if bundle:
            menu_item = PaletteMenuItem(_('Duplicate'), 'edit-duplicate',
                                        xo_color=XoColor(self._color))
            menu_item.connect('activate', self.__show_duplicate_alert)
        else:
            menu_item = PaletteMenuItem(_('Keep'), 'document-save',
                                        xo_color=XoColor(self._color))
            menu_item.connect('activate', self.__keep_in_journal_cb)

        box.append_item(menu_item)
        menu_item.show()
开发者ID:sugarlabs,项目名称:sugar,代码行数:36,代码来源:viewsource.py

示例5: _add_menu

# 需要导入模块: from sugar3.graphics.palettemenu import PaletteMenuItem [as 别名]
# 或者: from sugar3.graphics.palettemenu.PaletteMenuItem import connect [as 别名]
 def _add_menu(self, font_name, activate_cb):
     label = '<span font="%s">%s</span>' % (font_name, font_name)
     menu_item = PaletteMenuItem()
     menu_item.set_label(label)
     menu_item.connect('activate', activate_cb, font_name)
     self._menu_box.append_item(menu_item)
     menu_item.show()
开发者ID:AbrahmAB,项目名称:write-activity,代码行数:9,代码来源:fontcombobox.py

示例6: OwnerIcon

# 需要导入模块: from sugar3.graphics.palettemenu import PaletteMenuItem [as 别名]
# 或者: from sugar3.graphics.palettemenu.PaletteMenuItem import connect [as 别名]
class OwnerIcon(BuddyIcon):
    __gtype_name__ = 'SugarFavoritesOwnerIcon'

    __gsignals__ = {
        'register-activate': (GObject.SignalFlags.RUN_FIRST, None,
                              ([])),
    }

    def __init__(self, size):
        BuddyIcon.__init__(self, buddy=get_owner_instance(), pixel_size=size)

        self.palette_invoker.cache_palette = True

        self._palette_enabled = False
        self._register_menu = None

        # This is a workaround to skip the callback for
        # enter-notify-event in the parent class the first time.
        def __enter_notify_event_cb(icon, event):
            self.unset_state_flags(Gtk.StateFlags.PRELIGHT)
            self.disconnect(self._enter_notify_hid)

        self._enter_notify_hid = self.connect('enter-notify-event',
                                              __enter_notify_event_cb)

    def create_palette(self):
        if not self._palette_enabled:
            self._palette_enabled = True
            return

        palette = BuddyMenu(get_owner_instance())

        client = GConf.Client.get_default()
        backup_url = client.get_string('/desktop/sugar/backup_url')

        if not backup_url:
            self._register_menu = PaletteMenuItem(_('Register'),
                                                  'media-record')
        else:
            self._register_menu = PaletteMenuItem(_('Register again'),
                                                  'media-record')

        self._register_menu.connect('activate', self.__register_activate_cb)
        palette.menu_box.pack_end(self._register_menu, True, True, 0)
        self._register_menu.show()

        self.connect_to_palette_pop_events(palette)

        return palette

    def __register_activate_cb(self, menuitem):
        self.emit('register-activate')

    def set_registered(self):
        self.palette.menu_box.remove(self._register_menu)
        self._register_menu = PaletteMenuItem(_('Register again'),
                                              'media-record')
        self._register_menu.connect('activate', self.__register_activate_cb)
        self.palette.menu_box.pack_end(self._register_menu, True, True, 0)
        self._register_menu.show()
开发者ID:ajaygarg84,项目名称:sugar,代码行数:62,代码来源:favoritesview.py

示例7: create_palette

# 需要导入模块: from sugar3.graphics.palettemenu import PaletteMenuItem [as 别名]
# 或者: from sugar3.graphics.palettemenu.PaletteMenuItem import connect [as 别名]
    def create_palette(self):
        primary_text = GLib.markup_escape_text(self._model.bundle.get_name())
        secondary_text = GLib.markup_escape_text(self._model.get_name())
        palette_icon = Icon(file=self._model.bundle.get_icon(),
                            xo_color=self._model.get_color())
        palette_icon.props.icon_size = Gtk.IconSize.LARGE_TOOLBAR
        palette = Palette(None,
                          primary_text=primary_text,
                          secondary_text=secondary_text,
                          icon=palette_icon)

        private = self._model.props.private
        joined = get_owner_instance() in self._model.props.buddies

        menu_box = PaletteMenuBox()

        if joined:
            item = PaletteMenuItem(_('Resume'))
            icon = Icon(icon_size=Gtk.IconSize.MENU, icon_name='activity-start')
            item.set_image(icon)
            item.connect('activate', self.__palette_item_clicked_cb)
            menu_box.append_item(item)
        elif not private:
            item = PaletteMenuItem(_('Join'))
            icon = Icon(icon_size=Gtk.IconSize.MENU, icon_name='activity-start')
            item.set_image(icon)
            item.connect('activate', self.__palette_item_clicked_cb)
            menu_box.append_item(item)

        palette.set_content(menu_box)
        menu_box.show_all()

        self.connect_to_palette_pop_events(palette)
        return palette
开发者ID:ajaygarg84,项目名称:sugar,代码行数:36,代码来源:meshbox.py

示例8: setup_rollover_options

# 需要导入模块: from sugar3.graphics.palettemenu import PaletteMenuItem [as 别名]
# 或者: from sugar3.graphics.palettemenu.PaletteMenuItem import connect [as 别名]
    def setup_rollover_options(self, info):
        palette = Palette(info, text_maxlen=50)
        self.set_palette(palette)

        box = PaletteMenuBox()
        palette.set_content(box)
        box.show()

        menu_item = PaletteMenuItem(_('Remove'), 'list-remove')
        menu_item.connect('activate', self.item_remove_cb)
        box.append_item(menu_item)
        menu_item.show()

        separator = PaletteMenuItemSeparator()
        box.append_item(separator)
        separator.show()

        textview = Gtk.TextView()
        textview.props.height_request = style.GRID_CELL_SIZE * 2
        textview.props.width_request = style.GRID_CELL_SIZE * 3
        textview.props.hexpand = True
        textview.props.vexpand = True
        box.append_item(textview)
        textview.show()

        buffer = textview.get_buffer()
        if self.notes is None:
            buffer.set_text(_('Take notes on this page'))
        else:
            buffer.set_text(self.notes)
        buffer.connect('changed', self.__buffer_changed_cb)
开发者ID:sugarlabs,项目名称:browse-activity,代码行数:33,代码来源:linkbutton.py

示例9: __init__

# 需要导入模块: from sugar3.graphics.palettemenu import PaletteMenuItem [as 别名]
# 或者: from sugar3.graphics.palettemenu.PaletteMenuItem import connect [as 别名]
    def __init__(self):
        ToolButton.__init__(self)

        self._property = 'timestamp'
        self._order = Gtk.SortType.ASCENDING

        self.props.tooltip = _('Sort view')
        self.props.icon_name = 'view-lastedit'

        self.props.hide_tooltip_on_click = False
        self.palette_invoker.props.toggle_palette = True

        menu_box = PaletteMenuBox()
        self.props.palette.set_content(menu_box)
        menu_box.show()

        sort_options = [
            ('timestamp', 'view-lastedit', _('Sort by date modified')),
            ('creation_time', 'view-created', _('Sort by date created')),
            ('filesize', 'view-size', _('Sort by size')),
        ]

        for property_, icon, label in sort_options:
            button = PaletteMenuItem(label)
            button_icon = Icon(pixel_size=style.SMALL_ICON_SIZE,
                               icon_name=icon)
            button.set_image(button_icon)
            button_icon.show()
            button.connect('activate',
                           self.__sort_type_changed_cb,
                           property_,
                           icon)
            button.show()
            menu_box.append_item(button)
开发者ID:AbrahmAB,项目名称:sugar,代码行数:36,代码来源:journaltoolbox.py

示例10: _refresh_resume_palette

# 需要导入模块: from sugar3.graphics.palettemenu import PaletteMenuItem [as 别名]
# 或者: from sugar3.graphics.palettemenu.PaletteMenuItem import connect [as 别名]
    def _refresh_resume_palette(self):
        if self._metadata.get('activity_id', ''):
            # TRANS: Action label for resuming an activity.
            self._resume.set_tooltip(_('Resume'))
        else:
            # TRANS: Action label for starting an entry.
            self._resume.set_tooltip(_('Start'))

        palette = self._resume.get_palette()

        if self._resume_menu is not None:
            self._resume_menu.destroy()

        self._resume_menu = PaletteMenuBox()
        palette.set_content(self._resume_menu)
        self._resume_menu.show()

        for activity_info in misc.get_activities(self._metadata):
            menu_item = PaletteMenuItem(file_name=activity_info.get_icon(),
                                        text_label=activity_info.get_name())
            menu_item.connect('activate', self._resume_menu_item_activate_cb,
                              activity_info.get_bundle_id())
            self._resume_menu.append_item(menu_item)
            menu_item.show()

        if not misc.can_resume(self._metadata):
            self._resume.set_tooltip(_('No activity to start entry'))
开发者ID:AbrahmAB,项目名称:sugar,代码行数:29,代码来源:journaltoolbox.py

示例11: __init__

# 需要导入模块: from sugar3.graphics.palettemenu import PaletteMenuItem [as 别名]
# 或者: from sugar3.graphics.palettemenu.PaletteMenuItem import connect [as 别名]
    def __init__(self):
        ToolButton.__init__(self)

        self._property = 'timestamp'
        self._order = Gtk.SortType.ASCENDING

        self.props.tooltip = _('Sort view')
        self.props.icon_name = 'view-lastedit'

        self.props.hide_tooltip_on_click = False
        self.palette_invoker.props.toggle_palette = True

        menu_box = PaletteMenuBox()
        self.props.palette.set_content(menu_box)
        menu_box.show()

        for property_, icon, label in self._SORT_OPTIONS:
            button = PaletteMenuItem(label)
            button_icon = Icon(icon_size=Gtk.IconSize.MENU, icon_name=icon)
            button.set_image(button_icon)
            button_icon.show()
            button.connect('activate',
                           self.__sort_type_changed_cb,
                           property_,
                           icon)
            button.show()
            menu_box.append_item(button)
开发者ID:hgarrereyn,项目名称:sugar,代码行数:29,代码来源:journaltoolbox.py

示例12: __init__

# 需要导入模块: from sugar3.graphics.palettemenu import PaletteMenuItem [as 别名]
# 或者: from sugar3.graphics.palettemenu.PaletteMenuItem import connect [as 别名]
    def __init__(self, activity_info, journal_entries):
        ActivityPalette.__init__(self, activity_info)

        if not journal_entries:
            xo_color = XoColor('%s,%s' % (style.COLOR_BUTTON_GREY.get_svg(),
                                          style.COLOR_WHITE.get_svg()))
        else:
            xo_color = misc.get_icon_color(journal_entries[0])

        self.props.icon = Icon(file=activity_info.get_icon(),
                               xo_color=xo_color,
                               pixel_size=style.STANDARD_ICON_SIZE)

        if journal_entries:
            self.props.secondary_text = journal_entries[0]['title']

            menu_items = []
            for entry in journal_entries:
                icon_file_name = misc.get_icon_name(entry)
                color = misc.get_icon_color(entry)

                menu_item = PaletteMenuItem(text_label=entry['title'],
                                            file_name=icon_file_name,
                                            xo_color=color)
                menu_item.connect('activate', self.__resume_entry_cb, entry)
                menu_items.append(menu_item)
                menu_item.show()

            if journal_entries:
                separator = PaletteMenuItemSeparator()
                menu_items.append(separator)
                separator.show()

            for i in range(0, len(menu_items)):
                self.menu_box.pack_start(menu_items[i], True, True, 0)
开发者ID:AxEofBone7,项目名称:sugar,代码行数:37,代码来源:favoritesview.py

示例13: _add_erase_option

# 需要导入模块: from sugar3.graphics.palettemenu import PaletteMenuItem [as 别名]
# 或者: from sugar3.graphics.palettemenu.PaletteMenuItem import connect [as 别名]
    def _add_erase_option(self, registry, activity_info):
        menu_item = PaletteMenuItem(_("Erase"), "list-remove")
        menu_item.connect("activate", self.__erase_activate_cb)
        self.menu_box.append_item(menu_item)
        menu_item.show()

        if not os.access(activity_info.get_path(), os.W_OK) or registry.is_activity_protected(self._bundle_id):
            menu_item.props.sensitive = False
开发者ID:GhostAlgorithm,项目名称:sugar,代码行数:10,代码来源:activitieslist.py

示例14: create_menu_item

# 需要导入模块: from sugar3.graphics.palettemenu import PaletteMenuItem [as 别名]
# 或者: from sugar3.graphics.palettemenu.PaletteMenuItem import connect [as 别名]
 def create_menu_item(history_item, item_index):
     """Create a MenuItem for the back or forward palettes."""
     title = history_item.get_title()
     if not isinstance(title, unicode):
         title = unicode(title, "utf-8")
     # This is a fix until the Sugar MenuItem is fixed:
     menu_item = PaletteMenuItem(text_label=title)
     menu_item.connect("activate", self._history_item_activated_cb, item_index)
     return menu_item
开发者ID:richaseh,项目名称:browse,代码行数:11,代码来源:webtoolbar.py

示例15: create_menu_item

# 需要导入模块: from sugar3.graphics.palettemenu import PaletteMenuItem [as 别名]
# 或者: from sugar3.graphics.palettemenu.PaletteMenuItem import connect [as 别名]
 def create_menu_item(history_item):
     """Create a MenuItem for the back or forward palettes."""
     title = history_item.get_title() or _('No Title')
     if not isinstance(title, unicode):
         title = unicode(title, 'utf-8')
     # This is a fix until the Sugar MenuItem is fixed:
     menu_item = PaletteMenuItem(text_label=title)
     menu_item.connect('activate', self._history_item_activated_cb,
                       history_item)
     return menu_item
开发者ID:leonardcj,项目名称:browse-activity,代码行数:12,代码来源:webtoolbar.py


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