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)
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)
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: activity_name = self._bundle.get_name() else: activity_name = bundle_id self.set_primary_text(activity_name) title = self._invite.get_activity_title() if title is not None: self.set_secondary_text(title)
def __init__(self, file_name, document_path, title, bundle=False): RadioToolButton.__init__(self) self._document_path = document_path self._title = title self._jobject = None 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.__copy_to_home_cb) 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()
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'))
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'))
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)
def __init__(self, activity_info): self._activity_info = activity_info color = profile.get_color() activity_icon = Icon(file=activity_info.get_icon(), xo_color=color, pixel_size=style.STANDARD_ICON_SIZE) name = activity_info.get_name() Palette.__init__(self, primary_text=GLib.markup_escape_text(name), icon=activity_icon) xo_color = XoColor( '%s,%s' % (style.COLOR_WHITE.get_svg(), style.COLOR_TRANSPARENT.get_svg())) self.menu_box = PaletteMenuBox() menu_item = PaletteMenuItem(text_label=_('Start new'), file_name=activity_info.get_icon(), xo_color=xo_color) menu_item.connect('activate', self.__start_activate_cb) self.menu_box.pack_end(menu_item, True, True, 0) menu_item.show() self.set_content(self.menu_box) self.menu_box.show_all()
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
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)
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()
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)
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)
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()
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)
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)
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)
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
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()
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)
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
def _add_menu(self, option, icon=None, activate_cb=None): if icon is not None: menu_item = PaletteMenuItem(icon_name=icon) if activate_cb is not None: menu_item.connect('activate', activate_cb, [option, icon]) else: menu_item = PaletteMenuItem() if activate_cb is not None: menu_item.connect('activate', activate_cb, option) menu_item.set_label(option) self._menu_box.append_item(menu_item) menu_item.show()
class DisplayPalette(Palette): def __init__(self): Palette.__init__(self, label=_('My Display')) self._screenshot = PaletteMenuItem(_('Take a screenshot')) icon = Icon(icon_name='camera-external', pixel_size=style.SMALL_ICON_SIZE) self._screenshot.set_image(icon) icon.show() self._screenshot.connect('activate', self.__screenshot_cb) self._screenshot.show() self._box = PaletteMenuBox() self._brightness_manager = None # only add this widget if device available if brightness.get_instance().get_path(): self._add_brightness_manager() self._box.append_item(self._screenshot, 0, 0) self._box.show() self.set_content(self._box) self.connect('popup', self.__popup_cb) def _add_brightness_manager(self): self._brightness_manager = BrightnessManagerWidget(_('Brightness'), 'brightness-100') self._brightness_manager.show() separator = PaletteMenuItemSeparator() separator.show() self._box.append_item(self._brightness_manager, 0, 0) self._box.append_item(separator, 0, 0) def __popup_cb(self, palette): if self._brightness_manager is not None: self._brightness_manager.update() def __screenshot_cb(self, palette): frame_ = frame.get_view() frame_.hide() GLib.idle_add(self.__take_screenshot_cb, frame_) @staticmethod def __take_screenshot_cb(frame_): if frame_.is_visible(): return True take_screenshot() frame_.show() return False
def set_palette_list(self, options): _menu_item = PaletteMenuItem( text_label=options[list(options.keys())[0]]) req2 = _menu_item.get_preferred_size()[1] menuitem_width = req2.width menuitem_height = req2.height palette_width = Gdk.Screen.width() - style.GRID_CELL_SIZE palette_height = Gdk.Screen.height() - style.GRID_CELL_SIZE * 3 nx = min(self._MAXIMUM_PALETTE_COLUMNS, int(palette_width / menuitem_width)) ny = min(int(palette_height / menuitem_height), len(options) + 1) if ny >= len(options): nx = 1 ny = len(options) grid = Gtk.Grid() grid.set_row_spacing(style.DEFAULT_PADDING) grid.set_column_spacing(0) grid.set_border_width(0) grid.show() x = 0 y = 0 for key in sorted(options): menu_item = PaletteMenuItem() menu_item.set_label(options[key]) menu_item.set_size_request(style.GRID_CELL_SIZE * 3, -1) menu_item.connect('button-release-event', self._option_selected, key) grid.attach(menu_item, x, y, 1, 1) x += 1 if x == nx: x = 0 y += 1 menu_item.show() if palette_height < (y * menuitem_height + style.GRID_CELL_SIZE): # if the grid is bigger than the palette, put in a scrolledwindow scrolled_window = Gtk.ScrolledWindow() scrolled_window.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC) scrolled_window.set_size_request(nx * menuitem_width, (ny + 1) * menuitem_height) scrolled_window.add_with_viewport(grid) return scrolled_window else: return grid
def set_palette_list(instrument_list): text_label = instrument_list[0]['instrument_desc'] file_name = instrument_list[0]['file_name'] _menu_item = PaletteMenuItem(text_label=text_label, file_name=file_name) req2 = _menu_item.get_preferred_size()[1] menuitem_width = req2.width menuitem_height = req2.height palette_width = Gdk.Screen.width() - style.GRID_CELL_SIZE * 3 palette_height = Gdk.Screen.height() - style.GRID_CELL_SIZE * 3 nx = min(int(palette_width / menuitem_width), MAX_PALETTE_WIDTH) ny = min(int(palette_height / menuitem_height), len(instrument_list) + 1) if ny >= len(instrument_list): nx = 1 ny = len(instrument_list) grid = Gtk.Grid() grid.set_row_spacing(style.DEFAULT_PADDING) grid.set_column_spacing(0) grid.set_border_width(0) grid.show() x = 0 y = 0 for item in sorted( instrument_list, cmp=lambda x, y: cmp(x['instrument_desc'], y['instrument_desc'])): menu_item = PaletteMenuItem(text_label=item['instrument_desc'], file_name=item['file_name']) menu_item.connect('button-release-event', item['callback'], item) # menu_item.connect('button-release-event', lambda x: x, item) grid.attach(menu_item, x, y, 1, 1) x += 1 if x == nx: x = 0 y += 1 menu_item.show() if palette_height < (y * menuitem_height + style.GRID_CELL_SIZE): # if the grid is bigger than the palette, put in a scrolledwindow scrolled_window = Gtk.ScrolledWindow() scrolled_window.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC) scrolled_window.set_size_request(nx * menuitem_width, (ny + 1) * menuitem_height) scrolled_window.add_with_viewport(grid) return scrolled_window else: return grid
def _setup_quality_palette(self): self._quality_palette = self._quality_button.get_palette() box = PaletteMenuBox() self._quality_palette.set_content(box) box.show() for quality in QUALITY_VALUES: text = _('%s quality') % (quality) menu_item = PaletteMenuItem(text, icon_name=quality + '-quality') menu_item.connect('activate', self._quality_selected_cb, quality) box.append_item(menu_item) menu_item.show()
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 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()
def __init__(self, url): Palette.__init__(self, url) self.owns_clipboard = False self.url = self._url_check_protocol(url) menu_box = Gtk.VBox() self.set_content(menu_box) menu_box.show() self._content.set_border_width(1) menu_item = PaletteMenuItem(_('Copy to Clipboard'), 'edit-copy') menu_item.connect('activate', self._copy_to_clipboard_cb) menu_box.pack_start(menu_item, False, False, 0) menu_item.show() self.props.invoker = ContentInvoker()
def set_palette_list(palette_list, nx, ny, item_height, return_dict=False): palette_dict = {} item_width = style.GRID_CELL_SIZE * 3 grid = Gtk.Grid() grid.set_row_spacing(style.DEFAULT_PADDING) grid.set_column_spacing(0) grid.set_border_width(0) scrolled_window = Gtk.ScrolledWindow() scrolled_window.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC) scrolled_window.set_size_request(nx * item_width, ny * item_height) scrolled_window.set_shadow_type(Gtk.ShadowType.ETCHED_IN) scrolled_window.add_with_viewport(grid) grid.show() x = 0 y = 0 for item in palette_list: menu_item = PaletteMenuItem() menu_item.set_label(item['label']) menu_item.set_image(item['icon']) item['icon'].show() if return_dict: menu_item.set_image(item['selected']) item['selected'].hide() if return_dict: palette_dict[item['label']] = { 'menu': menu_item, 'icon': item['icon'], 'selected': item['selected'] } menu_item.connect('button-release-event', item['callback'], item['label']) grid.attach(menu_item, x, y, 1, 1) x += 1 if x == nx: x = 0 y += 1 menu_item.show() if return_dict: return scrolled_window, palette_dict else: return scrolled_window
def _setup_timer_palette(self): self._timer_palette = self._timer_button.get_palette() box = PaletteMenuBox() self._timer_palette.set_content(box) box.show() for seconds in TIMER_VALUES: if seconds == 0: text = _('Immediate') else: text = ngettext('%s second', '%s seconds', seconds) % seconds menu_item = PaletteMenuItem(text, icon_name='timer-%d' % (seconds)) menu_item.connect('activate', self._timer_selected_cb, seconds) box.append_item(menu_item) menu_item.show()
def _setup_duration_palette(self): self._duration_palette = self._duration_button.get_palette() box = PaletteMenuBox() self._duration_palette.set_content(box) box.show() for minutes in DURATION_VALUES: if minutes == 0: text = Gtk.Label(_('Immediate')) else: text = ngettext('%s minute', '%s minutes', minutes) % minutes menu_item = PaletteMenuItem(text, icon_name='duration-%d' % (minutes)) menu_item.connect('activate', self._duration_selected_cb, minutes) box.append_item(menu_item) menu_item.show()
def create_palette(self): palette = VolumePalette(self._mount) palette.set_group_id('frame') menu_item = PaletteMenuItem(_('Show contents')) color = profile.get_color() icon = Icon(icon_name=self._icon_name, pixel_size=style.SMALL_ICON_SIZE, xo_color=color) menu_item.set_image(icon) icon.show() menu_item.connect('activate', self.__show_contents_cb) palette.content_box.pack_start(menu_item, True, True, 0) palette.content_box.reorder_child(menu_item, 0) menu_item.show() return palette
def setup_palette(self): activity_name = self._home_activity.get_activity_name() if activity_name: self.props.primary_text = activity_name title = self._home_activity.get_title() if title and title != activity_name: self.props.secondary_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) menu_item.show() # TODO: share-with, keep menu_item = PaletteMenuItem(_('View Source'), 'view-source') menu_item.connect('activate', self.__view_source__cb) menu_item.set_accelerator('Shift+Alt+V') self.menu_box.append_item(menu_item) menu_item.show() help_url_and_title = get_help_url_and_title(self._home_activity) if help_url_and_title: menu_item = PaletteMenuItem(_('View Help'), 'toolbar-help') menu_item.connect('activate', self.__view_help__cb) menu_item.set_accelerator('Shift+Alt+H') self.menu_box.append_item(menu_item) menu_item.show() # avoid circular importing reference from jarabe.frame.notification import NotificationBox menu_item = NotificationBox(self._home_activity.get_activity_id()) self.menu_box.append_item(menu_item, 0, 0) separator = PaletteMenuItemSeparator() menu_item.add(separator) menu_item.reorder_child(separator, 0) separator.show() 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) menu_item.show() self.set_content(self.menu_box) self.menu_box.show()
def create_palette(self): palette = VolumePalette(self._mount) palette.set_group_id('frame') menu_item = PaletteMenuItem(_('Show contents')) client = GConf.Client.get_default() color = XoColor(client.get_string('/desktop/sugar/user/color')) icon = Icon(icon_name=self._icon_name, icon_size=Gtk.IconSize.MENU, xo_color=color) menu_item.set_image(icon) icon.show() menu_item.connect('activate', self.__show_contents_cb) palette.content_box.pack_start(menu_item, True, True, 0) palette.content_box.reorder_child(menu_item, 0) menu_item.show() return palette
def __init__(self, row, tree_view, collab): Palette.__init__(self, primary_text=_(row[MainList.COLUMN_TYPE])) self._collab = collab self._row = row self._tree_view = tree_view box = PaletteMenuBox() self.set_content(box) box.show() menu_item = PaletteMenuItem(_('Edit'), icon_name='toolbar-edit') menu_item.connect('activate', lambda *args: tree_view.edit(row)) box.append_item(menu_item) menu_item.show() menu_item = PaletteMenuItem(_('Delete'), icon_name='edit-delete') menu_item.connect('activate', self.__delete_cb) box.append_item(menu_item) menu_item.show()
def create_palette(self): 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: text = _('Register') else: text = _('Register again') register_menu = PaletteMenuItem(text, 'media-record') register_menu.connect('activate', self.__register_activate_cb) palette.menu_box.pack_end(register_menu, True, True, 0) register_menu.show() self.connect_to_palette_pop_events(palette) return palette
def __init__(self, mount): Palette.__init__(self, label=mount.get_name()) self._mount = mount path = mount.get_root().get_path() self.props.secondary_text = GLib.markup_escape_text(path) self.content_box = PaletteMenuBox() self.set_content(self.content_box) self.content_box.show() menu_item = PaletteMenuItem(pgettext('Volume', 'Remove')) icon = Icon(icon_name='media-eject', pixel_size=style.SMALL_ICON_SIZE) menu_item.set_image(icon) icon.show() menu_item.connect('activate', self.__unmount_activate_cb) self.content_box.append_item(menu_item) menu_item.show() separator = PaletteMenuItemSeparator() self.content_box.append_item(separator) separator.show() free_space_box = Gtk.VBox() free_space_box.set_spacing(style.DEFAULT_PADDING) self.content_box.append_item(free_space_box, vertical_padding=0) free_space_box.show() self._progress_bar = Gtk.ProgressBar() free_space_box.pack_start(self._progress_bar, True, True, 0) self._progress_bar.show() self._free_space_label = Gtk.Label() self._free_space_label.set_alignment(0.5, 0.5) free_space_box.pack_start(self._free_space_label, True, True, 0) self._free_space_label.show() self.connect('popup', self.__popup_cb)
def setup_palette(self): title = self._home_activity.get_title() self.set_primary_text(GLib.markup_escape_text(title)) box = PaletteMenuBox() self.set_content(box) box.show() menu_item = PaletteMenuItem(_('Show contents')) icon = Icon(file=self._home_activity.get_icon_path(), pixel_size=style.SMALL_ICON_SIZE, xo_color=self._home_activity.get_icon_color()) menu_item.set_image(icon) icon.show() menu_item.connect('activate', self.__open_activate_cb) box.append_item(menu_item) menu_item.show() separator = PaletteMenuItemSeparator() box.append_item(separator) separator.show() inner_box = Gtk.VBox() inner_box.set_spacing(style.DEFAULT_PADDING) box.append_item(inner_box, vertical_padding=0) inner_box.show() self._progress_bar = Gtk.ProgressBar() inner_box.add(self._progress_bar) self._progress_bar.show() self._free_space_label = Gtk.Label() self._free_space_label.set_alignment(0.5, 0.5) inner_box.add(self._free_space_label) self._free_space_label.show() self.connect('popup', self.__popup_cb)
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_TRANSPARENT.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, icon_size=Gtk.IconSize.LARGE_TOOLBAR) if journal_entries: title = journal_entries[0]['title'] self.props.secondary_text = glib.markup_escape_text(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)
def create(self): if self._link is not None: self.props.primary_text = GLib.markup_escape_text(self._link) else: self.props.primary_text = GLib.markup_escape_text(_('Terminal')) menu_box = Gtk.VBox() self.set_content(menu_box) menu_box.show() self._content.set_border_width(1) if self._link: menu_item = PaletteMenuItem(_('Follow link'), 'browse-follow-link') menu_item.connect('activate', self.__follow_activate_cb) menu_box.pack_start(menu_item, False, False, 0) menu_item.show() menu_item = PaletteMenuItem(_('Copy link'), 'edit-copy') menu_item.icon.props.xo_color = profile.get_color() menu_item.connect('activate', self.__copy_cb) menu_box.pack_start(menu_item, False, False, 0) menu_item.show() if not self._link: menu_item = PaletteMenuItem(_('Copy text'), 'edit-copy') menu_item.icon.props.xo_color = profile.get_color() menu_item.connect('activate', self.__copy_cb) menu_box.pack_start(menu_item, False, False, 0) menu_item.show() menu_item = PaletteMenuItem(_('Paste text'), 'edit-paste') menu_item.icon.props.xo_color = profile.get_color() menu_item.connect('activate', self.__paste_cb) menu_box.pack_start(menu_item, False, False, 0) menu_item.show()
def _add_my_items(self): item = PaletteMenuItem(_('Shutdown'), 'system-shutdown') item.connect('activate', self.__shutdown_activate_cb) self.menu_box.pack_start(item, True, True, 0) client = GConf.Client.get_default() if client.get_bool('/desktop/sugar/show_restart'): item = PaletteMenuItem(_('Restart'), 'system-restart') item.connect('activate', self.__reboot_activate_cb) self.menu_box.pack_start(item, True, True, 0) item.show() if client.get_bool('/desktop/sugar/show_logout'): item = PaletteMenuItem(_('Logout'), 'system-logout') item.connect('activate', self.__logout_activate_cb) self.menu_box.pack_start(item, True, True, 0) item.show() item = PaletteMenuItem(_('My Settings'), 'preferences-system') item.connect('activate', self.__controlpanel_activate_cb) self.menu_box.pack_start(item, True, True, 0) item.show()