Changeset 902 for branch/k0p/umitGUI/ProfileManager.py
- Timestamp:
- 06/30/07 15:07:29 (6 years ago)
- Files:
-
- 1 modified
-
branch/k0p/umitGUI/ProfileManager.py (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branch/k0p/umitGUI/ProfileManager.py
r895 r902 65 65 66 66 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 70 72 self.vbox = HIGVBox() 71 73 self.profiles_sw = HIGScrolledWindow() 72 74 #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) 75 76 self.profiles_tv = gtk.TreeView(self.model) 76 77 renderer = gtk.CellRendererText() 77 78 column = gtk.TreeViewColumn("Name", renderer, text=0) 78 79 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) 79 83 80 84 … … 87 91 #Buttons 88 92 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') 90 98 self.edit_button.connect("clicked", self.open_peditor) 91 99 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) 93 101 self.copy_button = HIGButton(stock='gtk-copy') 94 102 self.copy_button.connect("clicked", self.copy_profiles) 95 103 self.delete_button = HIGButton(stock=gtk.STOCK_DELETE) 96 104 self.delete_button.connect('clicked', self.delete_profile) 97 105 98 106 #Apply Buttons 99 self.hbox_apply = HIGHBox() 100 self.cancel_button = HIGButton(stock='gtk-cancel') 107 self.cancel_button = HIGButton(stock='gtk-close') 101 108 self.cancel_button.connect("clicked", self.quit) 102 self.ok_button = HIGButton(stock='gtk-ok')103 self.ok_button.connect("clicked", self.apply_modifications)104 109 105 110 def __fill_widgets(self): … … 107 112 108 113 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 117 118 #selection = self.profiles_tv.get_selection() 118 119 #selection.connect("changed", self.change_nmap_command) … … 125 126 Pack all widgets of windows 126 127 """ 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) 129 132 130 133 self.vbox.pack_start(self.profiles_sw, True, True, 0) … … 132 135 self.hbox_info.pack_start(self.command_label, False,False,0) 133 136 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 145 150 self.profiles_sw.set_size_request(400,170) 146 151 self.profiles_sw.add_with_viewport(self.profiles_tv) 147 152 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 151 154 152 155 def get_selected_profile(self): … … 164 167 """ 165 168 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())) 168 175 169 176 def new_wiz(self,widget): 170 177 w = Wizard() 171 178 w.set_notebook(None) 172 179 w.set_profilemanager(self.model) 173 180 w.show_all() 181 174 182 175 183 def open_peditor(self, widget): … … 189 197 # New Profile 190 198 pe = ProfileEditor() 199 pe.set_profilemanager(self.model) 191 200 pe.show_all() 201 self._reload_profile_list() 192 202 193 203 def copy_profiles(self, widget): … … 195 205 Copy selected Profile 196 206 """ 197 198 207 199 208 d = ProfileName(_("Insert a profile name")) … … 213 222 214 223 self.profiles.add_profile(profile_name,\ 215 save = False,\216 224 command=command,\ 217 225 hint=hint,\ … … 220 228 options=options.get_options()) 221 229 222 myiter = self.model.insert_after(None, None) 230 231 232 myiter = self.model.insert_before(None, None) 223 233 self.model.set_value(myiter, 0, profile_name) 234 self.model.set_value(myiter,1, self.profiles.get_hint(profile_name)) 224 235 225 236 … … 228 239 delete profile only at treeview 229 240 """ 230 #self.profiles.remove_profile()241 self.profiles.remove_profile(self.get_selected_profile()) 231 242 #Update treeview 232 243 treeselection = self.profiles_tv.get_selection() 233 244 (model,iter) = treeselection.get_selected() 234 model.remove(iter) 245 model.remove(iter) 246 247 248 235 249 236 250 def _reload_profile_list(self): … … 238 252 Reload a list of profiles 239 253 """ 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 251 264 252 265
