Changeset 4300
- Timestamp:
- 03/06/09 17:00:48 (4 years ago)
- Location:
- branch/NetworkInventory
- Files:
-
- 9 modified
-
. (modified) (1 prop)
-
higwidgets/higlabels.py (modified) (1 diff)
-
setup.py (modified) (1 diff)
-
umit/gui/CrashReport.py (modified) (1 diff)
-
umit/gui/NmapOutputViewer.py (modified) (1 diff)
-
umit/gui/OptionBuilder.py (modified) (29 diffs)
-
umit/gui/ProfileWizardEditor.py (modified) (3 diffs)
-
umit/gui/Search.py (modified) (2 diffs)
-
umit/gui/Splash.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branch/NetworkInventory
- Property svnmerge-integrated changed from /trunk:1-560,563-566,574,577-597,599-615,617-618,620-635,641-648,651,653-662,666-667,669-764,766-845,848-964,966-1038,1041,1047-1059,1070-1103,1113-1119,1139,1156-1187,1189,1196-1202,1206-1223,1225-1241,1244-1248,1251-1258,1260-1274,1276-1279,1281,1283-1284,1290-1295,1297-1305,1307-1308,1310-1311,1313-1322,1326,1328-1333,1335,1337-1397,1399-1418,1420-3939,3941-3945,3948-3952,3955-3978,3980-4122,4124-4287 to /trunk:1-560,563-566,574,577-597,599-615,617-618,620-635,641-648,651,653-662,666-667,669-764,766-845,848-964,966-1038,1041,1047-1059,1070-1103,1113-1119,1139,1156-1187,1189,1196-1202,1206-1223,1225-1241,1244-1248,1251-1258,1260-1274,1276-1279,1281,1283-1284,1290-1295,1297-1305,1307-1308,1310-1311,1313-1322,1326,1328-1333,1335,1337-1397,1399-1418,1420-3939,3941-3945,3948-3952,3955-3978,3980-4122,4124-4299
-
branch/NetworkInventory/higwidgets/higlabels.py
r4028 r4300 131 131 """ 132 132 def __init__(self, text=None, underline=False): 133 gtk.Label.__init__(self, text) 133 gtk.Label.__init__(self) 134 if text is not None: 135 self.set_text(text) 134 136 self.set_justify(gtk.JUSTIFY_LEFT) 135 137 self.set_alignment(0, 0.50) -
branch/NetworkInventory/setup.py
r4289 r4300 390 390 'License :: OSI Approved :: GNU General Public License (GPL)', 391 391 'Programming Language :: Python :: 2', 392 'Programming Language :: Python :: 2.5' 392 'Programming Language :: Python :: 2.4', 393 'Programming Language :: Python :: 2.5', 393 394 'Programming Language :: Python :: 2.6', 394 395 'Topic :: System :: Networking', -
branch/NetworkInventory/umit/gui/CrashReport.py
r4252 r4300 174 174 self.destroy() 175 175 gtk.main_quit() 176 sys.exit(0)177 176 178 177 def get_description(self): -
branch/NetworkInventory/umit/gui/NmapOutputViewer.py
r4252 r4300 417 417 418 418 buff = n.text_view.get_buffer() 419 buff.set_text( read_file("file_with_encoding_issues.txt"))420 419 buff.set_text(open("file_with_encoding_issues.txt", 'rb').read()) 420 421 421 gtk.main() -
branch/NetworkInventory/umit/gui/OptionBuilder.py
r4252 r4300 1 #!/usr/bin/env python2 1 # -*- coding: utf-8 -*- 3 2 # … … 21 20 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 22 21 22 import os 23 import sys 23 24 import gtk 24 25 25 from xml.dom import minidom 26 26 … … 29 29 from higwidgets.higbuttons import HIGButton 30 30 31 from umit.gui.ScriptManager import ScriptChooserDialog #MAX31 from umit.gui.ScriptManager import ScriptChooserDialog 32 32 from umit.gui.FileChoosers import AllFilesFileChooserDialog 33 34 #from umit.core.UmitConf import is_maemo35 33 36 34 from umit.core.NmapOptions import NmapOptions 37 35 from umit.core.I18N import _ 36 from umit.core.Utils import amiroot 38 37 from umit.core.OptionsConf import options_file 39 import os, sys 40 41 ## Integration 42 #class OptionTab(object): 43 #def __init__(self, root_tab, options, constructor, update_func): 44 #actions = {'option_list':self.__parse_option_list,\ 45 #'option_check':self.__parse_option_check} 46 47 #<<<<<<< .working 38 39 48 40 class OptionTab(object): 49 41 def __init__(self, root_tab, options, constructor, update_func): 50 actions = {'option_list':self.__parse_option_list,\ 51 'option_check':self.__parse_option_check} 42 actions = { 43 'option_list':self.__parse_option_list, 44 'option_check':self.__parse_option_check} 52 45 53 46 self.options = options … … 57 50 58 51 options_used = self.constructor.get_options() 59 52 60 53 # Cannot use list comprehhension because text nodes raise exception 61 54 # when tagName is called … … 65 58 else: 66 59 if option_element.tagName in actions.keys(): 67 self.widgets_list.append(actions[option_element.tagName](option_element, options_used)) 60 self.widgets_list.append( 61 actions[option_element.tagName](option_element, 62 options_used)) 68 63 69 64 def __parse_option_list(self, option_list, options_used): 70 65 options = option_list.getElementsByTagName(u'option') 71 66 72 67 label = HIGEntryLabel(option_list.getAttribute(u'label')) 73 68 opt_list = OptionList() 74 69 75 70 for opt in options: 76 71 opt_list.append(self.options.get_option(opt.getAttribute(u'name'))) 77 72 78 73 for i, row in enumerate(opt_list.list): 79 74 if row[0] in options_used: 80 75 opt_list.set_active(i) 81 76 82 77 return label, opt_list 83 84 def is_root(self): 85 """ 86 Returns if is a root users 87 """ 88 89 root = False 90 try: 91 if sys.platform == 'win32': root = True 92 elif os.getuid() == 0: root = True 93 except: pass 94 return root 95 78 96 79 def _disable_option(self, need_root): 97 80 """ 98 81 enable / disable option if non-root user. 99 82 """ 100 is_root = self.is_root() 101 102 return not is_root and need_root 103 104 83 return not amiroot() and need_root 84 85 105 86 def __with_icon(self, hint): 106 87 """ … … 108 89 """ 109 90 return hint!="" 110 91 111 92 def __parse_option_check(self, option_check, options_used): 112 #arg_type = option_check.getAttribute(u'arg_type')113 114 93 option = option_check.getAttribute(u'option') 115 94 arg_type = self.options.get_arg_type(option) … … 124 103 else: 125 104 check = OptionCheck(label, opt_parse) 126 check.set_active(option in options_used) 105 check.set_active(option in options_used) 127 106 if self._disable_option(need_root): 128 107 check.disable_widget() 129 type_mapping = { 130 "str": OptionEntry, 131 "int": OptionIntSpin, 132 "float": OptionFloatSpin, 133 "level": OptionLevelSpin, 134 "path": OptionFile, 135 "interface": OptionInterface, 136 "scriptlist": OptionScriptList 137 } 108 type_mapping = { 109 "str": OptionEntry, 110 "int": OptionIntSpin, 111 "float": OptionFloatSpin, 112 "level": OptionLevelSpin, 113 "path": OptionFile, 114 "interface": OptionInterface, 115 "scriptlist": OptionScriptList} 138 116 139 117 additional = None … … 171 149 elif te == type(OptionInterface()): 172 150 widget[1].child.connect('changed', self.update_entry, widget[0]) 173 151 174 152 def update_check(self, check, extra): 175 153 if check.get_active(): … … 191 169 192 170 self.update_command() 193 171 194 172 def update_entry(self, widget, check): 195 173 if not check.get_active(): … … 198 176 self.constructor.remove_option(check.option['name']) 199 177 self.constructor.add_option(check.option['name'], widget.get_text()) 200 178 201 179 self.update_command() 202 180 203 181 def update_level(self, widget, check): 204 182 if not check.get_active(): 205 183 check.set_active(True) 206 184 207 185 try: 208 186 self.constructor.remove_option(check.option['name']) … … 210 188 check.set_active(False) 211 189 else: 212 self.constructor.add_option(check.option['name'],\ 213 level=int(widget.get_text())) 190 self.constructor.add_option( 191 check.option['name'], 192 level=int(widget.get_text())) 214 193 except:pass 215 194 216 195 self.update_command() 217 196 … … 221 200 else: 222 201 self.constructor.remove_option(widget.last_selected) 223 202 224 203 option_name = widget.options[widget.get_active()]['name'] 225 204 226 205 self.constructor.add_option(option_name) 227 206 widget.last_selected = option_name 228 207 229 208 self.update_command() 230 209 … … 232 211 if self.update_func: 233 212 self.update_func() 234 235 213 214 236 215 class OptionBuilder(object): 237 216 def __init__(self, xml_file, constructor, update_func): … … 248 227 self.constructor = constructor 249 228 self.update_func = update_func 250 229 251 230 self.root_tag = "interface" 252 231 253 232 self.xml = self.xml.getElementsByTagName(self.root_tag)[0] 254 233 self.options = NmapOptions(options_file) 255 234 256 235 self.groups = self.__parse_groups() 257 236 self.section_names = self.__parse_section_names() 258 237 self.tabs = self.__parse_tabs() 259 238 260 239 261 240 def __parse_section_names(self): … … 265 244 dic[group] = grp.getAttribute(u'label') 266 245 return dic 267 246 268 247 def __parse_groups(self): 269 248 return [g_name.getAttribute(u'name') for g_name in \ … … 274 253 dic = {} 275 254 for tab_name in self.groups: 276 dic[tab_name] = OptionTab(self.xml.getElementsByTagName(tab_name)[0], 277 self.options, 278 self.constructor, 279 self.update_func) 255 dic[tab_name] = OptionTab( 256 self.xml.getElementsByTagName(tab_name)[0], 257 self.options, 258 self.constructor, 259 self.update_func) 280 260 return dic 281 261 … … 284 264 def enable_widget(self): 285 265 self.set_sensitive(True) 286 266 287 267 def disable_widget(self): 288 268 self.set_sensitive(False) … … 292 272 self.list = gtk.ListStore(str) 293 273 gtk.ComboBoxEntry.__init__(self, self.list) 294 274 295 275 cell = gtk.CellRendererText() 296 276 self.pack_start(cell, True) … … 301 281 self.list = gtk.ListStore(str) 302 282 gtk.ComboBox.__init__(self, self.list) 303 283 304 284 cell = gtk.CellRendererText() 305 285 self.pack_start(cell, True) 306 286 self.add_attribute(cell, 'text', 0) 307 287 308 288 self.options = [] 309 289 310 290 def append(self, option): 311 291 self.list.append([option[u'name']]) … … 314 294 class OptionCheckIcon(HIGHBox, OptionWidget): 315 295 def __init__(self, label=None, option=None, hint=None): 316 296 317 297 HIGHBox.__init__(self) 318 298 319 299 self.cbutton = OptionCheck(label,option) 320 300 self.option = option … … 322 302 self.pack_start(self.cbutton, False, False) 323 303 self.pack_start(self.hint, False, False, 5) 324 304 325 305 def connect(self, action, func, additional): 326 306 """ 327 connect checkbox 307 connect checkbox 328 308 """ 329 309 self.cbutton.connect(action, func, additional) 330 310 331 311 def set_active(self, value): 332 312 """ … … 334 314 """ 335 315 self.cbutton.set_active(value) 336 316 337 317 def get_active(self): 338 318 return self.cbutton.get_active() 339 319 340 320 def get_checkbox(self): 341 321 """ 342 Returns checkbox 322 Returns checkbox 343 323 example, to do connection 344 324 """ 345 325 return self.cbutton 346 326 347 327 def get_option(self): 348 328 return self.cbutton.get_option() 349 329 350 330 class OptionScriptList(HIGHBox, OptionWidget, object): 351 # From MAX352 331 def __init__(self): 353 332 HIGHBox.__init__(self) 354 333 355 334 self.entry = OptionEntry() 356 335 self.button = HIGButton(stock=gtk.STOCK_EDIT) 357 336 358 337 self._pack_expand_fill(self.entry) 359 338 self._pack_noexpand_nofill(self.button) 360 339 361 340 self.button.connect('clicked', self.open_dialog_cb) 341 362 342 def open_dialog_cb(self, widget): 363 343 dialog = ScriptChooserDialog(self.entry.get_text()) … … 369 349 def __init__(self, label=None, option=None): 370 350 gtk.CheckButton.__init__(self, label) 371 351 372 352 self.option = option 373 353 374 354 def get_option(self): 375 355 return self.option … … 400 380 def __init__(self, param=""): 401 381 HIGHBox.__init__(self) 402 382 403 383 self.entry = OptionEntry() 404 384 self.button = HIGButton(stock=gtk.STOCK_OPEN) 405 385 406 386 self._pack_expand_fill(self.entry) 407 387 self._pack_noexpand_nofill(self.button) … … 409 389 self.entry.set_text(param) 410 390 self.button.connect('clicked', self.open_dialog_cb) 411 391 412 392 def open_dialog_cb(self, widget): 413 393 dialog = AllFilesFileChooserDialog(_("Choose file")) … … 429 409 430 410 self.hint_image = gtk.Image() 431 self.hint_image.set_from_stock(gtk.STOCK_DIALOG_INFO, gtk.ICON_SIZE_SMALL_TOOLBAR) 411 self.hint_image.set_from_stock( 412 gtk.STOCK_DIALOG_INFO, 413 gtk.ICON_SIZE_SMALL_TOOLBAR) 432 414 433 415 self.add(self.hint_image) 434 416 self.add_events(gtk.gdk.BUTTON_MOTION_MASK) 435 417 self.connect("button-press-event", self.show_hint) 436 #self.connect("enter-notify-event", self.show_hint) 437 418 438 419 439 420 def show_hint(self, widget, event=None): … … 441 422 hint_window.show_all() 442 423 443 424 444 425 class HintWindow(gtk.Window): 445 426 446 427 def __init__(self, hint): 447 428 gtk.Window.__init__(self, gtk.WINDOW_POPUP) 448 429 self.set_position(gtk.WIN_POS_MOUSE) 449 430 bg_color = gtk.gdk.color_parse("#fbff99") 450 431 451 432 self.modify_bg(gtk.STATE_NORMAL, bg_color) 452 433 … … 455 436 self.event.set_border_width(10) 456 437 self.event.connect("button-press-event", self.close) 457 #self.event.connect("leave-notify-event", self.close)458 438 self.hint_label = gtk.Label(hint) 459 439 self.hint_label.set_use_markup(True) 460 440 self.hint_label.set_line_wrap(True) 461 441 462 442 self.event.add(self.hint_label) 463 443 self.add(self.event) … … 465 445 def close(self, widget, event=None): 466 446 self.destroy() 467 468 if __name__ == '__main__':469 o = OptionBuilder('profile_editor.xml')470 471 ol = OptionFile()472 w = gtk.Window()473 w.add(ol)474 w.show_all()475 w.connect('delete-event', lambda x,y,z=None: gtk.main_quit())476 gtk.main() -
branch/NetworkInventory/umit/gui/ProfileWizardEditor.py
r4252 r4300 194 194 box = HIGHBox() 195 195 box._pack_expand_fill(self.treeview) 196 self.profile_group_sw.add (box)196 self.profile_group_sw.add_with_viewport(box) 197 197 198 198 … … 290 290 column = gtk.TreeViewColumn("Name", renderer, text=0) 291 291 treeview.append_column(column) 292 self.prop_frame_option.add(treeview)292 prop_sw.add(treeview) 293 293 self.prop_frame_option.add(prop_sw) 294 294 … … 306 306 self.prop_exp = HIGExpander("Proprieties") 307 307 308 label = gtk.Label('s') 309 self.prop_exp.add(label) 310 self.prop_frame.add(self.prop_exp) 311 308 self.prop_frame.add(self.prop_exp) 309 312 310 313 311 -
branch/NetworkInventory/umit/gui/Search.py
r4252 r4300 86 86 self.fraction 87 87 except: 88 self.fraction = 0.2 88 self.fraction = 0.2 89 89 self.progress.set_fraction(self.fraction + self.progress.get_fraction()) 90 90 … … 92 92 filename = property(get_filename, 93 93 set_filename, 94 doc=_("File name beensearched"))94 doc=_("File's name being searched")) 95 95 path = property(get_path, 96 96 set_path, 97 doc=_("Path be enscanned"))97 doc=_("Path being scanned")) 98 98 fraction = property(get_fraction, 99 99 set_fraction, -
branch/NetworkInventory/umit/gui/Splash.py
r4252 r4300 76 76 77 77 if __name__ == "__main__": 78 from os.path import join79 s = Splash( join(".", "share", "pixmaps", "splash.png"))78 import os 79 s = Splash(os.path.join(".", "share", "pixmaps", "umit", "splash.png")) 80 80 gtk.main()
