Changeset 3393
- Timestamp:
- 08/10/08 13:13:43 (5 years ago)
- Location:
- branch/PacketManipulator
- Files:
-
- 3 modified
-
Dialogs/Preferences.py (modified) (7 diffs)
-
Manager/PreferenceManager.py (modified) (2 diffs)
-
pm-prefs.xml (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branch/PacketManipulator/Dialogs/Preferences.py
r3364 r3393 32 32 33 33 def set_active_text(combo, text): 34 print "implement me" 34 model = combo.get_model() 35 36 for idx in xrange(len(model)): 37 value = model.get_value(model.get_iter((idx, )), 0) 38 39 if value.lower() == text.lower(): 40 combo.set_active(idx) 41 return 35 42 36 43 TYPES = ( … … 64 71 65 72 self.set_border_width(4) 73 self.set_row_spacings(4) 74 66 75 self.create_ui() 67 76 self.show_all() … … 70 79 pass 71 80 81 def __create_option_widgets(self, name, lbl, widget): 82 label = None 83 84 if lbl: 85 label = gtk.Label(lbl) 86 label.set_use_markup(True) 87 label.set_alignment(0, 0.5) 88 89 for typo, func in CONSTRUCTORS: 90 if isinstance(widget, typo): 91 92 value = Prefs()[name].value 93 func(widget, value) 94 95 break 96 97 return label, widget 98 72 99 def create_ui(self): 73 idx = 0 74 75 for (name, lbl, widget) in self.widgets: 76 77 if lbl: 78 label = gtk.Label("<b>%s</b>" % lbl) 100 gidx = 0 101 102 for options in self.widgets: 103 104 if isinstance(options[1], tuple): 105 frame = gtk.Frame() 106 table = gtk.Table(len(options[1]), 2) 107 108 label = gtk.Label("<b>%s</b>" % options[0]) 79 109 label.set_use_markup(True) 80 label.set_alignment(0, 0.5) 81 82 self.attach(label, 0, 1, idx, idx + 1, yoptions=gtk.SHRINK) 83 self.attach(widget, 1, 2, idx, idx + 1, yoptions=gtk.SHRINK) 110 111 frame.set_label_widget(label) 112 frame.add(table) 113 114 table.set_border_width(4) 115 table.set_row_spacings(4) 116 117 idx = 0 118 for name, lbl, widget in options[1]: 119 lbl, widget = self.__create_option_widgets(name, lbl, widget) 120 121 if lbl: 122 table.attach(lbl, 0, 1, idx, idx + 1, yoptions=gtk.SHRINK) 123 table.attach(widget, 1, 2, idx, idx + 1, yoptions=gtk.SHRINK) 124 else: 125 table.attach(widget, 0, 2, idx, idx + 1, yoptions=gtk.SHRINK) 126 127 idx += 1 128 129 self.attach(frame, 0, 2, gidx, gidx + 1, yoptions=gtk.SHRINK) 84 130 else: 85 self.attach(widget, 0, 2, idx, idx + 1, yoptions=gtk.SHRINK) 86 87 for typo, func in CONSTRUCTORS: 88 if isinstance(widget, typo): 89 90 print func, widget, name 91 value = Prefs()[name].value 92 func(widget, value) 93 94 break 95 96 idx += 1 131 lbl, widget = self.__create_option_widgets(options[0], options[1], options[2]) 132 133 if lbl: 134 self.attach(lbl, 0, 1, gidx, gidx + 1, yoptions=gtk.SHRINK) 135 self.attach(widget, 1, 2, gidx, gidx + 1, yoptions=gtk.SHRINK) 136 else: 137 self.attach(widget, 0, 2, gidx, gidx + 1, yoptions=gtk.SHRINK) 138 139 gidx += 1 97 140 98 141 class GUIPage(Page): … … 103 146 self.widgets = [ 104 147 ('gui.docking', None, gtk.CheckButton('Use docking windows')), 105 ('gui.maintab.sniffview.font', 'Sniff view font:', gtk.FontButton()), 106 ('gui.maintab.sniffview.usecolors', None, gtk.CheckButton('Colorize rows')), 107 ('gui.maintab.hexview.font', 'HexView font:', gtk.FontButton()), 108 ('gui.maintab.hexview.bpl', 'Bytes per line:', gtk.SpinButton(gtk.Adjustment(8, 1, 16, 1, 1))) 148 149 ('Sniff perspective', 150 (('gui.maintab.sniffview.font', 'Sniff view font:', gtk.FontButton()), 151 ('gui.maintab.sniffview.usecolors', None, gtk.CheckButton('Colorize rows')))), 152 153 ('Hex view window', 154 (('gui.maintab.hexview.font', 'HexView font:', gtk.FontButton()), 155 ('gui.maintab.hexview.bpl', 'Bytes per line:', gtk.SpinButton(gtk.Adjustment(8, 1, 16, 1, 1))))) 109 156 ] 110 157 … … 159 206 self.vbox.pack_start(hbox) 160 207 self.vbox.set_border_width(4) 161 self.vbox.set_spacing(4) 208 self.vbox.set_spacing(6) 209 210 self.set_size_request(600, 400) 162 211 163 212 self.tree.get_selection().connect('changed', self.__on_switch_page) … … 183 232 page = self.notebook.get_nth_page(idx) 184 233 185 for option, lbl, widget in page.widgets: 186 187 for typo, func in TYPES: 188 if isinstance(widget, typo): 189 190 # We should call the functions 191 new_value = func(widget) 192 193 print "Setting", option, new_value 194 Prefs()[option].value = new_value 195 196 break 234 for options in page.widgets: 235 236 if isinstance(options[1], tuple): 237 for option, lbl, widget in options[1]: 238 self.__apply(widget, option) 239 else: 240 self.__apply(options[2], options[0]) 241 242 def __apply(self, widget, option): 243 for typo, func in TYPES: 244 if isinstance(widget, typo): 245 246 # We should call the functions 247 new_value = func(widget) 248 249 Prefs()[option].value = new_value 250 251 break 252 253 def save_changes(self): 254 Prefs().write_options() 197 255 198 256 def __on_response(self, dialog, id): … … 203 261 elif id == gtk.RESPONSE_OK: 204 262 self.apply_changes() 263 self.save_changes() 205 264 self.close() 206 265 -
branch/PacketManipulator/Manager/PreferenceManager.py
r3364 r3393 113 113 attr_vals = { 114 114 (None, u'id') : key, 115 (None, u'value') : option.value115 (None, u'value') : str(option.value) 116 116 } 117 117 … … 136 136 'gui.maintab.hexview.bpl' : 16, 137 137 138 'backend.system' : ' umpa',138 'backend.system' : 'scapy', 139 139 } 140 140 -
branch/PacketManipulator/pm-prefs.xml
r3347 r3393 1 <str id='backend.system' value='scapy'/> 1 <?xml version="1.0" encoding="utf-8"?> 2 <int value="16" id="gui.maintab.hexview.bpl"></int><bool value="False" id="gui.maintab.sniffview.usecolors"></bool><str value="Monospace 10" id="gui.maintab.hexview.font"></str><str value="Scapy" id="backend.system"></str><bool value="True" id="gui.docking"></bool><str value="Monospace 10" id="gui.maintab.sniffview.font"></str>
