(self, widget)
Palette selector changed
Palette selector changed
Palette selector changed
def on_palette_combobox_changed(self, widget):
        """Palette selector changed"""
        value = None
        active = widget.get_active()

        for key in list(self.palettevalues.keys()):
            if self.palettevalues[key] == active:
                value = key

        sensitive = value == 'custom'
        for palette_id in range(0, NUM_PALETTE_COLORS):
            self.get_palette_widget(palette_id).set_sensitive(sensitive)

        if value in self.palettes:
            palette = self.palettes[value]
            palettebits = palette.split(':')
            for palette_id in range(0, NUM_PALETTE_COLORS):
                # Update the visible elements
                color = Gdk.color_parse(palettebits[palette_id])
                self.load_palette_color(palette_id, color)
        elif value == 'custom':
            palettebits = []
            for palette_id in range(0, NUM_PALETTE_COLORS):
                # Save the custom values into the configuration.
                palettebits.append(get_color_string(self.get_palette_color(palette_id)))
            palette = ':'.join(palettebits)
        else:
            err('Unknown palette value: %s' % value)
            return

        self.config['palette'] = palette
        self.config.save()
def on_palette_combobox_changed ( self , widget ) : value = None active = widget . get_active ( ) for key in list ( self . palettevalues . keys ( ) ) : if self . palettevalues [ key ] == active : value = key sensitive = value == 'custom' for palette_id in range ( 0 , NUM_PALETTE_COLORS ) : self . get_palette_widget ( palette_id ) . set_sensitive ( sensitive ) if value in self . palettes : palette = self . palettes [ value ] palettebits = palette . split ( ':' ) for palette_id in range ( 0 , NUM_PALETTE_COLORS ) : # Update the visible elements color = Gdk . color_parse ( palettebits [ palette_id ] ) self . load_palette_color ( palette_id , color ) elif value == 'custom' : palettebits = [ ] for palette_id in range ( 0 , NUM_PALETTE_COLORS ) : # Save the custom values into the configuration. palettebits . append ( get_color_string ( self . get_palette_color ( palette_id ) ) ) palette = ':' . join ( palettebits ) else : err ( 'Unknown palette value: %s' % value ) return self . config [ 'palette' ] = palette self . config . save ( )