def __init__(self, activity, top_level_toolbox):
        self._activity = activity
        self.toolbox = top_level_toolbox

        Terminal.__init__(self, self)

        #set up tool box/menu buttons
        activity_toolbar = self.toolbox.get_activity_toolbar()

        separator = gtk.SeparatorToolItem()
        separator.set_draw(True)
        separator.show()
        activity_toolbar.insert(separator, 0)

        activity_go = ToolButton()
        activity_go.set_stock_id('gtk-media-forward')
        activity_go.set_icon_widget(None)
        activity_go.set_tooltip(_('Start Debugging'))
        activity_go.connect('clicked', self.project_run_cb)
        activity_go.add_accelerator('clicked', self.get_accelerator(),
                                    ord('O'), gtk.gdk.CONTROL_MASK,
                                    gtk.ACCEL_VISIBLE)
        activity_go.show()
        activity_toolbar.insert(activity_go, 0)

        activity_copy_tb = ToolButton('edit-copy')
        activity_copy_tb.set_tooltip(_('Copy'))
        activity_copy_tb.connect('clicked', self._copy_cb)
        activity_toolbar.insert(activity_copy_tb, 3)
        activity_copy_tb.show()

        activity_paste_tb = ToolButton('edit-paste')
        activity_paste_tb.set_tooltip(_('Paste'))
        activity_paste_tb.connect('clicked', self._paste_cb)
        activity_paste_tb.add_accelerator('clicked', self.get_accelerator(),
                                          ord('V'), gtk.gdk.CONTROL_MASK,
                                          gtk.ACCEL_VISIBLE)
        activity_toolbar.insert(activity_paste_tb, 4)
        activity_paste_tb.show()

        activity_tab_tb = sugar.graphics.toolbutton.ToolButton('list-add')
        activity_tab_tb.set_tooltip(_("Open New Tab"))
        activity_tab_tb.add_accelerator('clicked', self.get_accelerator(),
                                        ord('T'), gtk.gdk.CONTROL_MASK,
                                        gtk.ACCEL_VISIBLE)
        activity_tab_tb.show()
        activity_tab_tb.connect('clicked', self._open_tab_cb)
        activity_toolbar.insert(activity_tab_tb, 5)

        activity_tab_delete_tv = sugar.graphics.toolbutton.ToolButton(
            'list-remove')
        activity_tab_delete_tv.set_tooltip(_("Close Tab"))
        activity_tab_delete_tv.show()
        activity_tab_delete_tv.connect('clicked', self._close_tab_cb)
        activity_toolbar.insert(activity_tab_delete_tv, 6)

        activity_fullscreen_tb = sugar.graphics.toolbutton.ToolButton(
            'view-fullscreen')
        activity_fullscreen_tb.set_tooltip(_("Fullscreen"))
        activity_fullscreen_tb.connect('clicked',
                                       self._activity._fullscreen_cb)
        activity_toolbar.insert(activity_fullscreen_tb, 7)
        activity_fullscreen_tb.hide()
Exemple #2
0
    def __init__(self, activity):
        self._activity = activity

        GtkSourceview2Editor.__init__(self, activity)

        #set the default contents for edit,override fixed font size
        self.font_size = activity.debug_dict.get('font_size', 8)
        self.find_window = None

        self.editbar = gtk.Toolbar()
        self.last_folder = None
        editopen = ToolButton()
        editopen.set_stock_id('gtk-new')
        editopen.set_icon_widget(None)
        editopen.set_tooltip(_('New File'))
        editopen.connect('clicked', self._new_file_cb)
        editopen.add_accelerator('clicked', activity.accelerator, ord('N'),
                                 gtk.gdk.CONTROL_MASK, gtk.ACCEL_VISIBLE)
        #editopen.props.accelerator = '<Ctrl>O'
        editopen.show()
        self.editbar.insert(editopen, -1)

        editfile = ToolButton()
        editfile.set_stock_id('gtk-open')
        editfile.set_icon_widget(None)
        editfile.set_tooltip(_('Open File'))
        editfile.connect('clicked', self._read_file_cb)
        editfile.add_accelerator('clicked', activity.accelerator, ord('O'),
                                 gtk.gdk.CONTROL_MASK, gtk.ACCEL_VISIBLE)
        #editfile.props.accelerator = '<Ctrl>O'
        editfile.show()
        self.editbar.insert(editfile, -1)

        editsave = ToolButton()
        editsave.set_stock_id('gtk-save')
        editsave.set_icon_widget(None)
        editsave.set_tooltip(_('Save File'))
        editsave.add_accelerator('clicked', activity.accelerator, ord('S'),
                                 gtk.gdk.CONTROL_MASK, gtk.ACCEL_VISIBLE)
        #editsave.props.accelerator = '<Ctrl>S'
        editsave.connect('clicked', self.save_cb)
        editsave.show()
        self.editbar.insert(editsave, -1)

        editsaveas = ToolButton()
        editsaveas.set_stock_id('gtk-save-as')
        editsaveas.set_icon_widget(None)
        editsaveas.set_tooltip(_('Save As'))
        #editsaveas.props.accelerator = '<Ctrl>S'
        editsaveas.connect('clicked', self.save_file_cb)
        editsaveas.show()
        self.editbar.insert(editsaveas, -1)
        """
        editjournal = ToolButton(tooltip=_('Open Journal'))
        client = gconf.client_get_default()
        color = XoColor(client.get_string('/desktop/sugar/user/color'))
        journal_icon = Icon(icon_name='document-save', xo_color=color)
        editjournal.set_icon_widget(journal_icon)
        editjournal.connect('clicked', self._show_journal_object_picker_cb)
        #editjournal.props.accelerator = '<Ctrl>J'
        editjournal.show()
        self.editbar.insert(editjournal, -1)
        """

        separator = gtk.SeparatorToolItem()
        separator.set_draw(True)
        separator.show()
        self.editbar.insert(separator, -1)

        editundo = ToolButton('undo')
        editundo.set_tooltip(_('Undo'))
        editundo.connect('clicked', self.undo)
        editundo.add_accelerator('clicked', activity.accelerator, ord('Z'),
                                 gtk.gdk.CONTROL_MASK, gtk.ACCEL_VISIBLE)
        #editundo.props.accelerator = '<Ctrl>Z'
        editundo.show()
        self.editbar.insert(editundo, -1)

        editredo = ToolButton('redo')
        editredo.set_tooltip(_('Redo'))
        editredo.connect('clicked', self.redo)
        editredo.add_accelerator('clicked', activity.accelerator, ord('Y'),
                                 gtk.gdk.CONTROL_MASK, gtk.ACCEL_VISIBLE)
        #editredo.props.accelerator = '<Ctrl>Y'
        editredo.show()
        self.editbar.insert(editredo, -1)

        separator = gtk.SeparatorToolItem()
        separator.set_draw(True)
        separator.show()
        self.editbar.insert(separator, -1)

        editcut = ToolButton()
        editcut.set_stock_id('gtk-cut')
        editcut.set_icon_widget(None)
        editcut.set_tooltip(_('Cut'))
        self.edit_cut_handler_id = editcut.connect('clicked', self.cut)
        editcut.add_accelerator('clicked', activity.accelerator, ord('X'),
                                gtk.gdk.CONTROL_MASK, gtk.ACCEL_VISIBLE)
        #editcut.props.accelerator = '<Ctrl>X'
        self.editbar.insert(editcut, -1)
        editcut.show()

        editcopy = ToolButton('edit-copy')
        editcopy.set_tooltip(_('Copy'))
        self.edit_copy_handler_id = editcopy.connect('clicked',
                                                     self.copy_to_clipboard_cb)
        editcopy.add_accelerator('clicked', activity.accelerator, ord('C'),
                                 gtk.gdk.CONTROL_MASK, gtk.ACCEL_VISIBLE)
        #editcopy.props.accelerator = '<Ctrl>C'
        self.editbar.insert(editcopy, -1)
        editcopy.show()

        editpaste = ToolButton('edit-paste')
        editpaste.set_tooltip(_('Paste'))
        self.edit_paste_handler_id = editpaste.connect('clicked', self.paste)
        editpaste.add_accelerator('clicked', activity.accelerator, ord('V'),
                                  gtk.gdk.CONTROL_MASK, gtk.ACCEL_VISIBLE)
        #editpaste.props.accelerator = '<Ctrl>V'
        editpaste.show()
        self.editbar.insert(editpaste, -1)
        """
        separator = gtk.SeparatorToolItem()
        separator.set_draw(True)
        separator.show()
        self.editbar.insert(separator, -1)
        """
        editfind = ToolButton('viewmag1')
        editfind.set_tooltip(_('Find and Replace'))
        editfind.connect('clicked', self.show_find)
        editfind.add_accelerator('clicked', activity.accelerator, ord('F'),
                                 gtk.gdk.CONTROL_MASK, gtk.ACCEL_VISIBLE)
        #editfind.props.accelerator = '<Ctrl>F'
        editfind.show()
        self.editbar.insert(editfind, -1)
        """
        separator = gtk.SeparatorToolItem()
        separator.set_draw(True)
        separator.show()
        self.editbar.insert(separator, -1)
        """
        self.zoomout = ToolButton('zoom-out')
        self.zoomout.set_tooltip(_('Zoom out'))
        self.zoomout.connect('clicked', self.__zoomout_clicked_cb)
        self.editbar.insert(self.zoomout, -1)
        self.zoomout.show()

        self.zoomin = ToolButton('zoom-in')
        self.zoomin.set_tooltip(_('Zoom in'))
        self.zoomin.connect('clicked', self.__zoomin_clicked_cb)
        self.editbar.insert(self.zoomin, -1)
        self.zoomin.show()

        stop_button = ToolButton('activity-stop')
        stop_button.set_tooltip(_('Stop'))
        #stop_button.props.accelerator = '<Ctrl>Q'
        stop_button.connect('clicked', self.__stop_clicked_cb)
        self.editbar.insert(stop_button, -1)
        stop_button.show()

        self.editbar.show_all()