def __init__(self): HIGVBox.__init__(self) self.set_spacing(12) table = HIGTable() self.hbox = HIGHBox() self.description = HIGEntryLabel( _("""You wish to create a new profile,\ or just want to quickly create a command and run it once?""")) self.profile_radio = gtk.RadioButton(None, _('Profile')) self.command_radio = gtk.RadioButton(self.profile_radio, _('Command')) self.command_radio.connect('toggled', self.enable_target) self.profile_radio.connect('toggled', self.disable_target) self.target_label = HIGEntryLabel(_("Target")) self.target_entry = gtk.Entry() self.set_completion() self.hbox._pack_noexpand_nofill(hig_box_space_holder()) self.hbox._pack_noexpand_nofill(self.target_label) self.hbox._pack_expand_fill(self.target_entry) self.bar = ForwardBar() self._pack_noexpand_nofill(self.description) self._pack_expand_fill(table) self._pack_noexpand_nofill(self.bar) table.attach(self.profile_radio, 0, 1, 0, 1, yoptions=0) table.attach(self.command_radio, 0, 1, 1, 2, yoptions=0) table.attach(self.hbox, 0, 1, 2, 3, yoptions=0) self.disable_target()
class ExposeWindow(TabBox): """ Import a Widget with a small preview of Umit (PreviewWindow) Aim of widget is change structure of Umit like hide menu, etc """ def __init__(self, name): """ Create defaults Widget """ TabBox.__init__(self, name) def _create_widgets(self): """ Create widgets""" # Create table and attach it contains self.__table = HIGTable(5,2) binary_mask = gtk.EXPAND|gtk.SHRINK p = PreviewWindowObj() p.set_size_request(300,300) align = gtk.Alignment() align.add(p) align.set_padding(10,10,10,10) self.__table.attach(align, 0,1,0,1,binary_mask, gtk.FILL) self.pack_start(self.__table, False, False) def _create_expose_interface(self): pass
def __init__(self): HIGVBox.__init__(self) self.set_spacing(12) table = HIGTable() self.hbox = HIGHBox() self.description = HIGEntryLabel(_("""You wish to create a new profile,\ or just want to quickly create a command and run it once?""")) self.profile_radio = gtk.RadioButton(None, _('Profile')) self.command_radio = gtk.RadioButton(self.profile_radio, _('Command')) self.command_radio.connect('toggled', self.enable_target) self.profile_radio.connect('toggled', self.disable_target) self.target_label = HIGEntryLabel(_("Target")) self.target_entry = gtk.Entry() self.set_completion() self.hbox._pack_noexpand_nofill(hig_box_space_holder()) self.hbox._pack_noexpand_nofill(self.target_label) self.hbox._pack_expand_fill(self.target_entry) self.bar = ForwardBar() self._pack_noexpand_nofill(self.description) self._pack_expand_fill(table) self._pack_noexpand_nofill(self.bar) table.attach(self.profile_radio,0,1,0,1, yoptions=0) table.attach(self.command_radio,0,1,1,2, yoptions=0) table.attach(self.hbox,0,1,2,3, yoptions=0) self.disable_target()
def __init__(self): HIGVBox.__init__(self) self.set_spacing(12) self.prof = False self.description = HIGEntryLabel(_("""Please, enter the profile name, \ and optionally, enter a hint, description and annotation for this \ new profile""")) self.profile_label = HIGEntryLabel(_("Profile name")) self.hint_label = HIGEntryLabel(_("Hint")) self.description_label = HIGEntryLabel(_("Description")) self.annotation_label = HIGEntryLabel(_("Annotation")) self.profile_entry = gtk.Entry() self.hint_entry = gtk.Entry() self.description_scroll = HIGScrolledWindow() self.description_text = HIGTextView() self.annotation_scroll = HIGScrolledWindow() self.annotation_text = HIGTextView() self.description_scroll.add(self.description_text) self.annotation_scroll.add(self.annotation_text) table = HIGTable() self.bar = ForwardBar() self._pack_noexpand_nofill(self.description) self._pack_expand_fill(table) self._pack_noexpand_nofill(self.bar) table.attach(self.profile_label,0,1,0,1,xoptions=0) table.attach(self.profile_entry,1,2,0,1) table.attach(self.hint_label,0,1,1,2,xoptions=0) table.attach(self.hint_entry,1,2,1,2) table.attach(self.description_label,0,1,2,3,xoptions=0) table.attach(self.description_scroll,1,2,2,3) table.attach(self.annotation_label,0,1,3,4,xoptions=0) table.attach(self.annotation_scroll,1,2,3,4)
def __do_layout(self): """ Layout window widgets. """ main_vbox = HIGVBox() main_vbox.set_border_width(5) main_vbox.set_spacing(12) header_hbox = HIGHBox() schedp_hbox = HIGHBox() cron_box = HIGVBox() cron_table = HIGTable(5, 2) btns_hbox = HIGHBox() header_hbox._pack_expand_fill(self.ttitle) header_hbox._pack_noexpand_nofill(self.umit_logo) schedp_hbox._pack_noexpand_nofill(self.schedp_name_lbl) schedp_hbox._pack_expand_fill(self.schedp_name) # cron format settings_align = gtk.Alignment(0.5, 0.5, 1, 1) settings_align.set_padding(6, 0, 12, 0) cron_table.attach(self.cron_minute_lbl, 0, 1, 0, 1) cron_table.attach(self.cron_minute, 1, 2, 0, 1) cron_table.attach(self.cron_hour_lbl, 0, 1, 1, 2) cron_table.attach(self.cron_hour, 1, 2, 1, 2) cron_table.attach(self.cron_day_lbl, 0, 1, 2, 3) cron_table.attach(self.cron_day, 1, 2, 2, 3) cron_table.attach(self.cron_month_lbl, 0, 1, 3, 4) cron_table.attach(self.cron_month, 1, 2, 3, 4) cron_table.attach(self.cron_weekday_lbl, 0, 1, 4, 5) cron_table.attach(self.cron_weekday, 1, 2, 4, 5) cron_box._pack_noexpand_nofill(cron_table) settings_align.add(cron_box) self.cron_frame.add(settings_align) # bottom buttons btns_hbox.set_homogeneous(True) btns_hbox._pack_expand_fill(self.help) btns_hbox._pack_expand_fill(hig_box_space_holder()) btns_hbox._pack_expand_fill(self.apply) btns_hbox._pack_expand_fill(self.cancel) btns_hbox._pack_expand_fill(self.ok) main_vbox._pack_noexpand_nofill(header_hbox) main_vbox._pack_noexpand_nofill(gtk.HSeparator()) main_vbox._pack_noexpand_nofill(schedp_hbox) main_vbox._pack_noexpand_nofill(self.cron_frame) main_vbox.pack_end(btns_hbox, False, False, 0) self.add(main_vbox)
class ScanRunDetailsPage(HIGVBox): def __init__(self): HIGVBox.__init__(self) self.__create_widgets() def __create_widgets(self): na = _('Not available') self.command_expander = gtk.Expander("<b>"+_("Command Info")+"</b>") self.general_expander = gtk.Expander("<b>"+_("General Info")+"</b>") # Command info self.command_label = HIGEntryLabel(_('Command:')) self.info_command_label = HIGEntryLabel(na) self.nmap_version_label = HIGEntryLabel(_('Nmap Version:')) self.info_nmap_version_label = HIGEntryLabel(na) self.verbose_label = HIGEntryLabel(_('Verbosity level:')) self.info_verbose_label = HIGEntryLabel(na) self.debug_label = HIGEntryLabel(_('Debug level:')) self.info_debug_label = HIGEntryLabel(na) self.command_table = HIGTable() self.command_hbox = HIGHBox() # General info: self.start_label = HIGEntryLabel(_('Started on:')) self.info_start_label = HIGEntryLabel(na) self.finished_label = HIGEntryLabel(_('Finished on:')) self.info_finished_label = HIGEntryLabel(na) self.host_up_label = HIGEntryLabel(_('Hosts up:')) self.info_hosts_up_label = HIGEntryLabel(na) self.host_down_label = HIGEntryLabel(_('Hosts down:')) self.info_hosts_down_label = HIGEntryLabel(na) self.host_scanned_label = HIGEntryLabel(_('Hosts scanned:')) self.info_hosts_scanned_label = HIGEntryLabel(na) self.open_label = HIGEntryLabel(_('Open ports:')) self.info_open_label = HIGEntryLabel(na) self.filtered_label = HIGEntryLabel(_('Filtered ports:')) self.info_filtered_label = HIGEntryLabel(na) self.closed_label = HIGEntryLabel(_('Closed ports:')) self.info_closed_label = HIGEntryLabel(na) self.general_table = HIGTable() self.general_hbox = HIGHBox() def set_command_info(self, info): # Fix aligment! self.command_expander.set_use_markup(True) self.command_table.set_border_width(5) self.command_table.set_row_spacings(6) self.command_table.set_col_spacings(6) try:self.info_command_label.set_text(info['command']) except:pass try:self.info_nmap_version_label.set_text(info['version']) except:pass try:self.info_verbose_label.set_text(info['verbose']) except:pass try:self.info_debug_label.set_text(info['debug']) except:pass self.command_hbox._pack_noexpand_nofill(hig_box_space_holder()) self.command_hbox._pack_noexpand_nofill(self.command_table) self.command_table.attach(self.command_label,0,1,0,1) self.command_table.attach(self.info_command_label,1,2,0,1) self.command_table.attach(self.nmap_version_label,0,1,1,2) self.command_table.attach(self.info_nmap_version_label,1,2,1,2) self.command_table.attach(self.verbose_label,0,1,2,3) self.command_table.attach(self.info_verbose_label,1,2,2,3) self.command_table.attach(self.debug_label,0,1,3,4) self.command_table.attach(self.info_debug_label,1,2,3,4) self.command_expander.add(self.command_hbox) self._pack_noexpand_nofill(self.command_expander) self.command_expander.set_expanded(True) def set_general_info(self, info): # Fix aligment! self.general_expander.set_use_markup(True) self.general_table.set_border_width(5) self.general_table.set_row_spacings(6) self.general_table.set_col_spacings(6) try:self.info_start_label.set_text(info['start']) except:pass try:self.info_finished_label.set_text(info['finish']) except:pass try:self.info_hosts_up_label.set_text(info['hosts_up']) except:pass try:self.info_hosts_down_label.set_text(info['hosts_down']) except:pass try:self.info_hosts_scanned_label.set_text(info['hosts_scanned']) except:pass #try: self.info_open_label.set_text(info['open_ports']) #except:pass #try: self.info_filtered_label.set_text(info['filtered_ports']) #except:pass #try: self.info_closed_label.set_text(info['closed_ports']) #except:pass self.general_hbox._pack_noexpand_nofill(hig_box_space_holder()) self.general_hbox._pack_noexpand_nofill(self.general_table) self.general_table.attach(self.start_label,0,1,0,1) self.general_table.attach(self.info_start_label,1,2,0,1) self.general_table.attach(self.finished_label,0,1,1,2) self.general_table.attach(self.info_finished_label,1,2,1,2) self.general_table.attach(self.host_up_label,0,1,2,3) self.general_table.attach(self.info_hosts_up_label,1,2,2,3) self.general_table.attach(self.host_down_label,0,1,3,4) self.general_table.attach(self.info_hosts_down_label,1,2,3,4) self.general_table.attach(self.host_scanned_label,0,1,4,5) self.general_table.attach(self.info_hosts_scanned_label,1,2,4,5) self.general_table.attach(self.open_label,0,1,5,6) self.general_table.attach(self.info_open_label,1,2,5,6) self.general_table.attach(self.filtered_label,0,1,6,7) self.general_table.attach(self.info_filtered_label,1,2,6,7) self.general_table.attach(self.closed_label,0,1,7,8) self.general_table.attach(self.info_closed_label,1,2,7,8) self.general_expander.add(self.general_hbox) self._pack_noexpand_nofill(self.general_expander) self.general_expander.set_expanded(True) def set_scan_infos(self, scan_info): for scan in scan_info: exp = gtk.Expander('<b>%s - %s</b>' % (_('Scan Info'), scan['type'].capitalize())) exp.set_use_markup(True) hbox = HIGHBox() table = HIGTable() table.set_border_width(5) table.set_row_spacings(6) table.set_col_spacings(6) table.attach(HIGEntryLabel(_('Scan type:')),0,1,0,1) table.attach(HIGEntryLabel(scan['type']),1,2,0,1) table.attach(HIGEntryLabel(_('Protocol:')),0,1,1,2) table.attach(HIGEntryLabel(scan['protocol']),1,2,1,2) table.attach(HIGEntryLabel(_('# scanned ports:')),0,1,2,3) table.attach(HIGEntryLabel(scan['numservices']),1,2,2,3) table.attach(HIGEntryLabel(_('Services:')),0,1,3,4) table.attach(self.get_service_view(scan['services'].split(',')),\ 1,2,3,4) hbox._pack_noexpand_nofill(hig_box_space_holder()) hbox._pack_noexpand_nofill(table) exp.add (hbox) self._pack_noexpand_nofill(exp) def get_service_view(self, services): combo = gtk.combo_box_new_text() for i in services: combo.append_text(i) return combo
def __init__(self): HIGVBox.__init__(self) self.set_spacing(12) self.prof = False self.description = HIGEntryLabel( _("""Please, enter the profile name, \ and optionally, enter a hint, description and annotation for this \ new profile""")) self.profile_label = HIGEntryLabel(_("Profile name")) self.hint_label = HIGEntryLabel(_("Hint")) self.description_label = HIGEntryLabel(_("Description")) self.annotation_label = HIGEntryLabel(_("Annotation")) self.profile_entry = gtk.Entry() self.hint_entry = gtk.Entry() self.description_scroll = HIGScrolledWindow() self.description_text = HIGTextView() self.annotation_scroll = HIGScrolledWindow() self.annotation_text = HIGTextView() self.description_scroll.add(self.description_text) self.annotation_scroll.add(self.annotation_text) table = HIGTable() self.bar = ForwardBar() self._pack_noexpand_nofill(self.description) self._pack_expand_fill(table) self._pack_noexpand_nofill(self.bar) table.attach(self.profile_label, 0, 1, 0, 1, xoptions=0) table.attach(self.profile_entry, 1, 2, 0, 1) table.attach(self.hint_label, 0, 1, 1, 2, xoptions=0) table.attach(self.hint_entry, 1, 2, 1, 2) table.attach(self.description_label, 0, 1, 2, 3, xoptions=0) table.attach(self.description_scroll, 1, 2, 2, 3) table.attach(self.annotation_label, 0, 1, 3, 4, xoptions=0) table.attach(self.annotation_scroll, 1, 2, 3, 4)
class Proprieties(HIGScrolledWindow): ''' This box should be configurable if widget is of a type all configuration should be change to this type #tricks: option_list have a icon to fill with options and option_check have a list of options in combo to change ''' def __init__(self): HIGScrolledWindow.__init__(self) self._boxeditable = None vp = gtk.Viewport() self._create_widgets() vp.add(self._box) vp.set_shadow_type(gtk.SHADOW_NONE) self.add(vp) self._profilecore = None self._selected = None def set_profilecore(self, profilecore): self._profilecore = profilecore def _create_widgets(self): ''' Create the main entrys of the option ''' self._box = HIGVBox() self._table = HIGTable() #Name self._label_name = HIGEntryLabel(_('Name')) self._entry_name = HIGTextEntry() self._entry_name.connect('activate', self._update_label) #Type self._label_type = HIGEntryLabel(_('Type')) self._combo_type = gtk.combo_box_new_text() self._combo_type.append_text('') self._combo_type.append_text('Option List') self._combo_type.append_text('Option Check') self._combo_type.set_active(0) self._combo_type.connect('changed', self.change_combo) self._label_opt = HIGEntryLabel(_('Option')) self._entry_opt = HIGTextEntry() self._entry_opt.set_sensitive(False) #For option list open a dialog to add/remove options self._button_list = HIGButton('Edit Option List') img = gtk.Image() img_dir = os.path.join(pixmaps_dir, 'uie', 'combo.png') img.set_from_file(img_dir) self._button_list.set_image(img) self._button_list.connect('button-press-event', self._button_list_clicked) self._table.attach(self._label_name, 0, 1, 0, 1) self._table.attach(self._entry_name, 1, 2, 0, 1) self._table.attach(self._label_type, 0, 1, 1, 2) self._table.attach(self._combo_type, 1, 2, 1, 2) self._table.attach(self._button_list, 0, 2, 3, 4) self._table.attach(self._label_opt, 0, 1, 4, 5) self._table.attach(self._entry_opt, 1, 2, 4, 5) self._box.pack_start(self._table, False, False) def _button_list_clicked(self, widget, event): section_name = self._boxeditable.get_name() lm = ListManager(self._entry_name.get_text(), section_name, self._profilecore, self._selected, _('List of items')) def _update_label(self, widget): #XXX Replace by Command log.debug("Update Label") selected = self._selected cmd = CommandChangeLabel(selected, self._entry_name.get_text(), self._profilecore, self._boxeditable, True) command_manager.add_command(cmd) def change_combo(self, combo): model = combo.get_model() index = combo.get_active() if index: if model[index][0] == 'Option List': log.debug('Show Button List ') self._button_list.show() else: log.debug('Hide Button List ') self._button_list.hide() return def show_notebook_label(self): ''' show proprieties of notebook label and hide others ''' pass def show_item(self): pass def hide_item(self): self._label_opt.hide() self._entry_opt.hide() self._button_list.hide() self._combo_type.hide() self._label_type.hide() self._entry_name.hide() self._label_name.hide() def set_notebooklabel(self, selected): self._entry_name.show() self._label_name.show() self._entry_name.set_text(selected.get_text()) self._button_list.hide() self._combo_type.hide() self._label_type.hide() self._label_opt.hide() self._entry_opt.hide() self._selected = selected def set_item(self, selected): self._entry_name.show() self._label_name.show() self._selected = selected if selected.get_name() != None: self._entry_name.set_text(selected.get_name()) else: self.hide_item() return childs = selected.get_children() self._combo_type.show() self._label_type.show() child_label = childs[0] if isinstance(child_label, gtk.HBox): #OptionCheck self._label_opt.show() self._entry_opt.show() opt_ = self._profilecore.get_opt_check( self._boxeditable.get_name(), selected.get_name()) self._entry_opt.set_text(opt_) self._button_list.hide() child_label.cbutton.set_label(self._entry_name.get_text()) self._combo_type.set_active(2) #XXX: Put other widget that sensitible = False with option name elif isinstance(child_label, gtk.EventBox): #OptionList self._button_list.show() other = child_label.get_children()[0] other.set_label(self._entry_name.get_text()) self._combo_type.set_active(1) #Disable Combo to change OptionList/OptionChange self._combo_type.set_sensitive(False) def set_boxeditable(self, boxeditable): self._boxeditable = boxeditable def update(self): pass def disable_all(self): self._label_opt.hide() self._entry_opt.hide() self._button_list.hide() self._combo_type.hide() self._label_type.hide() self._entry_name.hide() self._label_name.hide() def load_data(self, option): pass def unload(self, option): pass
class PeerInfoPage(HIGVBox): """""" #---------------------------------------------------------------------- def __init__(self): """Constructor""" HIGVBox.__init__(self) self.__create_widgets() self.__pack_widgets() def __create_widgets(self): """""" self.peerinfo_hbox = HIGHBox() self.cloudagg_hbox = HIGHBox() self.superpeers_hbox = HIGHBox() self.pref_location_hbox = HIGHBox() self.peerinfo_section = HIGSectionLabel(_("Peer Info")) self.peerinfo_table = HIGTable() self.pref_location_section = HIGSectionLabel(_("Preferred Locations")) self.pref_location_table = HIGTable() self.cloudagg_section = HIGSectionLabel(_("Cloud Aggregator")) self.cloudagg_table = HIGTable() self.cloudagg_subhbox = HIGHBox() self.superpeers_section = HIGSectionLabel(_("Super Peers")) self.superpeers_table = HIGTable() self.peerid_label = HIGEntryLabel(_("Peer ID:")) self.email_label = HIGEntryLabel(_("Email Address:")) self.test_version_label = HIGEntryLabel(_("Test Sets Version:")) self.peerid_label2 = HIGEntryLabel() self.email_entry = gtk.Entry() self.test_version_label2 = HIGEntryLabel() self.longitude_label = HIGLabel(_("longitude:")) self.longitude_entry = gtk.Entry() self.latitude_label = HIGLabel(_("latitude:")) self.latitude_entry = gtk.Entry() self.cloudagg_entry = gtk.Entry() self.cloudagg_button = HIGButton(_("Reset")) self.cloudagg_button.connect('clicked', lambda w: self.reset_aggregator_url()) self.cloudagg_button.set_size_request(80, 28) self.superpeers_ip_label = HIGLabel(_("IP:")) self.superpeers_ip_entry = gtk.Entry() self.superpeers_ip_entry.set_size_request(160, 26) self.superpeers_port_label = HIGLabel(_("Port:")) self.superpeers_port_entry = gtk.Entry() self.superpeers_port_entry.set_size_request(80, 26) self.superpeers_subhbox = HIGHBox() self.btn_box = gtk.HButtonBox() self.superpeers_button1 = HIGButton(_("Add")) self.superpeers_button1.connect('clicked',lambda w:self.add_superpeer()) self.superpeers_button2 = HIGButton(_("Show all")) self.superpeers_button2.connect('clicked', lambda w: self.show_super_peer_list_window()) def __pack_widgets(self): self.set_border_width(12) self._pack_noexpand_nofill(self.peerinfo_section) self._pack_noexpand_nofill(self.peerinfo_hbox) self._pack_noexpand_nofill(self.pref_location_section) self._pack_noexpand_nofill(self.pref_location_hbox) self._pack_noexpand_nofill(self.cloudagg_section) self._pack_noexpand_nofill(self.cloudagg_hbox) self._pack_noexpand_nofill(self.superpeers_section) self._pack_noexpand_nofill(self.superpeers_hbox) self.peerinfo_hbox._pack_noexpand_nofill(hig_box_space_holder()) self.peerinfo_hbox._pack_expand_fill(self.peerinfo_table) self.pref_location_hbox._pack_noexpand_nofill(hig_box_space_holder()) self.pref_location_hbox._pack_expand_fill(self.pref_location_table) self.cloudagg_hbox._pack_noexpand_nofill(hig_box_space_holder()) self.cloudagg_hbox._pack_expand_fill(self.cloudagg_table) self.superpeers_hbox._pack_noexpand_nofill(hig_box_space_holder()) self.superpeers_hbox._pack_expand_fill(self.superpeers_table) self.peerinfo_table.attach_label(self.peerid_label, 0, 1, 0, 1) self.peerinfo_table.attach_label(self.email_label, 0, 1, 2, 3) self.peerinfo_table.attach_label(self.test_version_label, 0, 1, 1, 2) self.peerinfo_table.attach_label(self.test_version_label2, 1, 2, 1, 2) self.peerinfo_table.attach_label(self.peerid_label2, 1, 2, 0, 1) self.peerinfo_table.attach_entry(self.email_entry, 1, 2, 2, 3) self.pref_location_table.attach(self.longitude_label,0,1,0,1) self.pref_location_table.attach(self.longitude_entry,1,2,0,1) self.pref_location_table.attach(self.latitude_label,2,3,0,1) self.pref_location_table.attach(self.latitude_entry,3,4,0,1) self.cloudagg_subhbox._pack_expand_fill(self.cloudagg_entry) self.cloudagg_subhbox._pack_noexpand_nofill(self.cloudagg_button) self.cloudagg_table.attach_entry(self.cloudagg_subhbox, 0, 1, 0, 1) self.btn_box.set_layout(gtk.BUTTONBOX_END) self.btn_box.set_spacing(8) self.btn_box.pack_start(self.superpeers_button1) self.btn_box.pack_start(self.superpeers_button2) self.superpeers_subhbox._pack_expand_fill(self.superpeers_ip_label) self.superpeers_subhbox._pack_expand_fill(self.superpeers_ip_entry) self.superpeers_subhbox._pack_expand_fill(self.superpeers_port_label) self.superpeers_subhbox._pack_expand_fill(self.superpeers_port_entry) self.superpeers_subhbox._pack_noexpand_nofill(self.btn_box) self.superpeers_table.attach_label(self.superpeers_subhbox, 0, 1, 0, 1) def add_superpeer(self): """ Add Super Peer by manual into database """ ip = self.superpeers_ip_entry.get_text() port = self.superpeers_port_entry.get_text() g_db_helper.set_super_peer_manual(ip,port) def reset_aggregator_url(self): """ """ aggregator_url = 'http://east1.openmonitor.org' self.cloudagg_entry.set_text(aggregator_url) theApp.aggregator.base_url = aggregator_url g_config.set('network', 'aggregator_url', aggregator_url) g_db_helper.set_value('config','aggregator_url', aggregator_url) def show_super_peer_list_window(self): from umit.icm.agent.gui.Preference.SuperPeerSetting import SuperPeerListWindow,SuperPeersBox wnd = SuperPeerListWindow() wnd.show_all()
class FeedbackPage(HIGVBox): """""" #---------------------------------------------------------------------- def __init__(self): """Constructor""" HIGVBox.__init__(self) self.__create_widgets() self.__pack_widgets() self.__set_values() def __create_widgets(self): self.suggestion_hbox = HIGHBox() self.report_hbox = HIGHBox() self.suggestion_section = HIGSectionLabel(_("Test Suggestion")) self.suggestion_table = HIGTable() self.report_section = HIGSectionLabel(_("Bug Report")) self.report_table = HIGTable() # Website Suggestion self.website_suggestion_table = HIGTable() self.website_suggestion_slabel = HIGSectionLabel( _("Website Suggestion")) self.website_url_subhbox = HIGHBox() self.website_url_label = HIGEntryLabel(_("URL:")) self.website_url_entry = gtk.Entry() self.website_suggestion_sendbtn = HIGButton(_('Send')) self.website_suggestion_sendbtn.set_size_request(60, 25) self.website_suggestion_sendbtn.connect( 'clicked', lambda x: self.send_website_suggestion()) # Service Suggestion self.service_suggestion_table = HIGTable() self.service_suggestion_slabel = HIGSectionLabel( _("Service Suggestion")) self.service_name_subhbox = HIGHBox() self.service_name_label = HIGEntryLabel(_("Name:")) self.service_list_store = gtk.ListStore(str) self.service_name_entry = gtk.ComboBoxEntry(self.service_list_store, 0) self.service_host_subhbox = HIGHBox() self.service_host_label = HIGEntryLabel(_("Hostname:")) self.service_host_entry = gtk.Entry() self.service_ip_subhbox = HIGHBox() self.service_ip_label = HIGEntryLabel(_("IP:")) self.service_ip_entry = gtk.Entry() self.service_port_label = HIGEntryLabel(_("PORT:")) self.service_port_entry = gtk.Entry() self.service_suggestion_sendbtn = HIGButton(_('Send')) self.service_suggestion_sendbtn.set_size_request(60, 25) self.service_suggestion_sendbtn.connect( 'clicked', lambda x: self.send_service_suggestion()) self.report_namelabel = HIGEntryLabel(_("Your Name:")) self.report_nameentry = gtk.Entry() #self.report_nameentry.set_has_frame(True) self.report_nameentry.set_size_request(100, 26) self.report_emaillabel = HIGEntryLabel(_("Email:")) self.report_emailentry = gtk.Entry() self.report_emailentry.set_size_request(198, 26) self.report_subhbox1 = HIGHBox() self.report_sw = gtk.ScrolledWindow() self.report_sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.report_textview = gtk.TextView() self.report_textbuffer = self.report_textview.get_buffer() self.report_textview.set_editable(True) self.report_textview.set_wrap_mode(True) self.report_textview.set_border_width(2) self.report_sw.add(self.report_textview) self.report_sw.show() self.report_textview.show() self.report_subhbox2 = HIGHBox() self.report_sendbtn = HIGButton(_('Send')) self.report_sendbtn.set_size_request(60, 25) self.report_sendbtn.connect('clicked', lambda x: self.send_bug_report()) self.report_subhbox3 = HIGHBox() def __pack_widgets(self): self.set_border_width(12) self._pack_noexpand_nofill(self.suggestion_section) self._pack_noexpand_nofill(self.suggestion_hbox) self._pack_noexpand_nofill(self.report_section) self._pack_noexpand_nofill(self.report_hbox) #self.suggestion_hbox._pack_noexpand_nofill(hig_box_space_holder()) #self.suggestion_hbox._pack_expand_fill(self.suggestion_table) #self.report_hbox._pack_noexpand_nofill(hig_box_space_holder()) self.report_hbox._pack_expand_fill(self.report_table) self.suggestion_hbox._pack_expand_fill(self.suggestion_table) #self.suggestion_hbox._pack_expand_fill(self.service_suggestion_table) self.suggestion_table.attach_label(self.website_suggestion_slabel, 0, 2, 0, 1) self.suggestion_table.attach_label(self.website_url_label, 0, 1, 1, 2) self.suggestion_table.attach_entry(self.website_url_entry, 1, 2, 1, 2) self.suggestion_table.attach(self.website_suggestion_sendbtn, 0, 2, 2, 3, gtk.PACK_START) self.suggestion_table.attach_label(self.service_suggestion_slabel, 2, 4, 0, 1) self.suggestion_table.attach_label(self.service_name_label, 2, 3, 1, 2) self.suggestion_table.attach_entry(self.service_name_entry, 3, 4, 1, 2) self.suggestion_table.attach_label(self.service_host_label, 2, 3, 2, 3) self.suggestion_table.attach_entry(self.service_host_entry, 3, 4, 2, 3) self.suggestion_table.attach_label(self.service_ip_label, 2, 3, 3, 4) self.suggestion_table.attach_entry(self.service_ip_entry, 3, 4, 3, 4) self.suggestion_table.attach_label(self.service_port_label, 2, 3, 4, 5) self.suggestion_table.attach_entry(self.service_port_entry, 3, 4, 4, 5) self.suggestion_table.attach(self.service_suggestion_sendbtn, 2, 4, 5, 6, gtk.PACK_START) self.report_subhbox1.pack_start(self.report_namelabel, True, True, 0) self.report_subhbox1.pack_start(self.report_nameentry, True, True, 0) self.report_subhbox1.pack_start(self.report_emaillabel, True, True, 0) self.report_subhbox1.pack_start(self.report_emailentry) self.report_table.attach(self.report_subhbox1, 0, 1, 0, 1) self.report_subhbox2.pack_start(self.report_sw) self.report_table.attach(self.report_subhbox2, 0, 1, 1, 2) self.report_subhbox3.pack_start(self.report_sendbtn) self.report_table.attach(self.report_subhbox3, 0, 1, 2, 3, gtk.PACK_START) def __set_values(self): from umit.icm.agent.test import SUPPORTED_SERVICES for each in SUPPORTED_SERVICES: self.service_list_store.append([each]) def send_website_suggestion(self): website_url = self.website_url_entry.get_text() if website_url == '': alert = HIGAlertDialog(message_format=_("Missing fields."), secondary_text=_("Please input all fields " "for website suggestion.")) alert.run() alert.destroy() return d = theApp.aggregator.send_website_suggestion(website_url) d.addCallback(self.show_success) d.addErrback(self.show_failed) def send_service_suggestion(self): service_name = self.service_name_entry.child.get_text() host_name = self.service_host_entry.get_text() ip = self.service_ip_entry.get_text() port = int(self.service_port_entry.get_text()) if service_name == '' or host_name == '' or ip == '' or port == "": alert = HIGAlertDialog(message_format=_("Missing fields."), secondary_text=_("Please input all fields "\ "for service suggestion.")) alert.run() alert.destroy() return d = theApp.aggregator.send_service_suggestion(service_name, host_name, ip, port) d.addCallback(self.show_success) d.addErrback(self.show_failed) def send_bug_report(self): pass def show_failed(self, result): """ """ alert = HIGAlertDialog(message_format=_("Error."), secondary_text=_("Send to aggregaetor failed.")) alert.run() alert.destroy() def show_success(self, result): """ """ if result is not None: alert = HIGAlertDialog( message_format=_("Succuss."), secondary_text=_("Send to aggregaetor successfully.")) alert.run() alert.destroy() else: alert = HIGAlertDialog( message_format=_("Error."), secondary_text=_("Send to aggregaetor failed.")) alert.run() alert.destroy()
class ScanRunDetailsPage(HIGVBox): def __init__(self): HIGVBox.__init__(self) self.__create_widgets() def __create_widgets(self): na = _('Not available') self.command_expander = gtk.Expander("<b>" + _("Command Info") + "</b>") self.general_expander = gtk.Expander("<b>" + _("General Info") + "</b>") # Command info self.command_label = HIGEntryLabel(_('Command:')) self.info_command_label = HIGEntryLabel(na) self.nmap_version_label = HIGEntryLabel(_('Nmap Version:')) self.info_nmap_version_label = HIGEntryLabel(na) self.verbose_label = HIGEntryLabel(_('Verbosity level:')) self.info_verbose_label = HIGEntryLabel(na) self.debug_label = HIGEntryLabel(_('Debug level:')) self.info_debug_label = HIGEntryLabel(na) self.command_table = HIGTable() self.command_hbox = HIGHBox() # General info: self.start_label = HIGEntryLabel(_('Started on:')) self.info_start_label = HIGEntryLabel(na) self.finished_label = HIGEntryLabel(_('Finished on:')) self.info_finished_label = HIGEntryLabel(na) self.host_up_label = HIGEntryLabel(_('Hosts up:')) self.info_hosts_up_label = HIGEntryLabel(na) self.host_down_label = HIGEntryLabel(_('Hosts down:')) self.info_hosts_down_label = HIGEntryLabel(na) self.host_scanned_label = HIGEntryLabel(_('Hosts scanned:')) self.info_hosts_scanned_label = HIGEntryLabel(na) self.open_label = HIGEntryLabel(_('Open ports:')) self.info_open_label = HIGEntryLabel(na) self.filtered_label = HIGEntryLabel(_('Filtered ports:')) self.info_filtered_label = HIGEntryLabel(na) self.closed_label = HIGEntryLabel(_('Closed ports:')) self.info_closed_label = HIGEntryLabel(na) self.general_table = HIGTable() self.general_hbox = HIGHBox() def set_command_info(self, info): # Fix aligment! self.command_expander.set_use_markup(True) self.command_table.set_border_width(5) self.command_table.set_row_spacings(6) self.command_table.set_col_spacings(6) try: self.info_command_label.set_text(info['command']) except: pass try: self.info_nmap_version_label.set_text(info['version']) except: pass try: self.info_verbose_label.set_text(info['verbose']) except: pass try: self.info_debug_label.set_text(info['debug']) except: pass self.command_hbox._pack_noexpand_nofill(hig_box_space_holder()) self.command_hbox._pack_noexpand_nofill(self.command_table) self.command_table.attach(self.command_label, 0, 1, 0, 1) self.command_table.attach(self.info_command_label, 1, 2, 0, 1) self.command_table.attach(self.nmap_version_label, 0, 1, 1, 2) self.command_table.attach(self.info_nmap_version_label, 1, 2, 1, 2) self.command_table.attach(self.verbose_label, 0, 1, 2, 3) self.command_table.attach(self.info_verbose_label, 1, 2, 2, 3) self.command_table.attach(self.debug_label, 0, 1, 3, 4) self.command_table.attach(self.info_debug_label, 1, 2, 3, 4) self.command_expander.add(self.command_hbox) self._pack_noexpand_nofill(self.command_expander) self.command_expander.set_expanded(True) def set_general_info(self, info): # Fix aligment! self.general_expander.set_use_markup(True) self.general_table.set_border_width(5) self.general_table.set_row_spacings(6) self.general_table.set_col_spacings(6) try: self.info_start_label.set_text(info['start']) except: pass try: self.info_finished_label.set_text(info['finish']) except: pass try: self.info_hosts_up_label.set_text(info['hosts_up']) except: pass try: self.info_hosts_down_label.set_text(info['hosts_down']) except: pass try: self.info_hosts_scanned_label.set_text(info['hosts_scanned']) except: pass #try: self.info_open_label.set_text(info['open_ports']) #except:pass #try: self.info_filtered_label.set_text(info['filtered_ports']) #except:pass #try: self.info_closed_label.set_text(info['closed_ports']) #except:pass self.general_hbox._pack_noexpand_nofill(hig_box_space_holder()) self.general_hbox._pack_noexpand_nofill(self.general_table) self.general_table.attach(self.start_label, 0, 1, 0, 1) self.general_table.attach(self.info_start_label, 1, 2, 0, 1) self.general_table.attach(self.finished_label, 0, 1, 1, 2) self.general_table.attach(self.info_finished_label, 1, 2, 1, 2) self.general_table.attach(self.host_up_label, 0, 1, 2, 3) self.general_table.attach(self.info_hosts_up_label, 1, 2, 2, 3) self.general_table.attach(self.host_down_label, 0, 1, 3, 4) self.general_table.attach(self.info_hosts_down_label, 1, 2, 3, 4) self.general_table.attach(self.host_scanned_label, 0, 1, 4, 5) self.general_table.attach(self.info_hosts_scanned_label, 1, 2, 4, 5) self.general_table.attach(self.open_label, 0, 1, 5, 6) self.general_table.attach(self.info_open_label, 1, 2, 5, 6) self.general_table.attach(self.filtered_label, 0, 1, 6, 7) self.general_table.attach(self.info_filtered_label, 1, 2, 6, 7) self.general_table.attach(self.closed_label, 0, 1, 7, 8) self.general_table.attach(self.info_closed_label, 1, 2, 7, 8) self.general_expander.add(self.general_hbox) self._pack_noexpand_nofill(self.general_expander) self.general_expander.set_expanded(True) def set_scan_infos(self, scan_info): for scan in scan_info: exp = gtk.Expander('<b>%s - %s</b>' % (_('Scan Info'), scan['type'].capitalize())) exp.set_use_markup(True) hbox = HIGHBox() table = HIGTable() table.set_border_width(5) table.set_row_spacings(6) table.set_col_spacings(6) table.attach(HIGEntryLabel(_('Scan type:')), 0, 1, 0, 1) table.attach(HIGEntryLabel(scan['type']), 1, 2, 0, 1) table.attach(HIGEntryLabel(_('Protocol:')), 0, 1, 1, 2) table.attach(HIGEntryLabel(scan['protocol']), 1, 2, 1, 2) table.attach(HIGEntryLabel(_('# scanned ports:')), 0, 1, 2, 3) table.attach(HIGEntryLabel(scan['numservices']), 1, 2, 2, 3) table.attach(HIGEntryLabel(_('Services:')), 0, 1, 3, 4) table.attach(self.get_service_view(scan['services'].split(',')),\ 1,2,3,4) hbox._pack_noexpand_nofill(hig_box_space_holder()) hbox._pack_noexpand_nofill(table) exp.add(hbox) self._pack_noexpand_nofill(exp) def get_service_view(self, services): combo = gtk.combo_box_new_text() for i in services: combo.append_text(i) return combo
def set_scan_infos(self, scan_info): for scan in scan_info: exp = gtk.Expander('<b>%s - %s</b>' % (_('Scan Info'), scan['type'].capitalize())) exp.set_use_markup(True) hbox = HIGHBox() table = HIGTable() table.set_border_width(5) table.set_row_spacings(6) table.set_col_spacings(6) table.attach(HIGEntryLabel(_('Scan type:')), 0, 1, 0, 1) table.attach(HIGEntryLabel(scan['type']), 1, 2, 0, 1) table.attach(HIGEntryLabel(_('Protocol:')), 0, 1, 1, 2) table.attach(HIGEntryLabel(scan['protocol']), 1, 2, 1, 2) table.attach(HIGEntryLabel(_('# scanned ports:')), 0, 1, 2, 3) table.attach(HIGEntryLabel(scan['numservices']), 1, 2, 2, 3) table.attach(HIGEntryLabel(_('Services:')), 0, 1, 3, 4) table.attach(self.get_service_view(scan['services'].split(',')),\ 1,2,3,4) hbox._pack_noexpand_nofill(hig_box_space_holder()) hbox._pack_noexpand_nofill(table) exp.add(hbox) self._pack_noexpand_nofill(exp)
class FeedbackPage(HIGVBox): """""" #---------------------------------------------------------------------- def __init__(self): """Constructor""" HIGVBox.__init__(self) self.__create_widgets() self.__pack_widgets() self.__set_values() def __create_widgets(self): self.suggestion_hbox = HIGHBox() self.report_hbox = HIGHBox() self.suggestion_section = HIGSectionLabel(_("Test Suggestion")) self.suggestion_table = HIGTable() self.report_section = HIGSectionLabel(_("Bug Report")) self.report_table = HIGTable() # Website Suggestion self.website_suggestion_table = HIGTable() self.website_suggestion_slabel = HIGSectionLabel(_("Website Suggestion")) self.website_url_subhbox = HIGHBox() self.website_url_label = HIGEntryLabel(_("URL:")) self.website_url_entry = gtk.Entry() self.website_suggestion_sendbtn = HIGButton(_('Send')) self.website_suggestion_sendbtn.set_size_request(60, 25) self.website_suggestion_sendbtn.connect( 'clicked', lambda x: self.send_website_suggestion()) # Service Suggestion self.service_suggestion_table = HIGTable() self.service_suggestion_slabel = HIGSectionLabel(_("Service Suggestion")) self.service_name_subhbox = HIGHBox() self.service_name_label = HIGEntryLabel(_("Name:")) self.service_list_store = gtk.ListStore(str) self.service_name_entry = gtk.ComboBoxEntry(self.service_list_store, 0) self.service_host_subhbox = HIGHBox() self.service_host_label = HIGEntryLabel(_("Hostname:")) self.service_host_entry = gtk.Entry() self.service_ip_subhbox = HIGHBox() self.service_ip_label = HIGEntryLabel(_("IP:")) self.service_ip_entry = gtk.Entry() self.service_port_label = HIGEntryLabel(_("PORT:")) self.service_port_entry = gtk.Entry() self.service_suggestion_sendbtn = HIGButton(_('Send')) self.service_suggestion_sendbtn.set_size_request(60, 25) self.service_suggestion_sendbtn.connect( 'clicked', lambda x: self.send_service_suggestion()) self.report_namelabel = HIGEntryLabel(_("Your Name:")) self.report_nameentry = gtk.Entry() #self.report_nameentry.set_has_frame(True) self.report_nameentry.set_size_request(100, 26) self.report_emaillabel = HIGEntryLabel(_("Email:")) self.report_emailentry = gtk.Entry() self.report_emailentry.set_size_request(198, 26) self.report_subhbox1 = HIGHBox() self.report_sw = gtk.ScrolledWindow() self.report_sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.report_textview = gtk.TextView() self.report_textbuffer = self.report_textview.get_buffer() self.report_textview.set_editable(True) self.report_textview.set_wrap_mode(True) self.report_textview.set_border_width(2) self.report_sw.add(self.report_textview) self.report_sw.show() self.report_textview.show() self.report_subhbox2 = HIGHBox() self.report_sendbtn = HIGButton(_('Send')) self.report_sendbtn.set_size_request(60, 25) self.report_sendbtn.connect('clicked', lambda x: self.send_bug_report()) self.report_subhbox3 = HIGHBox() def __pack_widgets(self): self.set_border_width(12) self._pack_noexpand_nofill(self.suggestion_section) self._pack_noexpand_nofill(self.suggestion_hbox) self._pack_noexpand_nofill(self.report_section) self._pack_noexpand_nofill(self.report_hbox) #self.suggestion_hbox._pack_noexpand_nofill(hig_box_space_holder()) #self.suggestion_hbox._pack_expand_fill(self.suggestion_table) #self.report_hbox._pack_noexpand_nofill(hig_box_space_holder()) self.report_hbox._pack_expand_fill(self.report_table) self.suggestion_hbox._pack_expand_fill(self.suggestion_table) #self.suggestion_hbox._pack_expand_fill(self.service_suggestion_table) self.suggestion_table.attach_label(self.website_suggestion_slabel, 0, 2, 0, 1) self.suggestion_table.attach_label(self.website_url_label, 0, 1, 1, 2) self.suggestion_table.attach_entry(self.website_url_entry, 1, 2, 1, 2) self.suggestion_table.attach(self.website_suggestion_sendbtn, 0, 2, 2, 3, gtk.PACK_START) self.suggestion_table.attach_label(self.service_suggestion_slabel, 2, 4, 0, 1) self.suggestion_table.attach_label(self.service_name_label, 2, 3, 1, 2) self.suggestion_table.attach_entry(self.service_name_entry, 3, 4, 1, 2) self.suggestion_table.attach_label(self.service_host_label, 2, 3, 2, 3) self.suggestion_table.attach_entry(self.service_host_entry, 3, 4, 2, 3) self.suggestion_table.attach_label(self.service_ip_label, 2, 3, 3, 4) self.suggestion_table.attach_entry(self.service_ip_entry, 3, 4, 3, 4) self.suggestion_table.attach_label(self.service_port_label, 2, 3, 4, 5) self.suggestion_table.attach_entry(self.service_port_entry, 3, 4, 4, 5) self.suggestion_table.attach(self.service_suggestion_sendbtn, 2, 4, 5, 6, gtk.PACK_START) self.report_subhbox1.pack_start(self.report_namelabel, True, True, 0) self.report_subhbox1.pack_start(self.report_nameentry, True, True, 0) self.report_subhbox1.pack_start(self.report_emaillabel, True, True, 0) self.report_subhbox1.pack_start(self.report_emailentry) self.report_table.attach(self.report_subhbox1, 0, 1, 0, 1) self.report_subhbox2.pack_start(self.report_sw) self.report_table.attach(self.report_subhbox2, 0, 1, 1, 2) self.report_subhbox3.pack_start(self.report_sendbtn) self.report_table.attach(self.report_subhbox3, 0, 1, 2, 3, gtk.PACK_START) def __set_values(self): from umit.icm.agent.test import SUPPORTED_SERVICES for each in SUPPORTED_SERVICES: self.service_list_store.append([each]) def send_website_suggestion(self): website_url = self.website_url_entry.get_text() if website_url == '': alert = HIGAlertDialog(message_format=_("Missing fields."), secondary_text=_("Please input all fields " "for website suggestion.")) alert.run() alert.destroy() return d = theApp.aggregator.send_website_suggestion(website_url) d.addCallback(self.show_success) d.addErrback(self.show_failed) def send_service_suggestion(self): service_name = self.service_name_entry.child.get_text() host_name = self.service_host_entry.get_text() ip = self.service_ip_entry.get_text() port = int(self.service_port_entry.get_text()) if service_name == '' or host_name == '' or ip == '' or port == "": alert = HIGAlertDialog(message_format=_("Missing fields."), secondary_text=_("Please input all fields "\ "for service suggestion.")) alert.run() alert.destroy() return d = theApp.aggregator.send_service_suggestion(service_name, host_name, ip,port) d.addCallback(self.show_success) d.addErrback(self.show_failed) def send_bug_report(self): pass def show_failed(self,result): """ """ alert = HIGAlertDialog(message_format=_("Error."), secondary_text=_("Send to aggregaetor failed.")) alert.run() alert.destroy() def show_success(self, result): """ """ if result is not None: alert = HIGAlertDialog(message_format=_("Succuss."), secondary_text=_("Send to aggregaetor successfully.")) alert.run() alert.destroy() else: alert = HIGAlertDialog(message_format=_("Error."), secondary_text=_("Send to aggregaetor failed.")) alert.run() alert.destroy()
class GeneralSettings(TabBox, object): """ General Settings - Splash enable/disable - Warnings - Erros, log, configure bugreport - Autosave: clean up, define folder etc - Define Nmap Command """ def __init__(self, name): TabBox.__init__(self, name) def _create_widgets(self): """ Design all """ # Create general widgets self._create_widgets_common() self._create_widgets_autosave() self._create_widgets_error() # Packing main section self.pack_start(self._box_common, False, False) self.pack_start(self._box_error_frame, False, False) self.pack_start(self._box_save_frame, False, False) self._box_error_frame.set_shadow_type(gtk.SHADOW_NONE) self._box_error_frame.set_shadow_type(gtk.SHADOW_NONE) # Settings Values self.splash = general_settings.splash self.warnings_extensions = general_settings.warnings_extensions self.silent_root = general_settings.silent_root self.crash_report = general_settings.crash_report self.log = general_settings.log self.log_file = general_settings.log_file self.warnings_save = general_settings.warnings_save self._connect_events() def _create_widgets_common(self): """ generally tab """ self._box_common = HIGVBox() # pack main section self.__check_splash = gtk.CheckButton(_('Enable Splash on start')) self.__check_silent_root = gtk.CheckButton(\ _('Silent Warning Non-Root')) self.__check_warning_extensions = gtk.CheckButton(\ _('Set/Check extensions - Windows only')) self._box_common.pack_start(self.__check_splash, False, False) #self._box_common.pack_start(self.__check_warning_extensions, False, \ # False) self._box_common.pack_start(self.__check_silent_root, False, False) self.__label_nmap = HIGEntryLabel(_('Nmap Command')) self.__entry_nmap = HIGTextEntry() # Files usr saved on predefined directory: self.__label_path = HIGEntryLabel(_('Nmap Command')) self.__entry_path = HIGTextEntry() self.__button_path = HIGButton(_('Choose')) self.__box_path = HIGHBox() self.__box_path.pack_start(self.__label_path, False, False) self.__box_path.pack_end(self.__button_path, False, False) self._box_common.set_border_width(0) def _create_widgets_error(self): # Create Widgets self._box_error_frame = HIGFrame('Error') self._box_error = HIGTable(5, 2) self._box_error.set_border_width(10) self._box_error_frame.add(self._box_error) self.__crash_report = gtk.CheckButton(_('Enable Crash Report')) # Radio Button List self.__log_no = gtk.RadioButton(None, _('No log')) self.__log_terminal = gtk.RadioButton(self.__log_no, _('Enable log in terminal')) self.__log_file = gtk.RadioButton(self.__log_terminal,\ _('Enable log file')) self.__log_file_label = HIGEntryLabel(_('Log file')) self.__log_file_entry = HIGTextEntry() self.__log_file_entry.set_editable(False) # FIXME: Do default file ~/.umit/umit.log self.__log_file_browser = HIGButton(_('Browse file'), \ gtk.STOCK_DIRECTORY) tmpbox = HIGHBox() tmpbox.pack_start(self.__log_file_entry, False, False) tmpbox.pack_start(self.__log_file_browser, False, False) # attach table self._box_error.attach(self.__crash_report, 0,1,0,1,\ gtk.FILL|gtk.EXPAND| gtk.SHRINK, gtk.FILL) self._box_error.attach(self.__log_no, 0,1,1,2,\ gtk.FILL|gtk.EXPAND| gtk.SHRINK, gtk.FILL) self._box_error.attach(self.__log_terminal, 0,1,2,3,\ gtk.FILL|gtk.EXPAND| gtk.SHRINK, gtk.FILL) self._box_error.attach(self.__log_file, 0,1,3,4,\ gtk.FILL|gtk.EXPAND| gtk.SHRINK, gtk.FILL) self._box_error.attach(self.__log_file_label, 0,1,4,5,\ gtk.FILL|gtk.EXPAND| gtk.SHRINK, gtk.FILL) self._box_error.attach(tmpbox, 1,2,4,5,\ gtk.FILL|gtk.EXPAND| gtk.SHRINK, gtk.FILL) def _create_widgets_autosave(self): # Create Widgets self._box_save_frame = HIGFrame('Auto-save') self._box_save = HIGVBox() self._box_save_frame.add(self._box_save) self._box_save.set_border_width(10) self._warnings_save = gtk.CheckButton( _('Enable warnings without saving')) self._clean_b = HIGButton(_('Delete saved files'), gtk.STOCK_CLEAR) self._clean_b_box = HIGHBox() self._clean_b_box.pack_start(self._clean_b, False, True) # pack self._box_save.pack_start(self._warnings_save, False, False) self._box_save.pack_start(self._clean_b_box, False, False) def _connect_events(self): """ connect call backs """ self.__check_splash.connect('toggled', self.update_splash) self.__check_silent_root.connect('toggled', self.update_silent_root) self.__crash_report.connect('toggled', self.update_crash_report) self.__log_file.connect('toggled', self.update_log) self.__log_file.connect('toggled', self.update_log_file) self.__log_terminal.connect('toggled', self.update_log) self.__log_no.connect('toggled', self.update_log) self.__log_file_browser.connect('clicked', self.read_file) self.__log_file_entry.connect('changed', self.update_log_file_text) self._warnings_save.connect('toggled', self.update_save_warn) self._clean_b.connect('clicked', self.delete_files) self.update_log_file(None) # Callbacks def delete_files(self, widget): # NOTE: This method should be adapted in umit.core.UserConf # Creating an empty recent_scans file log.debug('>>> Reset store files: - %s' % base_paths['user_dir']) reset_user_dir(base_paths['user_dir']) def update_save_warn(self, widget): general_settings.warnings_save = self.warnings_save def read_file(self, widget): dialog = gtk.FileChooserDialog("Open..", None, gtk.FILE_CHOOSER_ACTION_SAVE, (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_SAVE_AS, gtk.RESPONSE_OK)) dialog.set_default_response(gtk.RESPONSE_OK) response = dialog.run() if response == gtk.RESPONSE_OK: # Get name of file self.__log_file_entry.set_text(dialog.get_filename()) dialog.destroy() def update_crash_report(self, widget): general_settings.crash_report = self.crash_report def update_splash(self, widget): general_settings.splash = self.splash def update_silent_root(self, widget): general_settings.silent_root = self.silent_root def update_log_file_text(self, widget): general_settings.log_file = self.log_file def update_log_file(self, widget): if not self.__log_file.get_active(): self.__log_file_active(False) else: self.__log_file_active(True) def update_log(self, widget): """ Verify if is enable, if it is not enable nothing to do """ if not widget.get_active(): return # Widget is enable. ## But which is enable? # Setting kind of log if widget == self.__log_no: general_settings.log = "None" elif widget == self.__log_terminal: general_settings.log = "Debug" elif widget == self.__log_file: general_settings.log = "File" # API def get_splash(self): return self.__check_splash.get_active() def set_splash(self, splash): self.__check_splash.set_active(splash) def set_warnings_extensions(self, extensions): self.__check_warning_extensions.set_active(extensions) def get_warnings_extensions(self): return self.__check_warning_extensions.get_active() def set_silent_root(self, root): self.__check_silent_root.set_active(root) def get_silent_root(self): return self.__check_silent_root.get_active() def set_crash_report(self, crash): self.__crash_report.set_active(crash) def get_crash_report(self): return self.__crash_report.get_active() def get_log(self): """ filter a str with None, Debug or File return: int (means 0 - No debug, 1 - debug, 2 - debug file) """ if self.__log_no.get_active(): return "None" elif self.__log_terminal.get_active(): return "Debug" elif self.__log_file.get_active(): return "File" else: raise LogException() def set_log(self, log): if log == "None": self.__log_no.set_active(True) elif log == "Debug": self.__log_terminal.set_active(True) elif log == "File": self.__log_file.set_active(True) def __log_file_active(self, bool): self.__log_file_label.set_sensitive(bool) self.__log_file_entry.set_sensitive(bool) self.__log_file_browser.set_sensitive(bool) def set_log_file(self, filename): self.__log_file_entry.set_text(filename) def get_log_file(self): return self.__log_file_entry.get_text() def set_warnings_save(self, save): self._warnings_save.set_active(save) def get_warnings_save(self): return self._warnings_save.get_active() # Propertys splash = property(get_splash, set_splash) warnings_extensions = property(get_warnings_extensions, \ set_warnings_extensions) silent_root = property(get_silent_root, set_silent_root) crash_report = property(get_crash_report, set_crash_report) log = property(get_log, set_log) log_file = property(get_log_file, set_log_file) warnings_save = property(get_warnings_save, set_warnings_save)
class PeerInfoPage(HIGVBox): """""" #---------------------------------------------------------------------- def __init__(self): """Constructor""" HIGVBox.__init__(self) self.__create_widgets() self.__pack_widgets() def __create_widgets(self): """""" self.peerinfo_hbox = HIGHBox() self.cloudagg_hbox = HIGHBox() self.superpeers_hbox = HIGHBox() self.pref_location_hbox = HIGHBox() self.peerinfo_section = HIGSectionLabel(_("Peer Info")) self.peerinfo_table = HIGTable() self.pref_location_section = HIGSectionLabel(_("Preferred Locations")) self.pref_location_table = HIGTable() self.cloudagg_section = HIGSectionLabel(_("Cloud Aggregator")) self.cloudagg_table = HIGTable() self.cloudagg_subhbox = HIGHBox() self.superpeers_section = HIGSectionLabel(_("Super Peers")) self.superpeers_table = HIGTable() self.peerid_label = HIGEntryLabel(_("Peer ID:")) self.email_label = HIGEntryLabel(_("Email Address:")) self.test_version_label = HIGEntryLabel(_("Test Sets Version:")) self.peerid_label2 = HIGEntryLabel() self.email_entry = gtk.Entry() self.test_version_label2 = HIGEntryLabel() self.longitude_label = HIGLabel(_("longitude:")) self.longitude_entry = gtk.Entry() self.latitude_label = HIGLabel(_("latitude:")) self.latitude_entry = gtk.Entry() self.cloudagg_entry = gtk.Entry() self.cloudagg_button = HIGButton(_("Reset")) self.cloudagg_button.connect('clicked', lambda w: self.reset_aggregator_url()) self.cloudagg_button.set_size_request(80, 28) self.superpeers_ip_label = HIGLabel(_("IP:")) self.superpeers_ip_entry = gtk.Entry() self.superpeers_ip_entry.set_size_request(160, 26) self.superpeers_port_label = HIGLabel(_("Port:")) self.superpeers_port_entry = gtk.Entry() self.superpeers_port_entry.set_size_request(80, 26) self.superpeers_subhbox = HIGHBox() self.btn_box = gtk.HButtonBox() self.superpeers_button1 = HIGButton(_("Add")) self.superpeers_button1.connect('clicked', lambda w: self.add_superpeer()) self.superpeers_button2 = HIGButton(_("Show all")) self.superpeers_button2.connect( 'clicked', lambda w: self.show_super_peer_list_window()) def __pack_widgets(self): self.set_border_width(12) self._pack_noexpand_nofill(self.peerinfo_section) self._pack_noexpand_nofill(self.peerinfo_hbox) self._pack_noexpand_nofill(self.pref_location_section) self._pack_noexpand_nofill(self.pref_location_hbox) self._pack_noexpand_nofill(self.cloudagg_section) self._pack_noexpand_nofill(self.cloudagg_hbox) self._pack_noexpand_nofill(self.superpeers_section) self._pack_noexpand_nofill(self.superpeers_hbox) self.peerinfo_hbox._pack_noexpand_nofill(hig_box_space_holder()) self.peerinfo_hbox._pack_expand_fill(self.peerinfo_table) self.pref_location_hbox._pack_noexpand_nofill(hig_box_space_holder()) self.pref_location_hbox._pack_expand_fill(self.pref_location_table) self.cloudagg_hbox._pack_noexpand_nofill(hig_box_space_holder()) self.cloudagg_hbox._pack_expand_fill(self.cloudagg_table) self.superpeers_hbox._pack_noexpand_nofill(hig_box_space_holder()) self.superpeers_hbox._pack_expand_fill(self.superpeers_table) self.peerinfo_table.attach_label(self.peerid_label, 0, 1, 0, 1) self.peerinfo_table.attach_label(self.email_label, 0, 1, 2, 3) self.peerinfo_table.attach_label(self.test_version_label, 0, 1, 1, 2) self.peerinfo_table.attach_label(self.test_version_label2, 1, 2, 1, 2) self.peerinfo_table.attach_label(self.peerid_label2, 1, 2, 0, 1) self.peerinfo_table.attach_entry(self.email_entry, 1, 2, 2, 3) self.pref_location_table.attach(self.longitude_label, 0, 1, 0, 1) self.pref_location_table.attach(self.longitude_entry, 1, 2, 0, 1) self.pref_location_table.attach(self.latitude_label, 2, 3, 0, 1) self.pref_location_table.attach(self.latitude_entry, 3, 4, 0, 1) self.cloudagg_subhbox._pack_expand_fill(self.cloudagg_entry) self.cloudagg_subhbox._pack_noexpand_nofill(self.cloudagg_button) self.cloudagg_table.attach_entry(self.cloudagg_subhbox, 0, 1, 0, 1) self.btn_box.set_layout(gtk.BUTTONBOX_END) self.btn_box.set_spacing(8) self.btn_box.pack_start(self.superpeers_button1) self.btn_box.pack_start(self.superpeers_button2) self.superpeers_subhbox._pack_expand_fill(self.superpeers_ip_label) self.superpeers_subhbox._pack_expand_fill(self.superpeers_ip_entry) self.superpeers_subhbox._pack_expand_fill(self.superpeers_port_label) self.superpeers_subhbox._pack_expand_fill(self.superpeers_port_entry) self.superpeers_subhbox._pack_noexpand_nofill(self.btn_box) self.superpeers_table.attach_label(self.superpeers_subhbox, 0, 1, 0, 1) def add_superpeer(self): """ Add Super Peer by manual into database """ ip = self.superpeers_ip_entry.get_text() port = self.superpeers_port_entry.get_text() g_db_helper.set_super_peer_manual(ip, port) def reset_aggregator_url(self): """ """ aggregator_url = 'http://east1.openmonitor.org' self.cloudagg_entry.set_text(aggregator_url) theApp.aggregator.base_url = aggregator_url g_config.set('network', 'aggregator_url', aggregator_url) g_db_helper.set_value('config', 'aggregator_url', aggregator_url) def show_super_peer_list_window(self): from umit.icm.agent.gui.Preference.SuperPeerSetting import SuperPeerListWindow, SuperPeersBox wnd = SuperPeerListWindow() wnd.show_all()
class NetworkTab(TabBox, object): def __init__(self, name): """ Create widgets of Proxy """ TabBox.__init__(self, name) self._connect_events() #Propertys: self.proxy = network_conf.proxy self.hostname = network_conf.hostname self.port = network_conf.port self.username = network_conf.username self.password = network_conf.password def _create_widgets(self): self._create_widgets_proxy() self.pack_start(self.__frame, False, False) def _create_widgets_proxy(self): self.__frame = TabFrame(_("Proxy Settings")) self.__frame.set_shadow_type(gtk.SHADOW_NONE) self.__frame_box = HIGTable(6,2, True) self._radio_no_proxy = gtk.RadioButton(None, _('No proxy server')) self._radio_proxy = gtk.RadioButton(self._radio_no_proxy, _('Configure server')) # Core Structure of data of proxy: fields = [] fields.append({'name':'hostname', 'label':_('Hostname'), 'values': network_conf.hostname, 'entry' : None }) fields.append({'name':'port', 'label':_('Port'), 'values': network_conf.port, 'entry' : None , 'type' : 'spin' }) fields.append({'name':'username', 'label':_('Username'), 'values': network_conf.username, 'entry' : None }) fields.append({'name': 'password', 'label':_('Password'), 'values': network_conf.password, 'entry' : None, 'type' : 'password' }) self.__proxy_fields = fields # Create, attach and set values of widgets of proxy xopt = gtk.FILL|gtk.EXPAND| gtk.SHRINK yopt = gtk.FILL self.__frame_box.attach(self._radio_no_proxy, 0,1,0,1, xopt, yopt) self.__frame_box.attach(self._radio_proxy,0,1,1,2) row = 2 # Create list of labels/entrys self.__label_list = [] self.__entry_list = [] for field in fields: # Create widgets label = gtk.Label(field['label']) if field.has_key('type') and field['type'] == 'spin': entry = IntSpin() else: entry = HIGTextEntry() # Add widgets to lists self.__label_list.append(label) self.__entry_list.append(entry) field['entry'] = entry # Customize label.set_alignment(1.0, 0.0) # Attachment Table self.__frame_box.attach(label, 0,1,row,row+1, \ xopt, yopt) self.__frame_box.attach(entry,1,2,row,row+1) # Increment row row = row + 1 self.__frame.add(self.__frame_box) def _connect_events(self): # Radio Connects self._radio_no_proxy.connect("toggled", self.update_proxy_details) self._radio_proxy.connect("toggled", self.update_proxy_details) # Proxy fields self.__get_proxy_entry('hostname').connect('changed', \ self.update_hostname) self.__get_proxy_entry('port').connect('changed', \ self.update_port) self.__get_proxy_entry('username').connect('changed', \ self.update_username) self.__get_proxy_entry('password').connect('changed', \ self.update_password) # Callbacks def update_proxy_details(self, widget): if not widget.get_active(): return if widget==self._radio_no_proxy: self.__active_proxy_details(False) network_conf.proxy = False elif widget==self._radio_proxy: self.__active_proxy_details(True) network_conf.proxy = True def update_hostname(self, widget): network_conf.hostname = widget.get_text() def update_port(self, widget): network_conf.port = widget.get_text() def update_username(self, widget): network_conf.username = widget.get_text() def update_password(self, widget): network_conf.password = widget.get_text() ############# def __get_proxy_entry(self, name): for field in self.__proxy_fields: if field['name'] == name: result = field['entry'] break assert result != None return result def __active_proxy_details(self, active): # Labels for label in self.__label_list: label.set_sensitive(active) # Entrys for entry in self.__entry_list: entry.set_sensitive(active) # API def get_proxy(self): if self._radio_no_proxy.get_active(): return False elif self._radio_proxy.get_active(): return True def set_proxy(self, proxy): print "setting proxy" if proxy: self._radio_proxy.set_active(True) self.__active_proxy_details(True) else: self._radio_no_proxy.set_active(True) self.__active_proxy_details(False) def get_hostname(self): entry = self.__get_proxy_entry('hostname') return entry.get_text() def set_hostname(self, hostname): entry = self.__get_proxy_entry('hostname') entry.set_text(hostname) def get_port(self): entry = self.__get_proxy_entry('port') return entry.get_text() def set_port(self, port): entry = self.__get_proxy_entry('port') entry.set_text(port) def get_username(self): entry = self.__get_proxy_entry('username') return entry.get_text() def set_username(self, username): entry = self.__get_proxy_entry('username') entry.set_text(username) def get_password(self): entry = self.__get_proxy_entry('password') return entry.get_text() def set_password(self, password): entry = self.__get_proxy_entry('password') entry.set_text(password) proxy = property(get_proxy, set_proxy) hostname = property(get_hostname, set_hostname) port = property(get_port, set_port) username = property(get_username, set_username) password = property(get_password, set_password)
class ScanChooser(HIGVBox): def __init__(self, scan_dict, num=""): HIGVBox.__init__(self) self.num = num self.scan_dict = scan_dict # Setting HIGVBox self.set_border_width(5) self.set_spacing(6) self._create_widgets() self._pack_hbox() self._attaching_widgets() self._set_scrolled() self._set_text_view() self._set_open_button() for scan in scan_dict: self.list_scan.append([scan]) self.combo_scan.connect('changed', self.show_scan) self._pack_noexpand_nofill(self.lbl_scan) self._pack_expand_fill(self.hbox) def _create_widgets(self): self.lbl_scan = HIGSectionLabel("%s %s" % (_("Scan Result"), str(self.num))) self.hbox = HIGHBox() self.table = HIGTable() self.list_scan = gtk.ListStore(str) self.combo_scan = gtk.ComboBoxEntry(self.list_scan, 0) self.btn_open_scan = gtk.Button(stock=gtk.STOCK_OPEN) self.exp_scan = gtk.Expander(_("Scan Result Visualization")) self.scrolled = gtk.ScrolledWindow() self.txt_scan_result = gtk.TextView() self.txg_tag = gtk.TextTag("scan_style") def get_buffer(self): return self.txt_scan_result.get_buffer() def show_scan(self, widget): try: self.txt_scan_result.get_buffer().\ set_text(self.normalize_output(\ self.scan_dict[widget.child.get_text()].nmap_output)) except KeyError: # Avoid to raise an error if the user writes within # the entry and the scan doesn't exits pass def normalize_output(self, output): return "\n".join(output.split("\\n")) def _pack_hbox(self): self.hbox._pack_noexpand_nofill(hig_box_space_holder()) self.hbox._pack_expand_fill(self.table) def _attaching_widgets(self): self.table.attach(self.combo_scan, 0, 1, 0, 1, yoptions=0) self.table.attach(self.btn_open_scan, 1, 2, 0, 1, yoptions=0, xoptions=0) self.table.attach(self.exp_scan, 0, 2, 1, 2) def _set_scrolled(self): self.scrolled.set_border_width(5) self.scrolled.set_size_request(-1, 160) # Packing scrolled window into expander self.exp_scan.add(self.scrolled) # Packing text view into scrolled window self.scrolled.add_with_viewport(self.txt_scan_result) # Setting scrolled window self.scrolled.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) def _set_text_view(self): self.txg_table = self.txt_scan_result.get_buffer().get_tag_table() self.txg_table.add(self.txg_tag) self.txg_tag.set_property("family", "Monospace") self.txt_scan_result.set_wrap_mode(gtk.WRAP_WORD) self.txt_scan_result.set_editable(False) self.txt_scan_result.get_buffer().connect("changed", self._text_changed_cb) def _set_open_button(self): self.btn_open_scan.connect('clicked', self.open_file) def open_file(self, widget): file_chooser = ResultsFileChooserDialog(_("Select Scan Result")) file_chooser.run() file_chosen = file_chooser.get_filename() file_chooser.destroy() if check_access(file_chosen, os.R_OK): try: parser = NmapParser(file_chosen) parser.parse() except: alert = HIGAlertDialog( message_format='<b>%s</b>' % _('File is not a Umit \ Scan Result'), secondary_text=_("Selected file is not a Umit Scan \ Result file. Umit can not parse this file. Please, select another.")) alert.run() alert.destroy() return False scan_name = os.path.split(file_chosen)[-1] self.add_scan(scan_name, parser) self.combo_scan.set_active(len(self.list_scan) - 1) else: alert = HIGAlertDialog( message_format='<b>%s</b>' % \ _('Can not open selected file'), secondary_text=_("Umit can not open selected file. Please, \ select another." )) alert.run() alert.destroy() def add_scan(self, scan_name, parser): scan_id = 1 new_scan_name = scan_name while new_scan_name in self.scan_dict: new_scan_name = "%s (%s)" % (scan_name, scan_id) scan_id += 1 self.list_scan.append([new_scan_name]) self.scan_dict[new_scan_name] = parser def _text_changed_cb(self, widget): buff = self.txt_scan_result.get_buffer() buff.apply_tag(self.txg_tag, buff.get_start_iter(), buff.get_end_iter()) def get_nmap_output(self): parsed = self.parsed_scan if parsed: return parsed.nmap_output return False def get_parsed_scan(self): selected_scan = self.combo_scan.child.get_text() if selected_scan: return self.scan_dict[selected_scan] return False nmap_output = property(get_nmap_output) parsed_scan = property(get_parsed_scan)
def __pack_widgets(self): self.add(self.main_vbox) # Packing widgets to main_vbox self.main_vbox._pack_noexpand_nofill(self.command_expander) self.main_vbox._pack_expand_fill(self.notebook) self.main_vbox._pack_noexpand_nofill(self.buttons_hbox) # Packing command_entry on command_expander self.command_expander.hbox.pack_start(self.command_entry) # Packing profile information tab on notebook self.notebook.append_page(self.profile_info_vbox, gtk.Label(_('Profile'))) self.profile_info_vbox.set_border_width(5) table = HIGTable() self.profile_info_vbox._pack_noexpand_nofill(self.profile_info_label) self.profile_info_vbox._pack_noexpand_nofill(HIGSpacer(table)) self.profile_annotation_scroll.add(self.profile_annotation_text) self.profile_description_scroll.add(self.profile_description_text) vbox_desc = HIGVBox() vbox_desc._pack_noexpand_nofill(self.profile_description_label) vbox_desc._pack_expand_fill(hig_box_space_holder()) vbox_ann = HIGVBox() vbox_ann._pack_noexpand_nofill(self.profile_annotation_label) vbox_ann._pack_expand_fill(hig_box_space_holder()) table.attach(self.profile_name_label, 0, 1, 0, 1) table.attach(self.profile_name_entry, 1, 2, 0, 1) #table.attach(self.profile_hint_label,0,1,1,2,xoptions=0) table.attach(self.profile_hint_label, 0, 1, 1, 2) table.attach(self.profile_hint_entry, 1, 2, 1, 2) table.attach(vbox_desc, 0, 1, 2, 3) table.attach(self.profile_description_scroll, 1, 2, 2, 3) table.attach(vbox_ann, 0, 1, 3, 4) table.attach(self.profile_annotation_scroll, 1, 2, 3, 4) # Packing buttons on button_hbox self.buttons_hbox.pack_start(self.help_button) #self.buttons_hbox.pack_start(self.delete_button) self.buttons_hbox.pack_start(self.cancel_button) self.buttons_hbox.pack_start(self.ok_button) self.buttons_hbox.set_border_width(5) self.buttons_hbox.set_spacing(6)
class ScanChooser(HIGVBox): def __init__(self, scan_dict, num=""): HIGVBox.__init__(self) self.num = num self.scan_dict = scan_dict # Setting HIGVBox self.set_border_width(5) self.set_spacing(6) self._create_widgets() self._pack_hbox() self._attaching_widgets() self._set_scrolled() self._set_text_view() self._set_open_button() for scan in scan_dict: self.list_scan.append([scan]) self.combo_scan.connect('changed', self.show_scan) self._pack_noexpand_nofill(self.lbl_scan) self._pack_expand_fill(self.hbox) def _create_widgets(self): self.lbl_scan = HIGSectionLabel("%s %s"%(_("Scan Result"), str(self.num))) self.hbox = HIGHBox() self.table = HIGTable() self.list_scan = gtk.ListStore(str) self.combo_scan = gtk.ComboBoxEntry(self.list_scan, 0) self.btn_open_scan = gtk.Button(stock=gtk.STOCK_OPEN) self.exp_scan = gtk.Expander(_("Scan Result Visualization")) self.scrolled = gtk.ScrolledWindow() self.txt_scan_result = gtk.TextView() self.txg_tag = gtk.TextTag("scan_style") def get_buffer(self): return self.txt_scan_result.get_buffer() def show_scan (self, widget): try: self.txt_scan_result.get_buffer().\ set_text(self.normalize_output(\ self.scan_dict[widget.child.get_text()].nmap_output)) except KeyError: # Avoid to raise an error if the user writes within # the entry and the scan doesn't exits pass def normalize_output(self, output): return "\n".join(output.split("\\n")) def _pack_hbox (self): self.hbox._pack_noexpand_nofill(hig_box_space_holder()) self.hbox._pack_expand_fill(self.table) def _attaching_widgets (self): self.table.attach(self.combo_scan, 0,1,0,1, yoptions=0) self.table.attach(self.btn_open_scan, 1,2,0,1, yoptions=0, xoptions=0) self.table.attach(self.exp_scan, 0,2,1,2) def _set_scrolled(self): self.scrolled.set_border_width(5) self.scrolled.set_size_request(-1, 160) # Packing scrolled window into expander self.exp_scan.add(self.scrolled) # Packing text view into scrolled window self.scrolled.add_with_viewport(self.txt_scan_result) # Setting scrolled window self.scrolled.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) def _set_text_view (self): self.txg_table = self.txt_scan_result.get_buffer().get_tag_table() self.txg_table.add(self.txg_tag) self.txg_tag.set_property("family", "Monospace") self.txt_scan_result.set_wrap_mode(gtk.WRAP_WORD) self.txt_scan_result.set_editable(False) self.txt_scan_result.get_buffer().connect("changed", self._text_changed_cb) def _set_open_button (self): self.btn_open_scan.connect('clicked', self.open_file) def open_file (self, widget): file_chooser = ResultsFileChooserDialog(_("Select Scan Result")) file_chooser.run() file_chosen = file_chooser.get_filename() file_chooser.destroy() if check_access(file_chosen, os.R_OK): try: parser = NmapParser(file_chosen) parser.parse() except: alert = HIGAlertDialog( message_format='<b>%s</b>' % _('File is not a Umit \ Scan Result'), secondary_text=_("Selected file is not a Umit Scan \ Result file. Umit can not parse this file. Please, select another.")) alert.run() alert.destroy() return False scan_name = os.path.split(file_chosen)[-1] self.add_scan(scan_name, parser) self.combo_scan.set_active(len(self.list_scan) - 1) else: alert = HIGAlertDialog( message_format='<b>%s</b>' % \ _('Can not open selected file'), secondary_text=_("Umit can not open selected file. Please, \ select another.")) alert.run() alert.destroy() def add_scan(self, scan_name, parser): scan_id = 1 new_scan_name = scan_name while new_scan_name in self.scan_dict: new_scan_name = "%s (%s)" % (scan_name, scan_id) scan_id += 1 self.list_scan.append([new_scan_name]) self.scan_dict[new_scan_name] = parser def _text_changed_cb (self, widget): buff = self.txt_scan_result.get_buffer () buff.apply_tag(self.txg_tag, buff.get_start_iter(), buff.get_end_iter()) def get_nmap_output(self): parsed = self.parsed_scan if parsed: return parsed.nmap_output return False def get_parsed_scan(self): selected_scan = self.combo_scan.child.get_text() if selected_scan: return self.scan_dict[selected_scan] return False nmap_output = property(get_nmap_output) parsed_scan = property(get_parsed_scan)
class NetworkTab(TabBox, object): def __init__(self, name): """ Create widgets of Proxy """ TabBox.__init__(self, name) self._connect_events() #Propertys: self.proxy = network_conf.proxy self.hostname = network_conf.hostname self.port = network_conf.port self.username = network_conf.username self.password = network_conf.password def _create_widgets(self): self._create_widgets_proxy() self.pack_start(self.__frame, False, False) def _create_widgets_proxy(self): self.__frame = TabFrame(_("Proxy Settings")) self.__frame.set_shadow_type(gtk.SHADOW_NONE) self.__frame_box = HIGTable(6, 2, True) self._radio_no_proxy = gtk.RadioButton(None, _('No proxy server')) self._radio_proxy = gtk.RadioButton(self._radio_no_proxy, _('Configure server')) # Core Structure of data of proxy: fields = [] fields.append({ 'name': 'hostname', 'label': _('Hostname'), 'values': network_conf.hostname, 'entry': None }) fields.append({ 'name': 'port', 'label': _('Port'), 'values': network_conf.port, 'entry': None, 'type': 'spin' }) fields.append({ 'name': 'username', 'label': _('Username'), 'values': network_conf.username, 'entry': None }) fields.append({ 'name': 'password', 'label': _('Password'), 'values': network_conf.password, 'entry': None, 'type': 'password' }) self.__proxy_fields = fields # Create, attach and set values of widgets of proxy xopt = gtk.FILL | gtk.EXPAND | gtk.SHRINK yopt = gtk.FILL self.__frame_box.attach(self._radio_no_proxy, 0, 1, 0, 1, xopt, yopt) self.__frame_box.attach(self._radio_proxy, 0, 1, 1, 2) row = 2 # Create list of labels/entrys self.__label_list = [] self.__entry_list = [] for field in fields: # Create widgets label = gtk.Label(field['label']) if field.has_key('type') and field['type'] == 'spin': entry = IntSpin() else: entry = HIGTextEntry() # Add widgets to lists self.__label_list.append(label) self.__entry_list.append(entry) field['entry'] = entry # Customize label.set_alignment(1.0, 0.0) # Attachment Table self.__frame_box.attach(label, 0,1,row,row+1, \ xopt, yopt) self.__frame_box.attach(entry, 1, 2, row, row + 1) # Increment row row = row + 1 self.__frame.add(self.__frame_box) def _connect_events(self): # Radio Connects self._radio_no_proxy.connect("toggled", self.update_proxy_details) self._radio_proxy.connect("toggled", self.update_proxy_details) # Proxy fields self.__get_proxy_entry('hostname').connect('changed', \ self.update_hostname) self.__get_proxy_entry('port').connect('changed', \ self.update_port) self.__get_proxy_entry('username').connect('changed', \ self.update_username) self.__get_proxy_entry('password').connect('changed', \ self.update_password) # Callbacks def update_proxy_details(self, widget): if not widget.get_active(): return if widget == self._radio_no_proxy: self.__active_proxy_details(False) network_conf.proxy = False elif widget == self._radio_proxy: self.__active_proxy_details(True) network_conf.proxy = True def update_hostname(self, widget): network_conf.hostname = widget.get_text() def update_port(self, widget): network_conf.port = widget.get_text() def update_username(self, widget): network_conf.username = widget.get_text() def update_password(self, widget): network_conf.password = widget.get_text() ############# def __get_proxy_entry(self, name): for field in self.__proxy_fields: if field['name'] == name: result = field['entry'] break assert result != None return result def __active_proxy_details(self, active): # Labels for label in self.__label_list: label.set_sensitive(active) # Entrys for entry in self.__entry_list: entry.set_sensitive(active) # API def get_proxy(self): if self._radio_no_proxy.get_active(): return False elif self._radio_proxy.get_active(): return True def set_proxy(self, proxy): print "setting proxy" if proxy: self._radio_proxy.set_active(True) self.__active_proxy_details(True) else: self._radio_no_proxy.set_active(True) self.__active_proxy_details(False) def get_hostname(self): entry = self.__get_proxy_entry('hostname') return entry.get_text() def set_hostname(self, hostname): entry = self.__get_proxy_entry('hostname') entry.set_text(hostname) def get_port(self): entry = self.__get_proxy_entry('port') return entry.get_text() def set_port(self, port): entry = self.__get_proxy_entry('port') entry.set_text(port) def get_username(self): entry = self.__get_proxy_entry('username') return entry.get_text() def set_username(self, username): entry = self.__get_proxy_entry('username') entry.set_text(username) def get_password(self): entry = self.__get_proxy_entry('password') return entry.get_text() def set_password(self, password): entry = self.__get_proxy_entry('password') entry.set_text(password) proxy = property(get_proxy, set_proxy) hostname = property(get_hostname, set_hostname) port = property(get_port, set_port) username = property(get_username, set_username) password = property(get_password, set_password)
class NmapOutputProperties(HIGDialog): def __init__(self, nmap_output_view): HIGDialog.__init__(self, _("Nmap Output Properties"), buttons=(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)) self.nmap_highlight = NmapOutputHighlight() self.__create_widgets() self.__pack_widgets() self.highlight_tab() self.vbox.show_all() def __create_widgets(self): self.properties_notebook = HIGNotebook() def __pack_widgets(self): self.vbox.pack_start(self.properties_notebook) def highlight_tab(self): # Creating highlight tab main box self.highlight_main_vbox = HIGVBox() # Creating highlight tab main table self.highlight_main_table = HIGTable() self.highlight_main_table.set_border_width(6) ############# # Properties: self.property_names = {"details": [_("details"), "MAC Address:"], "port_list": [_("port listing title"), "PORT STATE SERVICE"], "open_port": [_("open port"), "22/tcp open ssh"], "closed_port": [_("closed port"), "70/tcp closed gopher"], "filtered_port": [_("filtered port"), "80/tcp filtered http"], "date": [_("date"), "2006-05-26 11:14 BRT"], "hostname": [_("hostname"), "scanme.nmap.org"], "ip": [_("ip"), "127.0.0.1"]} for p in self.property_names: settings = self.nmap_highlight.__getattribute__(p) self.property_names[p].append(settings[0]) self.property_names[p].append(settings[1]) self.property_names[p].append(settings[2]) self.property_names[p].append(gtk.gdk.Color(*settings[3])) self.property_names[p].append(gtk.gdk.Color(*settings[4])) self.property_names[p].append(settings[5]) # Creating properties and related widgets and attaching it to main table y1 = 0 y2 = 1 for p in self.property_names: hp = HighlightProperty(p, self.property_names[p]) self.highlight_main_table.attach(hp.property_name_label, 0, 1, y1, y2) self.highlight_main_table.attach(hp.example_label, 1, 2, y1, y2) self.highlight_main_table.attach(hp.bold_tg_button, 2, 3, y1, y2) self.highlight_main_table.attach(hp.italic_tg_button, 3, 4, y1, y2) self.highlight_main_table.attach(hp.underline_tg_button, 4, 5, y1, y2) self.highlight_main_table.attach(hp.text_color_button, 5, 6, y1, y2) self.highlight_main_table.attach(hp.highlight_color_button, 6, 7, y1, y2) # Setting example styles and colors hp.update_example() self.property_names[p].append(hp) y1 += 1 y2 += 1 # Packing main table into main vbox self.highlight_main_vbox.pack_start(self.highlight_main_table) # Adding color tab self.properties_notebook.append_page(self.highlight_main_vbox, gtk.Label(_("Highlight definitions")))
class LoginDialog(HIGDialog): """""" #---------------------------------------------------------------------- def __init__(self, title=_('Open Monitor 2012')): """Constructor""" HIGDialog.__init__(self, title=title, flags=gtk.DIALOG_MODAL, buttons=(gtk.STOCK_OK, gtk.RESPONSE_ACCEPT)) self.set_position(gtk.WIN_POS_CENTER_ALWAYS) self.set_default_response(gtk.RESPONSE_ACCEPT) self.set_keep_above(True) self.set_size_request(480, 240) self.set_border_width(2) self._create_widgets() self._pack_widgets() self._connect_widgets() def _create_widgets(self): #Username self.username_label = HIGLabel(_("Username")) self.username_entry = HIGTextEntry() self.username_entry.set_activates_default(True) #Password self.password_label = HIGLabel(_("Password")) self.password_entry = HIGPasswordEntry() self.password_entry.set_activates_default(True) #Logo self.logo_openmonitor = gtk.gdk.pixbuf_new_from_file\ (os.path.join(IMAGES_DIR, 'logoOM.png')) self.logo_image = gtk.Image() self.logo_image.set_from_pixbuf(self.logo_openmonitor) #self.login_text = gtk.Label(_("Log into your ICM agent.")) #Register #self.register_button = HIGStockButton(gtk.STOCK_DIALOG_INFO,_("Register")) self.register_label = \ gtk.Label(_("<span foreground='blue'>" \ "Register id</span>")) self.register_label.set_use_markup(True) self.register_button = gtk.Button() self.register_button.add(self.register_label) self.register_button.set_relief(gtk.RELIEF_NONE) #Forget Password self.forgot_password_label = \ gtk.Label(_("<span foreground='blue'>" \ "Forgot password?</span>")) self.forgot_password_label.set_use_markup(True) self.forgot_password = gtk.Button() self.forgot_password.add(self.forgot_password_label) self.forgot_password.set_relief(gtk.RELIEF_NONE) #Auto Login self.auto_login_checkbtn = gtk.CheckButton(_("Auto login")) #Settings self.settings_button = HIGStockButton(gtk.STOCK_DIALOG_INFO,_("settings")) #Container self.hbox = HIGHBox(False,2) self.table = HIGTable(8,4,False) self.table.set_row_spacings(5) self.table.set_col_spacings(10) self.action_area.set_homogeneous(False) #tab orders self.orders = [self.username_entry, self.password_entry, self.register_button, self.forgot_password] def _pack_widgets(self): self.hbox.set_border_width(8) self.table.set_focus_chain(self.orders) self.table.attach(self.logo_image,0,7,0,5,gtk.FILL,gtk.FILL,0,0) self.table.attach(self.username_label,0,1,5,6,gtk.FILL,gtk.FILL,0,0) self.table.attach(self.username_entry,1,5,5,6,gtk.FILL|gtk.EXPAND,gtk.FILL|gtk.EXPAND,0,0) self.table.attach(self.password_label,0,1,6,7,gtk.FILL,gtk.FILL,0,0) self.table.attach(self.password_entry,1,5,6,7,gtk.FILL|gtk.EXPAND,gtk.FILL|gtk.EXPAND,0,0) self.table.attach(self.register_button,5,6,5,6,gtk.FILL,gtk.FILL,0,0) self.table.attach(self.forgot_password,5,6,6,7,gtk.FILL,gtk.FILL,0,0) self.table.attach(self.auto_login_checkbtn,1,3,7,8,gtk.FILL,gtk.FILL,0,0) self.hbox._pack_expand_fill(self.table) self.vbox.pack_start(self.hbox, False, False) spaceholder1 = hig_box_space_holder() spaceholder2 = hig_box_space_holder() spaceholder3 = hig_box_space_holder() self.action_area.pack_end(spaceholder1) self.action_area.pack_end(spaceholder2) self.action_area.pack_end(spaceholder3) self.action_area.pack_end(self.settings_button) self.action_area.reorder_child(self.settings_button, 0) self.action_area.reorder_child(spaceholder1, 1) self.action_area.reorder_child(spaceholder2, 2) self.action_area.reorder_child(spaceholder3, 2) def _connect_widgets(self): self.connect('response', self.check_response) self.register_button.connect('clicked', self._register) self.forgot_password.connect('clicked', self._forgot_password) self.settings_button.connect('clicked', self._settings) def _register(self, widget): #registration_form = RegistrationDialog() #registration_form.show_all() webbrowser.open(theApp.aggregator.base_url + "/accounts/register/") def _forgot_password(self, widget): webbrowser.open(theApp.aggregator.base_url + "/accounts/password/reset/") def check_response(self, widget, response_id): #There should collect the error information: help the user to check problem if response_id == gtk.RESPONSE_ACCEPT: # clicked on Ok btn username = self.username_entry.get_text() password = self.password_entry.get_text() save_login = self.auto_login_checkbtn.get_active() #Bug in this: If the user go to this window, the theApp.peer_info cannot is_registered #if not theApp.peer_info.is_registered: defer_ = theApp.login(username, password, save_login) # defer_ = theApp.register_agent(username, password) # defer_.addCallback( # lambda x: theApp.login(username, password, save_login)) #else: # defer_ = theApp.login(username, password, save_login) self.destroy() theApp.gtk_main.login_dlg = None elif response_id in (gtk.RESPONSE_DELETE_EVENT, gtk.RESPONSE_CANCEL, gtk.RESPONSE_NONE): self.destroy() theApp.gtk_main.login_dlg = None def _settings(self,widget): ''' configure settings: Server IP/Port: popup a new window ''' settings_form = SettingsDialog() settings_form.show_all()
class UpdatePage(HIGVBox): """""" def __init__(self): """Constructor""" HIGVBox.__init__(self) self.__create_widgets() self.__pack_widgets() self.__load_list() self.__connect_widgets() self.__init_db_text() def __create_widgets(self): """""" self.update_switch_hbox = HIGHBox() self.update_settings_hbox = HIGHBox() self.update_db_hbox = HIGHBox() self.update_switch_section = HIGSectionLabel(_("Update News Detect")) self.update_switch_table = HIGTable() self.update_settings_section = HIGSectionLabel(_("Update Settings")) self.update_settings_table = HIGTable() self.update_db_section = HIGSectionLabel(_("Update Database")) self.update_db_table = HIGTable() self.update_check = gtk.CheckButton(_("Automatically update")) self.update_switch_check = gtk.CheckButton(_("Software Update Detect Switch")) self.update_times_label = HIGEntryLabel(_("Auto detect update news")) self.update_method_label = HIGEntryLabel(_("Update method")) self.update_time_store = gtk.ListStore(str) self.update_time_entry = gtk.ComboBoxEntry(self.update_time_store, 0) self.update_method_store = gtk.ListStore(str) self.update_method_entry = gtk.ComboBoxEntry(self.update_method_store, 0) self.update_db_label = HIGEntryLabel() self.update_db_clear_button = gtk.Button(_("Clear Update Information")) def __pack_widgets(self): """""" self.set_border_width(12) self._pack_noexpand_nofill(self.update_switch_section) self._pack_noexpand_nofill(self.update_switch_hbox) self._pack_noexpand_nofill(hig_box_space_holder()) self._pack_noexpand_nofill(self.update_settings_section) self._pack_noexpand_nofill(self.update_settings_hbox) self._pack_noexpand_nofill(self.update_db_section) self._pack_noexpand_nofill(self.update_db_hbox) self.update_switch_hbox._pack_noexpand_nofill(hig_box_space_holder()) self.update_switch_hbox._pack_expand_fill(self.update_switch_table) self.update_settings_hbox._pack_noexpand_nofill(hig_box_space_holder()) self.update_settings_hbox._pack_expand_fill(self.update_settings_table) self.update_db_hbox._pack_noexpand_nofill(hig_box_space_holder()) self.update_db_hbox._pack_expand_fill(self.update_db_table) self.update_switch_table.attach_label(self.update_check, 0, 2, 0, 1) self.update_switch_table.attach_label(self.update_switch_check, 0, 2, 1, 2) self.update_settings_table.attach_label(self.update_times_label, 0, 1, 0, 1) self.update_settings_table.attach_entry(self.update_time_entry, 1, 2, 0, 1) self.update_settings_table.attach_label(self.update_method_label, 0, 1, 1, 2) self.update_settings_table.attach_entry(self.update_method_entry, 1, 2, 1, 2) self.update_db_table.attach_label(self.update_db_label, 1, 3, 0, 1) self.update_db_table.attach(self.update_db_clear_button, 0, 1, 0, 1) def __init_db_text(self): """""" rs = g_db_helper.select("select * from updates") count = len(rs) self.update_db_label.set_text(str(_("%d records in update database now."%(count)))) def __connect_widgets(self): """""" self.update_check.connect('toggled',lambda w:self.__change_widgets_status()) self.update_db_clear_button.connect("clicked", lambda w:self.__clear_update_db()) def __clear_update_db(self): """""" g_db_helper.execute("delete from updates") g_db_helper.commit() self.update_db_label.set_text(str(_("Clear software update database!"))) def __change_widgets_status(self): """""" if self.update_check.get_active(): self.__disable_widgets() else: self.__enable_widgets() def __load_list(self): """""" for s in update_time_str.keys(): #print s self.update_time_store.append([s]) for s in update_method_str.keys(): #print s self.update_method_store.append([s]) def __disable_widgets(self): """""" self.update_switch_check.set_sensitive(False) self.update_method_entry.set_sensitive(False) self.update_time_entry.set_sensitive(False) def __enable_widgets(self): """""" self.update_switch_check.set_sensitive(True) self.update_method_entry.set_sensitive(True) self.update_time_entry.set_sensitive(True)
class UpdatePage(HIGVBox): """""" def __init__(self): """Constructor""" HIGVBox.__init__(self) self.__create_widgets() self.__pack_widgets() self.__load_list() self.__connect_widgets() self.__init_db_text() def __create_widgets(self): """""" self.update_switch_hbox = HIGHBox() self.update_settings_hbox = HIGHBox() self.update_db_hbox = HIGHBox() self.update_switch_section = HIGSectionLabel(_("Update News Detect")) self.update_switch_table = HIGTable() self.update_settings_section = HIGSectionLabel(_("Update Settings")) self.update_settings_table = HIGTable() self.update_db_section = HIGSectionLabel(_("Update Database")) self.update_db_table = HIGTable() self.update_check = gtk.CheckButton(_("Automatically update")) self.update_switch_check = gtk.CheckButton( _("Software Update Detect Switch")) self.update_times_label = HIGEntryLabel(_("Auto detect update news")) self.update_method_label = HIGEntryLabel(_("Update method")) self.update_time_store = gtk.ListStore(str) self.update_time_entry = gtk.ComboBoxEntry(self.update_time_store, 0) self.update_method_store = gtk.ListStore(str) self.update_method_entry = gtk.ComboBoxEntry(self.update_method_store, 0) self.update_db_label = HIGEntryLabel() self.update_db_clear_button = gtk.Button(_("Clear Update Information")) def __pack_widgets(self): """""" self.set_border_width(12) self._pack_noexpand_nofill(self.update_switch_section) self._pack_noexpand_nofill(self.update_switch_hbox) self._pack_noexpand_nofill(hig_box_space_holder()) self._pack_noexpand_nofill(self.update_settings_section) self._pack_noexpand_nofill(self.update_settings_hbox) self._pack_noexpand_nofill(self.update_db_section) self._pack_noexpand_nofill(self.update_db_hbox) self.update_switch_hbox._pack_noexpand_nofill(hig_box_space_holder()) self.update_switch_hbox._pack_expand_fill(self.update_switch_table) self.update_settings_hbox._pack_noexpand_nofill(hig_box_space_holder()) self.update_settings_hbox._pack_expand_fill(self.update_settings_table) self.update_db_hbox._pack_noexpand_nofill(hig_box_space_holder()) self.update_db_hbox._pack_expand_fill(self.update_db_table) self.update_switch_table.attach_label(self.update_check, 0, 2, 0, 1) self.update_switch_table.attach_label(self.update_switch_check, 0, 2, 1, 2) self.update_settings_table.attach_label(self.update_times_label, 0, 1, 0, 1) self.update_settings_table.attach_entry(self.update_time_entry, 1, 2, 0, 1) self.update_settings_table.attach_label(self.update_method_label, 0, 1, 1, 2) self.update_settings_table.attach_entry(self.update_method_entry, 1, 2, 1, 2) self.update_db_table.attach_label(self.update_db_label, 1, 3, 0, 1) self.update_db_table.attach(self.update_db_clear_button, 0, 1, 0, 1) def __init_db_text(self): """""" rs = g_db_helper.select("select * from updates") count = len(rs) self.update_db_label.set_text( str(_("%d records in update database now." % (count)))) def __connect_widgets(self): """""" self.update_check.connect('toggled', lambda w: self.__change_widgets_status()) self.update_db_clear_button.connect("clicked", lambda w: self.__clear_update_db()) def __clear_update_db(self): """""" g_db_helper.execute("delete from updates") g_db_helper.commit() self.update_db_label.set_text(str( _("Clear software update database!"))) def __change_widgets_status(self): """""" if self.update_check.get_active(): self.__disable_widgets() else: self.__enable_widgets() def __load_list(self): """""" for s in update_time_str.keys(): #print s self.update_time_store.append([s]) for s in update_method_str.keys(): #print s self.update_method_store.append([s]) def __disable_widgets(self): """""" self.update_switch_check.set_sensitive(False) self.update_method_entry.set_sensitive(False) self.update_time_entry.set_sensitive(False) def __enable_widgets(self): """""" self.update_switch_check.set_sensitive(True) self.update_method_entry.set_sensitive(True) self.update_time_entry.set_sensitive(True)
class BoxEditable(HIGVBox): def __init__(self, section_name, profile, listoptions, notebook_parent, new=False): """ A Box Editable contains a options of each tab @param section_name: section name <tab> @type section_name: str @param profile: A class that view and modify xml file @type profile: ProfileCore @param listoptions: The List of Options to update XML (I guess to confirm) @type listoptions: ListOptions @param notebook_parent: Notebook @type notebook_parent: Notebook or Subclass @param new: It's a new tab or not @type new: bool """ HIGVBox.__init__(self) self._coords = {} self._parent = notebook_parent self._last = None #Profile Core do a manage at profile_editor.xml file self._profilecore = None self._profile = profile self._listoptions = listoptions self._table = HIGTable() self._section_name = section_name if not new : self._options = self._profile.get_section(section_name) self._table.set_border_width(3) c = self.get_colormap() color = c.alloc_color(0,0,0) self._table.modify_fg(gtk.STATE_NORMAL,color ) #self._fill_table() box_tmp = HIGVBox() box_tmp.pack_start(self._table, False, False) self._sw = HIGScrolledWindow() #self._sw.set_size_request(400,200) vp = gtk.Viewport() vp.add(box_tmp) vp.set_shadow_type(gtk.SHADOW_NONE) self._sw.add(vp) self.pack_start(self._sw, True, True) self._old_selected = None self._x = 0 self._y = 0 self.connect('button-press-event', self._bp) #Private API def _bp(self, widget,event): pass def _fill_table(self): k = 0 self._old_po = None for i in self._options: t = SpecialHBox() type = i.get_type() if type== 'option_check': name_option = i.get_option() hint = self._listoptions.get_hint(name_option) tmp_widget = OptionCheckIcon(i.get_label(),name_option,hint) t.pack_start(tmp_widget) arg_type = self._listoptions.get_arg_type(name_option) if arg_type!= '': additional = type_mapping[arg_type]() t.pack_start(additional) po = ProfileOption('option_check', i.get_label(),name_option, arg_type,None) po.set_section(self.get_name()) t.set_profileoption(po) elif type == 'option_list': eventbox = gtk.EventBox() label = HIGEntryLabel(i.get_label()) eventbox.add(label) tmp_widget = OptionList() list = [] for j in i.get_option_list(): d = {} d['name'] = j tmp_widget.append(d) list.append(j) po = ProfileOption('option_list', i.get_label(),i.get_label(), None,list) po.set_section(self.get_name()) t.set_profileoption(po) t.pack_start(eventbox) t.pack_start(tmp_widget) #t.drag_source_set(gtk.gdk.BUTTON1_MASK | #gtk.gdk.BUTTON3_MASK, #target, #gtk.gdk.ACTION_COPY | #gtk.gdk.ACTION_MOVE) #t.connect('drag_data_get', self.source_drag_data_get) #XXX : I think that is very important ( I only comment to get focus) if self._old_po!=None: self._old_po.set_next_opt(i.get_label()) self._old_po = po t.set_flags( t.flags() | gtk.CAN_FOCUS) t.connect('button-press-event', self._button_press_event) t.connect('key-press-event', self._key_press_event) t.set_name(i.get_label()) t.connect('drag_data_received', self.drag_received) t.drag_dest_set(gtk.DEST_DEFAULT_ALL, target[:-1], gtk.gdk.ACTION_COPY | gtk.gdk.ACTION_MOVE) self._table.attach(t, 0,2, k,k+1) self._coords[t] = [k, k+1] self._x = k self._y = k+1 k =k +1 self._last = t def delete_on_item(self, widget): if not widget.is_voidplace(): # remove widgets like checkbuttons or others and put voidplace childs = widget.get_children() cmd = CommandAddRemoveOption(widget,childs, self._profilecore,self, False) widget.set_select(False) command_manager.add_command(cmd) log.debug(' Remove Widgets like CheckButtons or others and put voidplace') else: # remove voidplace and delete the widget from table/box #XXX cmd = CommandAddRemoveVoidplace(self, widget, self._coords, False) #widget.unload_voidplace() command_manager.add_command(cmd) log.debug('Remove voidplace and delete the widget from table') self._parent.emit('need-save', 'Sent', None) def _key_press_event(self, widget, event): _keyval = gtk.gdk.keyval_name(event.keyval) if _keyval == "Delete" and self._old_selected!=None : self.delete_on_item(widget) #self._table.remove(widget) #childs = self._table.get_children() #for i in childs: #if i.is_voidplace(): #i.do_resize_voidplace() def _button_press_event(self,widget, event): widget.set_select(True) self._parent.select(False) if widget == self._old_selected : log.debug('Do nothing') if widget.is_voidplace(): widget.do_draw() widget.grab_focus() return widget.do_draw() if self._old_selected != None: self._old_selected.set_select(False) log.debug('drawing') self._old_selected = widget widget.grab_focus() self._parent.emit('changed', 'Options', self._parent.get_current_page()) #Public API def set_name(self, name): self._section_name = name def get_name(self): return self._section_name def get_generic_widget(self, widget, num): ''' Get widget - None Vodplace ''' result = None num = num x1,y1 = self._coords[widget] while True : for i in self._coords: x,y = self._coords[i] if x == (x1-num) and y == (y1-num): result = i break if result!=None and result.is_voidplace(): num = num +1 result = None else: break return result def get_next_widget(self, widget): ''' Get the next widget - None Vodplace ''' if widget == self._last: return None return self.get_generic_widget(widget, -1) def get_prev_widget(self, widget): ''' Get a Previews widget - None Voidplace ''' x, y = self._coords[widget] if x == 0 and y == 1: return None return self.get_generic_widget(widget, 1) def can_move_up(self): widget = self._old_selected x = 0 if widget!= None : try: x,y = self._coords[widget] except KeyError: return False return x != 0 def can_move_down(self): widget = self._old_selected y = len(self._coords) if widget!= None : try: x,y = self._coords[widget] except KeyError: return return y != (len(self._coords)) def send_signal_save(self): self._parent.emit('need-save', 'Sent', None) def send_signal(self): self._parent.emit('changed', 'Options', self._parent.get_current_page()) def create_item(self): t = SpecialHBox() e = gtk.EventBox() label = gtk.Label('-') label.set_size_request(-1, 23) #e.add(label) t.pack_start(label) t.set_flags( t.flags() | gtk.CAN_FOCUS) t.connect('button-press-event', self._button_press_event) t.connect('key-press-event', self._key_press_event) t.connect('drag_data_received', self.drag_received) t.drag_dest_set(gtk.DEST_DEFAULT_ALL, target[:-1], gtk.gdk.ACTION_COPY | gtk.gdk.ACTION_MOVE) return t def add_voidplace(self, position): # Create SpecialHBox with Voidplace t = self.create_item() cmd = CommandVoidPlaceAttach(self, t, self._coords, True) command_manager.add_command(cmd) self._parent.emit('need-save', 'Sent', None) #if position == -1 : #x, y = self._x,self._y #self._table.attach() #else: ## Choose the position #pass def move_item_down(self): ''' Move selected item to down ''' assert self.can_move_down() cmd = CommandMove(self, self._old_selected, self._coords, self._profilecore, False) command_manager.add_command(cmd) self.send_signal() self.send_signal_save() def move_item_up(self): ''' Move selected item to up ''' assert self.can_move_up() cmd = CommandMove(self, self._old_selected, self._coords, self._profilecore, True) command_manager.add_command(cmd) self.send_signal() self.send_signal_save() def search_option(self, name): ''' returns widget ''' list = self._table.get_children() result = None for i in list : if i.get_name() == name : result = i break return result def set_profile_core(self, profile_core): self._profilecore = profile_core def option_builder(self, option_name, type): ''' construct a widget with the name of the option @return: A widget @rtype: Widget like OptionCheck or others ''' result = [] hint = self._listoptions.get_hint(option_name) #label, option_name, hint tmp_widget = OptionCheckIcon(option_name,option_name,hint) result.append(tmp_widget) arg_type = self._listoptions.get_arg_type(option_name) if arg_type!= '': additional = type_mapping[arg_type]() result.append(additional) return result def _is_widget(self, name): return name[0:4] == '_wid' def _create_option_list(self, widget): eventbox = gtk.EventBox() name = 'New Option List' label = HIGEntryLabel(name) eventbox.add(label) tmp_widget = OptionList() list = [] void = {'name':''} j = 'None' d = {} d['name'] = j tmp_widget.append(void) tmp_widget.append(d) list.append(j) po = ProfileOption('option_list',name ,None, None,list) po.set_section(self.get_name()) widget.set_profileoption(po) widgets = [] widgets.append(eventbox) widgets.append(tmp_widget) widget.set_name(name) return widgets def exec_option_list(self, w): widgets = self._create_option_list( w) cmd = CommandAddRemoveOption(w,widgets, self._profile,self, True) command_manager.add_command(cmd) def exec_checkopt(self, name, w): option_name = name opt = self._listoptions.get_option_class(name) profileoption = option_to_profileoption(opt) profileoption.set_section(self.get_name()) arg_type = self._listoptions.get_arg_type(name) widgets = self.option_builder(option_name, arg_type) w.set_profileoption(profileoption) w.set_name(name) cmd = CommandAddRemoveOption(w, widgets, self._profilecore, self,True) command_manager.add_command(cmd) def drag_received(self,w, context, x, y, data, info, time): if not w.is_voidplace(): return option_name = data.data if self._is_widget(option_name) : if option_name == '_widget_option_list': self.exec_option_list(w) #widgets = self._create_option_list( w) #cmd = CommandAddRemoveOption(w,widgets, self._profile, #True) #command_manager.add_command(cmd) return name = data.data self.exec_checkopt(name, w) #Remove child #childs = w.get_children() #w.remove(childs[0]) #Add #for child in widgets: #t = gtk.Label('fsck') #tmp_w.pack_start(child) #child.show_all() #w.unload_voidplace() def get_table(self): return self._table def set_last(self, last): self._last = last def get_last(self): return self._last def source_drag_data_get(self, btn, context, selection_data, info, time): selection_data.set(selection_data.target, 8, "I'm Data!")
def __pack_widgets(self): self.add(self.main_vbox) # Packing widgets to main_vbox self.main_vbox._pack_noexpand_nofill(self.command_expander) self.main_vbox._pack_expand_fill(self.notebook) self.main_vbox._pack_noexpand_nofill(self.buttons_hbox) # Packing command_entry on command_expander self.command_expander.hbox.pack_start(self.command_entry) # Packing profile information tab on notebook self.notebook.append_page(self.profile_info_vbox, gtk.Label(_('Profile'))) self.profile_info_vbox.set_border_width(5) table = HIGTable() self.profile_info_vbox._pack_noexpand_nofill(self.profile_info_label) self.profile_info_vbox._pack_noexpand_nofill(HIGSpacer(table)) self.profile_annotation_scroll.add(self.profile_annotation_text) self.profile_description_scroll.add(self.profile_description_text) vbox_desc = HIGVBox() vbox_desc._pack_noexpand_nofill(self.profile_description_label) vbox_desc._pack_expand_fill(hig_box_space_holder()) vbox_ann = HIGVBox() vbox_ann._pack_noexpand_nofill(self.profile_annotation_label) vbox_ann._pack_expand_fill(hig_box_space_holder()) table.attach(self.profile_name_label,0,1,0,1) table.attach(self.profile_name_entry,1,2,0,1) #table.attach(self.profile_hint_label,0,1,1,2,xoptions=0) table.attach(self.profile_hint_label,0,1,1,2) table.attach(self.profile_hint_entry,1,2,1,2) table.attach(vbox_desc,0,1,2,3) table.attach(self.profile_description_scroll,1,2,2,3) table.attach(vbox_ann,0,1,3,4) table.attach(self.profile_annotation_scroll,1,2,3,4) # Packing buttons on button_hbox self.buttons_hbox.pack_start(self.help_button) #self.buttons_hbox.pack_start(self.delete_button) self.buttons_hbox.pack_start(self.cancel_button) self.buttons_hbox.pack_start(self.ok_button) self.buttons_hbox.set_border_width(5) self.buttons_hbox.set_spacing(6)
def set_scan_infos(self, scan_info): for scan in scan_info: exp = gtk.Expander('<b>%s - %s</b>' % (_('Scan Info'), scan['type'].capitalize())) exp.set_use_markup(True) hbox = HIGHBox() table = HIGTable() table.set_border_width(5) table.set_row_spacings(6) table.set_col_spacings(6) table.attach(HIGEntryLabel(_('Scan type:')),0,1,0,1) table.attach(HIGEntryLabel(scan['type']),1,2,0,1) table.attach(HIGEntryLabel(_('Protocol:')),0,1,1,2) table.attach(HIGEntryLabel(scan['protocol']),1,2,1,2) table.attach(HIGEntryLabel(_('# scanned ports:')),0,1,2,3) table.attach(HIGEntryLabel(scan['numservices']),1,2,2,3) table.attach(HIGEntryLabel(_('Services:')),0,1,3,4) table.attach(self.get_service_view(scan['services'].split(',')),\ 1,2,3,4) hbox._pack_noexpand_nofill(hig_box_space_holder()) hbox._pack_noexpand_nofill(table) exp.add (hbox) self._pack_noexpand_nofill(exp)
class Proprieties(HIGScrolledWindow): ''' This box should be configurable if widget is of a type all configuration should be change to this type #tricks: option_list have a icon to fill with options and option_check have a list of options in combo to change ''' def __init__(self): HIGScrolledWindow.__init__(self) self._boxeditable = None vp = gtk.Viewport() self._create_widgets() vp.add(self._box) vp.set_shadow_type(gtk.SHADOW_NONE) self.add(vp) self._profilecore = None self._selected = None def set_profilecore(self, profilecore): self._profilecore = profilecore def _create_widgets(self): ''' Create the main entrys of the option ''' self._box = HIGVBox() self._table = HIGTable() #Name self._label_name = HIGEntryLabel(_('Name')) self._entry_name = HIGTextEntry() self._entry_name.connect('activate', self._update_label) #Type self._label_type = HIGEntryLabel(_('Type')) self._combo_type = gtk.combo_box_new_text() self._combo_type.append_text('') self._combo_type.append_text('Option List') self._combo_type.append_text('Option Check') self._combo_type.set_active(0) self._combo_type.connect('changed', self.change_combo) self._label_opt = HIGEntryLabel(_('Option')) self._entry_opt = HIGTextEntry() self._entry_opt.set_sensitive(False) #For option list open a dialog to add/remove options self._button_list = HIGButton('Edit Option List') img = gtk.Image() img_dir = os.path.join(pixmaps_dir, 'uie', 'combo.png') img.set_from_file(img_dir) self._button_list.set_image(img) self._button_list.connect('button-press-event', self._button_list_clicked) self._table.attach(self._label_name, 0,1,0, 1) self._table.attach(self._entry_name, 1,2,0,1) self._table.attach(self._label_type, 0,1,1,2) self._table.attach(self._combo_type, 1,2,1, 2) self._table.attach(self._button_list, 0,2, 3,4) self._table.attach(self._label_opt, 0,1, 4,5) self._table.attach(self._entry_opt, 1,2,4,5) self._box.pack_start(self._table, False, False) def _button_list_clicked(self, widget, event): section_name = self._boxeditable.get_name() lm = ListManager(self._entry_name.get_text(),section_name, self._profilecore, self._selected, _('List of items')) def _update_label(self, widget): #XXX Replace by Command log.debug("Update Label") selected = self._selected cmd = CommandChangeLabel(selected, self._entry_name.get_text(), self._profilecore,self._boxeditable, True) command_manager.add_command(cmd) def change_combo(self,combo): model = combo.get_model() index = combo.get_active() if index: if model[index][0]=='Option List': log.debug('Show Button List ') self._button_list.show() else: log.debug('Hide Button List ') self._button_list.hide() return def show_notebook_label(self): ''' show proprieties of notebook label and hide others ''' pass def show_item(self): pass def hide_item(self): self._label_opt.hide() self._entry_opt.hide() self._button_list.hide() self._combo_type.hide() self._label_type.hide() self._entry_name.hide() self._label_name.hide() def set_notebooklabel(self, selected): self._entry_name.show() self._label_name.show() self._entry_name.set_text(selected.get_text()) self._button_list.hide() self._combo_type.hide() self._label_type.hide() self._label_opt.hide() self._entry_opt.hide() self._selected = selected def set_item(self, selected): self._entry_name.show() self._label_name.show() self._selected = selected if selected.get_name()!=None: self._entry_name.set_text(selected.get_name()) else: self.hide_item() return childs = selected.get_children() self._combo_type.show() self._label_type.show() child_label = childs[0] if isinstance(child_label, gtk.HBox): #OptionCheck self._label_opt.show() self._entry_opt.show() opt_ = self._profilecore.get_opt_check(self._boxeditable.get_name(), selected.get_name()) self._entry_opt.set_text(opt_) self._button_list.hide() child_label.cbutton.set_label(self._entry_name.get_text()) self._combo_type.set_active(2) #XXX: Put other widget that sensitible = False with option name elif isinstance(child_label, gtk.EventBox): #OptionList self._button_list.show() other = child_label.get_children()[0] other.set_label(self._entry_name.get_text()) self._combo_type.set_active(1) #Disable Combo to change OptionList/OptionChange self._combo_type.set_sensitive(False) def set_boxeditable(self, boxeditable): self._boxeditable = boxeditable def update(self): pass def disable_all(self): self._label_opt.hide() self._entry_opt.hide() self._button_list.hide() self._combo_type.hide() self._label_type.hide() self._entry_name.hide() self._label_name.hide() def load_data(self, option): pass def unload(self,option): pass
class BoxEditable(HIGVBox): def __init__(self, section_name, profile, listoptions, notebook_parent, new=False): """ A Box Editable contains a options of each tab @param section_name: section name <tab> @type section_name: str @param profile: A class that view and modify xml file @type profile: ProfileCore @param listoptions: The List of Options to update XML (I guess to confirm) @type listoptions: ListOptions @param notebook_parent: Notebook @type notebook_parent: Notebook or Subclass @param new: It's a new tab or not @type new: bool """ HIGVBox.__init__(self) self._coords = {} self._parent = notebook_parent self._last = None #Profile Core do a manage at profile_editor.xml file self._profilecore = None self._profile = profile self._listoptions = listoptions self._table = HIGTable() self._section_name = section_name if not new: self._options = self._profile.get_section(section_name) self._table.set_border_width(3) c = self.get_colormap() color = c.alloc_color(0, 0, 0) self._table.modify_fg(gtk.STATE_NORMAL, color) #self._fill_table() box_tmp = HIGVBox() box_tmp.pack_start(self._table, False, False) self._sw = HIGScrolledWindow() #self._sw.set_size_request(400,200) vp = gtk.Viewport() vp.add(box_tmp) vp.set_shadow_type(gtk.SHADOW_NONE) self._sw.add(vp) self.pack_start(self._sw, True, True) self._old_selected = None self._x = 0 self._y = 0 self.connect('button-press-event', self._bp) #Private API def _bp(self, widget, event): pass def _fill_table(self): k = 0 self._old_po = None for i in self._options: t = SpecialHBox() type = i.get_type() if type == 'option_check': name_option = i.get_option() hint = self._listoptions.get_hint(name_option) tmp_widget = OptionCheckIcon(i.get_label(), name_option, hint) t.pack_start(tmp_widget) arg_type = self._listoptions.get_arg_type(name_option) if arg_type != '': additional = type_mapping[arg_type]() t.pack_start(additional) po = ProfileOption('option_check', i.get_label(), name_option, arg_type, None) po.set_section(self.get_name()) t.set_profileoption(po) elif type == 'option_list': eventbox = gtk.EventBox() label = HIGEntryLabel(i.get_label()) eventbox.add(label) tmp_widget = OptionList() list = [] for j in i.get_option_list(): d = {} d['name'] = j tmp_widget.append(d) list.append(j) po = ProfileOption('option_list', i.get_label(), i.get_label(), None, list) po.set_section(self.get_name()) t.set_profileoption(po) t.pack_start(eventbox) t.pack_start(tmp_widget) #t.drag_source_set(gtk.gdk.BUTTON1_MASK | #gtk.gdk.BUTTON3_MASK, #target, #gtk.gdk.ACTION_COPY | #gtk.gdk.ACTION_MOVE) #t.connect('drag_data_get', self.source_drag_data_get) #XXX : I think that is very important ( I only comment to get focus) if self._old_po != None: self._old_po.set_next_opt(i.get_label()) self._old_po = po t.set_flags(t.flags() | gtk.CAN_FOCUS) t.connect('button-press-event', self._button_press_event) t.connect('key-press-event', self._key_press_event) t.set_name(i.get_label()) t.connect('drag_data_received', self.drag_received) t.drag_dest_set(gtk.DEST_DEFAULT_ALL, target[:-1], gtk.gdk.ACTION_COPY | gtk.gdk.ACTION_MOVE) self._table.attach(t, 0, 2, k, k + 1) self._coords[t] = [k, k + 1] self._x = k self._y = k + 1 k = k + 1 self._last = t def delete_on_item(self, widget): if not widget.is_voidplace(): # remove widgets like checkbuttons or others and put voidplace childs = widget.get_children() cmd = CommandAddRemoveOption(widget, childs, self._profilecore, self, False) widget.set_select(False) command_manager.add_command(cmd) log.debug( ' Remove Widgets like CheckButtons or others and put voidplace' ) else: # remove voidplace and delete the widget from table/box #XXX cmd = CommandAddRemoveVoidplace(self, widget, self._coords, False) #widget.unload_voidplace() command_manager.add_command(cmd) log.debug('Remove voidplace and delete the widget from table') self._parent.emit('need-save', 'Sent', None) def _key_press_event(self, widget, event): _keyval = gtk.gdk.keyval_name(event.keyval) if _keyval == "Delete" and self._old_selected != None: self.delete_on_item(widget) #self._table.remove(widget) #childs = self._table.get_children() #for i in childs: #if i.is_voidplace(): #i.do_resize_voidplace() def _button_press_event(self, widget, event): widget.set_select(True) self._parent.select(False) if widget == self._old_selected: log.debug('Do nothing') if widget.is_voidplace(): widget.do_draw() widget.grab_focus() return widget.do_draw() if self._old_selected != None: self._old_selected.set_select(False) log.debug('drawing') self._old_selected = widget widget.grab_focus() self._parent.emit('changed', 'Options', self._parent.get_current_page()) #Public API def set_name(self, name): self._section_name = name def get_name(self): return self._section_name def get_generic_widget(self, widget, num): ''' Get widget - None Vodplace ''' result = None num = num x1, y1 = self._coords[widget] while True: for i in self._coords: x, y = self._coords[i] if x == (x1 - num) and y == (y1 - num): result = i break if result != None and result.is_voidplace(): num = num + 1 result = None else: break return result def get_next_widget(self, widget): ''' Get the next widget - None Vodplace ''' if widget == self._last: return None return self.get_generic_widget(widget, -1) def get_prev_widget(self, widget): ''' Get a Previews widget - None Voidplace ''' x, y = self._coords[widget] if x == 0 and y == 1: return None return self.get_generic_widget(widget, 1) def can_move_up(self): widget = self._old_selected x = 0 if widget != None: try: x, y = self._coords[widget] except KeyError: return False return x != 0 def can_move_down(self): widget = self._old_selected y = len(self._coords) if widget != None: try: x, y = self._coords[widget] except KeyError: return return y != (len(self._coords)) def send_signal_save(self): self._parent.emit('need-save', 'Sent', None) def send_signal(self): self._parent.emit('changed', 'Options', self._parent.get_current_page()) def create_item(self): t = SpecialHBox() e = gtk.EventBox() label = gtk.Label('-') label.set_size_request(-1, 23) #e.add(label) t.pack_start(label) t.set_flags(t.flags() | gtk.CAN_FOCUS) t.connect('button-press-event', self._button_press_event) t.connect('key-press-event', self._key_press_event) t.connect('drag_data_received', self.drag_received) t.drag_dest_set(gtk.DEST_DEFAULT_ALL, target[:-1], gtk.gdk.ACTION_COPY | gtk.gdk.ACTION_MOVE) return t def add_voidplace(self, position): # Create SpecialHBox with Voidplace t = self.create_item() cmd = CommandVoidPlaceAttach(self, t, self._coords, True) command_manager.add_command(cmd) self._parent.emit('need-save', 'Sent', None) #if position == -1 : #x, y = self._x,self._y #self._table.attach() #else: ## Choose the position #pass def move_item_down(self): ''' Move selected item to down ''' assert self.can_move_down() cmd = CommandMove(self, self._old_selected, self._coords, self._profilecore, False) command_manager.add_command(cmd) self.send_signal() self.send_signal_save() def move_item_up(self): ''' Move selected item to up ''' assert self.can_move_up() cmd = CommandMove(self, self._old_selected, self._coords, self._profilecore, True) command_manager.add_command(cmd) self.send_signal() self.send_signal_save() def search_option(self, name): ''' returns widget ''' list = self._table.get_children() result = None for i in list: if i.get_name() == name: result = i break return result def set_profile_core(self, profile_core): self._profilecore = profile_core def option_builder(self, option_name, type): ''' construct a widget with the name of the option @return: A widget @rtype: Widget like OptionCheck or others ''' result = [] hint = self._listoptions.get_hint(option_name) #label, option_name, hint tmp_widget = OptionCheckIcon(option_name, option_name, hint) result.append(tmp_widget) arg_type = self._listoptions.get_arg_type(option_name) if arg_type != '': additional = type_mapping[arg_type]() result.append(additional) return result def _is_widget(self, name): return name[0:4] == '_wid' def _create_option_list(self, widget): eventbox = gtk.EventBox() name = 'New Option List' label = HIGEntryLabel(name) eventbox.add(label) tmp_widget = OptionList() list = [] void = {'name': ''} j = 'None' d = {} d['name'] = j tmp_widget.append(void) tmp_widget.append(d) list.append(j) po = ProfileOption('option_list', name, None, None, list) po.set_section(self.get_name()) widget.set_profileoption(po) widgets = [] widgets.append(eventbox) widgets.append(tmp_widget) widget.set_name(name) return widgets def exec_option_list(self, w): widgets = self._create_option_list(w) cmd = CommandAddRemoveOption(w, widgets, self._profile, self, True) command_manager.add_command(cmd) def exec_checkopt(self, name, w): option_name = name opt = self._listoptions.get_option_class(name) profileoption = option_to_profileoption(opt) profileoption.set_section(self.get_name()) arg_type = self._listoptions.get_arg_type(name) widgets = self.option_builder(option_name, arg_type) w.set_profileoption(profileoption) w.set_name(name) cmd = CommandAddRemoveOption(w, widgets, self._profilecore, self, True) command_manager.add_command(cmd) def drag_received(self, w, context, x, y, data, info, time): if not w.is_voidplace(): return option_name = data.data if self._is_widget(option_name): if option_name == '_widget_option_list': self.exec_option_list(w) #widgets = self._create_option_list( w) #cmd = CommandAddRemoveOption(w,widgets, self._profile, #True) #command_manager.add_command(cmd) return name = data.data self.exec_checkopt(name, w) #Remove child #childs = w.get_children() #w.remove(childs[0]) #Add #for child in widgets: #t = gtk.Label('fsck') #tmp_w.pack_start(child) #child.show_all() #w.unload_voidplace() def get_table(self): return self._table def set_last(self, last): self._last = last def get_last(self): return self._last def source_drag_data_get(self, btn, context, selection_data, info, time): selection_data.set(selection_data.target, 8, "I'm Data!")