Show
Ignore:
Timestamp:
06/30/07 15:07:29 (6 years ago)
Author:
kop-labs
Message:

fix of visual

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branch/k0p/umitGUI/ProfileManager.py

    r895 r902  
    6565         
    6666        self.main_frame = HIGFrame("Profiles") 
    67         self.main_frame.set_shadow_type(gtk.SHADOW_ETCHED_OUT) 
    68          
    69          
     67        #self.main_frame.set_shadow_type(gtk.SHADOW_ETCHED_OUT) 
     68 
     69        self.align = gtk.Alignment(0.0, 0.0, 1.0, 1.0) 
     70        self.align.set_padding(0,0,12,0) 
     71         
    7072        self.vbox = HIGVBox() 
    7173        self.profiles_sw = HIGScrolledWindow() 
    7274        #TreeView 
    73         self.hbox_aux_tv = HIGHBox() 
    74         self.model = gtk.TreeStore(gobject.TYPE_STRING) 
     75        self.model = gtk.TreeStore(gobject.TYPE_STRING, gobject.TYPE_STRING) 
    7576        self.profiles_tv = gtk.TreeView(self.model) 
    7677        renderer = gtk.CellRendererText() 
    7778        column = gtk.TreeViewColumn("Name", renderer, text=0) 
    7879        self.profiles_tv.append_column(column) 
     80        renderer_hint = gtk.CellRendererText() 
     81        column_hint = gtk.TreeViewColumn("Hint", renderer_hint, text=1) 
     82        self.profiles_tv.append_column(column_hint) 
    7983         
    8084 
     
    8791        #Buttons 
    8892        self.hbox_buttons = HIGHBox() 
    89         self.edit_button = HIGButton(stock='gtk-edit') 
     93 
     94        self.wiz_button = HIGButton(title='Wizard', stock='gtk-convert') 
     95        self.wiz_button.connect("clicked", self.new_wiz) 
     96 
     97        self.edit_button = HIGButton(stock='gtk-edit') 
    9098        self.edit_button.connect("clicked", self.open_peditor) 
    9199        self.new_button = HIGButton(stock='gtk-new') 
    92         self.new_button.connect("clicked", self.new_wiz) 
     100        self.new_button.connect("clicked", self.open_peditor) 
    93101        self.copy_button = HIGButton(stock='gtk-copy') 
    94102        self.copy_button.connect("clicked", self.copy_profiles) 
    95103        self.delete_button = HIGButton(stock=gtk.STOCK_DELETE) 
    96104        self.delete_button.connect('clicked', self.delete_profile)       
    97          
     105         
    98106        #Apply Buttons 
    99         self.hbox_apply = HIGHBox() 
    100         self.cancel_button = HIGButton(stock='gtk-cancel') 
     107        self.cancel_button = HIGButton(stock='gtk-close') 
    101108        self.cancel_button.connect("clicked", self.quit) 
    102         self.ok_button = HIGButton(stock='gtk-ok') 
    103         self.ok_button.connect("clicked", self.apply_modifications) 
    104109 
    105110    def __fill_widgets(self): 
     
    107112                 
    108113        self.profiles = CommandProfile() 
    109         profiles = self.profiles.sections() 
    110         profiles.sort() 
    111          
    112         
    113         for command in profiles: 
    114             myiter = self.model.insert_after(None, None) 
    115             self.model.set_value(myiter, 0, command) 
    116              
     114 
     115 
     116        self._reload_profile_list() 
     117 
    117118        #selection = self.profiles_tv.get_selection() 
    118119        #selection.connect("changed", self.change_nmap_command) 
     
    125126        Pack all widgets of windows  
    126127        """ 
    127         self.vbox_main.pack_start(self.main_frame) 
    128         self.main_frame.add(self.vbox) 
     128        self.vbox_main.pack_start(self.main_frame, True, True) 
     129        self.main_frame.add(self.align) 
     130        self.align.add(self.vbox) 
     131        self.vbox.set_border_width(6) 
    129132         
    130133        self.vbox.pack_start(self.profiles_sw, True, True, 0) 
     
    132135        self.hbox_info.pack_start(self.command_label, False,False,0) 
    133136        self.hbox_info.pack_start(self.command_entry, True, True, 0) 
    134         self.vbox.pack_start(self.hbox_info, True, True,0) 
    135          
    136         self.vbox.pack_start(self.hbox_buttons, False, True, 0) 
    137          
    138         self.hbox_buttons.pack_end(self.copy_button, False, True) 
    139         self.hbox_buttons.pack_end(self.edit_button, False, True) 
    140         self.hbox_buttons.pack_end(self.delete_button, False, True) 
    141         self.hbox_buttons.pack_end(self.new_button, False, True) 
    142  
    143          
    144         #self.hbox_aux_tv .pack_start(self.profiles_tv,False, False) 
     137        self.vbox.pack_start(self.hbox_info, False,False,0) 
     138         
     139 
     140 
     141        self.hbox_buttons.pack_end(self.cancel_button)     
     142        self.hbox_buttons.pack_end(self.copy_button, True, True) 
     143        self.hbox_buttons.pack_end(self.edit_button, True, True) 
     144        self.hbox_buttons.pack_end(self.delete_button, True, True) 
     145        self.hbox_buttons.pack_end(self.new_button, True, True) 
     146        self.hbox_buttons.pack_end(self.wiz_button, True, True) 
     147        self.hbox_buttons.set_spacing(6) 
     148        self.vbox_main.pack_start(self.hbox_buttons, False, False) 
     149         
    145150        self.profiles_sw.set_size_request(400,170) 
    146151        self.profiles_sw.add_with_viewport(self.profiles_tv)  
    147152 
    148         self.hbox_apply.pack_end(self.ok_button) 
    149         self.hbox_apply.pack_end(self.cancel_button) 
    150         self.vbox_main.pack_start(self.hbox_apply) 
     153 
    151154         
    152155    def get_selected_profile(self): 
     
    164167        """ 
    165168        assert widget_tv != None 
    166          
    167         self.command_entry.set_text(self.profiles.get_command(self.get_selected_profile()))      
     169        # it call __init__ because when wizard or profile are open,   
     170        # need update profiles 
     171        self.profiles.__init__() 
     172        # update text entry of command 
     173        self.command_entry.set_text(self.profiles.get_command( 
     174            self.get_selected_profile()))        
    168175     
    169176    def new_wiz(self,widget): 
    170177        w = Wizard() 
    171178        w.set_notebook(None) 
    172          
     179        w.set_profilemanager(self.model) 
    173180        w.show_all() 
     181         
    174182 
    175183    def open_peditor(self, widget): 
     
    189197            # New Profile 
    190198            pe = ProfileEditor() 
     199            pe.set_profilemanager(self.model) 
    191200            pe.show_all() 
     201            self._reload_profile_list() 
    192202     
    193203    def copy_profiles(self, widget): 
     
    195205        Copy selected Profile 
    196206        """ 
    197  
    198207 
    199208        d = ProfileName(_("Insert a profile name")) 
     
    213222 
    214223        self.profiles.add_profile(profile_name,\ 
    215                                   save = False,\ 
    216224                                  command=command,\ 
    217225                                  hint=hint,\ 
     
    220228                                  options=options.get_options()) 
    221229         
    222         myiter = self.model.insert_after(None, None) 
     230         
     231         
     232        myiter = self.model.insert_before(None, None) 
    223233        self.model.set_value(myiter, 0, profile_name) 
     234        self.model.set_value(myiter,1, self.profiles.get_hint(profile_name)) 
    224235         
    225236 
     
    228239        delete profile only at treeview  
    229240        """ 
    230         #self.profiles.remove_profile() 
     241        self.profiles.remove_profile(self.get_selected_profile()) 
    231242        #Update treeview 
    232243        treeselection = self.profiles_tv.get_selection() 
    233244        (model,iter) = treeselection.get_selected() 
    234         model.remove(iter)       
     245        model.remove(iter) 
     246         
     247         
     248         
    235249         
    236250    def _reload_profile_list(self): 
     
    238252        Reload a list of profiles 
    239253        """ 
    240          
    241          
    242      
    243     def apply_modifications(self, widget): 
    244         """ 
    245         Apply changes when clicked ok. Save based on treeview.  
    246         """ 
    247          
    248         self.profiles.save_changes() 
    249          
    250          
     254        profiles = self.profiles.sections() 
     255        profiles.sort() 
     256        self.model.clear() 
     257         
     258        
     259        for command in profiles: 
     260            myiter = self.model.insert_before(None, None) 
     261            self.model.set_value(myiter, 0, command) 
     262            self.model.set_value(myiter,1, self.profiles.get_hint(command)) 
     263     
    251264         
    252265