Changeset 895

Show
Ignore:
Timestamp:
06/29/07 16:57:47 (6 years ago)
Author:
kop-labs
Message:

copy

Location:
branch/k0p
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • branch/k0p/umitCore/UmitConf.py

    r871 r895  
    203203            return self.set(profile, attribute, value) 
    204204 
    205     def add_profile(self, profile_name, **attributes): 
     205    def add_profile(self, profile_name, save=True, **attributes): 
    206206        try: self.add_section(profile_name) 
    207207        except: return None 
     
    212212        for opt in options: 
    213213            if options[opt]: 
    214                 self._set_it(profile_name, opt, options[opt]) 
    215         self.save_changes() 
     214                self._set_it(profile_name, opt, options[opt], save) 
     215        if save: 
     216            self.save_changes() 
     217         
    216218 
    217219    def remove_profile(self, profile_name): 
  • branch/k0p/umitGUI/ProfileEditor.py

    r891 r895  
    321321        self.deleted=False         
    322322        self.quit() 
    323          
    324    
    325      
    326          
    327          
     323 
    328324 
    329325 
  • branch/k0p/umitGUI/ProfileManager.py

    r894 r895  
    3030 
    3131from umitGUI.Wizard import Wizard 
    32  
     32from umitCore.NmapCommand import CommandConstructor 
    3333# Testing at devel  
    3434from os.path import split, join 
     
    101101        self.cancel_button.connect("clicked", self.quit) 
    102102        self.ok_button = HIGButton(stock='gtk-ok') 
     103        self.ok_button.connect("clicked", self.apply_modifications) 
    103104 
    104105    def __fill_widgets(self): 
     
    194195        Copy selected Profile 
    195196        """ 
     197 
     198 
    196199        d = ProfileName(_("Insert a profile name")) 
     200        profile_name = d.run() 
     201        if profile_name == None: 
     202            return None 
     203        #get commands of selected profile 
     204        profile_selected = self.get_selected_profile() 
     205        command = self.profiles.get_command(profile_selected) 
     206        hint = self.profiles.get_hint(profile_selected) 
     207        description = self.profiles.get_description(profile_selected) 
     208        annotation = self.profiles.get_annotation(profile_selected) 
     209        #Options??? 
     210        prof = self.profiles.get_profile(profile_selected) 
     211        options_used = prof['options'] 
     212        options = CommandConstructor(options_used) 
     213 
     214        self.profiles.add_profile(profile_name,\ 
     215                                  save = False,\ 
     216                                  command=command,\ 
     217                                  hint=hint,\ 
     218                                  description=description,\ 
     219                                  annotation=annotation,\ 
     220                                  options=options.get_options()) 
     221         
     222        myiter = self.model.insert_after(None, None) 
     223        self.model.set_value(myiter, 0, profile_name) 
     224         
    197225 
    198226    def delete_profile(self, widget=None): 
     
    206234        model.remove(iter)       
    207235         
    208          
    209      
     236    def _reload_profile_list(self): 
     237        """ 
     238        Reload a list of profiles 
     239        """ 
     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         
     251         
     252         
    210253    def quit(self, widget): 
    211254        self.destroy() 
    212          
    213 class ProfileName: 
     255     
     256         
     257class ProfileName(HIGDialog): 
    214258    def __init__(self, text): 
    215         d = HIGDialog(title=_('Profile\'s Name'), 
    216                       buttons=(gtk.STOCK_OK, gtk.RESPONSE_ACCEPT)) 
     259        HIGDialog.__init__(self, _('Profile\'s Name')) 
     260 
    217261        dialog_label = HIGDialogLabel(text) 
    218262        dialog_label.show() 
    219         d.vbox.pack_start(dialog_label) 
    220  
    221         entry_text = HIGTextEntry() 
    222         entry_text.show() 
    223         d.vbox.pack_start(entry_text) 
    224          
    225         d.run() 
    226          
    227         d.destroy() 
     263        self.vbox.pack_start(dialog_label) 
     264        self.entry_text = HIGTextEntry() 
     265        self.entry_text.show() 
     266        self.vbox.pack_start(self.entry_text) 
     267        self.add_button(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL) 
     268        self.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK) 
     269     
     270    def run(self): 
     271        """ 
     272        Returns text of entry 
     273        and None if someone clicked Cancel. 
     274        """ 
     275        text = None 
     276        response = HIGDialog.run(self) 
     277        text = self.entry_text.get_text() 
     278        if response==gtk.RESPONSE_CANCEL: 
     279            text = None 
     280        self.destroy() 
     281        return text 
     282 
    228283         
    229284class ProfileChosse(HIGHBox):