Ticket #51: 0004-Updated-the-corresponding-code-of-the-preferences-wi.patch

File 0004-Updated-the-corresponding-code-of-the-preferences-wi.patch, 3.9 KB (added by tatofoo, 2 years ago)

These patches were made with git format-patch

  • src/prefs.py

    From 2c288713b1a3aeb1f71581a503d0a1fb0965ba08 Mon Sep 17 00:00:00 2001
    From: Eduardo Grajeda <tatofoo@gmail.com>
    Date: Fri, 2 Apr 2010 15:08:51 -0600
    Subject: [PATCH 4/4] Updated the corresponding code of the preferences window
    
    ---
     src/prefs.py |   69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     1 files changed, 69 insertions(+), 0 deletions(-)
    
    diff --git a/src/prefs.py b/src/prefs.py
    index 5789b71..b0a69bf 100644
    a b  
    8585              ]} 
    8686    ] 
    8787 
     88PALETTES = [ 
     89    # tango 
     90    '#000000000000:#cccc00000000:#4e4e9a9a0606:#c4c4a0a00000:#34346565a4a4:' 
     91    '#757550507b7b:#060698209a9a:#d3d3d7d7cfcf:#555557575353:#efef29292929:' 
     92    '#8a8ae2e23434:#fcfce9e94f4f:#72729f9fcfcf:#adad7f7fa8a8:#3434e2e2e2e2:' 
     93    '#eeeeeeeeecec', 
     94 
     95    # linux console 
     96    '#000000000000:#aaaa00000000:#0000aaaa0000:#aaaa55550000:#00000000aaaa:' 
     97    '#aaaa0000aaaa:#0000aaaaaaaa:#aaaaaaaaaaaa:#555555555555:#ffff55555555:' 
     98    '#5555ffff5555:#ffffffff5555:#55555555ffff:#ffff5555ffff:#5555ffffffff:' 
     99    '#ffffffffffff', 
     100 
     101    # xterm 
     102    '#000000000000:#cdcb00000000:#0000cdcb0000:#cdcbcdcb0000:#1e1a908fffff:' 
     103    '#cdcb0000cdcb:#0000cdcbcdcb:#e5e2e5e2e5e2:#4ccc4ccc4ccc:#ffff00000000:' 
     104    '#0000ffff0000:#ffffffff0000:#46458281b4ae:#ffff0000ffff:#0000ffffffff:' 
     105    '#ffffffffffff', 
     106 
     107    # rxvt 
     108    '#000000000000:#cdcd00000000:#0000cdcd0000:#cdcdcdcd0000:#00000000cdcd:' 
     109    '#cdcd0000cdcd:#0000cdcdcdcd:#fafaebebd7d7:#404040404040:#ffff00000000:' 
     110    '#0000ffff0000:#ffffffff0000:#00000000ffff:#ffff0000ffff:#0000ffffffff:' 
     111    '#ffffffffffff' 
     112] 
     113 
    88114class PrefsCallbacks(object): 
    89115    """Holds callbacks that will be used in the PrefsDialg class. 
    90116    """ 
     
    353379        self.client.unset(KEY('/general/compat_delete')) 
    354380        self.reload_erase_combos() 
    355381 
     382    def on_palette_name_changed(self, combo): 
     383        """Changes the value of palette in gconf 
     384        """ 
     385        palette_index = combo.get_active() 
     386        if palette_index == 4: 
     387            return 
     388        self.client.set_string(KEY('/style/font/palette'),  
     389            PALETTES[palette_index])  
     390        self.set_palette_colors(PALETTES[palette_index]) 
     391 
     392    def on_palette_color_set(self, btn): 
     393        """Changes the value of palette in gconf 
     394        """ 
     395        palette = [] 
     396        for i in range(16): 
     397            palette.append(hexify_color( 
     398                self.get_widget('palette_%d' % i).get_color())) 
     399        palette = ':'.join(palette) 
     400        self.client.set_string(KEY('/style/font/palette'), palette) 
     401        self.set_palette_name(palette) 
     402 
     403    def set_palette_name(self, palette): 
     404        """If the given palette matches an existing one, shows it in the 
     405        combobox 
     406        """ 
     407        self.get_widget('palette_name').set_active(4) 
     408        for i in range(len(PALETTES)): 
     409            if palette == PALETTES[i]: 
     410                self.get_widget('palette_name').set_active(i) 
     411     
     412    def set_palette_colors(self, palette): 
     413        """Updates the color buttons with the given palette 
     414        """ 
     415        palette = palette.split(':') 
     416        for i in range(16): 
     417            color = gtk.gdk.color_parse(palette[i]) 
     418            self.get_widget('palette_%d' % i).set_color(color) 
     419 
    356420    def reload_erase_combos(self, btn=None): 
    357421        """Read from gconf the value of compat_{backspace,delete} vars 
    358422        and select the right option in combos. 
     
    453517        except (ValueError, TypeError): 
    454518            warnings.warn('Unable to parse color %s' % val, Warning) 
    455519 
     520        # palette 
     521        value = self.client.get_string(KEY('/style/font/palette')) 
     522        self.set_palette_name(value) 
     523        self.set_palette_colors(value) 
     524     
    456525        # background image 
    457526        value = self.client.get_string(KEY('/style/background/image')) 
    458527        if os.path.isfile(value or ''):