def __init__(self, primary_text): Palette.__init__(self, label=primary_text) self._disconnect_item = None self._channel_label = gtk.Label() self._channel_label.props.xalign = 0.0 self._channel_label.show() self._ip_address_label = gtk.Label() self._info = gtk.VBox() def _padded(child, xalign=0, yalign=0.5): padder = gtk.Alignment(xalign=xalign, yalign=yalign, xscale=1, yscale=0.33) padder.set_padding(style.DEFAULT_SPACING, style.DEFAULT_SPACING, style.DEFAULT_SPACING, style.DEFAULT_SPACING) padder.add(child) return padder self._info.pack_start(_padded(self._channel_label)) self._info.pack_start(_padded(self._ip_address_label)) self._info.show_all() self._disconnect_item = MenuItem(_('Disconnect')) icon = Icon(icon_size=gtk.ICON_SIZE_MENU, icon_name='media-eject') self._disconnect_item.set_image(icon) self._disconnect_item.connect('activate', self.__disconnect_activate_cb) self.menu.append(self._disconnect_item)
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) vbox = gtk.VBox() self.set_content(vbox) vbox.show() self._progress_bar = gtk.ProgressBar() vbox.add(self._progress_bar) self._progress_bar.show() self._free_space_label = gtk.Label() self._free_space_label.set_alignment(0.5, 0.5) vbox.add(self._free_space_label) self._free_space_label.show() self.connect('popup', self.__popup_cb) menu_item = MenuItem(pgettext('Volume', 'Remove')) icon = Icon(icon_name='media-eject', icon_size=gtk.ICON_SIZE_MENU) menu_item.set_image(icon) icon.show() menu_item.connect('activate', self.__unmount_activate_cb) self.menu.append(menu_item) menu_item.show()
def __init__(self): label = glib.markup_escape_text(_('Wired Network')) Palette.__init__(self, primary_text=label) self._speed_label = gtk.Label() self._speed_label.props.xalign = 0.0 self._speed_label.show() self._ip_address_label = gtk.Label() self._info = gtk.VBox() def _padded(child, xalign=0, yalign=0.5): padder = gtk.Alignment(xalign=xalign, yalign=yalign, xscale=1, yscale=0.33) padder.set_padding(style.DEFAULT_SPACING, style.DEFAULT_SPACING, style.DEFAULT_SPACING, style.DEFAULT_SPACING) padder.add(child) return padder self._info.pack_start(_padded(self._speed_label)) self._info.pack_start(_padded(self._ip_address_label)) self._info.show_all() self.set_content(self._info) self.props.secondary_text = glib.markup_escape_text(_('Connected'))
def __init__(self, invite): Palette.__init__(self, '') self._invite = invite menu_item = MenuItem(_('Join'), icon_name='dialog-ok') menu_item.connect('activate', self.__join_activate_cb) self.menu.append(menu_item) menu_item.show() menu_item = MenuItem(_('Decline'), icon_name='dialog-cancel') menu_item.connect('activate', self.__decline_activate_cb) self.menu.append(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(glib.markup_escape_text(name))
def __init__(self, **kwargs): self._color = gtk.gdk.Color(0, 0, 0) self._previous_color = self._color.copy() self._scales = None Palette.__init__(self, **kwargs) self.connect('popup', self.__popup_cb) self.connect('popdown', self.__popdown_cb) self._picker_hbox = gtk.HBox() self.set_content(self._picker_hbox) self._swatch_tray = gtk.Table() self._picker_hbox.pack_start(self._swatch_tray) self._picker_hbox.pack_start(gtk.VSeparator(), padding=style.DEFAULT_SPACING) self._chooser_table = gtk.Table(3, 2) self._chooser_table.set_col_spacing(0, style.DEFAULT_PADDING) self._scales = [] self._scales.append(self._create_color_scale(_('Red'), self._RED, 0)) self._scales.append( self._create_color_scale(_('Green'), self._GREEN, 1)) self._scales.append(self._create_color_scale(_('Blue'), self._BLUE, 2)) self._picker_hbox.add(self._chooser_table) self._picker_hbox.show_all() self._build_swatches()
def __init__(self, **kwargs): self._color = gtk.gdk.Color(0, 0, 0) self._previous_color = self._color.copy() self._scales = None Palette.__init__(self, **kwargs) self.connect('popup', self.__popup_cb) self.connect('popdown', self.__popdown_cb) self._picker_hbox = gtk.HBox() self.set_content(self._picker_hbox) self._swatch_tray = gtk.Table() self._picker_hbox.pack_start(self._swatch_tray) self._picker_hbox.pack_start(gtk.VSeparator(), padding=style.DEFAULT_SPACING) self._chooser_table = gtk.Table(3, 2) self._chooser_table.set_col_spacing(0, style.DEFAULT_PADDING) self._scales = [] self._scales.append( self._create_color_scale(_('Red'), self._RED, 0)) self._scales.append( self._create_color_scale(_('Green'), self._GREEN, 1)) self._scales.append( self._create_color_scale(_('Blue'), self._BLUE, 2)) self._picker_hbox.add(self._chooser_table) self._picker_hbox.show_all() self._build_swatches()
def __init__(self, url): Palette.__init__(self, url) self.url = url_check_protocol(url) menu_item = MenuItem(_('Copy to Clipboard'), 'edit-copy') menu_item.connect('activate', self._copy_to_clipboard_cb) self.menu.append(menu_item) menu_item.show()
def __init__(self, buddy): self._buddy = buddy nick, colors = buddy buddy_icon = Icon(icon_name='computer-xo', icon_size=style.STANDARD_ICON_SIZE, xo_color=XoColor(colors)) Palette.__init__(self, primary_text=glib.markup_escape_text(nick), icon=buddy_icon)
def __init__(self, url): Palette.__init__(self, url) self.owns_clipboard = False self.url = _url_check_protocol(url) menu_item = MenuItem(_('Copy to Clipboard'), 'edit-copy') menu_item.connect('activate', self._copy_to_clipboard_cb) self.menu.append(menu_item) menu_item.show()
def __init__(self, file_transfer): Palette.__init__(self, glib.markup_escape_text(file_transfer.title)) self.file_transfer = file_transfer self.progress_bar = None self.progress_label = None self._notify_transferred_bytes_handler = None self.connect('popup', self.__popup_cb) self.connect('popdown', self.__popdown_cb)
def set_tooltip(self, tooltip): """ Set a simple palette with just a single label. """ if self.palette is None or self._tooltip is None: self.palette = Palette(tooltip) elif self.palette is not None: self.palette.set_primary_text(tooltip) self._tooltip = tooltip # Set label, shows up when toolbar overflows gtk.ToolButton.set_label(self, tooltip)
def __init__(self, label, tree): Palette.__init__(self, label) self.tree = tree background = gtk.VBox() self.set_content(background) default_view = gtk.RadioButton() default_view.props.label = _('Default list view') default_view.connect('clicked', self._listview_cb, 'default') background.pack_start(default_view) for type, props in sorted(TRAITS.items(), cmp=lambda x, y: cmp(x[1]['title'], y[1]['title'])): i = gtk.RadioButton() i.props.label = props['title'] i.props.group = default_view background.pack_start(i) if type == this.config['list_type']: i.props.active = True i.connect('clicked', self._listview_cb, type) separator = gtk.Label(' ') background.pack_start(separator) self.expander = gtk.Expander(_('Columns')) # XXX suppress gtk artifacts during the second showing # if expander was expanded/unexpanded before expander_box = gtk.EventBox() expander_box.add(self.expander) background.pack_start(expander_box) self.model = gtk.ListStore(bool, str) self.view = gtk.TreeView(self.model) self.view.props.headers_visible = False self.expander.add(self.view) cell = gtk.CellRendererToggle() cell.props.activatable = True cell.props.cell_background_gdk = style.COLOR_BLACK.get_gdk_color() cell.connect('toggled', self._toggled_cb) self.view.insert_column_with_attributes(0, '', cell, active=0) cell = gtk.CellRendererText() cell.props.cell_background_gdk = style.COLOR_BLACK.get_gdk_color() cell.props.foreground_gdk = style.COLOR_WHITE.get_gdk_color() self.view.insert_column_with_attributes(1, '', cell, text=1) background.show_all() self.connect('popup', self._popup_cb) self.connect('popdown', self._popdown_cb)
def __init__(self, home_activity): Palette.__init__(self) self._notify_launch_hid = None if home_activity.props.launch_status == shell.Activity.LAUNCHING: self._notify_launch_hid = home_activity.connect( \ 'notify::launch-status', self.__notify_launch_status_cb) self.set_primary_text(glib.markup_escape_text(_('Starting...'))) elif home_activity.props.launch_status == shell.Activity.LAUNCH_FAILED: self._on_failed_launch() else: self.setup_palette()
def __init__(self): label = glib.markup_escape_text(_('Wireless modem')) Palette.__init__(self, primary_text=label) self._current_state = None self._failed_connection = False self._toggle_state_item = MenuItem('') self._toggle_state_item.connect('activate', self.__toggle_state_cb) self.menu.append(self._toggle_state_item) self._toggle_state_item.show() self.info_box = gtk.VBox() self.error_title_label = gtk.Label("") self.error_title_label.set_alignment(0, 0.5) self.error_title_label.set_line_wrap(True) self.info_box.pack_start(self.error_title_label) self.error_description_label = gtk.Label("") self.error_description_label.set_alignment(0, 0.5) self.error_description_label.set_line_wrap(True) self.info_box.pack_start(self.error_description_label) self.connection_info_box = gtk.HBox() icon = Icon(icon_name='data-upload', icon_size=gtk.ICON_SIZE_MENU) self.connection_info_box.pack_start(icon) icon.show() self._data_label_up = gtk.Label() self._data_label_up.props.xalign = 0.0 label_alignment = self._add_widget_with_padding(self._data_label_up) self.connection_info_box.pack_start(label_alignment) self._data_label_up.show() label_alignment.show() icon = Icon(icon_name='data-download', icon_size=gtk.ICON_SIZE_MENU) self.connection_info_box.pack_start(icon) icon.show() self._data_label_down = gtk.Label() self._data_label_down.props.xalign = 0.0 label_alignment = self._add_widget_with_padding(self._data_label_down) self.connection_info_box.pack_start(label_alignment) self._data_label_down.show() label_alignment.show() self.info_box.pack_start(self.connection_info_box) self.info_box.show() self.set_content(self.info_box) self.set_state(_GSM_STATE_NOT_READY)
def __init__(self, primary_text, manager): Palette.__init__(self, label=primary_text) self._manager = manager self._manager.connect('play', self._set_menu_state, 'play') self._manager.connect('stop', self._set_menu_state, 'stop') self._manager.connect('pause', self._set_menu_state, 'pause') vbox = gtk.VBox() self.set_content(vbox) self._play_icon = Icon(icon_name='player_play') self._pause_icon = Icon(icon_name='player_pause') self._play_pause_menu = MenuItem(text_label=_('Say selected text')) self._play_pause_menu.set_image(self._play_icon) self._play_pause_menu.connect('activate', self.__play_activated_cb) self._play_pause_menu.show() self._stop_menu = MenuItem(icon_name='player_stop', text_label=_('Stop playback')) self._stop_menu.connect('activate', self.__stop_activated_cb) self._stop_menu.set_sensitive(False) self._stop_menu.show() self.menu.append(self._play_pause_menu) self.menu.append(self._stop_menu) self._adj_pitch = gtk.Adjustment(value=self._manager.get_pitch(), lower=self._manager.MIN_PITCH, upper=self._manager.MAX_PITCH) self._hscale_pitch = gtk.HScale(self._adj_pitch) self._hscale_pitch.set_draw_value(False) vbox.pack_start(gtk.Label(_('Pitch')), padding=style.DEFAULT_PADDING) vbox.pack_start(self._hscale_pitch) self._adj_rate = gtk.Adjustment(value=self._manager.get_rate(), lower=self._manager.MIN_RATE, upper=self._manager.MAX_RATE) self._hscale_rate = gtk.HScale(self._adj_rate) self._hscale_rate.set_draw_value(False) vbox.pack_start(gtk.Label(_('Rate')), padding=style.DEFAULT_PADDING) vbox.pack_start(self._hscale_rate) vbox.show_all() self._adj_pitch.connect('value_changed', self.__adj_pitch_changed_cb) self._adj_rate.connect('value_changed', self.__adj_rate_changed_cb)
def __init__(self, mount): Palette.__init__(self, glib.markup_escape_text(_('Journal'))) vbox = gtk.VBox() self.set_content(vbox) vbox.show() self._progress_bar = gtk.ProgressBar() vbox.add(self._progress_bar) self._progress_bar.show() self._free_space_label = gtk.Label() self._free_space_label.set_alignment(0.5, 0.5) vbox.add(self._free_space_label) self._free_space_label.show() self.connect('popup', self.__popup_cb)
def addBlock(self, data, name, block): # tooltip invoker = WidgetInvoker(block) invoker._position_hint = WidgetInvoker.AT_CURSOR invoker.set_palette(Palette(name)) block.add_events(gtk.gdk.BUTTON_PRESS_MASK | gtk.gdk.BUTTON_RELEASE_MASK | gtk.gdk.ENTER_NOTIFY_MASK | gtk.gdk.LEAVE_NOTIFY_MASK | gtk.gdk.POINTER_MOTION_MASK | gtk.gdk.POINTER_MOTION_HINT_MASK) block.connect("button-press-event", self.on_button_press) block.connect("button-release-event", self.on_button_release) block.connect("motion-notify-event", self.on_motion_notify) block.data = data self.blocks.append(block) if self._testAgainstFilter(block): self.pickerBox.pack_start(block, False, False, 3) block.show_all() return block
def __init__(self, primary_text, icon): """ Create the palette and initilize with current touchpad status. """ Palette.__init__(self, label=primary_text) self._icon = icon vbox = gtk.VBox() self.set_content(vbox) self._status_text = gtk.Label() vbox.pack_start(self._status_text, padding=style.DEFAULT_PADDING) self._status_text.show() vbox.show() self._mode = _read_touchpad_mode() self._update()
def _add_button(self, icon_name, label, accelerator, zoom_level): if self.get_children(): group = self.get_children()[0] else: group = None button = RadioToolButton(named_icon=icon_name, group=group, accelerator=accelerator) button.connect("clicked", self.__level_clicked_cb, zoom_level) self.add(button) button.show() palette = Palette(glib.markup_escape_text(label)) palette.props.invoker = FrameWidgetInvoker(button) palette.set_group_id("frame") button.set_palette(palette) return button
def __init__(self): Palette.__init__(self, _('Root')) self.connect('popup', self._popup_cb) box = gtk.VBox() self.set_content(box) self.radio = [None] * 3 self.radio[0] = gtk.RadioButton(self.radio[0], _('Hide local objects')) box.pack_start(self.radio[0]) self.radio[1] = gtk.RadioButton(self.radio[0], _('Show all local objects')) box.pack_start(self.radio[1]) self.radio[2] = gtk.RadioButton(self.radio[0]) box.pack_start(self.radio[2]) separator = gtk.Label() box.pack_start(separator) self.setup = gtk.Button(_('Add current path to filter')) self.setup.connect('clicked', self._setup_cb) setup_box = gtk.HBox() setup_box.pack_start(self.setup, False) box.pack_start(setup_box) box.show_all() self.config = model.this['path'] for tag_type, tag, name in self.config['root_path']: button = _create_button(name) this.last_root.append([tag_type, tag, [button]]) this.pos = self.config['root_type'] self.radio[this.pos].props.active = True model.local_source.set_active(this.pos) if this.pos == 2: this.root = [] + this.last_root _query(None, this.pos) self.radio[0].connect('toggled', self._non_filter_cb, 0, False) self.radio[1].connect('toggled', self._non_filter_cb, 1, True) self.radio[2].connect('toggled', self._filter_cb)
def __init__(self, editor): Palette.__init__(self, _('Pronounce text during tile flip')) self.face = speak.face.View() toolbar = gtk.HBox() toolbar.modify_bg(gtk.STATE_NORMAL, style.COLOR_BLACK.get_gdk_color()) usespeak_play = ToolButton(icon_name='media-playback-start') usespeak_play.connect('clicked', lambda button: self.face.say(editor.get_text())) toolbar.pack_start(usespeak_play, False) self.voices = speak.widgets.Voices(self.face) toolbar.pack_start(ToolComboBox(self.voices)) toolbar.show_all() self.set_content(toolbar)
def _load_toolbar(self): toolbar = gtk.Toolbar() # Remove Feed Palette remove_button = ToolButton(icon_name='list-remove') vbox = gtk.VBox() label = gtk.Label(_('Really delete feed?')) vbox.pack_start(label) hbox = gtk.HBox() expander_label = gtk.Label(' ') hbox.pack_start(expander_label) #b = gtk.Button(icon_name='stock-remove') b = ToolButton(icon_name='list-remove') #b.set_use_stock(True) b.connect('clicked', self._on_remove_feed_activate) hbox.pack_start(b, False) vbox.pack_start(hbox) palette = Palette(_('Remove Feed?')) palette.set_content(vbox) vbox.show_all() remove_button.set_palette(palette) toolbar.insert(remove_button, -1) remove_button.show() # Add Feed Palette button = ToolButton(icon_name='list-add') toolbar.insert(button, -1) button.show() self._add_feed_dialog = AddFeedDialog.AddFeedDialog( gtk.glade.XML(os.path.join(self.glade_prefix, 'penguintv.glade'), "window_add_feed", 'penguintv'), self) #MAGIC content = self._add_feed_dialog.extract_content() content.show_all() #button.connect('clicked', self._add_feed_dialog.show) palette = Palette(_('Subscribe to Feed')) palette.set_content(content) button.set_palette(palette) self._feedlist = gtk.ListStore(int, str, str) self._combo = gtk.ComboBox(self._feedlist) cell = gtk.CellRendererText() self._combo.pack_start(cell, True) self._combo.add_attribute(cell, 'text', 1) self._combo.connect("changed", self._on_combo_select) toolcombo = ToolComboBox(self._combo) toolbar.insert(toolcombo, -1) toolcombo.show_all() toolbar.show() return toolbar
def __init__(self, primary_text): Palette.__init__(self, primary_text) self._level = 0 self._time = 0 self._status = _STATUS_NOT_PRESENT self._progress_bar = gtk.ProgressBar() self._progress_bar.set_size_request( style.zoom(style.GRID_CELL_SIZE * 4), -1) self._progress_bar.show() self._status_label = gtk.Label() self._status_label.show() vbox = gtk.VBox() vbox.pack_start(self._progress_bar) vbox.pack_start(self._status_label) vbox.show() self._progress_widget = vbox self.set_content(self._progress_widget)
def create_palette(self, text, help_cb): p = Palette(text) if help_cb is not None: item = MenuItem(_('Help'), 'action-help') item.connect('activate', help_cb) item.show() p.menu.append(item) self.set_palette(p)
def _add_button(self, icon_name, label, accelerator, zoom_level): if self.get_children(): group = self.get_children()[0] else: group = None button = RadioToolButton(named_icon=icon_name, group=group, accelerator=accelerator) button.connect('clicked', self.__level_clicked_cb, zoom_level) self.add(button) button.show() palette = Palette(glib.markup_escape_text(label)) palette.props.invoker = FrameWidgetInvoker(button) palette.set_group_id('frame') button.set_palette(palette) return button
def __init__(self, buddy): self._buddy = buddy buddy_icon = Icon(icon_name='computer-xo', xo_color=buddy.get_color(), icon_size=gtk.ICON_SIZE_LARGE_TOOLBAR) nick = buddy.get_nick() Palette.__init__(self, None, primary_text=glib.markup_escape_text(nick), icon=buddy_icon) self._invite_menu = None self._active_activity_changed_hid = None self.connect('destroy', self.__destroy_cb) self._buddy.connect('notify::nick', self.__buddy_notify_nick_cb) if buddy.is_owner(): self._add_my_items() else: self._add_buddy_items()
def __init__(self): Palette.__init__(self, _('Tag sidebar')) box = gtk.VBox() self.set_content(box) pos = 2 * [None] pos[0] = gtk.RadioButton(None, _('On the left side')) pos[0].connect('clicked', self._cb, 0) box.pack_start(pos[0]) pos[1] = gtk.RadioButton(pos[0], _('On the right side')) pos[1].connect('clicked', self._cb, 1) box.pack_start(pos[1]) saved_pos = this.config['sidebar_separator'] pos[this.config['sidebar_position']].props.active = True this.workspace.props.position = saved_pos box.show_all()
def __init__(self, activity_info): self._activity_info = activity_info client = gconf.client_get_default() color = XoColor(client.get_string('/desktop/sugar/user/color')) activity_icon = Icon(file=activity_info.get_icon(), xo_color=color, icon_size=gtk.ICON_SIZE_LARGE_TOOLBAR) 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())) menu_item = MenuItem(text_label=_('Start new'), file_name=activity_info.get_icon(), xo_color=xo_color) menu_item.connect('activate', self.__start_activate_cb) self.menu.append(menu_item) menu_item.show()
def __init__(self, label, tag_type, view): Palette.__init__(self, label) box = gtk.VBox() self.set_content(box) def sort_cb(widget, sort): if not widget.props.active: return view.sort = sort model.this['tag_sidebar'][`tag_type`]['cloud_by_size'] = \ (sort == SORT_COUNT) view.update(force=True) alphabet = gtk.RadioButton(None, _('Sort alphabetically')) alphabet.connect('clicked', sort_cb, SORT_ALPHABET) box.pack_start(alphabet) by_size = gtk.RadioButton(alphabet, _('Sort by size')) by_size.connect('clicked', sort_cb, SORT_COUNT) box.pack_start(by_size) separator = gtk.HSeparator() box.pack_start(separator) def reverse_cb(widget): view.reverse = widget.props.active model.this['tag_sidebar'][`tag_type`]['cloud_reverse'] = \ widget.props.active view.update(force=True) reverse = gtk.CheckButton(_('Reverse order')) reverse.connect('clicked', reverse_cb) box.pack_start(reverse) box.show_all() if model.this['tag_sidebar'][ ` tag_type `]['cloud_by_size']: by_size.props.active = True
def __init__(self, primary_text, model): Palette.__init__(self, label=primary_text) self._model = model vbox = gtk.VBox() self.set_content(vbox) vbox.show() vol_step = sound.VOLUME_STEP self._adjustment = gtk.Adjustment(value=self._model.props.level, lower=0, upper=100 + vol_step, step_incr=vol_step, page_incr=vol_step, page_size=vol_step) self._hscale = gtk.HScale(self._adjustment) self._hscale.set_digits(0) self._hscale.set_draw_value(False) vbox.add(self._hscale) self._hscale.show() self._mute_item = MenuItem('') self._mute_icon = Icon(icon_size=gtk.ICON_SIZE_MENU) self._mute_item.set_image(self._mute_icon) self.menu.append(self._mute_item) self._mute_item.show() self._adjustment_handler_id = \ self._adjustment.connect('value_changed', self.__adjustment_changed_cb) self._model_notify_level_handler_id = \ self._model.connect('notify::level', self.__level_changed_cb) self._model.connect('notify::muted', self.__muted_changed_cb) self._mute_item.connect('activate', self.__mute_activate_cb) self.connect('popup', self.__popup_cb)
def __init__(self, browser, title, url, owner_document): Palette.__init__(self) self._browser = browser self._title = title self._url = url self._owner_document = owner_document if title is not None: self.props.primary_text = title self.props.secondary_text = url else: self.props.primary_text = url menu_item = MenuItem(_('Follow link'), 'edit-copy') menu_item.connect('activate', self.__follow_activate_cb) self.menu.append(menu_item) menu_item.show() menu_item = MenuItem(_('Copy')) icon = Icon(icon_name='edit-copy', xo_color=profile.get_color(), icon_size=gtk.ICON_SIZE_MENU) menu_item.set_image(icon) menu_item.connect('activate', self.__copy_activate_cb) self.menu.append(menu_item) menu_item.show() if url.startswith('javascript:'): # only show if the link is a bookmarklet menu_item = MenuItem(_('Save bookmarklet')) menu_item.connect('activate', self.__bookmarklet_activate_cb) self.menu.append(menu_item) menu_item.show() else: # for all other links menu_item = MenuItem(_('Download link')) menu_item.connect('activate', self.__download_activate_cb) self.menu.append(menu_item) menu_item.show()
def __init__(self, title, url, owner_document): Palette.__init__(self) self._title = title self._url = url self._owner_document = owner_document self.props.primary_text = title self.props.secondary_text = url menu_item = MenuItem(_('Copy')) icon = Icon(icon_name='edit-copy', xo_color=profile.get_color(), icon_size=gtk.ICON_SIZE_MENU) menu_item.set_image(icon) menu_item.connect('activate', self.__copy_activate_cb) self.menu.append(menu_item) menu_item.show() menu_item = MenuItem(_('Download image')) menu_item.connect('activate', self.__download_activate_cb) self.menu.append(menu_item) menu_item.show()
def _set_up_documents_button(self): documents_path = model.get_documents_path() if documents_path is not None: button = DocumentsButton(documents_path) button.props.group = self._volume_buttons[0] label = glib.markup_escape_text(_('Documents')) button.set_palette(Palette(label)) button.connect('toggled', self._button_toggled_cb) button.show() position = self.get_item_index(self._volume_buttons[-1]) + 1 self.insert(button, position) self._volume_buttons.append(button) self.show()
def __init__(self, activity_info): self._activity_info = activity_info client = gconf.client_get_default() color = XoColor(client.get_string('/desktop/sugar/user/color')) activity_icon = Icon(file=activity_info.get_icon(), xo_color=color, icon_size=gtk.ICON_SIZE_LARGE_TOOLBAR) 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())) menu_item = MenuItem(text_label=_('Start new'), file_name=activity_info.get_icon(), xo_color=xo_color) menu_item.connect('activate', self.__start_activate_cb) self.menu.append(menu_item) menu_item.show()
def __init__(self, cb_object): Palette.__init__(self, text_maxlen=100) self._cb_object = cb_object self.set_group_id('frame') cb_service = clipboard.get_instance() cb_service.connect('object-state-changed', self._object_state_changed_cb) self._progress_bar = None self._remove_item = MenuItem(pgettext('Clipboard', 'Remove'), 'list-remove') self._remove_item.connect('activate', self._remove_item_activate_cb) self.menu.append(self._remove_item) self._remove_item.show() self._open_item = MenuItem(_('Open'), 'zoom-activity') self._open_item.connect('activate', self._open_item_activate_cb) self.menu.append(self._open_item) self._open_item.show() self._journal_item = MenuItem(_('Keep')) client = gconf.client_get_default() color = XoColor(client.get_string('/desktop/sugar/user/color')) icon = Icon(icon_name='document-save', icon_size=gtk.ICON_SIZE_MENU, xo_color=color) self._journal_item.set_image(icon) self._journal_item.connect('activate', self._journal_item_activate_cb) self.menu.append(self._journal_item) self._journal_item.show() self._update()
def __init__(self, recd): super(RecdButton, self).__init__() self._recd = recd self.set_icon_widget(self.get_image()) self._copy_menu_item_handler = None palette = Palette(recd.title) self.set_palette(palette) self._rem_menu_item = gtk.MenuItem(_('Remove')) self._rem_menu_item_handler = self._rem_menu_item.connect( 'activate', self._remove_clicked) palette.menu.append(self._rem_menu_item) self._rem_menu_item.show() self._add_copy_menu_item()
def _load_toolbar(self): toolbar = gtk.Toolbar() # Remove Feed Palette remove_button = ToolButton(icon_name='list-remove') vbox = gtk.VBox() label = gtk.Label(_('Really delete feed?')) vbox.pack_start(label) hbox = gtk.HBox() expander_label = gtk.Label(' ') hbox.pack_start(expander_label) #b = gtk.Button(icon_name='stock-remove') b = ToolButton(icon_name='list-remove') #b.set_use_stock(True) b.connect('clicked', self._on_remove_feed_activate) hbox.pack_start(b, False) vbox.pack_start(hbox) palette = Palette(_('Remove Feed?')) palette.set_content(vbox) vbox.show_all() remove_button.set_palette(palette) toolbar.insert(remove_button, -1) remove_button.show() # Add Feed Palette button = ToolButton(icon_name='list-add') toolbar.insert(button, -1) button.show() self._add_feed_dialog = AddFeedDialog.AddFeedDialog(gtk.glade.XML(os.path.join(self.glade_prefix, 'penguintv.glade'), "window_add_feed",'penguintv'), self) #MAGIC content = self._add_feed_dialog.extract_content() content.show_all() #button.connect('clicked', self._add_feed_dialog.show) palette = Palette(_('Subscribe to Feed')) palette.set_content(content) button.set_palette(palette) self._feedlist = gtk.ListStore(int, str, str) self._combo = gtk.ComboBox(self._feedlist) cell = gtk.CellRendererText() self._combo.pack_start(cell, True) self._combo.add_attribute(cell, 'text', 1) self._combo.connect("changed", self._on_combo_select) toolcombo = ToolComboBox(self._combo) toolbar.insert(toolcombo, -1) toolcombo.show_all() toolbar.show() return toolbar
def setup_rollover_options(self): palette = Palette(Constants.istrSavedMap) self.set_palette(palette) self.tag_menu_item = gtk.MenuItem(Constants.istrTagMap) self.ACTIVATE_TAG_ID = self.tag_menu_item.connect( 'activate', self._tagCb) palette.menu.append(self.tag_menu_item) self.tag_menu_item.show() self.rem_menu_item = gtk.MenuItem(Constants.istrRemove) self.ACTIVATE_REMOVE_ID = self.rem_menu_item.connect( 'activate', self._itemRemoveCb) palette.menu.append(self.rem_menu_item) self.rem_menu_item.show() self.copy_menu_item = gtk.MenuItem(Constants.istrCopyToClipboard) self.ACTIVATE_COPY_ID = self.copy_menu_item.connect( 'activate', self._itemCopyToClipboardCb) self.get_palette().menu.append(self.copy_menu_item) self.copy_menu_item.show()
def __init__( self, label, mini ): Palette.__init__( self, label ) self.connect('popup', self.handlePopup) self.connect('popdown', self.handlePopdown) self.mini = mini self.tooltips = gtk.Tooltips() self.loopedSound = False self.soundLength = 1.00 self.start = 0 self.end = 1.00 self.dur = 0.01 self.volume = 1 self.register = 0 self.ok = True self.mainBox = gtk.VBox() self.controlsBox = gtk.HBox() self.GUI = {} self.soundBox = gtk.HBox() self.soundLabel = gtk.Label(_('Sound: ')) self.soundMenuBox = BigComboBox() self.sounds = os.listdir(Config.DATA_DIR) for sound in self.sounds: self.soundMenuBox.append_item(self.sounds.index(sound), sound) self.soundMenuBox.connect('changed', self.handleSound) self.soundBox.pack_start(self.soundLabel, False, False, padding=10) self.soundBox.pack_start(self.soundMenuBox, False, False, padding=10) self.mainBox.pack_start(self.soundBox, False, False, 10) nameBox = gtk.VBox() self.nameEntry = gtk.Entry() entrycolor = gtk.gdk.Color() self.nameEntry.modify_text(gtk.STATE_NORMAL, entrycolor) self.nameEntry.set_text("name_of_the_sound") nameBox.pack_start(self.nameEntry) self.mainBox.pack_start(nameBox, False, False, 10) registerBox = gtk.HBox() self.registerBoxLabel = gtk.Label(_('Register: ')) self.registerMenuBox = BigComboBox() self.registers = ['LOW', 'MID', 'HIGH', 'PUNCH'] for reg in self.registers: self.registerMenuBox.append_item(self.registers.index(reg), reg) self.registerMenuBox.connect('changed', self.handleRegister) registerBox.pack_start(self.registerBoxLabel, False, False, padding=10) registerBox.pack_end(self.registerMenuBox, False, False, padding=10) self.mainBox.pack_start(registerBox, False, False, 10) loopedBox = gtk.HBox() loopedLabel = gtk.Label("Looped sound: ") loopedToggle = ImageToggleButton('checkOff.png', 'checkOn.png') loopedToggle.connect('button-press-event', self.handleLooped ) loopedBox.pack_start(loopedLabel, False, False, padding=10) loopedBox.pack_end(loopedToggle, False, False, padding=10) self.mainBox.pack_start(loopedBox, False, False, 10) startBox = gtk.VBox() self.startAdjust = gtk.Adjustment( 0.01, 0, 1., .001, .001, 0) self.GUI['startSlider'] = gtk.VScale( adjustment = self.startAdjust ) self.startAdjust.connect("value-changed", self.handleStart) self.GUI['startSlider'].set_inverted(True) self.GUI['startSlider'].set_size_request(50, 200) self.GUI['startSlider'].set_digits(3) self.handleStart( self.startAdjust ) startBox.pack_start(self.GUI['startSlider'], True, True, 5) self.controlsBox.pack_start(startBox) endBox = gtk.VBox() self.endAdjust = gtk.Adjustment( 0.9, 0, 1, .001, .001, 0) self.GUI['endSlider'] = gtk.VScale( adjustment = self.endAdjust ) self.endAdjust.connect("value-changed", self.handleEnd) self.GUI['endSlider'].set_inverted(True) self.GUI['endSlider'].set_size_request(50, 200) self.GUI['endSlider'].set_digits(3) self.handleEnd( self.endAdjust ) endBox.pack_start(self.GUI['endSlider'], True, True, 5) self.controlsBox.pack_start(endBox) durBox = gtk.VBox() self.durAdjust = gtk.Adjustment( 0.01, 0, 0.2, .001, .001, 0) self.GUI['durSlider'] = gtk.VScale( adjustment = self.durAdjust ) self.durAdjust.connect("value-changed", self.handleDur) self.GUI['durSlider'].set_inverted(True) self.GUI['durSlider'].set_size_request(50, 200) self.GUI['durSlider'].set_digits(3) self.handleDur( self.durAdjust ) durBox.pack_start(self.GUI['durSlider'], True, True, 5) self.controlsBox.pack_start(durBox) volBox = gtk.VBox() self.volAdjust = gtk.Adjustment( 1, 0, 2, .01, .01, 0) self.GUI['volSlider'] = gtk.VScale( adjustment = self.volAdjust ) self.volAdjust.connect("value-changed", self.handleVol) self.GUI['volSlider'].set_inverted(True) self.GUI['volSlider'].set_size_request(50, 200) self.GUI['volSlider'].set_digits(3) self.handleVol( self.volAdjust ) volBox.pack_start(self.GUI['volSlider'], True, True, 5) self.controlsBox.pack_start(volBox) self.mainBox.pack_start(self.controlsBox, False, False, 10) previewBox = gtk.VBox() self.playStopButton = ImageToggleButton('miniplay.png', 'stop.png') self.playStopButton.connect('button-press-event' , self.handlePlayButton) previewBox.pack_start(self.playStopButton) self.mainBox.pack_start(previewBox, False, False, 10) checkBox = gtk.VBox() checkButton = ImageButton(Config.TAM_TAM_ROOT + '/icons/accept.svg') checkButton.connect('clicked' , self.handleCheck) checkBox.pack_start(checkButton) self.mainBox.pack_start(checkBox, False, False, 10) self.mainBox.show_all() self.set_content(self.mainBox)
def set_tooltip(self, text): self.set_palette(Palette(text))
def __init__(self, label, jam): Palette.__init__(self, label) self.connect('popup', self.handlePopup) self.connect('popdown', self.handlePopdown) self.jam = jam self.tooltips = gtk.Tooltips() self.loopedSound = False self.soundLength = 1.00 self.start = 0 self.end = 1.00 self.dur = 0.01 self.volume = 1 self.register = 0 self.ok = True self.mainBox = gtk.VBox() self.controlsBox = gtk.HBox() self.GUI = {} self.soundBox = gtk.HBox() self.soundLabel = gtk.Label(_('Sound: ')) self.soundMenuBox = BigComboBox() self.sounds = [snd for snd in os.listdir(Config.DATA_DIR) \ if snd != 'snds_info'] for sound in self.sounds: self.soundMenuBox.append_item(self.sounds.index(sound), sound) self.soundMenuBox.connect('changed', self.handleSound) self.soundBox.pack_start(self.soundLabel, False, False, padding=10) self.soundBox.pack_start(self.soundMenuBox, False, False, padding=10) self.mainBox.pack_start(self.soundBox, False, False, 10) nameBox = gtk.VBox() self.nameEntry = gtk.Entry() entrycolor = gtk.gdk.Color() self.nameEntry.modify_text(gtk.STATE_NORMAL, entrycolor) self.nameEntry.set_text("name_of_the_sound") nameBox.pack_start(self.nameEntry) self.mainBox.pack_start(nameBox, False, False, 10) registerBox = gtk.HBox() self.registerBoxLabel = gtk.Label(_('Register: ')) self.registerMenuBox = BigComboBox() self.registers = ['LOW', 'MID', 'HIGH', 'PUNCH'] for reg in self.registers: self.registerMenuBox.append_item(self.registers.index(reg), reg) self.registerMenuBox.connect('changed', self.handleRegister) registerBox.pack_start(self.registerBoxLabel, False, False, padding=10) registerBox.pack_end(self.registerMenuBox, False, False, padding=10) self.mainBox.pack_start(registerBox, False, False, 10) loopedBox = gtk.HBox() loopedLabel = gtk.Label("Looped sound: ") loopedToggle = ImageToggleButton('checkOff.png', 'checkOn.png') loopedToggle.connect('button-press-event', self.handleLooped) loopedBox.pack_start(loopedLabel, False, False, padding=10) loopedBox.pack_end(loopedToggle, False, False, padding=10) self.mainBox.pack_start(loopedBox, False, False, 10) startBox = gtk.VBox() self.startAdjust = gtk.Adjustment(0.01, 0, 1., .001, .001, 0) self.GUI['startSlider'] = gtk.VScale(adjustment=self.startAdjust) self.startAdjust.connect("value-changed", self.handleStart) self.GUI['startSlider'].set_inverted(True) self.GUI['startSlider'].set_size_request(50, 200) self.GUI['startSlider'].set_digits(3) # tooltip closes loop settings palette!!! #self._add_tooltip(self.GUI['startSlider'], _("Loop start position")) self.handleStart(self.startAdjust) startBox.pack_start(self.GUI['startSlider'], True, True, 5) self.controlsBox.pack_start(startBox) endBox = gtk.VBox() self.endAdjust = gtk.Adjustment(0.9, 0, 1, .001, .001, 0) self.GUI['endSlider'] = gtk.VScale(adjustment=self.endAdjust) self.endAdjust.connect("value-changed", self.handleEnd) self.GUI['endSlider'].set_inverted(True) self.GUI['endSlider'].set_size_request(50, 200) self.GUI['endSlider'].set_digits(3) self.handleEnd(self.endAdjust) endBox.pack_start(self.GUI['endSlider'], True, True, 5) self.controlsBox.pack_start(endBox) durBox = gtk.VBox() self.durAdjust = gtk.Adjustment(0.01, 0, 0.2, .001, .001, 0) self.GUI['durSlider'] = gtk.VScale(adjustment=self.durAdjust) self.durAdjust.connect("value-changed", self.handleDur) self.GUI['durSlider'].set_inverted(True) self.GUI['durSlider'].set_size_request(50, 200) self.GUI['durSlider'].set_digits(3) self.handleDur(self.durAdjust) durBox.pack_start(self.GUI['durSlider'], True, True, 5) self.controlsBox.pack_start(durBox) volBox = gtk.VBox() self.volAdjust = gtk.Adjustment(1, 0, 2, .01, .01, 0) self.GUI['volSlider'] = gtk.VScale(adjustment=self.volAdjust) self.volAdjust.connect("value-changed", self.handleVol) self.GUI['volSlider'].set_inverted(True) self.GUI['volSlider'].set_size_request(50, 200) self.GUI['volSlider'].set_digits(3) self.handleVol(self.volAdjust) volBox.pack_start(self.GUI['volSlider'], True, True, 5) self.controlsBox.pack_start(volBox) self.mainBox.pack_start(self.controlsBox, False, False, 10) previewBox = gtk.VBox() self.playStopButton = ImageToggleButton('miniplay.png', 'stop.png') self.playStopButton.connect('button-press-event', self.handlePlayButton) previewBox.pack_start(self.playStopButton) self.mainBox.pack_start(previewBox, False, False, 10) checkBox = gtk.VBox() checkButton = ImageButton(Config.TAM_TAM_ROOT + '/icons/accept.svg') checkButton.connect('clicked', self.handleCheck) checkBox.pack_start(checkButton) self.mainBox.pack_start(checkBox, False, False, 10) self.mainBox.show_all() self.set_content(self.mainBox)
def __init__(self, tag): tag_icon = Icon(file='icons/'+tag.icon+'.svg', xo_color=profile.get_color(), icon_size=gtk.ICON_SIZE_SMALL_TOOLBAR) Palette.__init__(self, primary_text=tag.label, icon=tag_icon) self._tag = tag
def set_tooltip(self, text): from sugar.graphics.palette import Palette self.set_palette(Palette(text))
def __init__(self, **kwargs): Palette.__init__(self, **kwargs) self.button_box = gtk.HBox() self.button_box.show() self.set_content(self.button_box)
""" Test the style of toggle and radio buttons inside a palette. The buttons contains only an icon and should be rendered similarly to the toolbar controls. Ticket #2855. """ import gtk from sugar.graphics.palette import Palette from sugar.graphics.icon import Icon import common test = common.TestPalette() palette = Palette('Test radio and toggle') test.set_palette(palette) box = gtk.HBox() toggle = gtk.ToggleButton() icon = Icon(icon_name='go-previous', icon_size=gtk.ICON_SIZE_LARGE_TOOLBAR) toggle.set_image(icon) box.pack_start(toggle, False) toggle.show() radio = gtk.RadioButton() icon = Icon(icon_name='go-next', icon_size=gtk.ICON_SIZE_LARGE_TOOLBAR)
class ToolButton(gtk.ToolButton): __gtype_name__ = 'SugarToolButton' def __init__(self, icon_name=None, **kwargs): self._accelerator = None self._tooltip = None self._palette_invoker = ToolInvoker() gobject.GObject.__init__(self, **kwargs) self._palette_invoker.attach_tool(self) if icon_name: self.set_icon(icon_name) self.get_child().connect('can-activate-accel', self.__button_can_activate_accel_cb) self.connect('destroy', self.__destroy_cb) def __destroy_cb(self, icon): if self._palette_invoker is not None: self._palette_invoker.detach() def __button_can_activate_accel_cb(self, button, signal_id): # Accept activation via accelerators regardless of this widget's state return True def set_tooltip(self, tooltip): """ Set a simple palette with just a single label. """ if self.palette is None or self._tooltip is None: self.palette = Palette(tooltip) elif self.palette is not None: self.palette.set_primary_text(tooltip) self._tooltip = tooltip # Set label, shows up when toolbar overflows gtk.ToolButton.set_label(self, tooltip) def get_tooltip(self): return self._tooltip tooltip = gobject.property(type=str, setter=set_tooltip, getter=get_tooltip) def set_accelerator(self, accelerator): self._accelerator = accelerator setup_accelerator(self) def get_accelerator(self): return self._accelerator accelerator = gobject.property(type=str, setter=set_accelerator, getter=get_accelerator) def set_icon(self, icon_name): icon = Icon(icon_name=icon_name) self.set_icon_widget(icon) icon.show() icon_name = gobject.property(type=str, setter=set_icon) def create_palette(self): return None def get_palette(self): return self._palette_invoker.palette def set_palette(self, palette): self._palette_invoker.palette = palette palette = gobject.property( type=object, setter=set_palette, getter=get_palette) def get_palette_invoker(self): return self._palette_invoker def set_palette_invoker(self, palette_invoker): self._palette_invoker.detach() self._palette_invoker = palette_invoker palette_invoker = gobject.property( type=object, setter=set_palette_invoker, getter=get_palette_invoker) def do_expose_event(self, event): child = self.get_child() allocation = self.get_allocation() if self.palette and self.palette.is_up(): invoker = self.palette.props.invoker invoker.draw_rectangle(event, self.palette) elif child.state == gtk.STATE_PRELIGHT: child.style.paint_box(event.window, gtk.STATE_PRELIGHT, gtk.SHADOW_NONE, event.area, child, 'toolbutton-prelight', allocation.x, allocation.y, allocation.width, allocation.height) gtk.ToolButton.do_expose_event(self, event) def do_clicked(self): if self.palette: self.palette.popdown(True)
class RadioToolButton(gtk.RadioToolButton): """ An implementation of a "push" button. """ __gtype_name__ = 'SugarRadioToolButton' def __init__(self, **kwargs): self._accelerator = None self._tooltip = None self._xo_color = None self._palette_invoker = ToolInvoker() gobject.GObject.__init__(self, **kwargs) self._palette_invoker.attach_tool(self) self.connect('destroy', self.__destroy_cb) def __destroy_cb(self, icon): if self._palette_invoker is not None: self._palette_invoker.detach() def set_tooltip(self, tooltip): """ Set a simple palette with just a single label. Parameters ---------- tooltip: Returns ------- None """ if self.palette is None or self._tooltip is None: self.palette = Palette(tooltip) elif self.palette is not None: self.palette.set_primary_text(tooltip) self._tooltip = tooltip # Set label, shows up when toolbar overflows gtk.RadioToolButton.set_label(self, tooltip) def get_tooltip(self): return self._tooltip tooltip = gobject.property(type=str, setter=set_tooltip, getter=get_tooltip) def set_accelerator(self, accelerator): """ Sets the accelerator. Parameters ---------- accelerator: Returns ------- None """ self._accelerator = accelerator toolbutton.setup_accelerator(self) def get_accelerator(self): """ Returns the accelerator for the button. Parameters ---------- None Returns ------ accelerator: """ return self._accelerator accelerator = gobject.property(type=str, setter=set_accelerator, getter=get_accelerator) def set_named_icon(self, named_icon): icon = Icon(icon_name=named_icon, xo_color=self._xo_color, icon_size=gtk.ICON_SIZE_LARGE_TOOLBAR) self.set_icon_widget(icon) icon.show() def get_named_icon(self): if self.props.icon_widget is not None: return self.props.icon_widget.props.icon_name else: return None named_icon = gobject.property(type=str, setter=set_named_icon, getter=get_named_icon) def set_xo_color(self, xo_color): if self._xo_color != xo_color: self._xo_color = xo_color if self.props.icon_widget is not None: self.props.icon_widget.props.xo_color = xo_color def get_xo_color(self): return self._xo_color xo_color = gobject.property(type=object, setter=set_xo_color, getter=get_xo_color) def create_palette(self): return None def get_palette(self): return self._palette_invoker.palette def set_palette(self, palette): self._palette_invoker.palette = palette palette = gobject.property(type=object, setter=set_palette, getter=get_palette) def get_palette_invoker(self): return self._palette_invoker def set_palette_invoker(self, palette_invoker): self._palette_invoker.detach() self._palette_invoker = palette_invoker palette_invoker = gobject.property(type=object, setter=set_palette_invoker, getter=get_palette_invoker) def do_expose_event(self, event): child = self.get_child() allocation = self.get_allocation() if self.palette and self.palette.is_up(): invoker = self.palette.props.invoker invoker.draw_rectangle(event, self.palette) elif child.state == gtk.STATE_PRELIGHT: child.style.paint_box(event.window, gtk.STATE_PRELIGHT, gtk.SHADOW_NONE, event.area, child, 'toolbutton-prelight', allocation.x, allocation.y, allocation.width, allocation.height) gtk.RadioToolButton.do_expose_event(self, event) def do_clicked(self): if self.palette: self.palette.popdown(True)
class RadioToolButton(gtk.RadioToolButton): """ An implementation of a "push" button. """ __gtype_name__ = 'SugarRadioToolButton' def __init__(self, **kwargs): self._accelerator = None self._tooltip = None self._xo_color = None self._palette_invoker = ToolInvoker() gobject.GObject.__init__(self, **kwargs) self._palette_invoker.attach_tool(self) self.connect('destroy', self.__destroy_cb) def __destroy_cb(self, icon): if self._palette_invoker is not None: self._palette_invoker.detach() def set_tooltip(self, tooltip): """ Set a simple palette with just a single label. Parameters ---------- tooltip: Returns ------- None """ if self.palette is None or self._tooltip is None: self.palette = Palette(tooltip) elif self.palette is not None: self.palette.set_primary_text(tooltip) self._tooltip = tooltip # Set label, shows up when toolbar overflows gtk.RadioToolButton.set_label(self, tooltip) def get_tooltip(self): return self._tooltip tooltip = gobject.property(type=str, setter=set_tooltip, getter=get_tooltip) def set_accelerator(self, accelerator): """ Sets the accelerator. Parameters ---------- accelerator: Returns ------- None """ self._accelerator = accelerator toolbutton.setup_accelerator(self) def get_accelerator(self): """ Returns the accelerator for the button. Parameters ---------- None Returns ------ accelerator: """ return self._accelerator accelerator = gobject.property(type=str, setter=set_accelerator, getter=get_accelerator) def set_named_icon(self, named_icon): icon = Icon(icon_name=named_icon, xo_color=self._xo_color, icon_size=gtk.ICON_SIZE_LARGE_TOOLBAR) self.set_icon_widget(icon) icon.show() def get_named_icon(self): if self.props.icon_widget is not None: return self.props.icon_widget.props.icon_name else: return None named_icon = gobject.property(type=str, setter=set_named_icon, getter=get_named_icon) def set_xo_color(self, xo_color): if self._xo_color != xo_color: self._xo_color = xo_color if self.props.icon_widget is not None: self.props.icon_widget.props.xo_color = xo_color def get_xo_color(self): return self._xo_color xo_color = gobject.property(type=object, setter=set_xo_color, getter=get_xo_color) def create_palette(self): return None def get_palette(self): return self._palette_invoker.palette def set_palette(self, palette): self._palette_invoker.palette = palette palette = gobject.property( type=object, setter=set_palette, getter=get_palette) def get_palette_invoker(self): return self._palette_invoker def set_palette_invoker(self, palette_invoker): self._palette_invoker.detach() self._palette_invoker = palette_invoker palette_invoker = gobject.property( type=object, setter=set_palette_invoker, getter=get_palette_invoker) def do_expose_event(self, event): child = self.get_child() allocation = self.get_allocation() if self.palette and self.palette.is_up(): invoker = self.palette.props.invoker invoker.draw_rectangle(event, self.palette) elif child.state == gtk.STATE_PRELIGHT: child.style.paint_box(event.window, gtk.STATE_PRELIGHT, gtk.SHADOW_NONE, event.area, child, "toolbutton-prelight", allocation.x, allocation.y, allocation.width, allocation.height) gtk.RadioToolButton.do_expose_event(self, event)
def __init__(self, metadata, detail=False): self._metadata = metadata activity_icon = Icon(icon_size=gtk.ICON_SIZE_LARGE_TOOLBAR) activity_icon.props.file = misc.get_icon_name(metadata) color = misc.get_icon_color(metadata) activity_icon.props.xo_color = color if 'title' in metadata: title = gobject.markup_escape_text(metadata['title']) else: title = glib.markup_escape_text(_('Untitled')) Palette.__init__(self, primary_text=title, icon=activity_icon) if misc.get_activities(metadata) or misc.is_bundle(metadata): if metadata.get('activity_id', ''): resume_label = _('Resume') resume_with_label = _('Resume with') else: resume_label = _('Start') resume_with_label = _('Start with') menu_item = MenuItem(resume_label, 'activity-start') menu_item.connect('activate', self.__start_activate_cb) self.menu.append(menu_item) menu_item.show() menu_item = MenuItem(resume_with_label, 'activity-start') self.menu.append(menu_item) menu_item.show() start_with_menu = StartWithMenu(self._metadata) menu_item.set_submenu(start_with_menu) else: menu_item = MenuItem(_('No activity to start entry')) menu_item.set_sensitive(False) self.menu.append(menu_item) menu_item.show() menu_item = MenuItem(_('Copy to')) icon = Icon(icon_name='edit-copy', xo_color=color, icon_size=gtk.ICON_SIZE_MENU) menu_item.set_image(icon) self.menu.append(menu_item) menu_item.show() copy_menu = CopyMenu(metadata) copy_menu.connect('volume-error', self.__volume_error_cb) menu_item.set_submenu(copy_menu) if self._metadata['mountpoint'] == '/': menu_item = MenuItem(_('Duplicate')) icon = Icon(icon_name='edit-duplicate', xo_color=color, icon_size=gtk.ICON_SIZE_MENU) menu_item.set_image(icon) menu_item.connect('activate', self.__duplicate_activate_cb) self.menu.append(menu_item) menu_item.show() menu_item = MenuItem(_('Send to'), 'document-send') self.menu.append(menu_item) menu_item.show() friends_menu = FriendsMenu() friends_menu.connect('friend-selected', self.__friend_selected_cb) menu_item.set_submenu(friends_menu) if detail == True: menu_item = MenuItem(_('View Details'), 'go-right') menu_item.connect('activate', self.__detail_activate_cb) self.menu.append(menu_item) menu_item.show() menu_item = MenuItem(_('Erase'), 'list-remove') menu_item.connect('activate', self.__erase_activate_cb) self.menu.append(menu_item) menu_item.show()