Changeset 200

Show
Ignore:
Timestamp:
07/06/08 11:07:40 (6 months ago)
Author:
poillubo
Message:

* focus and wallpaper support in pycagenconf

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/utils/pycagenconf

    r199 r200  
    141141    def __init__(self): 
    142142        self.frame_vbox.add(gtk.Label(str='Not implemented!'))         
     143 
     144    @staticmethod 
     145    def show_obj_name(_, cell, store, iter): 
     146        obj = store.get_value(iter, 0) 
     147        cell.set_property('text', obj.__name__) 
    143148 
    144149    def generate_vars(self, _): 
     
    205210            buttons = gtk.ComboBox(self.store) 
    206211            buttons.pack_start(cell, True) 
    207             buttons.set_cell_data_func(cell, self.show_button_name) 
     212            buttons.set_cell_data_func(cell, self.show_obj_name) 
    208213            buttons.set_active(0) 
    209214            hbox.add(buttons) 
     
    212217                               buttons_vbox, self.buttons_vars[i]) 
    213218            hbox.add(gtk_button) 
    214  
    215     @staticmethod 
    216     def show_button_name(_, cell, store, iter): 
    217         button = store.get_value(iter, 0) 
    218         cell.set_property('text', button.__name__) 
    219219 
    220220    def add_button(self, _, buttons, vbox, buttons_vars): 
     
    284284    label = 'misc' 
    285285 
     286    def __init__(self): 
     287        self.table = gtk.Table(rows=2, columns=2) 
     288        self.focuses_store = gtk.ListStore(object,) 
     289        for focus in find_default_focuses(): 
     290            self.focuses_store.append((focus,)) 
     291        self.focuses = gtk.ComboBox(self.focuses_store) 
     292        cell = gtk.CellRendererText() 
     293        self.focuses.pack_start(cell, True) 
     294        self.focuses.set_cell_data_func(cell, self.show_repr_obj_name) 
     295        self.focuses.set_active(0) 
     296        for i, title in enumerate(('default focus', 'wallpaper path')): 
     297            entry_label = make_label_with_right_alignment(title) 
     298            self.table.attach(entry_label, 0, 1, i, i + 1, 
     299                              xoptions=gtk.SHRINK|gtk.FILL) 
     300        self.table.attach(self.focuses, 1, 2, 0, 1) 
     301        self.wallpaper_path = gtk.Entry() 
     302        self.table.attach(self.wallpaper_path, 1, 2, 1, 2) 
     303        self.frame_vbox.pack_start(self.table, expand=False) 
     304 
     305    @staticmethod 
     306    def show_repr_obj_name(_, cell, store, iter): 
     307        obj = store.get_value(iter, 0) 
     308        cell.set_property('text', repr(obj.__name__)) 
     309 
     310    def generate_vars(self, gen_vars): 
     311        active = self.focuses.get_active() 
     312        if active < 0: 
     313            return 
     314 
     315        gen_vars['focus'] = repr(self.focuses_store[active][0].__name__) 
     316        gen_vars['wallpaper_path'] = self.wallpaper_path.get_text() 
     317 
     318    def generate_code(self, gen_code): 
     319        gen_code[Locations.misc].append('%(wm_name)s.set_focus(%(focus)s)') 
     320        if self.wallpaper_path.get_text(): 
     321            gen_code[Locations.misc].append( 
     322                '%(wm_name)s.set_wallpaper(%(wallpaper_path)s)') 
     323 
    286324class PluginsPage(BasePage): 
    287325    label = 'plugins' 
     
    304342        cell = gtk.CellRendererText() 
    305343        self.plugins.pack_start(cell, True) 
    306         self.plugins.set_cell_data_func(cell, self.show_plugin_name) 
     344        self.plugins.set_cell_data_func(cell, self.show_obj_name) 
    307345        self.plugins.set_active(0) 
    308346        hbox.add(self.plugins) 
    309347        hbox.add(button) 
    310  
    311     @staticmethod 
    312     def show_plugin_name(_, cell, store, iter): 
    313         plugin = store.get_value(iter, 0) 
    314         cell.set_property('text', plugin.__name__) 
    315348 
    316349    def add_plugin(self, _, vbox):