def __init__(self, activity): gtk.Toolbar.__init__(self) voicebar = gtk.Toolbar() self._activity = activity if not speech.supported: return self.load_speech_parameters() self.sorted_voices = [i for i in speech.voices()] self.sorted_voices.sort(self.compare_voices) default = 0 for voice in self.sorted_voices: if voice[0] == speech.voice[0]: break default = default + 1 # Play button self.play_btn = ToggleToolButton('media-playback-start') self.play_btn.show() self.play_btn.connect('toggled', self.play_cb) self.insert(self.play_btn, -1) self.play_btn.set_tooltip(_('Play / Pause')) self.voice_combo = ComboBox() for voice in self.sorted_voices: self.voice_combo.append_item(voice, voice[0]) self.voice_combo.set_active(default) self.voice_combo.connect('changed', self.voice_changed_cb) combotool = ToolComboBox(self.voice_combo) self.insert(combotool, -1) combotool.show() self.pitchadj = gtk.Adjustment(0, -100, 100, 1, 10, 0) pitchbar = gtk.HScale(self.pitchadj) pitchbar.set_draw_value(False) pitchbar.set_update_policy(gtk.UPDATE_DISCONTINUOUS) pitchbar.set_size_request(150, 15) self.pitchadj.set_value(speech.pitch) pitchtool = gtk.ToolItem() pitchtool.add(pitchbar) pitchtool.show() self.insert(pitchtool, -1) pitchbar.show() self.rateadj = gtk.Adjustment(0, -100, 100, 1, 10, 0) ratebar = gtk.HScale(self.rateadj) ratebar.set_draw_value(False) ratebar.set_update_policy(gtk.UPDATE_DISCONTINUOUS) ratebar.set_size_request(150, 15) self.rateadj.set_value(speech.rate) ratetool = gtk.ToolItem() ratetool.add(ratebar) ratetool.show() self.insert(ratetool, -1) ratebar.show() self.pitchadj.connect("value_changed", self.pitch_adjusted_cb) self.rateadj.connect("value_changed", self.rate_adjusted_cb)
def get_tool_item(self): self.toolitem = ToggleToolButton() self.toolitem.set_named_icon( stock.icons[self._stock_id] if self._stock_id in stock.icons else self._stock_id) self.toolitem.set_active(self.default_value) self.toolitem.connect('toggled', self.toggled_cb) self.setup_tooltip() return self.toolitem
def __init__(self): gtk.Toolbar.__init__(self) self._mount_point = None self._search_entry = iconentry.IconEntry() self._search_entry.set_icon_from_name(iconentry.ICON_ENTRY_PRIMARY, 'system-search') self._search_entry.connect('activate', self._search_entry_activated_cb) self._search_entry.connect('changed', self._search_entry_changed_cb) self._search_entry.add_clear_button() self._autosearch_timer = None self._add_widget(self._search_entry, expand=True) self._favorite_button = ToggleToolButton('emblem-favorite') self._favorite_button.connect('toggled', self.__favorite_button_toggled_cb) self.insert(self._favorite_button, -1) self._favorite_button.show() self._what_search_combo = ComboBox() self._what_combo_changed_sid = self._what_search_combo.connect( 'changed', self._combo_changed_cb) tool_item = ToolComboBox(self._what_search_combo) self.insert(tool_item, -1) tool_item.show() self._when_search_combo = self._get_when_search_combo() tool_item = ToolComboBox(self._when_search_combo) self.insert(tool_item, -1) tool_item.show() self._sorting_button = SortingButton() self._sorting_button.connect('clicked', self.__sorting_button_clicked_cb) self.insert(self._sorting_button, -1) self._sorting_button.connect('sort-property-changed', self.__sort_changed_cb) self._sorting_button.show() # TODO: enable it when the DS supports saving the buddies. #self._with_search_combo = self._get_with_search_combo() #tool_item = ToolComboBox(self._with_search_combo) #self.insert(tool_item, -1) #tool_item.show() self._query = self._build_query() self.refresh_filters()
def __init__(self, jam): gtk.Toolbar.__init__(self) def _insertSeparator(x=1): for i in range(x): self.separator = gtk.SeparatorToolItem() self.separator.set_draw(True) self.insert(self.separator, -1) self.separator.show() #self.toolbox = toolbox self.jam = jam if Config.FEATURES_MIC: self.micRec1Button = ToolButton('rec1') self.micRec1Button.connect('clicked', self.jam.micRec, 'mic1') self.insert(self.micRec1Button, -1) self.micRec1Button.show() self.micRec1Button.set_tooltip(_('Record microphone into slot 1')) self.micRec2Button = ToolButton('rec2') self.micRec2Button.connect('clicked', self.jam.micRec, 'mic2') self.insert(self.micRec2Button, -1) self.micRec2Button.show() self.micRec2Button.set_tooltip(_('Record microphone into slot 2')) self.micRec3Button = ToolButton('rec3') self.micRec3Button.connect('clicked', self.jam.micRec, 'mic3') self.insert(self.micRec3Button, -1) self.micRec3Button.show() self.micRec3Button.set_tooltip(_('Record microphone into slot 3')) self.micRec4Button = ToolButton('rec4') self.micRec4Button.connect('clicked', self.jam.micRec, 'mic4') self.insert(self.micRec4Button, -1) self.micRec4Button.show() self.micRec4Button.set_tooltip(('Record microphone into slot 4')) _insertSeparator() if Config.FEATURES_NEWSOUNDS: self._loopSettingsPalette = LoopSettingsPalette( _('Add new Sound'), self.jam) self.loopSetButton = ToggleToolButton('loop') self.loopSetButton.set_palette(self._loopSettingsPalette) self.insert(self.loopSetButton, -1) self.loopSetButton.show() self.show_all()
def __init__(self, handle): self.notebook = gtk.Notebook() SharedActivity.__init__(self, self.notebook, SERVICE, handle) self.notebook.show() self.notebook.props.show_border = False self.notebook.props.show_tabs = False self.montage = montage.View() self.notebook.append_page(self.montage) self.lessons = lessons.View() self.lessons.show() self.notebook.append_page(self.lessons) toolbox = ToolbarBox() toolbox.show() toolbox.toolbar.insert(ActivityToolbarButton(self), -1) separator = gtk.SeparatorToolItem() separator.set_draw(False) toolbox.toolbar.insert(separator, -1) lessons_button = ToggleToolButton('mamamedia') lessons_button.connect('toggled', self.__toggled_lessons_button_cb) lessons_button.set_tooltip(_('Lessons')) toolbox.toolbar.insert(lessons_button, -1) separator = gtk.SeparatorToolItem() separator.set_draw(False) toolbox.toolbar.insert(separator, -1) self.notebook_toolbar = gtk.Notebook() self.notebook_toolbar.props.show_border = False self.notebook_toolbar.props.show_tabs = False self.notebook_toolbar.append_page(self._create_montage_toolbar()) self.notebook_toolbar.append_page(self._create_lessons_toolbar()) self.notebook_toolbar.show() notebook_item = gtk.ToolItem() notebook_item.set_expand(True) notebook_item.add(self.notebook_toolbar) notebook_item.show() toolbox.toolbar.insert(notebook_item, -1) toolbox.toolbar.insert(StopButton(self), -1) toolbox.show_all() self.toolbar_box = toolbox
def __init__(self, edit, toolbar): self.edit = edit self.txt_toggle = ToggleToolButton('ascii') self.img_toggle = ToggleToolButton('image') self.txt_toggle.set_tooltip(_('Text')) self.txt_toggle.connect('toggled', self._toggle_cb, [self.txt_toggle, self.img_toggle]) toolbar.insert(self.txt_toggle, -1) self.img_toggle.set_tooltip(_('Images')) self.img_toggle.connect('toggled', self._toggle_cb, [self.txt_toggle, self.img_toggle]) toolbar.insert(self.img_toggle, -1) self.separator = gtk.SeparatorToolItem() toolbar.insert(self.separator, -1) for tab in TABS: for i in tab.toolitems: toolbar.insert(i, -1) self.txt_toggle.set_active(True)
def common_playback_buttons(toolbar, owner): """ Playback and mute buttons are either on the main toolbar or the Playback toolbar, depending upon whether or not the new toolbars are available. """ toolbar.stopButton = ToolButton('media-playback-stop') toolbar.stopButton.connect('clicked', owner.handleStopButton) toolbar.insert(toolbar.stopButton, -1) toolbar.stopButton.show() toolbar.stopButton.set_tooltip(_('Stop Loops')) toolbar.muteButton = ToggleToolButton('mute') toolbar.muteButton.connect('clicked', owner.handleMuteButton) toolbar.insert(toolbar.muteButton, -1) toolbar.muteButton.show() toolbar.muteButton.set_tooltip(_('Mute Loops'))
def _button_factory(name='', toolbar=None, cb=None, arg=None, tooltip=None, toggle=True): ''' Add a toggle button to a toolbar ''' if toggle: button = ToggleToolButton(name) else: button = ToolButton(name) if cb is not None: if arg is None: button.connect('clicked', cb) else: button.connect('clicked', cb, arg) if toolbar is not None: toolbar.insert(button, -1) button.show() if tooltip is not None: button.set_tooltip(tooltip) return button
def _create_montage_toolbar(self): toolbar = gtk.Toolbar() playButtonImg = gtk.Image() playButtonImg.show() playButtonImg.set_from_icon_name('media-playback-start', gtk.ICON_SIZE_LARGE_TOOLBAR) pauseButtonImg = gtk.Image() pauseButtonImg.show() pauseButtonImg.set_from_icon_name('media-playback-pause', gtk.ICON_SIZE_LARGE_TOOLBAR) self.playButton = ToggleToolButton('media-playback-start') self.playButton.connect('toggled', self.__play_cb, playButtonImg, pauseButtonImg) toolbar.insert(self.playButton, -1) self.playButton.set_tooltip(_('Play / Pause')) tempo = TempoSlider(0, 10) tempo.adjustment.connect("value-changed", self.__tempo_cb) tempo.set_size_request(250, -1) tempo.set_value(5) tempo_item = gtk.ToolItem() tempo_item.add(tempo) toolbar.insert(tempo_item, -1) separator = gtk.SeparatorToolItem() toolbar.insert(separator, -1) clear_tape = ToolButton('sl-reset') clear_tape.connect('clicked', self.__clear_tape_cb) clear_tape.set_tooltip(_('Reset')) toolbar.insert(clear_tape, -1) toolbar.show_all() return toolbar
def __init__(self, handle): activity.Activity.__init__(self, handle, True) self.max_participants = 1 # CANVAS scroll = gtk.ScrolledWindow() scroll.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) self.notes_area = NotesArea() scroll.add_with_viewport(self.notes_area) self.set_canvas(scroll) # TOOLBARS toolbarbox = ToolbarBox() activity_button = ActivityToolbarButton(self) toolbarbox.toolbar.insert(activity_button, 0) activity_button.show() separator = gtk.SeparatorToolItem() toolbarbox.toolbar.insert(separator, -1) note_add = ToolButton('gtk-add') note_add.set_tooltip(_('Add a note')) note_add.connect('clicked', self.__add_note_cb) toolbarbox.toolbar.insert(note_add, -1) note_remove = ToggleToolButton('gtk-remove') note_remove.set_tooltip(_('Remove notes')) note_remove.connect('clicked', self._active_remove) toolbarbox.toolbar.insert(note_remove, -1) separator = gtk.SeparatorToolItem() toolbarbox.toolbar.insert(separator, -1) back = ToolButton('go-left') back.set_tooltip(_('Select previous note')) back.set_sensitive(False) back.connect('clicked', lambda w: self.notes_area.select_note(-1)) toolbarbox.toolbar.insert(back, -1) _next = ToolButton('go-right') _next.set_tooltip(_('Select next note')) _next.connect('clicked', lambda w: self.notes_area.select_note(+1)) _next.set_sensitive(False) toolbarbox.toolbar.insert(_next, -1) separator = gtk.SeparatorToolItem() separator.set_draw(False) separator.set_expand(True) toolbarbox.toolbar.insert(separator, -1) stopbtn = StopButton(self) toolbarbox.toolbar.insert(stopbtn, -1) self.set_toolbar_box(toolbarbox) self.notes_area.connect('no-notes', self._no_notes, note_remove, back, _next) self.notes_area.connect('note-added', self._note_added, back, _next) self.show_all()
def __init__(self, handle): activity.Activity.__init__(self, handle) self.y1 = y1 self.y2 = y2 self.y3 = y3 self.x_max = x_max self.x_min = x_min self.x_scale = x_scale self.y_max = y_max self.y_min = y_min self.y_scale = y_scale if have_toolbox: self.toolbar_box = ToolbarBox() self.activity_button = ActivityToolbarButton(self) self.activity_button.page.share.hide() self.toolbar_box.toolbar.insert(self.activity_button, 0) self.activity_button.show() self.graph_item = ToolbarButton() self.graph_item.props.icon_name = 'graph' else: self.toolbox = activity.ActivityToolbox(self) activity_toolbar = self.toolbox.get_activity_toolbar() activity_toolbar.share.props.visible = False self.graph_toolbar = gtk.Toolbar() if have_toolbox: self.graph_item.props.page = self.graph_toolbar else: self.toolbox.add_toolbar(_('Graph'), self.graph_toolbar) self.plot_item = ToolButton('gtk-refresh') self.plot_item.props.tooltip = _("Plot") self.plot_item.connect("clicked", self.plot) self.plot_item.show() self.graph_toolbar.insert(self.plot_item, 0) self.evaluate_item = ToolButton('evaluate') self.evaluate_item.props.tooltip = _('Evaluate') self.evaluate_item.connect("clicked", self.evaluate) self.evaluate_item.show() self.graph_toolbar.insert(self.evaluate_item, -1) separator = gtk.SeparatorToolItem() separator.show() self.graph_toolbar.insert(separator, -1) self.zoom_in_item = ToolButton('zoom-in') self.zoom_in_item.props.tooltip = _('Zoom In') self.zoom_in_item.connect("clicked", self.zoom_in) self.zoom_in_item.show() self.graph_toolbar.insert(self.zoom_in_item, -1) self.zoom_out_item = ToolButton('zoom-out') self.zoom_out_item.props.tooltip = _('Zoom Out') self.zoom_out_item.connect("clicked", self.zoom_out) self.zoom_out_item.show() self.graph_toolbar.insert(self.zoom_out_item, -1) self.zoom_reset_item = ToolButton('zoom-original') self.zoom_reset_item.props.tooltip = _('Zoom Reset') self.zoom_reset_item.connect("clicked", self.zoom_reset) self.zoom_reset_item.show() self.graph_toolbar.insert(self.zoom_reset_item, -1) separator = gtk.SeparatorToolItem() separator.show() self.graph_toolbar.insert(separator, -1) self.connect_points_item = ToggleToolButton('connect-points') self.connect_points_item.set_tooltip(_("Connect Points")) self.connect_points_item.set_active(True) self.connect_points_item.connect("toggled", self.toggle_connect) self.connect_points_item.show() self.graph_toolbar.insert(self.connect_points_item, -1) separator = gtk.SeparatorToolItem() separator.show() self.graph_toolbar.insert(separator, -1) self.decimal_item = RadioToolButton() self.decimal_item.set_named_icon('decimal') self.decimal_item.set_tooltip(_("Decimal Scale Style")) self.decimal_item.connect("toggled", self.scale_dec) self.decimal_item.show() self.graph_toolbar.insert(self.decimal_item, -1) self.radians_item = RadioToolButton() self.radians_item.set_named_icon('radian') self.radians_item.set_tooltip(_("Radians Scale Style")) self.radians_item.set_group(self.decimal_item) self.radians_item.connect("toggled", self.scale_rad) self.radians_item.show() self.graph_toolbar.insert(self.radians_item, -1) self.custom_item = RadioToolButton() self.custom_item.set_named_icon('custom') self.custom_item.set_tooltip(_("Custom Scale Style")) self.custom_item.set_group(self.radians_item) self.custom_item.connect("toggled", self.scale_cust) self.custom_item.show() self.graph_toolbar.insert(self.custom_item, -1) self.graph_toolbar.show() if have_toolbox: self.graph_item.show() self.toolbar_box.toolbar.insert(self.graph_item, -1) separator = gtk.SeparatorToolItem() separator.set_draw(False) separator.set_expand(True) separator.show() self.toolbar_box.toolbar.insert(separator, -1) self.stop = StopButton(self) self.stop.show() self.toolbar_box.toolbar.insert(self.stop, -1) self.set_toolbar_box(self.toolbar_box) self.toolbar_box.show() else: self.toolbox.show() self.set_toolbox(self.toolbox) self.v_box = gtk.VBox() self.set_canvas(self.v_box) self.parameter_entries = gtk.Table(6, 3) self.y1_entry = gtk.Entry() self.y2_entry = gtk.Entry() self.y3_entry = gtk.Entry() self.x_min_entry = gtk.Entry() self.x_min_entry.set_size_request(90, 24) self.x_min_entry.set_alignment(1) self.x_max_entry = gtk.Entry() self.x_max_entry.set_size_request(90, 24) self.x_max_entry.set_alignment(1) self.x_scale_entry = gtk.Entry() self.x_scale_entry.set_size_request(90, 24) self.x_scale_entry.set_alignment(1) self.y_min_entry = gtk.Entry() self.y_min_entry.set_size_request(90, 24) self.y_min_entry.set_alignment(1) self.y_max_entry = gtk.Entry() self.y_max_entry.set_size_request(90, 24) self.y_max_entry.set_alignment(1) self.y_scale_entry = gtk.Entry() self.y_scale_entry.set_size_request(90, 24) self.y_scale_entry.set_alignment(1) self.y1_entry.set_text(self.y1) self.y2_entry.set_text(self.y2) self.y3_entry.set_text(self.y3) self.x_min_entry.set_text(self.x_min) self.x_max_entry.set_text(self.x_max) self.x_scale_entry.set_text(self.x_scale) self.y_min_entry.set_text(self.y_min) self.y_max_entry.set_text(self.y_max) self.y_scale_entry.set_text(self.y_scale) self.scale_box = gtk.HBox() label = gtk.Label("y1 = ") label.set_alignment(0, .5) label.modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse("blue")) self.parameter_entries.attach(label, 0, 1, 0, 1, xpadding=5, ypadding=5, xoptions=gtk.FILL) self.parameter_entries.attach(self.y1_entry, 1, 2, 0, 1) label = gtk.Label(_("X min")) label.set_alignment(1, .5) self.parameter_entries.attach(label, 2, 3, 0, 1, xpadding=5, ypadding=7, xoptions=gtk.FILL) self.parameter_entries.attach(self.x_min_entry, 3, 4, 0, 1, xoptions=gtk.FILL) label = gtk.Label(_("Y min")) label.set_alignment(1, .5) self.parameter_entries.attach(label, 4, 5, 0, 1, xpadding=5, ypadding=5, xoptions=gtk.FILL) self.parameter_entries.attach(self.y_min_entry, 5, 6, 0, 1, xpadding=5, xoptions=gtk.FILL) label = gtk.Label("y2 = ") label.set_alignment(0, .5) label.modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse("red")) self.parameter_entries.attach(label, 0, 1, 1, 2, xpadding=5, ypadding=5, xoptions=gtk.FILL) self.parameter_entries.attach(self.y2_entry, 1, 2, 1, 2) label = gtk.Label(_("X max")) label.set_alignment(1, .5) self.parameter_entries.attach(label, 2, 3, 1, 2, xpadding=5, ypadding=7, xoptions=gtk.FILL) self.parameter_entries.attach(self.x_max_entry, 3, 4, 1, 2, xoptions=gtk.FILL) label = gtk.Label(_("Y max")) label.set_alignment(1, .5) self.parameter_entries.attach(label, 4, 5, 1, 2, xpadding=5, ypadding=5, xoptions=gtk.FILL) self.parameter_entries.attach(self.y_max_entry, 5, 6, 1, 2, xpadding=5, xoptions=gtk.FILL) label = gtk.Label("y3 = ") label.set_alignment(0, .5) label.modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse("DarkGreen")) self.parameter_entries.attach(label, 0, 1, 2, 3, xpadding=5, ypadding=5, xoptions=gtk.FILL) self.parameter_entries.attach(self.y3_entry, 1, 2, 2, 3) label = gtk.Label(_("X scale")) label.set_alignment(0, .5) self.scale_box.add(label) self.scale_box.add(self.x_scale_entry) label = gtk.Label(_("Y scale")) label.set_alignment(0, .5) self.scale_box.add(label) self.scale_box.add(self.y_scale_entry) self.parameter_entries.attach(self.scale_box, 2, 6, 2, 3, xpadding=5, xoptions=gtk.FILL) self.v_box.pack_start(self.parameter_entries, False, True, 4) self.parameter_entries.show_all() self.graph = GraphClass(self) self.v_box.pack_start(self.graph.drawing_area, True, True, 0) self.status_bar = gtk.Statusbar() self.status_bar.ContextId = self.status_bar.get_context_id("Dummy") self.status_bar.show() self.v_box.pack_end(self.status_bar, False, True, 0) self.v_box.show_all()
def __init__(self, miniTamTam): gtk.Toolbar.__init__(self) def _insertSeparator(x = 1): for i in range(x): self.separator = gtk.SeparatorToolItem() self.separator.set_draw(True) self.insert(self.separator,-1) self.separator.show() self.miniTamTam = miniTamTam self.micRec1Button = ToolButton('rec1') self.micRec1Button.connect('clicked',self.miniTamTam.micRec,'mic1') self.insert(self.micRec1Button, -1) self.micRec1Button.show() self.micRec1Button.set_tooltip(_('Record microphone into slot 1')) self.micRec2Button = ToolButton('rec2') self.micRec2Button.connect('clicked',self.miniTamTam.micRec,'mic2') self.insert(self.micRec2Button, -1) self.micRec2Button.show() self.micRec2Button.set_tooltip(_('Record microphone into slot 2')) self.micRec3Button = ToolButton('rec3') self.micRec3Button.connect('clicked',self.miniTamTam.micRec,'mic3') self.insert(self.micRec3Button, -1) self.micRec3Button.show() self.micRec3Button.set_tooltip(_('Record microphone into slot 3')) self.micRec4Button = ToolButton('rec4') self.micRec4Button.connect('clicked',self.miniTamTam.micRec,'mic4') self.insert(self.micRec4Button, -1) self.micRec4Button.show() self.micRec4Button.set_tooltip(('Record microphone into slot 4')) _insertSeparator() self.keyboardRecButton = ToggleToolButton('keyrec') self.keyboardRecButton.connect('clicked', self.miniTamTam.sequencer.handleRecordButton ) self.insert(self.keyboardRecButton, -1) self.keyboardRecButton.show() self.keyboardRecButton.set_tooltip(_('Click to record a loop')) self.keyboardRecOverButton = ToggleToolButton('overrec') self.keyboardRecOverButton.connect('clicked', self.miniTamTam.sequencer.handleOverButton ) self.insert(self.keyboardRecOverButton, -1) self.keyboardRecOverButton.show() self.keyboardRecOverButton.set_tooltip(_('Click to add a loop')) #self.keyboardRecOverButton.set_sensitive(False) self.keyboardRecMinusButton = ToolButton('minusrec') self.keyboardRecMinusButton.connect('clicked', self.miniTamTam.sequencer.clearSequencer ) self.insert(self.keyboardRecMinusButton, -1) self.keyboardRecMinusButton.show() self.keyboardRecMinusButton.set_tooltip(_('Click to clear all loops')) _insertSeparator() self._loopSettingsPalette = LoopSettingsPalette(_('Add new Sound'), self.miniTamTam) self.loopSetButton = ToggleToolButton('loop') self.loopSetButton.set_palette(self._loopSettingsPalette) self.insert(self.loopSetButton, -1) self.loopSetButton.show()
def __init__(self, montage): gtk.Toolbar.__init__(self) self.montage = montage # edit buttons setframe = ToolButton('dialog-ok') setframe.connect('clicked', self._setframe_cb) setframe.set_tooltip(_('Set frame')) self.insert(setframe, -1) clearframe = ToolButton('gtk-delete') clearframe.connect('clicked', self._clearframe_cb) clearframe.set_tooltip(_('Clear frame')) self.insert(clearframe, -1) resetframe = ToolButton('gtk-cancel') resetframe.connect('clicked', self._resetframe_cb) resetframe.set_tooltip(_('Reset')) self.insert(resetframe, -1) separator = gtk.SeparatorToolItem() self.insert(separator, -1) # play/pause buttons play_img_1 = gtk.Image() play_img_1.set_from_icon_name('media-playback-start-back', gtk.ICON_SIZE_LARGE_TOOLBAR) pause_img_1 = gtk.Image() pause_img_1.set_from_icon_name('media-playback-pause', gtk.ICON_SIZE_LARGE_TOOLBAR) play_img_2 = gtk.Image() play_img_2.set_from_icon_name('media-playback-start', gtk.ICON_SIZE_LARGE_TOOLBAR) pause_img_2 = gtk.Image() pause_img_2.set_from_icon_name('media-playback-pause', gtk.ICON_SIZE_LARGE_TOOLBAR) paly_1 = ToggleToolButton('media-playback-start-back') play_2 = ToggleToolButton('media-playback-start') paly_1.connect('toggled', self._play_cb, (paly_1, play_2), (play_img_1, pause_img_1), self.montage.playbackwards) self.insert(paly_1, -1) paly_1.set_tooltip(_('Play backward / Pause')) play_2.connect('toggled', self._play_cb, (play_2, paly_1), (play_img_2, pause_img_2), self.montage.playforwards) self.insert(play_2, -1) play_2.set_tooltip(_('Play forward / Pause')) # tempo button tempo = TempoSlider(0, 99) tempo.adjustment.connect("value-changed", self._tempo_cb) tempo.set_size_request(250, -1) tempo.set_value(50) tempo_item = gtk.ToolItem() tempo_item.add(tempo) self.insert(tempo_item, -1) separator = gtk.SeparatorToolItem() self.insert(separator, -1) # export buttons exportframe = ToolButton('image') exportframe.connect('clicked', self._exportframe_cb) exportframe.set_tooltip(_('Snapshot')) self.insert(exportframe, -1) self.show_all()
def __init__ (self, handle): if os.path.exists('/tmp/1'): os.remove('/tmp/1') activity.Activity.__init__ (self, handle) # abiword uses the current directory for all its file dialogs os.chdir(os.path.expanduser('~')) # create our main abiword canvas self.abiword_canvas = Canvas() self.set_canvas(self.abiword_canvas) self.abiword_canvas.connect_after('map-event', self.__map_event_cb) self.abiword_canvas.show() if os.path.exists('/tmp/2'): os.remove('/tmp/2') toolbar_box = ToolbarBox() activity_button = ActivityToolbarButton(self) separator = gtk.SeparatorToolItem() separator.show() activity_button.props.page.insert(separator, 2) export_button = ExportButton(self, self.abiword_canvas) export_button.show() activity_button.props.page.insert(export_button, 2) toolbar_box.toolbar.insert(activity_button, 0) edit_toolbar = ToolbarButton() edit_toolbar.props.page = EditToolbar(self, toolbar_box) edit_toolbar.props.icon_name = 'toolbar-edit' edit_toolbar.props.label = _('Edit') toolbar_box.toolbar.insert(edit_toolbar, -1) view_toolbar = ToolbarButton() view_toolbar.props.page = ViewToolbar(self.abiword_canvas) view_toolbar.props.icon_name = 'toolbar-view' view_toolbar.props.label = _('View') toolbar_box.toolbar.insert(view_toolbar, -1) separator = gtk.SeparatorToolItem() toolbar_box.toolbar.insert(separator, -1) toolbar_box.show_all() self.set_toolbar_box(toolbar_box) if os.path.exists('/tmp/3'): os.remove('/tmp/3') text_toolbar = ToolbarButton() text_toolbar.props.page = TextToolbar(self.abiword_canvas) text_toolbar.props.icon_name = 'format-text' text_toolbar.props.label = _('Text') toolbar_box.toolbar.insert(text_toolbar, -1) para_toolbar = ToolbarButton() para_toolbar.props.page = ParagraphToolbar(self.abiword_canvas) para_toolbar.props.icon_name = 'paragraph-bar' para_toolbar.props.label = _('Paragraph') toolbar_box.toolbar.insert(para_toolbar, -1) list_toolbar = ToolbarButton() list_toolbar.props.page = ListToolbar(self.abiword_canvas) list_toolbar.props.icon_name = 'toolbar-bulletlist' list_toolbar.props.label = _('Bullet List') toolbar_box.toolbar.insert(list_toolbar, -1) insert_toolbar = ToolbarButton() insert_toolbar.props.page = InsertToolbar(self.abiword_canvas) insert_toolbar.props.icon_name = 'insert-table' insert_toolbar.props.label = _('Table') toolbar_box.toolbar.insert(insert_toolbar, -1) separator = gtk.SeparatorToolItem() toolbar_box.toolbar.insert(separator, -1) bold = ToggleToolButton('format-text-bold') bold.set_tooltip(_('Bold')) bold_id = bold.connect('clicked', lambda sender: self.abiword_canvas.toggle_bold()) self.abiword_canvas.connect('bold', lambda abi, b: self._setToggleButtonState(bold, b, bold_id)) toolbar_box.toolbar.insert(bold, -1) italic = ToggleToolButton('format-text-italic') italic.set_tooltip(_('Italic')) italic_id = italic.connect('clicked', lambda sender: self.abiword_canvas.toggle_italic()) self.abiword_canvas.connect('italic', lambda abi, b: self._setToggleButtonState(italic, b, italic_id)) toolbar_box.toolbar.insert(italic, -1) underline = ToggleToolButton('format-text-underline') underline.set_tooltip(_('Underline')) underline_id = underline.connect('clicked', lambda sender: self.abiword_canvas.toggle_underline()) self.abiword_canvas.connect('underline', lambda abi, b: self._setToggleButtonState(underline, b, underline_id)) toolbar_box.toolbar.insert(underline, -1) separator = gtk.SeparatorToolItem() toolbar_box.toolbar.insert(separator, -1) color = ColorToolButton() color.connect('color-set', self._text_color_cb, self.abiword_canvas) tool_item = gtk.ToolItem() tool_item.add(color) toolbar_box.toolbar.insert(tool_item, -1) self.abiword_canvas.connect('color', lambda abi, r, g, b: color.set_color(gtk.gdk.Color(r * 256, g * 256, b * 256))) separator = gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) separator.show() toolbar_box.toolbar.insert(separator, -1) stop = StopButton(self) toolbar_box.toolbar.insert(stop, -1) toolbar_box.show_all() self.set_toolbar_box(toolbar_box) self._zoom_handler = self.abiword_canvas.connect("zoom", self.__zoom_cb)
def __init__(self, handle): activity.Activity.__init__(self, handle, True) self.max_participants = 1 # ****** Editor ****** self.editor = Editor(self) self.editor.set_size_request(800, 790) scroll = gtk.ScrolledWindow() scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) scroll.add(self.editor) scroll.show_all() vbox = gtk.VBox() vbox.pack_start(scroll, True, True, 0) vbox.show_all() self.set_canvas(vbox) # ****** Toolbars ****** self.toolbar_box = ToolbarBox() activity_button = ActivityToolbarButton(self) activity_toolbar = activity_button.page # Abrir objeto / Open object open_obj_btn = ToolButton("open-from-journal") open_obj_btn.connect("clicked", file_choosers.open_from_journal, None, self) open_obj_btn.set_tooltip(_("Open object from journal")) activity_toolbar.insert(open_obj_btn, -1) # Separador / Separator separator = gtk.SeparatorToolItem() separator.set_draw(True) separator.set_expand(False) activity_toolbar.insert(separator, -1) # ****** Open File button ****** open_btn = ToolButton("fileopen") open_btn.set_tooltip(_("Open File")) open_btn.set_accelerator('<ctrl>o') open_btn.connect("clicked", self.open_file) activity_toolbar.insert(open_btn, -1) # ****** Save File button ****** save_btn = ToolButton("stock_save") save_btn.set_tooltip(_("Save this file")) save_btn.set_accelerator('<ctrl>s') save_btn.connect("clicked", self.save_file) activity_toolbar.insert(save_btn, -1) activity_toolbar.show_all() activity_toolbar.stop.hide() # Guardar como / Save As save_as = gtk.MenuItem(_("Save on the file system.")) activity_toolbar.keep.props.palette.menu.append(save_as) save_as.connect("activate", self.save_file_as) save_as.show() # Nuevo / New new = ToolButton("new") new.set_tooltip(_("New file")) new.set_accelerator('<ctrl>n') new.connect("clicked", self.new) activity_toolbar.insert(new, 6) new.show() activity_toolbar.keep.show() self.toolbar_box.toolbar.insert(activity_button, 0) # Edicion / Edit Toolbar edit_toolbar = EditToolbar() edit_toolbar_button = ToolbarButton(label=_("Edit"), page=edit_toolbar, icon_name='toolbar-edit') edit_toolbar.cut = ToolButton("cut") edit_toolbar.cut.set_tooltip(_("Cut")) edit_toolbar.cut.set_accelerator('<ctrl>x') edit_toolbar.insert(edit_toolbar.cut, 4) separator = gtk.SeparatorToolItem() separator.set_draw(False) separator.set_expand(True) edit_toolbar.insert(separator, -1) edit_toolbar.pep8_btn = ToolButton('pep8') edit_toolbar.pep8_btn.set_tooltip(_("PEP 8 Check")) edit_toolbar.pep8_btn.connect("clicked", self.pep8_check) edit_toolbar.insert(edit_toolbar.pep8_btn, -1) edit_toolbar.pep8_datetime_separator = gtk.SeparatorToolItem() edit_toolbar.pep8_datetime_separator.set_draw(True) edit_toolbar.insert(edit_toolbar.pep8_datetime_separator, -1) insert_datetime = ToolButton("insert-datetime") insert_datetime.connect("clicked", self.editor._insert_date_time) insert_datetime.set_tooltip(_("Insert date and time")) edit_toolbar.insert(insert_datetime, -1) insert_datetime.show_all() edit_toolbar.copy.connect("clicked", self.editor._copy_cb) edit_toolbar.paste.connect("clicked", self.editor._paste_cb) edit_toolbar.undo.connect("clicked", self.editor._undo_cb) edit_toolbar.redo.connect("clicked", self.editor._redo_cb) edit_toolbar.cut.connect("clicked", self.editor._cut_cb) edit_toolbar.show_all() edit_toolbar.pep8_btn.hide() edit_toolbar.pep8_datetime_separator.set_draw(False) self.toolbar_box.toolbar.insert(edit_toolbar_button, -1) self.edit_toolbar = edit_toolbar # Separador / Separator separator = gtk.SeparatorToolItem() separator.set_draw(False) self.toolbar_box.toolbar.insert(separator, -1) # Buscar / Search search_entry = iconentry.IconEntry() search_entry.set_size_request(gtk.gdk.screen_width() / 3, -1) search_entry.set_icon_from_name(iconentry.ICON_ENTRY_PRIMARY, 'system-search') search_entry.add_clear_button() search_entry.connect('activate', self.editor._search_entry_activate_cb) search_entry.connect('changed', self.editor._search_entry_changed_cb) search_item = gtk.ToolItem() search_item.add(search_entry) self.toolbox.toolbar.insert(search_item, -1) self._search_prev = ToolButton('go-previous-paired') self._search_prev.set_tooltip(_('Previous')) self._search_prev.connect('clicked', self.editor._search_prev_cb) self.toolbox.toolbar.insert(self._search_prev, -1) self._search_next = ToolButton('go-next-paired') self._search_next.set_tooltip(_('Next')) self._search_next.connect('clicked', self.editor._search_next_cb) self.toolbox.toolbar.insert(self._search_next, -1) # Preferencias / preferences preferences_toolbar = gtk.Toolbar() show_line_numbers = ToggleToolButton('show-numbers') show_line_numbers.set_tooltip(_("Show line numbers")) show_line_numbers.set_active(True) show_line_numbers.connect("clicked", \ self.editor._set_show_line_numbers) show_line_numbers.show() preferences_toolbar.insert(show_line_numbers, -1) self.editor._make_languages_combo(preferences_toolbar) self.editor.make_style_combo(preferences_toolbar) preferences = ToolbarButton() preferences.props.page = preferences_toolbar preferences.props.icon_name = 'preferences-system' preferences.show_all() self.toolbar_box.toolbar.insert(preferences, -1) font_options = FontToolbarButton() font_options.connect("load-pango-context", self.load_pango_context) font_options.load_toolbar() font_options.connect("font-changed", self.change_font) self.toolbar_box.toolbar.insert(font_options, -1) font_options.show() # Separador / Separator separator = gtk.SeparatorToolItem() separator.set_draw(False) separator.set_expand(True) self.toolbar_box.toolbar.insert(separator, -1) # Boton salir / Stop Button exit = StopButton(self) self.toolbar_box.toolbar.insert(exit, -1) self.toolbar_box.show_all() self.set_toolbar_box(self.toolbar_box) # Barra de estado de PEP8 / PEP8 status bar self.pep8_bar = gtk.Statusbar() self.pep8_bar.label = gtk.Label() self.pep8_bar.add(self.pep8_bar.label) vbox.pack_end(self.pep8_bar, False, True, 0)
def __init__(self): gtk.Toolbar.__init__(self) voicebar = gtk.Toolbar() self.activity = None self.sorted_voices = [i for i in speech.voices()] self.sorted_voices.sort(self.compare_voices) default = 0 for voice in self.sorted_voices: if voice[0] == 'default': break default = default + 1 # Play button Image play_img = gtk.Image() play_img.show() play_img.set_from_icon_name('media-playback-start', gtk.ICON_SIZE_LARGE_TOOLBAR) # Pause button Image pause_img = gtk.Image() pause_img.show() pause_img.set_from_icon_name('media-playback-pause', gtk.ICON_SIZE_LARGE_TOOLBAR) # Play button self.play_btn = ToggleToolButton('media-playback-start') self.play_btn.show() self.play_btn.connect('toggled', self._play_cb, [play_img, pause_img]) self.insert(self.play_btn, -1) self.play_btn.set_tooltip(_('Play / Pause')) self.voice_combo = ComboBox() self.voice_combo.connect('changed', self.voice_changed_cb) for voice in self.sorted_voices: self.voice_combo.append_item(voice, voice[0]) self.voice_combo.set_active(default) combotool = ToolComboBox(self.voice_combo) self.insert(combotool, -1) combotool.show() self.pitchadj = gtk.Adjustment(0, -100, 100, 1, 10, 0) self.pitchadj.connect("value_changed", self.pitch_adjusted_cb) pitchbar = gtk.HScale(self.pitchadj) pitchbar.set_draw_value(False) pitchbar.set_update_policy(gtk.UPDATE_DISCONTINUOUS) pitchbar.set_size_request(240,15) pitchtool = gtk.ToolItem() pitchtool.add(pitchbar) pitchtool.show() self.insert(pitchtool, -1) pitchbar.show() self.rateadj = gtk.Adjustment(0, -100, 100, 1, 10, 0) self.rateadj.connect("value_changed", self.rate_adjusted_cb) ratebar = gtk.HScale(self.rateadj) ratebar.set_draw_value(False) ratebar.set_update_policy(gtk.UPDATE_DISCONTINUOUS) ratebar.set_size_request(240,15) ratetool = gtk.ToolItem() ratetool.add(ratebar) ratetool.show() self.insert(ratetool, -1) ratebar.show()
def __init__(self, toolbox, abiword_canvas, parent): self._colorseldlg = None gtk.Toolbar.__init__(self) self._toolbox = toolbox self._abiword_canvas = abiword_canvas self._parent = parent self._bold = ToggleToolButton('format-text-bold') self._bold.set_tooltip(_('Bold')) self._bold_id = self._bold.connect('clicked', self._bold_cb) self._abiword_canvas.connect('bold', self._isBold_cb) self.insert(self._bold, -1) self._bold.show() self._italic = ToggleToolButton('format-text-italic') self._italic.set_tooltip(_('Italic')) self._italic_id = self._italic.connect('clicked', self._italic_cb) self._abiword_canvas.connect('italic', self._isItalic_cb) self.insert(self._italic, -1) self._italic.show() self._underline = ToggleToolButton('format-text-underline') self._underline.set_tooltip(_('Underline')) self._underline_id = self._underline.connect('clicked', self._underline_cb) self._abiword_canvas.connect('underline', self._isUnderline_cb) self.insert(self._underline, -1) self._underline.show() self._text_color = gtk.ColorButton() self._text_color_id = self._text_color.connect('color-set', self._text_color_cb) tool_item = gtk.ToolItem() tool_item.add(self._text_color) self.insert(tool_item, -1) tool_item.show_all() separator = gtk.SeparatorToolItem() separator.set_draw(True) separator.show() self.insert(separator, -1) self._font_size_icon = Icon(icon_name="format-text-size", icon_size=gtk.ICON_SIZE_LARGE_TOOLBAR) tool_item = gtk.ToolItem() tool_item.add(self._font_size_icon) self.insert(tool_item, -1) tool_item.show_all() self._font_size_combo = ComboBox() self._font_sizes = [ '8', '9', '10', '11', '12', '14', '16', '20', '22', '24', '26', '28', '36', '48', '72' ] self._font_size_changed_id = self._font_size_combo.connect( 'changed', self._font_size_changed_cb) for i, s in enumerate(self._font_sizes): self._font_size_combo.append_item(i, s, None) if s == '12': self._font_size_combo.set_active(i) tool_item = ToolComboBox(self._font_size_combo) self.insert(tool_item, -1) tool_item.show() self._has_custom_fonts = False self._font_combo = ComboBox() self._fonts = sorted(self._abiword_canvas.get_font_names()) self._fonts_changed_id = self._font_combo.connect( 'changed', self._font_changed_cb) for i, f in enumerate(self._fonts): self._font_combo.append_item(i, f, None) if f == 'Times New Roman': self._font_combo.set_active(i) tool_item = ToolComboBox(self._font_combo) self.insert(tool_item, -1) tool_item.show() separator = gtk.SeparatorToolItem() separator.set_draw(True) self.insert(separator, -1) separator.show() self._alignment = ComboBox() self._alignment.append_item(self._ACTION_ALIGNMENT_LEFT, None, 'format-justify-left') self._alignment.append_item(self._ACTION_ALIGNMENT_CENTER, None, 'format-justify-center') self._alignment.append_item(self._ACTION_ALIGNMENT_RIGHT, None, 'format-justify-right') self._alignment.append_item(self._ACTION_ALIGNMENT_JUSTIFY, None, 'format-justify-fill') self._alignment_changed_id = \ self._alignment.connect('changed', self._alignment_changed_cb) tool_item = ToolComboBox(self._alignment) self.insert(tool_item, -1) tool_item.show() self._abiword_canvas.connect('color', self._color_cb) self._abiword_canvas.connect('font-size', self._font_size_cb) self._abiword_canvas.connect('font-family', self._font_family_cb) self._abiword_canvas.connect('left-align', self._isLeftAlign_cb) self._abiword_canvas.connect('center-align', self._isCenterAlign_cb) self._abiword_canvas.connect('right-align', self._isRightAlign_cb) self._abiword_canvas.connect('justify-align', self._isJustifyAlign_cb) self._text_selected_handler = self._abiword_canvas.connect( 'text-selected', self._text_selected_cb) ####btn salir del barrido del menu item self._btn_barrido_menu = ToolButton() self._btn_barrido_menu.set_tooltip(_('Salir \nMenú')) self._btn_barrido_menu_id = self._btn_barrido_menu.connect( 'clicked', self._btn_barrido_menu_cb) self.insert(self._btn_barrido_menu, -1) self._btn_barrido_menu.set_no_show_all(True)