Пример #1
0
    def apply_settings(self):
        """Apply terminal settings"""
        # let parent class do its work
        PluginBase.apply_settings(self)
        options = self._parent.options
        section = options.section('terminal')

        if self._terminal_type == TerminalType.VTE:
            # apply terminal scroll bar policy
            show_scrollbars = section.get('show_scrollbars')
            scrollbar_vertical = self._container.get_vscrollbar()
            scrollbar_vertical.set_child_visible(show_scrollbars)

            # apply cursor shape
            shape = section.get('cursor_shape')
            shape_type = {
                CursorShape.BLOCK: vte.CURSOR_SHAPE_BLOCK,
                CursorShape.IBEAM: vte.CURSOR_SHAPE_IBEAM,
                CursorShape.UNDERLINE: vte.CURSOR_SHAPE_UNDERLINE
            }
            self._terminal.set_cursor_shape(shape_type[shape])

            # apply allow bold
            self._terminal.set_allow_bold(section.get('allow_bold'))

            # apply mouse autohiding
            self._terminal.set_mouse_autohide(section.get('mouse_autohide'))

            # apply font
            if section.get('use_system_font') and gconf is not None:
                self.__set_system_font()

            else:
                self._terminal.set_font_from_string(section.get('font'))
Пример #2
0
	def apply_settings(self):
		"""Apply terminal settings"""
		# let parent class do its work
		PluginBase.apply_settings(self)
		options = self._parent.options
		section = options.section('terminal')

		if self._terminal_type == TerminalType.VTE:
			# apply terminal scroll bar policy
			show_scrollbars = section.get('show_scrollbars')
			scrollbar_vertical = self._container.get_vscrollbar()
			scrollbar_vertical.set_child_visible(show_scrollbars)

			# apply cursor shape
			shape = section.get('cursor_shape')
			shape_type = {
					CursorShape.BLOCK: vte.CURSOR_SHAPE_BLOCK,
					CursorShape.IBEAM: vte.CURSOR_SHAPE_IBEAM,
					CursorShape.UNDERLINE: vte.CURSOR_SHAPE_UNDERLINE
				}
			self._terminal.set_cursor_shape(shape_type[shape])

			# apply allow bold
			self._terminal.set_allow_bold(section.get('allow_bold'))

			# apply mouse autohiding
			self._terminal.set_mouse_autohide(section.get('mouse_autohide'))

			# apply font
			if section.get('use_system_font') and gconf is not None:
				self.__set_system_font()

			else:
				self._terminal.set_font_from_string(section.get('font'))
Пример #3
0
	def _configure_accelerators(self):
		"""Configure accelerator group"""
		group = AcceleratorGroup(self._parent)
		keyval = gtk.gdk.keyval_from_name

		# give parent chance to register its own accelerator group
		PluginBase._configure_accelerators(self)

		# modify plugin accelerator group so we can have terminal auto-complete with tab
		plugin_group = self._accelerator_groups[0]
		plugin_group.disable_accelerator('focus_opposite_object')
		plugin_group.disable_accelerator('close_tab')

		# configure accelerator group
		group.set_name('terminal')
		group.set_title(_('Terminal'))

		# add all methods to group
		group.add_method('create_terminal', _('Create terminal tab'), self._create_terminal)
		group.add_method('copy_to_clipboard', _('Copy selection to clipboard'), self._copy_selection)
		group.add_method('paste_from_clipboard', _('Paste from clipboard'), self._paste_selection)
		group.add_method('focus_opposite_object', _('Focus opposite object'), self._parent.focus_opposite_object)
		group.add_method('close_tab', _('Close tab'), self._close_tab)

		# configure accelerators
		group.set_accelerator('create_terminal', keyval('z'), gtk.gdk.CONTROL_MASK)
		group.set_accelerator('copy_to_clipboard', keyval('c'), gtk.gdk.CONTROL_MASK | gtk.gdk.SHIFT_MASK)
		group.set_accelerator('paste_from_clipboard', keyval('v'), gtk.gdk.CONTROL_MASK | gtk.gdk.SHIFT_MASK)
		group.set_accelerator('focus_opposite_object', keyval('Tab'), gtk.gdk.CONTROL_MASK | gtk.gdk.MOD1_MASK)
		group.set_accelerator('close_tab', keyval('w'), gtk.gdk.CONTROL_MASK)

		# add accelerator group to the list
		self._accelerator_groups.append(group)
Пример #4
0
	def _configure_accelerators(self):
		"""Configure accelerator group"""
		group = AcceleratorGroup(self._parent)
		keyval = gtk.gdk.keyval_from_name

		# give parent chance to register its own accelerator group
		PluginBase._configure_accelerators(self)

		# modify plugin accelerator group so we can have terminal auto-complete with tab
		plugin_group = self._accelerator_groups[0]
		plugin_group.disable_accelerator('focus_opposite_object')
		plugin_group.disable_accelerator('close_tab')

		# configure accelerator group
		group.set_name('terminal')
		group.set_title(_('Terminal'))

		# add all methods to group
		group.add_method('create_terminal', _('Create terminal tab'), self._create_terminal)
		group.add_method('copy_to_clipboard', _('Copy selection to clipboard'), self._copy_selection)
		group.add_method('paste_from_clipboard', _('Paste from clipboard'), self._paste_selection)
		group.add_method('focus_opposite_object', _('Focus opposite object'), self._parent.focus_opposite_object)
		group.add_method('close_tab', _('Close tab'), self._close_tab)

		# configure accelerators
		group.set_accelerator('create_terminal', keyval('z'), gtk.gdk.CONTROL_MASK)
		group.set_accelerator('copy_to_clipboard', keyval('c'), gtk.gdk.CONTROL_MASK | gtk.gdk.SHIFT_MASK)
		group.set_accelerator('paste_from_clipboard', keyval('v'), gtk.gdk.CONTROL_MASK | gtk.gdk.SHIFT_MASK)
		group.set_accelerator('focus_opposite_object', keyval('Tab'), gtk.gdk.CONTROL_MASK | gtk.gdk.MOD1_MASK)
		group.set_accelerator('close_tab', keyval('w'), gtk.gdk.CONTROL_MASK)

		# add accelerator group to the list
		self._accelerator_groups.append(group)
Пример #5
0
    def focus_main_object(self):
        """Give focus to main object"""
        result = False

        if self._terminal_type == TerminalType.VTE:
            result = PluginBase.focus_main_object(self)

        elif self._terminal_type == TerminalType.EXTERNAL:
            self._main_object.child_focus(gtk.DIR_TAB_FORWARD)
            result = True

        return result
Пример #6
0
	def focus_main_object(self):
		"""Give focus to main object"""
		result = False

		if self._terminal_type == TerminalType.VTE:
			result = PluginBase.focus_main_object(self)

		elif self._terminal_type == TerminalType.EXTERNAL:
			self._main_object.child_focus(gtk.DIR_TAB_FORWARD)
			result = True

		return result
Пример #7
0
    def __init__(self, parent, notebook, options):
        PluginBase.__init__(self, parent, notebook, options)

        # make options available in local namespace
        options = self._parent.options
        section = options.section('terminal')

        self._menu = None

        # change list icon
        self._title_bar.set_icon_from_name('terminal')

        # terminal menu button
        self._menu_button = gtk.Button()

        if options.get('tab_button_icons'):
            # set icon
            image_menu = gtk.Image()
            image_menu.set_from_icon_name(gtk.STOCK_EDIT, gtk.ICON_SIZE_MENU)
            self._menu_button.set_image(image_menu)
        else:
            # set text
            self._menu_button = gtk.Button(ButtonText.MENU)

        self._menu_button.set_focus_on_click(False)
        self._menu_button.set_tooltip_text(_('Terminal menu'))
        self._menu_button.connect('clicked', self._show_terminal_menu)

        # pack buttons
        self._title_bar.add_control(self._menu_button)

        # create main object
        self._terminal_type = section.get('type')

        if self._terminal_type == TerminalType.VTE and vte is not None:
            self._vte_present = True
            self._terminal = vte.Terminal()
            self._terminal.connect('window-title-changed', self._update_title)

            # unset drag source
            self._terminal.drag_source_unset()

            # configure terminal widget
            shape = section.get('cursor_shape')
            shape_type = {
                CursorShape.BLOCK: vte.CURSOR_SHAPE_BLOCK,
                CursorShape.IBEAM: vte.CURSOR_SHAPE_IBEAM,
                CursorShape.UNDERLINE: vte.CURSOR_SHAPE_UNDERLINE
            }
            self._terminal.set_cursor_shape(shape_type[shape])

            self._terminal.set_allow_bold(section.get('allow_bold'))
            self._terminal.set_mouse_autohide(section.get('mouse_autohide'))

            if section.get('use_system_font') and gconf is not None:
                self.__set_system_font()

            else:
                self._terminal.set_font_from_string(section.get('font'))

        elif self._terminal_type == TerminalType.EXTERNAL:
            self._terminal = gtk.Socket()

        else:
            # failsafe when VTE module is not present
            # NOTE: Cursor needs to be visible for 'close tab' accelerator.
            self._terminal = gtk.TextView()
            text = _('\n\nPython VTE module is not installed on this system!')
            self._terminal.get_buffer().set_text(text)
            self._terminal.set_editable(False)
            self._terminal.set_justification(gtk.JUSTIFY_CENTER)
            self._terminal.set_wrap_mode(gtk.WRAP_WORD)

        # terminal container
        if self._terminal_type == TerminalType.VTE:
            self._container = gtk.ScrolledWindow()
            self._container.set_shadow_type(gtk.SHADOW_IN)

            # apply scrollbar visibility
            show_scrollbars = section.get('show_scrollbars')
            scrollbar_vertical = self._container.get_vscrollbar()
            scrollbar_horizontal = self._container.get_hscrollbar()

            scrollbar_vertical.set_child_visible(show_scrollbars)
            scrollbar_horizontal.set_child_visible(False)

        elif self._terminal_type == TerminalType.EXTERNAL:
            self._container = gtk.Viewport()
            self._container.set_shadow_type(gtk.SHADOW_IN)

        # pack terminal
        self._container.add(self._terminal)
        self.pack_start(self._container, True, True, 0)

        # connect events to main object
        self._connect_main_object(self._terminal)

        # create menu
        self._create_menu()
Пример #8
0
 def _duplicate_tab(self, widget, data=None):
     """Creates new tab with same path"""
     PluginBase._duplicate_tab(self, None, self._options)
     return True
Пример #9
0
	def __init__(self, parent, notebook, options):
		PluginBase.__init__(self, parent, notebook, options)

		# make options available in local namespace
		options = self._parent.options
		section = options.section('terminal')

		self._menu = None

		# change list icon
		self._title_bar.set_icon_from_name('terminal')

		# terminal menu button
		self._menu_button = gtk.Button()

		if options.get('tab_button_icons'):
			# set icon
			image_menu = gtk.Image()
			image_menu.set_from_icon_name(gtk.STOCK_EDIT, gtk.ICON_SIZE_MENU)
			self._menu_button.set_image(image_menu)
		else:
			# set text
			self._menu_button = gtk.Button(ButtonText.MENU)

		self._menu_button.set_focus_on_click(False)
		self._menu_button.set_tooltip_text(_('Terminal menu'))
		self._menu_button.connect('clicked', self._show_terminal_menu)

		# pack buttons
		self._title_bar.add_control(self._menu_button)

		# create main object
		self._terminal_type = section.get('type') 
	
		if self._terminal_type == TerminalType.VTE and vte is not None:
			self._vte_present = True
			self._terminal = vte.Terminal()
			self._terminal.connect('window-title-changed', self._update_title)

			# unset drag source
			self._terminal.drag_source_unset()

			# configure terminal widget
			shape = section.get('cursor_shape')
			shape_type = {
					CursorShape.BLOCK: vte.CURSOR_SHAPE_BLOCK,
					CursorShape.IBEAM: vte.CURSOR_SHAPE_IBEAM,
					CursorShape.UNDERLINE: vte.CURSOR_SHAPE_UNDERLINE
				}
			self._terminal.set_cursor_shape(shape_type[shape])

			self._terminal.set_allow_bold(section.get('allow_bold'))
			self._terminal.set_mouse_autohide(section.get('mouse_autohide'))

			if section.get('use_system_font') and gconf is not None:
				self.__set_system_font()

			else:
				self._terminal.set_font_from_string(section.get('font'))

		elif self._terminal_type == TerminalType.EXTERNAL:
			self._terminal = gtk.Socket()
			
		else:
			# failsafe when VTE module is not present
			# NOTE: Cursor needs to be visible for 'close tab' accelerator.
			self._terminal = gtk.TextView()
			text = _('\n\nPython VTE module is not installed on this system!')
			self._terminal.get_buffer().set_text(text)
			self._terminal.set_editable(False)
			self._terminal.set_justification(gtk.JUSTIFY_CENTER)
			self._terminal.set_wrap_mode(gtk.WRAP_WORD)

		# terminal container
		if self._terminal_type == TerminalType.VTE:
			self._container = gtk.ScrolledWindow()
			self._container.set_shadow_type(gtk.SHADOW_IN)

			# apply scrollbar visibility
			show_scrollbars = section.get('show_scrollbars')
			scrollbar_vertical = self._container.get_vscrollbar()
			scrollbar_horizontal = self._container.get_hscrollbar()

			scrollbar_vertical.set_child_visible(show_scrollbars)
			scrollbar_horizontal.set_child_visible(False)

		elif self._terminal_type == TerminalType.EXTERNAL:
			self._container = gtk.Viewport()
			self._container.set_shadow_type(gtk.SHADOW_IN)

		# pack terminal
		self._container.add(self._terminal)
		self.pack_start(self._container, True, True, 0)

		# connect events to main object
		self._connect_main_object(self._terminal)
		
		# create menu
		self._create_menu()
Пример #10
0
	def _duplicate_tab(self, widget, data=None):
		"""Creates new tab with same path"""
		PluginBase._duplicate_tab(self, None, self._options)
		return True