def _destroy_callback(window): open_windows.remove(window) if len(open_windows) == 0: gtk.main_quit() try: from zenmapCore.UmitDB import UmitDB except ImportError as e: log.debug(">>> Not cleaning up database: %s." % str(e)) else: # Cleaning up data base UmitDB().cleanup(SearchConfig().converted_save_time)
# A global list of open scan windows. When the last one is destroyed, we call # gtk.main_quit. open_windows = [] def _destroy_callback(window): open_windows.remove(window) if len(open_windows) == 0: gtk.main_quit() try: from zenmapCore.UmitDB import UmitDB except ImportError, e: log.debug(">>> Not cleaning up database: %s." % str(e)) else: # Cleaning up data base UmitDB().cleanup(SearchConfig().converted_save_time) def new_window(): from zenmapGUI.MainWindow import ScanWindow w = ScanWindow() w.connect("destroy", _destroy_callback) if is_maemo(): import hildon hildon_app = hildon.Program() hildon_app.add_window(w) open_windows.append(w) return w # Script found at
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
from time import localtime from types import StringTypes from datetime import date as Date from zenmapCore.Name import APP_DISPLAY_NAME from zenmapCore.I18N import _ from zenmapCore.UmitLogging import log from zenmapCore.NmapCommand import split_quoted from zenmapCore.NmapParser import months from zenmapCore.SearchResult import SearchDir, SearchDB from zenmapCore.UmitConf import is_maemo from zenmapCore.UmitConf import SearchConfig from zenmapGUI.FileChoosers import DirectoryChooserDialog search_config = SearchConfig() class SearchParser(object): """This class is responsible for parsing the search string, and updating the search dictionary (which is, in turn, passed to classes that perform the actual search). It holds a reference to the SearchGUI object, which is used to access its search_dict dictionary, so that all dictionary handling is performed here. It is also responsible for adding additional directories to the SearchGUI object via the 'dir:' operator.""" def __init__(self, search_gui): self.search_gui = search_gui self.search_dict = search_gui.search_dict # We need to make an operator->searchkey mapping, since the search entry # field and the search classes have different syntax.
def _destroy_callback(window): open_windows.remove(window) if len(open_windows) == 0: gtk.main_quit() # Cleaning up data base UmitDB().cleanup(SearchConfig().converted_save_time)