(self, _widget=None)
Reconfigure our settings
Reconfigure our settings
Reconfigure our settings
def reconfigure(self, _widget=None):
        """Reconfigure our settings"""
        dbg('Terminal::reconfigure')
        self.cnxids.remove_signal(self.vte, 'realize')

        # Handle child command exiting
        self.cnxids.remove_signal(self.vte, 'child-exited')

        if self.config['exit_action'] == 'restart':
            self.cnxids.new(self.vte, 'child-exited', self.spawn_child, True)
        elif self.config['exit_action'] == 'hold':
            self.cnxids.new(self.vte, 'child-exited', self.held_open, True)
        elif self.config['exit_action'] in ('close', 'left'):
            self.cnxids.new(self.vte, 'child-exited',
                                            lambda x, y: self.emit('close-term'))

        # Word char support was missing from vte 0.38, silently skip this setting
        if hasattr(self.vte, 'set_word_char_exceptions'):
            self.vte.set_word_char_exceptions(self.config['word_chars'])
        self.vte.set_mouse_autohide(self.config['mouse_autohide'])

        backspace = self.config['backspace_binding']
        delete = self.config['delete_binding']

        try:
            if backspace == 'ascii-del':
                backbind = Vte.ERASE_ASCII_DELETE
            elif backspace == 'control-h':
                backbind = Vte.ERASE_ASCII_BACKSPACE
            elif backspace == 'escape-sequence':
                backbind = Vte.ERASE_DELETE_SEQUENCE
            else:
                backbind = Vte.ERASE_AUTO
        except AttributeError:
            if backspace == 'ascii-del':
                backbind = 2
            elif backspace == 'control-h':
                backbind = 1
            elif backspace == 'escape-sequence':
                backbind = 3
            else:
                backbind = 0

        try:
            if delete == 'ascii-del':
                delbind = Vte.ERASE_ASCII_DELETE
            elif delete == 'control-h':
                delbind = Vte.ERASE_ASCII_BACKSPACE
            elif delete == 'escape-sequence':
                delbind = Vte.ERASE_DELETE_SEQUENCE
            else:
                delbind = Vte.ERASE_AUTO
        except AttributeError:
            if delete == 'ascii-del':
                delbind = 2
            elif delete == 'control-h':
                delbind = 1
            elif delete == 'escape-sequence':
                delbind = 3
            else:
                delbind = 0

        self.vte.set_backspace_binding(backbind)
        self.vte.set_delete_binding(delbind)

        if not self.custom_font_size:
            try:
                if self.config['use_system_font'] == True:
                    font = self.config.get_system_mono_font()
                else:
                    font = self.config['font']
                self.set_font(Pango.FontDescription(font))
            except:
                pass
        self.vte.set_allow_bold(self.config['allow_bold'])
        if hasattr(self.vte,'set_cell_height_scale'): 
            self.vte.set_cell_height_scale(self.config['cell_height'])
        if hasattr(self.vte,'set_cell_width_scale'):
            self.vte.set_cell_width_scale(self.config['cell_width'])
        if hasattr(self.vte, 'set_bold_is_bright'):
            self.vte.set_bold_is_bright(self.config['bold_is_bright'])

        if self.config['use_theme_colors']:
            self.fgcolor_active = self.vte.get_style_context().get_color(Gtk.StateType.NORMAL)  # VERIFY FOR GTK3: do these really take the theme colors?
            self.bgcolor = self.vte.get_style_context().get_background_color(Gtk.StateType.NORMAL)
        else:
            self.fgcolor_active = Gdk.RGBA()
            self.fgcolor_active.parse(self.config['foreground_color'])
            self.bgcolor = Gdk.RGBA()
            self.bgcolor.parse(self.config['background_color'])

        if self.config['background_type'] in ('transparent', 'image'):
            self.bgcolor.alpha = self.config['background_darkness']
        else:
            self.bgcolor.alpha = 1

        if self.config['background_type'] == 'image' and self.config['background_image'] != '':
            self.set_background_image(self.config['background_image'])
        else:
            self.background_image = None

        factor = self.config['inactive_color_offset']
        if factor > 1.0:
          factor = 1.0
        self.fgcolor_inactive = self.fgcolor_active.copy()
        dbg(("fgcolor_inactive set to: RGB(%s,%s,%s)", getattr(self.fgcolor_inactive, "red"),
                                                      getattr(self.fgcolor_inactive, "green"),
                                                      getattr(self.fgcolor_inactive, "blue")))

        for bit in ['red', 'green', 'blue']:
            setattr(self.fgcolor_inactive, bit,
                    getattr(self.fgcolor_inactive, bit) * factor)

        dbg(("fgcolor_inactive set to: RGB(%s,%s,%s)", getattr(self.fgcolor_inactive, "red"),
                                                      getattr(self.fgcolor_inactive, "green"),
                                                      getattr(self.fgcolor_inactive, "blue")))
        colors = self.config['palette'].split(':')
        self.palette_active = []
        for color in colors:
            if color:
                newcolor = Gdk.RGBA()
                newcolor.parse(color)
                self.palette_active.append(newcolor)
        if len(colors) == 16:
            # RGB values for indices 16..255 copied from vte source in order to dim them
            shades = [0, 95, 135, 175, 215, 255]
            for r in range(0, 6):
                for g in range(0, 6):
                    for b in range(0, 6):
                        newcolor = Gdk.RGBA()
                        setattr(newcolor, "red",   shades[r] / 255.0)
                        setattr(newcolor, "green", shades[g] / 255.0)
                        setattr(newcolor, "blue",  shades[b] / 255.0)
                        self.palette_active.append(newcolor)
            for y in range(8, 248, 10):
                newcolor = Gdk.RGBA()
                setattr(newcolor, "red",   y / 255.0)
                setattr(newcolor, "green", y / 255.0)
                setattr(newcolor, "blue",  y / 255.0)
                self.palette_active.append(newcolor)
        self.palette_inactive = []
        for color in self.palette_active:
            newcolor = Gdk.RGBA()
            for bit in ['red', 'green', 'blue']:
                setattr(newcolor, bit,
                        getattr(color, bit) * factor)
            self.palette_inactive.append(newcolor)
        if self.terminator.last_focused_term == self:
            self.vte.set_colors(self.fgcolor_active, self.bgcolor,
                                self.palette_active)
        else:
            self.vte.set_colors(self.fgcolor_inactive, self.bgcolor,
                                self.palette_inactive)
        profiles = self.config.base.profiles
        terminal_box_style_context = self.terminalbox.get_style_context()
        for profile in list(profiles.keys()):
            munged_profile = "terminator-profile-%s" % (
                "".join([c if c.isalnum() else "-" for c in profile]))
            if terminal_box_style_context.has_class(munged_profile):
                terminal_box_style_context.remove_class(munged_profile)
        munged_profile = "".join([c if c.isalnum() else "-" for c in self.get_profile()])
        css_class_name = "terminator-profile-%s" % (munged_profile)
        terminal_box_style_context.add_class(css_class_name)
        self.set_cursor_color()
        self.vte.set_cursor_shape(getattr(Vte.CursorShape,
                                          self.config['cursor_shape'].upper()));

        if self.config['cursor_blink'] == True:
            self.vte.set_cursor_blink_mode(Vte.CursorBlinkMode.ON)
        else:
            self.vte.set_cursor_blink_mode(Vte.CursorBlinkMode.OFF)

        if self.config['force_no_bell'] == True:
            self.vte.set_audible_bell(False)
            self.cnxids.remove_signal(self.vte, 'bell')
        else:
            self.vte.set_audible_bell(self.config['audible_bell'])
            self.cnxids.remove_signal(self.vte, 'bell')
            if self.config['urgent_bell'] == True or \
               self.config['icon_bell'] == True or \
               self.config['visible_bell'] == True:
                try:
                    self.cnxids.new(self.vte, 'bell', self.on_bell)
                except TypeError:
                    err('bell signal unavailable with this version of VTE')

        if self.config['scrollback_infinite'] == True:
            scrollback_lines = -1
        else:
            scrollback_lines = self.config['scrollback_lines']
        self.vte.set_scrollback_lines(scrollback_lines)
        self.vte.set_scroll_on_keystroke(self.config['scroll_on_keystroke'])
        self.vte.set_scroll_on_output(self.config['scroll_on_output'])

        if self.config['scrollbar_position'] in ['disabled', 'hidden']:
            self.scrollbar.hide()
        else:
            self.scrollbar.show()
            if self.config['scrollbar_position'] == 'left':
                self.terminalbox.reorder_child(self.scrollbar, 0)
            elif self.config['scrollbar_position'] == 'right':
                self.terminalbox.reorder_child(self.vte, 0)

        self.titlebar.update()
        self.vte.queue_draw()
def reconfigure ( self , _widget = None ) : dbg ( 'Terminal::reconfigure' ) self . cnxids . remove_signal ( self . vte , 'realize' ) # Handle child command exiting self . cnxids . remove_signal ( self . vte , 'child-exited' ) if self . config [ 'exit_action' ] == 'restart' : self . cnxids . new ( self . vte , 'child-exited' , self . spawn_child , True ) elif self . config [ 'exit_action' ] == 'hold' : self . cnxids . new ( self . vte , 'child-exited' , self . held_open , True ) elif self . config [ 'exit_action' ] in ( 'close' , 'left' ) : self . cnxids . new ( self . vte , 'child-exited' , lambda x , y : self . emit ( 'close-term' ) ) # Word char support was missing from vte 0.38, silently skip this setting if hasattr ( self . vte , 'set_word_char_exceptions' ) : self . vte . set_word_char_exceptions ( self . config [ 'word_chars' ] ) self . vte . set_mouse_autohide ( self . config [ 'mouse_autohide' ] ) backspace = self . config [ 'backspace_binding' ] delete = self . config [ 'delete_binding' ] try : if backspace == 'ascii-del' : backbind = Vte . ERASE_ASCII_DELETE elif backspace == 'control-h' : backbind = Vte . ERASE_ASCII_BACKSPACE elif backspace == 'escape-sequence' : backbind = Vte . ERASE_DELETE_SEQUENCE else : backbind = Vte . ERASE_AUTO except AttributeError : if backspace == 'ascii-del' : backbind = 2 elif backspace == 'control-h' : backbind = 1 elif backspace == 'escape-sequence' : backbind = 3 else : backbind = 0 try : if delete == 'ascii-del' : delbind = Vte . ERASE_ASCII_DELETE elif delete == 'control-h' : delbind = Vte . ERASE_ASCII_BACKSPACE elif delete == 'escape-sequence' : delbind = Vte . ERASE_DELETE_SEQUENCE else : delbind = Vte . ERASE_AUTO except AttributeError : if delete == 'ascii-del' : delbind = 2 elif delete == 'control-h' : delbind = 1 elif delete == 'escape-sequence' : delbind = 3 else : delbind = 0 self . vte . set_backspace_binding ( backbind ) self . vte . set_delete_binding ( delbind ) if not self . custom_font_size : try : if self . config [ 'use_system_font' ] == True : font = self . config . get_system_mono_font ( ) else : font = self . config [ 'font' ] self . set_font ( Pango . FontDescription ( font ) ) except : pass self . vte . set_allow_bold ( self . config [ 'allow_bold' ] ) if hasattr ( self . vte , 'set_cell_height_scale' ) : self . vte . set_cell_height_scale ( self . config [ 'cell_height' ] ) if hasattr ( self . vte , 'set_cell_width_scale' ) : self . vte . set_cell_width_scale ( self . config [ 'cell_width' ] ) if hasattr ( self . vte , 'set_bold_is_bright' ) : self . vte . set_bold_is_bright ( self . config [ 'bold_is_bright' ] ) if self . config [ 'use_theme_colors' ] : self . fgcolor_active = self . vte . get_style_context ( ) . get_color ( Gtk . StateType . NORMAL ) # VERIFY FOR GTK3: do these really take the theme colors? self . bgcolor = self . vte . get_style_context ( ) . get_background_color ( Gtk . StateType . NORMAL ) else : self . fgcolor_active = Gdk . RGBA ( ) self . fgcolor_active . parse ( self . config [ 'foreground_color' ] ) self . bgcolor = Gdk . RGBA ( ) self . bgcolor . parse ( self . config [ 'background_color' ] ) if self . config [ 'background_type' ] in ( 'transparent' , 'image' ) : self . bgcolor . alpha = self . config [ 'background_darkness' ] else : self . bgcolor . alpha = 1 if self . config [ 'background_type' ] == 'image' and self . config [ 'background_image' ] != '' : self . set_background_image ( self . config [ 'background_image' ] ) else : self . background_image = None factor = self . config [ 'inactive_color_offset' ] if factor > 1.0 : factor = 1.0 self . fgcolor_inactive = self . fgcolor_active . copy ( ) dbg ( ( "fgcolor_inactive set to: RGB(%s,%s,%s)" , getattr ( self . fgcolor_inactive , "red" ) , getattr ( self . fgcolor_inactive , "green" ) , getattr ( self . fgcolor_inactive , "blue" ) ) ) for bit in [ 'red' , 'green' , 'blue' ] : setattr ( self . fgcolor_inactive , bit , getattr ( self . fgcolor_inactive , bit ) * factor ) dbg ( ( "fgcolor_inactive set to: RGB(%s,%s,%s)" , getattr ( self . fgcolor_inactive , "red" ) , getattr ( self . fgcolor_inactive , "green" ) , getattr ( self . fgcolor_inactive , "blue" ) ) ) colors = self . config [ 'palette' ] . split ( ':' ) self . palette_active = [ ] for color in colors : if color : newcolor = Gdk . RGBA ( ) newcolor . parse ( color ) self . palette_active . append ( newcolor ) if len ( colors ) == 16 : # RGB values for indices 16..255 copied from vte source in order to dim them shades = [ 0 , 95 , 135 , 175 , 215 , 255 ] for r in range ( 0 , 6 ) : for g in range ( 0 , 6 ) : for b in range ( 0 , 6 ) : newcolor = Gdk . RGBA ( ) setattr ( newcolor , "red" , shades [ r ] / 255.0 ) setattr ( newcolor , "green" , shades [ g ] / 255.0 ) setattr ( newcolor , "blue" , shades [ b ] / 255.0 ) self . palette_active . append ( newcolor ) for y in range ( 8 , 248 , 10 ) : newcolor = Gdk . RGBA ( ) setattr ( newcolor , "red" , y / 255.0 ) setattr ( newcolor , "green" , y / 255.0 ) setattr ( newcolor , "blue" , y / 255.0 ) self . palette_active . append ( newcolor ) self . palette_inactive = [ ] for color in self . palette_active : newcolor = Gdk . RGBA ( ) for bit in [ 'red' , 'green' , 'blue' ] : setattr ( newcolor , bit , getattr ( color , bit ) * factor ) self . palette_inactive . append ( newcolor ) if self . terminator . last_focused_term == self : self . vte . set_colors ( self . fgcolor_active , self . bgcolor , self . palette_active ) else : self . vte . set_colors ( self . fgcolor_inactive , self . bgcolor , self . palette_inactive ) profiles = self . config . base . profiles terminal_box_style_context = self . terminalbox . get_style_context ( ) for profile in list ( profiles . keys ( ) ) : munged_profile = "terminator-profile-%s" % ( "" . join ( [ c if c . isalnum ( ) else "-" for c in profile ] ) ) if terminal_box_style_context . has_class ( munged_profile ) : terminal_box_style_context . remove_class ( munged_profile ) munged_profile = "" . join ( [ c if c . isalnum ( ) else "-" for c in self . get_profile ( ) ] ) css_class_name = "terminator-profile-%s" % ( munged_profile ) terminal_box_style_context . add_class ( css_class_name ) self . set_cursor_color ( ) self . vte . set_cursor_shape ( getattr ( Vte . CursorShape , self . config [ 'cursor_shape' ] . upper ( ) ) ) if self . config [ 'cursor_blink' ] == True : self . vte . set_cursor_blink_mode ( Vte . CursorBlinkMode . ON ) else : self . vte . set_cursor_blink_mode ( Vte . CursorBlinkMode . OFF ) if self . config [ 'force_no_bell' ] == True : self . vte . set_audible_bell ( False ) self . cnxids . remove_signal ( self . vte , 'bell' ) else : self . vte . set_audible_bell ( self . config [ 'audible_bell' ] ) self . cnxids . remove_signal ( self . vte , 'bell' ) if self . config [ 'urgent_bell' ] == True or self . config [ 'icon_bell' ] == True or self . config [ 'visible_bell' ] == True : try : self . cnxids . new ( self . vte , 'bell' , self . on_bell ) except TypeError : err ( 'bell signal unavailable with this version of VTE' ) if self . config [ 'scrollback_infinite' ] == True : scrollback_lines = - 1 else : scrollback_lines = self . config [ 'scrollback_lines' ] self . vte . set_scrollback_lines ( scrollback_lines ) self . vte . set_scroll_on_keystroke ( self . config [ 'scroll_on_keystroke' ] ) self . vte . set_scroll_on_output ( self . config [ 'scroll_on_output' ] ) if self . config [ 'scrollbar_position' ] in [ 'disabled' , 'hidden' ] : self . scrollbar . hide ( ) else : self . scrollbar . show ( ) if self . config [ 'scrollbar_position' ] == 'left' : self . terminalbox . reorder_child ( self . scrollbar , 0 ) elif self . config [ 'scrollbar_position' ] == 'right' : self . terminalbox . reorder_child ( self . vte , 0 ) self . titlebar . update ( ) self . vte . queue_draw ( )