def delete_profile(self, widget=None, extra=None): if self.deletable: dialog = HIGDialog(buttons=(gtk.STOCK_OK, gtk.RESPONSE_OK, gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)) alert = HIGEntryLabel('<b>'+_("Deleting Profile")+'</b>') text = HIGEntryLabel(_('Your profile is going to be deleted! Click\ Ok to continue, or Cancel to go back to Profile Editor.')) hbox = HIGHBox() hbox.set_border_width(5) hbox.set_spacing(12) vbox = HIGVBox() vbox.set_border_width(5) vbox.set_spacing(12) image = gtk.Image() image.set_from_stock(gtk.STOCK_DIALOG_WARNING, gtk.ICON_SIZE_DIALOG) vbox.pack_start(alert) vbox.pack_start(text) hbox.pack_start(image) hbox.pack_start(vbox) dialog.vbox.pack_start(hbox) dialog.vbox.show_all() response = dialog.run() dialog.destroy() if response == gtk.RESPONSE_CANCEL: return True self.profile.remove_profile(self.profile_name) self.update_profile_entry() self.destroy()
def __init__(self, colors): # Shows colors and chars legend HIGDialog.__init__(self, title=_('Color Descriptions'), buttons=(gtk.STOCK_OK, gtk.RESPONSE_ACCEPT)) self.colors = colors self._create_widgets() self._pack_widgets() self._connect_widgets()
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 __init__(self): HIGDialog.__init__(self) self.set_title( _("About %s and %s") % (NMAP_DISPLAY_NAME, APP_DISPLAY_NAME)) self.vbox.set_border_width(12) self.vbox.set_spacing(12) label = gtk.Label() label.set_markup('<span size="xx-large" weight="bold">%s %s</span>' % (escape(APP_DISPLAY_NAME), escape(VERSION))) label.set_selectable(True) self.vbox.pack_start(label) label = gtk.Label() label.set_markup('<span size="small">%s</span>' % (escape(APP_COPYRIGHT))) self.vbox.pack_start(label) entry = _program_entry( NMAP_DISPLAY_NAME, NMAP_WEB_SITE, _("%s is a free and open source utility for network exploration " "and security auditing.") % NMAP_DISPLAY_NAME) self.vbox.pack_start(entry) entry = _program_entry( APP_DISPLAY_NAME, APP_WEB_SITE, _("%s is a multi-platform graphical %s frontend and results viewer. " "It was originally derived from %s.") % (APP_DISPLAY_NAME, NMAP_DISPLAY_NAME, UMIT_DISPLAY_NAME)) self.vbox.pack_start(entry) entry = _program_entry( UMIT_DISPLAY_NAME, UMIT_WEB_SITE, _("%s is an %s GUI created as part of the Nmap/Google Summer " "of Code program.") % (UMIT_DISPLAY_NAME, NMAP_DISPLAY_NAME)) button = gtk.Button(_("%s credits") % UMIT_DISPLAY_NAME) button.connect("clicked", self._show_umit_credits) entry.hbox.pack_start(button, False) self.vbox.pack_start(entry) self.vbox.show_all() close_button = self.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CANCEL) self.set_default_response(gtk.RESPONSE_CANCEL) close_button.grab_focus() self.set_has_separator(False) self.set_resizable(False) self._umit_credits_dialog = None self.connect("response", self._close)
def __init__(self, type, value, tb): HIGDialog.__init__(self) gtk.Window.__init__(self) self.set_title(_('Crash Report')) self.set_position(gtk.WIN_POS_CENTER_ALWAYS) self._create_widgets() self._pack_widgets() self._connect_widgets() trace = "".join(traceback.format_exception(type, value, tb)) text = "Version: " + VERSION + "\n" + trace self.description_text.get_buffer().set_text(text)
def __init__(self): HIGDialog.__init__(self) self.set_title(_("About %s and %s") % ( NMAP_DISPLAY_NAME, APP_DISPLAY_NAME)) self.vbox.set_border_width(12) self.vbox.set_spacing(12) label = gtk.Label() label.set_markup( '<span size="xx-large" weight="bold">%s %s</span>' % ( escape(APP_DISPLAY_NAME), escape(VERSION))) label.set_selectable(True) self.vbox.pack_start(label) label = gtk.Label() label.set_markup( '<span size="small">%s</span>' % (escape(APP_COPYRIGHT))) self.vbox.pack_start(label) entry = _program_entry(NMAP_DISPLAY_NAME, NMAP_WEB_SITE, _( "%s is a free and open source utility for network exploration " "and security auditing.") % NMAP_DISPLAY_NAME) self.vbox.pack_start(entry) entry = _program_entry(APP_DISPLAY_NAME, APP_WEB_SITE, _( "%s is a multi-platform graphical %s frontend and results viewer. " "It was originally derived from %s.") % ( APP_DISPLAY_NAME, NMAP_DISPLAY_NAME, UMIT_DISPLAY_NAME)) self.vbox.pack_start(entry) entry = _program_entry(UMIT_DISPLAY_NAME, UMIT_WEB_SITE, _( "%s is an %s GUI created as part of the Nmap/Google Summer " "of Code program.") % (UMIT_DISPLAY_NAME, NMAP_DISPLAY_NAME)) button = gtk.Button(_("%s credits") % UMIT_DISPLAY_NAME) button.connect("clicked", self._show_umit_credits) entry.hbox.pack_start(button, False) self.vbox.pack_start(entry) self.vbox.show_all() close_button = self.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CANCEL) self.set_default_response(gtk.RESPONSE_CANCEL) close_button.grab_focus() self.set_has_separator(False) self.set_resizable(False) self._umit_credits_dialog = None self.connect("response", self._close)
def _exit_cb(self, *args): """Closes the window, prompting for confirmation if necessary. If one of the tabs couldn't be closed, the function returns True and doesn't exit the application.""" if self.scan_interface.changed: log.debug("Found changes on closing window") dialog = HIGDialog( buttons=(_('Close anyway').encode('utf-8'), gtk.RESPONSE_CLOSE, gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)) alert = HIGEntryLabel('<b>%s</b>' % _("Unsaved changes")) text = HIGEntryLabel(_("The given scan has unsaved changes.\n" "What do you want to do?")) hbox = HIGHBox() hbox.set_border_width(5) hbox.set_spacing(12) vbox = HIGVBox() vbox.set_border_width(5) vbox.set_spacing(12) image = gtk.Image() image.set_from_stock( gtk.STOCK_DIALOG_QUESTION, gtk.ICON_SIZE_DIALOG) vbox.pack_start(alert) vbox.pack_start(text) hbox.pack_start(image) hbox.pack_start(vbox) dialog.vbox.pack_start(hbox) dialog.vbox.show_all() response = dialog.run() dialog.destroy() if response == gtk.RESPONSE_CANCEL: return True search_config = SearchConfig() if search_config.store_results: self.store_result(self.scan_interface) elif self.scan_interface.num_scans_running() > 0: log.debug("Trying to close a window with a running scan") dialog = HIGDialog( buttons=(_('Close anyway').encode('utf-8'), gtk.RESPONSE_CLOSE, gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)) alert = HIGEntryLabel('<b>%s</b>' % _("Trying to close")) text = HIGEntryLabel(_( "The window you are trying to close has a scan running in " "the background.\nWhat do you want to do?")) hbox = HIGHBox() hbox.set_border_width(5) hbox.set_spacing(12) vbox = HIGVBox() vbox.set_border_width(5) vbox.set_spacing(12) image = gtk.Image() image.set_from_stock( gtk.STOCK_DIALOG_WARNING, gtk.ICON_SIZE_DIALOG) vbox.pack_start(alert) vbox.pack_start(text) hbox.pack_start(image) hbox.pack_start(vbox) dialog.vbox.pack_start(hbox) dialog.vbox.show_all() response = dialog.run() dialog.destroy() if response == gtk.RESPONSE_CLOSE: self.scan_interface.kill_all_scans() elif response == gtk.RESPONSE_CANCEL: return True window = WindowConfig() window.x, window.y = self.get_position() window.width, window.height = self.get_size() window.save_changes() if config_parser.failed: alert = HIGAlertDialog( message_format=_("Can't save Zenmap configuration"), # newline before path to help avoid weird line wrapping secondary_text=_( 'An error occurred when saving to\n%s' '\nThe error was: %s.' ) % (Path.user_config_file, config_parser.failed)) alert.run() alert.destroy() self.destroy() return False
def _save_scan_results_cb(self, widget): """'Save Scan' callback function. If it's OK to save the scan, it displays a 'Save File' dialog and saves the scan. If not, it displays an appropriate alert dialog.""" num_scans = len(self.scan_interface.inventory.get_scans()) if num_scans == 0: alert = HIGAlertDialog( message_format=_('Nothing to save'), secondary_text=_( 'There are no scans with results to be saved. ' 'Run a scan with the "Scan" button first.')) alert.run() alert.destroy() return num_scans_running = self.scan_interface.num_scans_running() if num_scans_running > 0: if num_scans_running == 1: text = _("There is a scan still running. " "Wait until it finishes and then save.") else: text = _("There are %u scans still running. Wait until they " "finish and then save.") % num_scans_running alert = HIGAlertDialog(message_format=_('Scan is running'), secondary_text=text) alert.run() alert.destroy() return # If there's more than one scan in the inventory, display a warning # dialog saying that only the most recent scan will be saved selected = 0 if num_scans > 1: #text = _("You have %u scans loaded in the current view. " # "Only the most recent scan will be saved." % num_scans) #alert = HIGAlertDialog( # message_format=_("More than one scan loaded"), # secondary_text=text) #alert.run() #alert.destroy() dlg = HIGDialog( title="Choose a scan to save", parent=self, flags=gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_SAVE, gtk.RESPONSE_OK)) dlg.vbox.pack_start(gtk.Label( "You have %u scans loaded in the current view.\n" "Select the scan which you would like to save." % num_scans), False) scan_combo = gtk.combo_box_new_text() for scan in self.scan_interface.inventory.get_scans(): scan_combo.append_text(scan.nmap_command) scan_combo.set_active(0) dlg.vbox.pack_start(scan_combo, False) dlg.vbox.show_all() if dlg.run() == gtk.RESPONSE_OK: selected = scan_combo.get_active() dlg.destroy() else: dlg.destroy() return # Show the dialog to choose the path to save scan result self._save_results_filechooser_dialog = \ SaveResultsFileChooserDialog(title=_('Save Scan')) # Supply a default file name if this scan was previously saved. if self.scan_interface.saved_filename: self._save_results_filechooser_dialog.set_filename( self.scan_interface.saved_filename) response = self._save_results_filechooser_dialog.run() filename = None if (response == gtk.RESPONSE_OK): filename = self._save_results_filechooser_dialog.get_filename() format = self._save_results_filechooser_dialog.get_format() # add .xml to filename if there is no other extension if filename.find('.') == -1: filename += ".xml" self._save(self.scan_interface, filename, selected, format) self._save_results_filechooser_dialog.destroy() self._save_results_filechooser_dialog = None