本文整理汇总了Python中sugar3.graphics.palettemenu.PaletteMenuItem类的典型用法代码示例。如果您正苦于以下问题:Python PaletteMenuItem类的具体用法?Python PaletteMenuItem怎么用?Python PaletteMenuItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PaletteMenuItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _create_palette
def _create_palette(self):
self._palette_icon = Icon(
icon_name=self._ICON_NAME + str(self._channel),
pixel_size=style.STANDARD_ICON_SIZE)
palette_ = palette.Palette(_('Ad-hoc Network %d') % (self._channel, ),
icon=self._palette_icon)
self.menu_box = Gtk.VBox()
self._connect_item = PaletteMenuItem(_('Connect'))
icon = Icon(pixel_size=style.SMALL_ICON_SIZE, icon_name='dialog-ok')
self._connect_item.set_image(icon)
self._connect_item.connect('activate', self.__connect_activate_cb)
self.menu_box.add(self._connect_item)
self._disconnect_item = PaletteMenuItem(_('Disconnect'))
icon = Icon(pixel_size=style.SMALL_ICON_SIZE, icon_name='media-eject')
self._disconnect_item.set_image(icon)
self._disconnect_item.connect(
'activate', self.__disconnect_activate_cb)
self.menu_box.add(self._disconnect_item)
palette_.set_content(self.menu_box)
self.menu_box.show_all()
self._disconnect_item.hide()
self.connect_to_palette_pop_events(palette_)
return palette_
示例2: create_palette
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
示例3: setup_rollover_options
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)
示例4: __init__
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)
示例5: _create_palette
def _create_palette(self):
icon_name = get_icon_state(_AP_ICON_NAME, self._strength)
self._palette_icon = Icon(icon_name=icon_name,
icon_size=style.STANDARD_ICON_SIZE,
badge_name=self.props.badge_name)
label = GLib.markup_escape_text(self._display_name)
p = palette.Palette(primary_text=label, icon=self._palette_icon)
self.menu_box = Gtk.VBox()
self._connect_item = PaletteMenuItem(_('Connect'))
icon = Icon(icon_size=Gtk.IconSize.MENU, icon_name='dialog-ok')
self._connect_item.set_image(icon)
self._connect_item.connect('activate', self.__connect_activate_cb)
self.menu_box.add(self._connect_item)
self._disconnect_item = PaletteMenuItem(_('Disconnect'))
icon = Icon(icon_size=Gtk.IconSize.MENU, icon_name='media-eject')
self._disconnect_item.set_image(icon)
self._disconnect_item.connect('activate', self.__disconnect_activate_cb)
self.menu_box.add(self._disconnect_item)
p.set_content(self.menu_box)
self.menu_box.show_all()
self.connect_to_palette_pop_events(p)
return p
示例6: __init__
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)
示例7: __init__
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)
示例8: _refresh_resume_palette
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'))
示例9: create_palette
def create_palette(self):
if not self._palette_enabled:
self._palette_enabled = True
return
palette = BuddyMenu(get_owner_instance())
settings = Gio.Settings('org.sugarlabs')
if settings.get_boolean('show-register'):
backup_url = settings.get_string('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
示例10: create_palette
def create_palette(self):
if not self._palette_enabled:
self._palette_enabled = True
return
palette = BuddyMenu(get_owner_instance())
client = GConf.Client.get_default()
if client.get_bool('/desktop/sugar/show_register'):
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
示例11: __init__
def __init__(self, text_label=None):
PaletteMenuItem.__init__(self, text_label=None, text_maxlen=0)
self.id_enter_notify_cb = self.connect('enter-notify-event',
self.__enter_notify_cb)
self.id_leave_notify_cb = self.connect('leave-notify-event',
self.__leave_notify_cb)
self.set_label(text_label)
示例12: _add_erase_option
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
示例13: create_menu_item
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
示例14: create_menu_item
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
示例15: setup_palette
def setup_palette(self):
activity_name = self._home_activity.get_activity_name()
if activity_name:
self.props.primary_text = glib.markup_escape_text(activity_name)
title = self._home_activity.get_title()
if title and title != activity_name:
self.props.secondary_text = glib.markup_escape_text(title)
self.menu_box = PaletteMenuBox()
menu_item = PaletteMenuItem(_('Resume'), 'activity-start')
menu_item.connect('activate', self.__resume_activate_cb)
self.menu_box.append_item(menu_item)
# TODO: share-with, keep
menu_item = PaletteMenuItem(_('View Source'), 'view-source')
menu_item.connect('activate', self.__view_source__cb)
self.menu_box.append_item(menu_item)
separator = PaletteMenuItemSeparator()
self.menu_box.append_item(separator)
separator.show()
menu_item = PaletteMenuItem(_('Stop'), 'activity-stop')
menu_item.connect('activate', self.__stop_activate_cb)
self.menu_box.append_item(menu_item)
self.set_content(self.menu_box)
self.menu_box.show_all()