Ejemplo n.º 1
0
    def _insert_create_tools(self, create_toolbar):
        # Stop/play button
        self.stop_play_state = True
        self.stop_play = ToolButton('media-playback-stop')
        self.stop_play.set_tooltip(_("Stop"))
        self.stop_play.set_accelerator(_('<ctrl>space'))
        self.stop_play.connect('clicked', self.stop_play_cb)
        create_toolbar.insert(self.stop_play, -1)
        self.stop_play.show()

        separator = gtk.SeparatorToolItem()
        create_toolbar.insert(separator, -1)
        separator.show()

        # Make + add the component buttons
        self.radioList = {}
        firstButton = None
        for c in tools.allTools:
            button = RadioToolButton(named_icon=c.icon)
            if firstButton:
                button.set_group(firstButton)
            else:
                button.set_group(None)
                firstButton = button
            button.set_tooltip(c.toolTip)
            button.set_accelerator(c.toolAccelerator)
            button.connect('clicked', self.radioClicked)
            create_toolbar.insert(button, -1)
            button.show()
            self.radioList[button] = c.name
Ejemplo n.º 2
0
    def __init__(self, parent):
        gtk.Toolbar.__init__(self)
        self._parent = parent

        text_mode_btn = RadioToolButton(named_icon='text-mode')
        text_mode_btn.set_tooltip(_('Text mode'))
        text_mode_btn.set_accelerator(_('<ctrl>t'))
        text_mode_btn.set_group(None)
        text_mode_btn.connect('clicked', self._parent.mode_cb,
                              MMapArea.MODE_TEXT)
        self._parent.btn_group = text_mode_btn
        self.insert(text_mode_btn, -1)

        image_mode_btn = RadioToolButton(named_icon='image-mode')
        image_mode_btn.set_group(text_mode_btn)
        image_mode_btn.set_tooltip(_('Image add mode'))
        image_mode_btn.set_accelerator(_('<ctrl>i'))
        image_mode_btn.connect('clicked', self._parent.mode_cb,
                               MMapArea.MODE_IMAGE)
        self.insert(image_mode_btn, -1)

        draw_mode_btn = RadioToolButton(named_icon='draw-mode')
        draw_mode_btn.set_group(text_mode_btn)
        draw_mode_btn.set_tooltip(_('Drawing mode'))
        draw_mode_btn.set_accelerator(_('<ctrl>d'))
        draw_mode_btn.connect('clicked', self._parent.mode_cb,
                              MMapArea.MODE_DRAW)
        self.insert(draw_mode_btn, -1)

        label_mode_btn = RadioToolButton(named_icon='label-mode')
        label_mode_btn.set_tooltip(_('Label mode'))
        label_mode_btn.set_accelerator(_('<ctrl>a'))
        label_mode_btn.set_group(text_mode_btn)
        label_mode_btn.connect('clicked', self._parent.mode_cb,
                               MMapArea.MODE_LABEL)
        self.insert(label_mode_btn, -1)

        self.show_all()
Ejemplo n.º 3
0
    def __init__(self, parent):
        gtk.Toolbar.__init__(self)
        self._parent = parent

        text_mode_btn = RadioToolButton(named_icon='text-mode')
        text_mode_btn.set_tooltip(_('Text mode'))
        text_mode_btn.set_accelerator(_('<ctrl>t'))
        text_mode_btn.set_group(None)
        text_mode_btn.connect('clicked', self._parent.mode_cb,
                              MMapArea.MODE_TEXT)
        self._parent.btn_group = text_mode_btn
        self.insert(text_mode_btn, -1)

        image_mode_btn = RadioToolButton(named_icon='image-mode')
        image_mode_btn.set_group(text_mode_btn)
        image_mode_btn.set_tooltip(_('Image add mode'))
        image_mode_btn.set_accelerator(_('<ctrl>i'))
        image_mode_btn.connect('clicked', self._parent.mode_cb,
                               MMapArea.MODE_IMAGE)
        self.insert(image_mode_btn, -1)

        draw_mode_btn = RadioToolButton(named_icon='draw-mode')
        draw_mode_btn.set_group(text_mode_btn)
        draw_mode_btn.set_tooltip(_('Drawing mode'))
        draw_mode_btn.set_accelerator(_('<ctrl>d'))
        draw_mode_btn.connect('clicked', self._parent.mode_cb,
                              MMapArea.MODE_DRAW)
        self.insert(draw_mode_btn, -1)

        label_mode_btn = RadioToolButton(named_icon='label-mode')
        label_mode_btn.set_tooltip(_('Label mode'))
        label_mode_btn.set_accelerator(_('<ctrl>a'))
        label_mode_btn.set_group(text_mode_btn)
        label_mode_btn.connect('clicked', self._parent.mode_cb,
                               MMapArea.MODE_LABEL)
        self.insert(label_mode_btn, -1)

        self.show_all()
Ejemplo n.º 4
0
class ActionButtons():
    ''' This class manages the action buttons that move among toolsbars '''
    def __init__(self, parent):
        self._main_toolbar = parent.get_toolbar_box().toolbar
        self._main_area = parent._main_area
        self._erase_button = parent.edit_toolbar.erase_button
        self._sw = parent._sw

        if HASTOOLBARBOX:
            target_toolbar = self._main_toolbar
        else:
            target_toolbar = self.parent.edit_toolbar

        self._mods = RadioToolButton(named_icon='select-mode')
        self._mods.set_tooltip(_('Select thoughts'))
        self._mods.set_group(parent.btn_group)
        self._mods.set_accelerator(_('<ctrl>e'))
        self._mods.connect('clicked', parent.mode_cb, MMapArea.MODE_NULL)
        target_toolbar.insert(self._mods, -1)

        self._link_button = RadioToolButton(named_icon='link')
        self._link_button.set_tooltip(_('Link/unlink two selected thoughts'))
        self._link_button.set_group(parent.btn_group)
        self._link_button.set_accelerator(_('<ctrl>l'))
        self._link_button.connect('clicked', self.__link_cb)
        target_toolbar.insert(self._link_button, -1)

        self.move_button = RadioToolButton(named_icon='move')
        self.move_button.set_tooltip(_('Move selected thoughs'))
        self.move_button.set_group(parent.btn_group)
        self.move_button.set_accelerator(_('<ctrl>m'))
        self.move_button.connect('clicked', self.__move_cb)
        target_toolbar.insert(self.move_button, -1)

        self.drag_button = RadioToolButton(named_icon='drag')
        self.drag_button.set_tooltip(_('Scroll the screen'))
        self.drag_button.set_group(parent.btn_group)
        self.drag_button.connect('clicked', self.__drag_cb)
        target_toolbar.insert(self.drag_button, -1)

        if HASTOOLBARBOX:
            self._separator_2 = gtk.SeparatorToolItem()
            self._separator_2.props.draw = False
            #self._separator_2.set_size_request(0, -1)
            self._separator_2.set_expand(True)
            self._separator_2.show()
            target_toolbar.insert(self._separator_2, -1)

            self._stop_button = StopButton(parent)
            target_toolbar.insert(self._stop_button, -1)

    def stop_dragging(self):
        if self._main_area.is_dragging():
            self._main_area.drag_menu_cb(self._sw, False)

    def _stop_moving(self):
        self._main_area.move_mode = False

    def __link_cb(self, widget):
        self._stop_moving()
        self.stop_dragging()
        self._main_area.link_menu_cb()

    def __move_cb(self, widget):
        self.stop_dragging()
        if self._main_area.move_mode:
            self._main_area.stop_moving()
        else:
            self._main_area.start_moving(self.move_button)
        self._erase_button.set_sensitive(False)

    def __drag_cb(self, widget):
        # If we were moving, stop
        self._stop_moving()
        if not self._main_area.is_dragging():
            self._main_area.drag_menu_cb(self._sw, True)
        else:
            self.stop_dragging()
        self._erase_button.set_sensitive(False)

    def reconfigure(self):
        ''' If screen width has changed, we may need to reconfigure
        the toolbars '''
        if not HASTOOLBARBOX:
            return

        if hasattr(self, '_separator_2'):
            if gtk.gdk.screen_width() / 13 > style.GRID_CELL_SIZE:
                if self._separator_2.get_parent() is None:
                    self._main_toolbar.remove(self._stop_button)
                    self._main_toolbar.insert(self._separator_2, -1)
                    self._main_toolbar.insert(self._stop_button, -1)
            else:
                self._main_toolbar.remove(self._separator_2)
Ejemplo n.º 5
0
class ActionButtons():

    ''' This class manages the action buttons that move among toolsbars '''

    def __init__(self, parent):
        self._main_toolbar = parent.get_toolbar_box().toolbar
        self._main_area = parent._main_area
        self._erase_button = parent.edit_toolbar.erase_button
        self._sw = parent._sw

        if HASTOOLBARBOX:
            target_toolbar = self._main_toolbar
        else:
            target_toolbar = self.parent.edit_toolbar

        self._mods = RadioToolButton(named_icon='select-mode')
        self._mods.set_tooltip(_('Select thoughts'))
        self._mods.set_group(parent.btn_group)
        self._mods.set_accelerator(_('<ctrl>e'))
        self._mods.connect('clicked', parent.mode_cb, MMapArea.MODE_NULL)
        target_toolbar.insert(self._mods, -1)

        self._link_button = RadioToolButton(named_icon='link')
        self._link_button.set_tooltip(_('Link/unlink two selected thoughts'))
        self._link_button.set_group(parent.btn_group)
        self._link_button.set_accelerator(_('<ctrl>l'))
        self._link_button.connect('clicked', self.__link_cb)
        target_toolbar.insert(self._link_button, -1)

        self.move_button = RadioToolButton(named_icon='move')
        self.move_button.set_tooltip(_('Move selected thoughs'))
        self.move_button.set_group(parent.btn_group)
        self.move_button.set_accelerator(_('<ctrl>m'))
        self.move_button.connect('clicked', self.__move_cb)
        target_toolbar.insert(self.move_button, -1)

        self.drag_button = RadioToolButton(named_icon='drag')
        self.drag_button.set_tooltip(_('Scroll the screen'))
        self.drag_button.set_group(parent.btn_group)
        self.drag_button.connect('clicked', self.__drag_cb)
        target_toolbar.insert(self.drag_button, -1)

        if HASTOOLBARBOX:
            self._separator_2 = gtk.SeparatorToolItem()
            self._separator_2.props.draw = False
            # self._separator_2.set_size_request(0, -1)
            self._separator_2.set_expand(True)
            self._separator_2.show()
            target_toolbar.insert(self._separator_2, -1)

            self._stop_button = StopButton(parent)
            target_toolbar.insert(self._stop_button, -1)

    def stop_dragging(self):
        if self._main_area.is_dragging():
            self._main_area.drag_menu_cb(self._sw, False)

    def _stop_moving(self):
        self._main_area.move_mode = False

    def __link_cb(self, widget):
        self._stop_moving()
        self.stop_dragging()
        self._main_area.link_menu_cb()

    def __move_cb(self, widget):
        self.stop_dragging()
        if self._main_area.move_mode:
            self._main_area.stop_moving()
        else:
            self._main_area.start_moving(self.move_button)
        self._erase_button.set_sensitive(False)

    def __drag_cb(self, widget):
        # If we were moving, stop
        self._stop_moving()
        if not self._main_area.is_dragging():
            self._main_area.drag_menu_cb(self._sw, True)
        else:
            self.stop_dragging()
        self._erase_button.set_sensitive(False)

    def reconfigure(self):
        ''' If screen width has changed, we may need to reconfigure
        the toolbars '''
        if not HASTOOLBARBOX:
            return

        if hasattr(self, '_separator_2'):
            if gtk.gdk.screen_width() / 13 > style.GRID_CELL_SIZE:
                if self._separator_2.get_parent() is None:
                    self._main_toolbar.remove(self._stop_button)
                    self._main_toolbar.insert(self._separator_2, -1)
                    self._main_toolbar.insert(self._stop_button, -1)
            else:
                self._main_toolbar.remove(self._separator_2)