(self, profile)
Update the profile values for a given profile
Update the profile values for a given profile
Update the profile values for a given profile
def set_profile_values(self, profile):
        """Update the profile values for a given profile"""
        self.config.set_profile(profile)
        guiget = self.builder.get_object

        dbg('PrefsEditor::set_profile_values: Setting profile %s' % profile)

        ## General tab
        # Use system font
        widget = guiget('system_font_checkbutton')
        widget.set_active(self.config['use_system_font'])
        self.on_system_font_checkbutton_toggled(widget)
        # Font selector
        widget = guiget('font_selector')

        if self.config['use_system_font'] == True:
            fontname = self.config.get_system_mono_font()
            if fontname is not None:
                widget.set_font_name(fontname)
        else:
            widget.set_font_name(self.config['font'])
        # Allow bold text
        widget = guiget('allow_bold_checkbutton')
        widget.set_active(self.config['allow_bold'])
        # Icon terminal bell
        widget = guiget('icon_bell_checkbutton')
        widget.set_active(self.config['icon_bell'])
        # Visual terminal bell
        widget = guiget('visual_bell_checkbutton')
        widget.set_active(self.config['visible_bell'])
        # Audible terminal bell
        widget = guiget('audible_bell_checkbutton')
        widget.set_active(self.config['audible_bell'])
        # WM_URGENT terminal bell
        widget = guiget('urgent_bell_checkbutton')
        widget.set_active(self.config['urgent_bell'])
        # Show titlebar
        widget = guiget('show_titlebar')
        widget.set_active(self.config['show_titlebar'])
        # Copy on selection
        widget = guiget('copy_on_selection')
        widget.set_active(self.config['copy_on_selection'])
        # Word chars
        widget = guiget('word_chars_entry')
        widget.set_text(self.config['word_chars'])
        # Word char support was missing from vte 0.38, hide from the UI
        if not hasattr(self.term.vte, 'set_word_char_exceptions'):
            guiget('word_chars_hbox').hide()
        # Cursor shape
        widget = guiget('cursor_shape_combobox')
        if self.config['cursor_shape'] == 'underline':
            active = 1
        elif self.config['cursor_shape'] == 'ibeam':
            active = 2
        else:
            active = 0
        widget.set_active(active)
        # Cursor blink
        widget = guiget('cursor_blink')
        widget.set_active(self.config['cursor_blink'])
        # Cursor use default colors
        widget = guiget('cursor_color_default_checkbutton')
        widget.set_active(self.config['cursor_color_default'])
        # Cursor foreground
        widget = guiget('cursor_fg_color')
        try:
            widget.set_color(Gdk.color_parse(self.config['cursor_fg_color']))
        except:
            try:
                widget.set_color(Gdk.color_parse(self.config['background_color']))
            except:
                widget.set_color(Gdk.color_parse('#000000'))
        # Cursor background
        widget = guiget('cursor_bg_color')
        try:
            widget.set_color(Gdk.color_parse(self.config['cursor_bg_color']))
        except:
            try:
                widget.set_color(Gdk.color_parse(self.config['foreground_color']))
            except:
                widget.set_color(Gdk.color_parse('#ffffff'))

        ## Command tab
        # Login shell
        widget = guiget('login_shell_checkbutton')
        widget.set_active(self.config['login_shell'])
        # Use Custom command
        widget = guiget('use_custom_command_checkbutton')
        widget.set_active(self.config['use_custom_command'])
        self.on_use_custom_command_checkbutton_toggled(widget)
        # Custom Command
        widget = guiget('custom_command_entry')
        widget.set_text(self.config['custom_command'])
        # Exit action
        widget = guiget('exit_action_combobox')
        if self.config['exit_action'] == 'restart':
            widget.set_active(1)
        elif self.config['exit_action'] == 'hold':
            widget.set_active(2)
        else:
            # Default is to close the terminal
            widget.set_active(0)

        ## Colors tab
        # Use system colors
        widget = guiget('use_theme_colors_checkbutton')
        widget.set_active(self.config['use_theme_colors'])
        # Bold is bright
        widget = guiget('bold_text_is_bright_checkbutton')
        widget.set_active(self.config['bold_is_bright'])
        # Colorscheme
        widget = guiget('color_scheme_combobox')
        scheme = None
        for ascheme in self.colourschemes:
            forecol = self.colourschemes[ascheme][0]
            backcol = self.colourschemes[ascheme][1]
            if self.config['foreground_color'].lower() == forecol and \
               self.config['background_color'].lower() == backcol:
                scheme = ascheme
                break
        if scheme not in self.colorschemevalues:
            if self.config['foreground_color'] in [None, ''] or \
               self.config['background_color'] in [None, '']:
                scheme = 'grey_on_black'
            else:
                scheme = 'custom'
        # NOTE: The scheme is set in the GUI widget after the fore/back colours
        # Foreground color
        widget = guiget('foreground_colorbutton')
        widget.set_events(Gdk.EventMask.BUTTON_PRESS_MASK)

        if scheme == 'custom':
            widget.set_sensitive(True)
        else:
            widget.set_sensitive(False)
        # Background color
        widget = guiget('background_colorbutton')
        widget.set_events(Gdk.EventMask.BUTTON_PRESS_MASK)
        if scheme == 'custom':
            widget.set_sensitive(True)
        else:
            widget.set_sensitive(False)
        # Now actually set the scheme
        widget = guiget('color_scheme_combobox')
        widget.set_active(self.colorschemevalues[scheme])
        # Palette scheme
        widget = guiget('palette_combobox')
        palette = None
        for apalette in self.palettes:
            if self.config['palette'].lower() == self.palettes[apalette]:
                palette = apalette
        if palette not in self.palettevalues:
            if self.config['palette'] in [None, '']:
                palette = 'rxvt'
            else:
                palette = 'custom'
        # NOTE: The palette selector is set after the colour pickers
        # Palette colour pickers
        for palette_id in range(0, NUM_PALETTE_COLORS):
            widget = self.get_palette_widget(palette_id)
            widget.set_events(Gdk.EventMask.BUTTON_PRESS_MASK)
            def on_palette_click(event, data, widget=widget):
                self.edit_palette_button(widget)
            widget.connect('button-press-event', on_palette_click)
        self.load_palette()
        # Now set the palette selector widget
        widget = guiget('palette_combobox')
        widget.set_active(self.palettevalues[palette])
        # Inactive terminal shading
        widget = guiget('inactive_color_offset')
        widget.set_value(float(self.config['inactive_color_offset']))
        widget = guiget('inactive_color_offset_value_label')
        widget.set_text('%d%%' % (int(float(self.config['inactive_color_offset'])*100)))
        # Open links with a single click (instead of a Ctrl-left click)
        widget = guiget('link_single_click')
        widget.set_active(self.config['link_single_click'])
        # Use custom URL handler
        widget = guiget('use_custom_url_handler_checkbox')
        widget.set_active(self.config['use_custom_url_handler'])
        self.on_use_custom_url_handler_checkbutton_toggled(widget)
        # Custom URL handler
        widget = guiget('custom_url_handler_entry')
        widget.set_text(self.config['custom_url_handler'])

        ## Background tab
        # Radio values
        if self.config['background_type'] == 'solid':
            guiget('solid_radiobutton').set_active(True)
        elif self.config['background_type'] == 'transparent':
            guiget('transparent_radiobutton').set_active(True)
        elif self.config['background_type'] == 'image':
            guiget('image_radiobutton').set_active(True)
        self.update_background_tab()
        # Background shading
        widget = guiget('background_darkness_scale')
        widget.set_value(float(self.config['background_darkness']))
        widget = guiget('background_image_file')
        widget.set_filename(self.config['background_image'])
   
        ## Scrolling tab
        # Scrollbar position
        widget = guiget('scrollbar_position_combobox')
        value = self.config['scrollbar_position']
        if value == 'left':
            widget.set_active(0)
        elif value in ['disabled', 'hidden']:
            widget.set_active(2)
        else:
            widget.set_active(1)
        # Scrollback lines
        widget = guiget('scrollback_lines_spinbutton')
        widget.set_value(self.config['scrollback_lines'])
        # Scrollback infinite
        widget = guiget('scrollback_infinite')
        widget.set_active(self.config['scrollback_infinite'])
        # Scroll on outut
        widget = guiget('scroll_on_output_checkbutton')
        widget.set_active(self.config['scroll_on_output'])
        # Scroll on keystroke
        widget = guiget('scroll_on_keystroke_checkbutton')
        widget.set_active(self.config['scroll_on_keystroke'])

        ## Compatibility tab
        # Backspace key
        widget = guiget('backspace_binding_combobox')
        value = self.config['backspace_binding']
        if value == 'control-h':
            widget.set_active(1)
        elif value == 'ascii-del':
            widget.set_active(2)
        elif value == 'escape-sequence':
            widget.set_active(3)
        else:
            widget.set_active(0)
        # Delete key
        widget = guiget('delete_binding_combobox')
        value = self.config['delete_binding']
        if value == 'control-h':
            widget.set_active(1)
        elif value == 'ascii-del':
            widget.set_active(2)
        elif value == 'escape-sequence':
            widget.set_active(3)
        else:
            widget.set_active(0)

        ## Titlebar tab
        # Titlebar colors
        for bit in ['title_transmit_fg_color', 'title_transmit_bg_color',
            'title_receive_fg_color', 'title_receive_bg_color',
            'title_inactive_fg_color', 'title_inactive_bg_color']:
            widget = guiget(bit)
            widget.set_color(Gdk.color_parse(self.config[bit]))
        # Hide size text from the title bar
        widget = guiget('title_hide_sizetextcheck')
        widget.set_active(self.config['title_hide_sizetext'])
        # Use system font
        widget = guiget('title_system_font_checkbutton')
        widget.set_active(self.config['title_use_system_font'])
        self.on_title_system_font_checkbutton_toggled(widget)
        # Font selector
        widget = guiget('title_font_selector')
        if self.config['title_use_system_font'] == True:
            fontname = self.config.get_system_prop_font()
            if fontname is not None:
                widget.set_font_name(fontname)
        else:
            widget.set_font_name(self.config['title_font'])
def set_profile_values ( self , profile ) : self . config . set_profile ( profile ) guiget = self . builder . get_object dbg ( 'PrefsEditor::set_profile_values: Setting profile %s' % profile ) ## General tab # Use system font widget = guiget ( 'system_font_checkbutton' ) widget . set_active ( self . config [ 'use_system_font' ] ) self . on_system_font_checkbutton_toggled ( widget ) # Font selector widget = guiget ( 'font_selector' ) if self . config [ 'use_system_font' ] == True : fontname = self . config . get_system_mono_font ( ) if fontname is not None : widget . set_font_name ( fontname ) else : widget . set_font_name ( self . config [ 'font' ] ) # Allow bold text widget = guiget ( 'allow_bold_checkbutton' ) widget . set_active ( self . config [ 'allow_bold' ] ) # Icon terminal bell widget = guiget ( 'icon_bell_checkbutton' ) widget . set_active ( self . config [ 'icon_bell' ] ) # Visual terminal bell widget = guiget ( 'visual_bell_checkbutton' ) widget . set_active ( self . config [ 'visible_bell' ] ) # Audible terminal bell widget = guiget ( 'audible_bell_checkbutton' ) widget . set_active ( self . config [ 'audible_bell' ] ) # WM_URGENT terminal bell widget = guiget ( 'urgent_bell_checkbutton' ) widget . set_active ( self . config [ 'urgent_bell' ] ) # Show titlebar widget = guiget ( 'show_titlebar' ) widget . set_active ( self . config [ 'show_titlebar' ] ) # Copy on selection widget = guiget ( 'copy_on_selection' ) widget . set_active ( self . config [ 'copy_on_selection' ] ) # Word chars widget = guiget ( 'word_chars_entry' ) widget . set_text ( self . config [ 'word_chars' ] ) # Word char support was missing from vte 0.38, hide from the UI if not hasattr ( self . term . vte , 'set_word_char_exceptions' ) : guiget ( 'word_chars_hbox' ) . hide ( ) # Cursor shape widget = guiget ( 'cursor_shape_combobox' ) if self . config [ 'cursor_shape' ] == 'underline' : active = 1 elif self . config [ 'cursor_shape' ] == 'ibeam' : active = 2 else : active = 0 widget . set_active ( active ) # Cursor blink widget = guiget ( 'cursor_blink' ) widget . set_active ( self . config [ 'cursor_blink' ] ) # Cursor use default colors widget = guiget ( 'cursor_color_default_checkbutton' ) widget . set_active ( self . config [ 'cursor_color_default' ] ) # Cursor foreground widget = guiget ( 'cursor_fg_color' ) try : widget . set_color ( Gdk . color_parse ( self . config [ 'cursor_fg_color' ] ) ) except : try : widget . set_color ( Gdk . color_parse ( self . config [ 'background_color' ] ) ) except : widget . set_color ( Gdk . color_parse ( '#000000' ) ) # Cursor background widget = guiget ( 'cursor_bg_color' ) try : widget . set_color ( Gdk . color_parse ( self . config [ 'cursor_bg_color' ] ) ) except : try : widget . set_color ( Gdk . color_parse ( self . config [ 'foreground_color' ] ) ) except : widget . set_color ( Gdk . color_parse ( '#ffffff' ) ) ## Command tab # Login shell widget = guiget ( 'login_shell_checkbutton' ) widget . set_active ( self . config [ 'login_shell' ] ) # Use Custom command widget = guiget ( 'use_custom_command_checkbutton' ) widget . set_active ( self . config [ 'use_custom_command' ] ) self . on_use_custom_command_checkbutton_toggled ( widget ) # Custom Command widget = guiget ( 'custom_command_entry' ) widget . set_text ( self . config [ 'custom_command' ] ) # Exit action widget = guiget ( 'exit_action_combobox' ) if self . config [ 'exit_action' ] == 'restart' : widget . set_active ( 1 ) elif self . config [ 'exit_action' ] == 'hold' : widget . set_active ( 2 ) else : # Default is to close the terminal widget . set_active ( 0 ) ## Colors tab # Use system colors widget = guiget ( 'use_theme_colors_checkbutton' ) widget . set_active ( self . config [ 'use_theme_colors' ] ) # Bold is bright widget = guiget ( 'bold_text_is_bright_checkbutton' ) widget . set_active ( self . config [ 'bold_is_bright' ] ) # Colorscheme widget = guiget ( 'color_scheme_combobox' ) scheme = None for ascheme in self . colourschemes : forecol = self . colourschemes [ ascheme ] [ 0 ] backcol = self . colourschemes [ ascheme ] [ 1 ] if self . config [ 'foreground_color' ] . lower ( ) == forecol and self . config [ 'background_color' ] . lower ( ) == backcol : scheme = ascheme break if scheme not in self . colorschemevalues : if self . config [ 'foreground_color' ] in [ None , '' ] or self . config [ 'background_color' ] in [ None , '' ] : scheme = 'grey_on_black' else : scheme = 'custom' # NOTE: The scheme is set in the GUI widget after the fore/back colours # Foreground color widget = guiget ( 'foreground_colorbutton' ) widget . set_events ( Gdk . EventMask . BUTTON_PRESS_MASK ) if scheme == 'custom' : widget . set_sensitive ( True ) else : widget . set_sensitive ( False ) # Background color widget = guiget ( 'background_colorbutton' ) widget . set_events ( Gdk . EventMask . BUTTON_PRESS_MASK ) if scheme == 'custom' : widget . set_sensitive ( True ) else : widget . set_sensitive ( False ) # Now actually set the scheme widget = guiget ( 'color_scheme_combobox' ) widget . set_active ( self . colorschemevalues [ scheme ] ) # Palette scheme widget = guiget ( 'palette_combobox' ) palette = None for apalette in self . palettes : if self . config [ 'palette' ] . lower ( ) == self . palettes [ apalette ] : palette = apalette if palette not in self . palettevalues : if self . config [ 'palette' ] in [ None , '' ] : palette = 'rxvt' else : palette = 'custom' # NOTE: The palette selector is set after the colour pickers # Palette colour pickers for palette_id in range ( 0 , NUM_PALETTE_COLORS ) : widget = self . get_palette_widget ( palette_id ) widget . set_events ( Gdk . EventMask . BUTTON_PRESS_MASK ) def on_palette_click ( event , data , widget = widget ) : self . edit_palette_button ( widget ) widget . connect ( 'button-press-event' , on_palette_click ) self . load_palette ( ) # Now set the palette selector widget widget = guiget ( 'palette_combobox' ) widget . set_active ( self . palettevalues [ palette ] ) # Inactive terminal shading widget = guiget ( 'inactive_color_offset' ) widget . set_value ( float ( self . config [ 'inactive_color_offset' ] ) ) widget = guiget ( 'inactive_color_offset_value_label' ) widget . set_text ( '%d%%' % ( int ( float ( self . config [ 'inactive_color_offset' ] ) * 100 ) ) ) # Open links with a single click (instead of a Ctrl-left click) widget = guiget ( 'link_single_click' ) widget . set_active ( self . config [ 'link_single_click' ] ) # Use custom URL handler widget = guiget ( 'use_custom_url_handler_checkbox' ) widget . set_active ( self . config [ 'use_custom_url_handler' ] ) self . on_use_custom_url_handler_checkbutton_toggled ( widget ) # Custom URL handler widget = guiget ( 'custom_url_handler_entry' ) widget . set_text ( self . config [ 'custom_url_handler' ] ) ## Background tab # Radio values if self . config [ 'background_type' ] == 'solid' : guiget ( 'solid_radiobutton' ) . set_active ( True ) elif self . config [ 'background_type' ] == 'transparent' : guiget ( 'transparent_radiobutton' ) . set_active ( True ) elif self . config [ 'background_type' ] == 'image' : guiget ( 'image_radiobutton' ) . set_active ( True ) self . update_background_tab ( ) # Background shading widget = guiget ( 'background_darkness_scale' ) widget . set_value ( float ( self . config [ 'background_darkness' ] ) ) widget = guiget ( 'background_image_file' ) widget . set_filename ( self . config [ 'background_image' ] ) ## Scrolling tab # Scrollbar position widget = guiget ( 'scrollbar_position_combobox' ) value = self . config [ 'scrollbar_position' ] if value == 'left' : widget . set_active ( 0 ) elif value in [ 'disabled' , 'hidden' ] : widget . set_active ( 2 ) else : widget . set_active ( 1 ) # Scrollback lines widget = guiget ( 'scrollback_lines_spinbutton' ) widget . set_value ( self . config [ 'scrollback_lines' ] ) # Scrollback infinite widget = guiget ( 'scrollback_infinite' ) widget . set_active ( self . config [ 'scrollback_infinite' ] ) # Scroll on outut widget = guiget ( 'scroll_on_output_checkbutton' ) widget . set_active ( self . config [ 'scroll_on_output' ] ) # Scroll on keystroke widget = guiget ( 'scroll_on_keystroke_checkbutton' ) widget . set_active ( self . config [ 'scroll_on_keystroke' ] ) ## Compatibility tab # Backspace key widget = guiget ( 'backspace_binding_combobox' ) value = self . config [ 'backspace_binding' ] if value == 'control-h' : widget . set_active ( 1 ) elif value == 'ascii-del' : widget . set_active ( 2 ) elif value == 'escape-sequence' : widget . set_active ( 3 ) else : widget . set_active ( 0 ) # Delete key widget = guiget ( 'delete_binding_combobox' ) value = self . config [ 'delete_binding' ] if value == 'control-h' : widget . set_active ( 1 ) elif value == 'ascii-del' : widget . set_active ( 2 ) elif value == 'escape-sequence' : widget . set_active ( 3 ) else : widget . set_active ( 0 ) ## Titlebar tab # Titlebar colors for bit in [ 'title_transmit_fg_color' , 'title_transmit_bg_color' , 'title_receive_fg_color' , 'title_receive_bg_color' , 'title_inactive_fg_color' , 'title_inactive_bg_color' ] : widget = guiget ( bit ) widget . set_color ( Gdk . color_parse ( self . config [ bit ] ) ) # Hide size text from the title bar widget = guiget ( 'title_hide_sizetextcheck' ) widget . set_active ( self . config [ 'title_hide_sizetext' ] ) # Use system font widget = guiget ( 'title_system_font_checkbutton' ) widget . set_active ( self . config [ 'title_use_system_font' ] ) self . on_title_system_font_checkbutton_toggled ( widget ) # Font selector widget = guiget ( 'title_font_selector' ) if self . config [ 'title_use_system_font' ] == True : fontname = self . config . get_system_prop_font ( ) if fontname is not None : widget . set_font_name ( fontname ) else : widget . set_font_name ( self . config [ 'title_font' ] )