mirror of
https://github.com/nmap/nmap.git
synced 2026-01-02 12:59:02 +00:00
Merge #2088: Update Zenmap to Python 3 and PyGObject
Note: Ndiff build will be broken until subsequent changes are made. Deprecation warnings will need to be addressed in future changes. Closes #2088
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -58,7 +57,11 @@
|
||||
# * *
|
||||
# ***************************************************************************/
|
||||
|
||||
import gtk
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk
|
||||
|
||||
import webbrowser
|
||||
|
||||
from zenmapGUI.higwidgets.higdialogs import HIGDialog
|
||||
@@ -84,7 +87,7 @@ xml.__path__ = [x for x in xml.__path__ if "_xmlplus" not in x]
|
||||
from xml.sax.saxutils import escape
|
||||
|
||||
|
||||
class _program_entry(gtk.VBox):
|
||||
class _program_entry(Gtk.Box):
|
||||
"""A little box containing labels with a program's name and
|
||||
description and a clickable link to its web site."""
|
||||
|
||||
@@ -93,34 +96,30 @@ class _program_entry(gtk.VBox):
|
||||
NAME_WEB_SITE_SPACING = 20
|
||||
|
||||
def __init__(self, name=None, web_site=None, description=None):
|
||||
gtk.VBox.__init__(self)
|
||||
Gtk.Box.__init__(self, orientation=Gtk.Orientation.VERTICAL)
|
||||
|
||||
self.hbox = gtk.HBox(False, self.NAME_WEB_SITE_SPACING)
|
||||
self.pack_start(self.hbox)
|
||||
self.hbox = Gtk.Box.new(Gtk.Orientation.HORIZONTAL,
|
||||
self.NAME_WEB_SITE_SPACING)
|
||||
self.pack_start(self.hbox, True, True, 0)
|
||||
|
||||
if name is not None:
|
||||
name_label = gtk.Label()
|
||||
name_label = Gtk.Label()
|
||||
name_label.set_markup(
|
||||
'<span size="large" weight="bold">%s</span>' % escape(
|
||||
name))
|
||||
self.hbox.pack_start(name_label, False)
|
||||
self.hbox.pack_start(name_label, False, True, 0)
|
||||
|
||||
if web_site is not None:
|
||||
try:
|
||||
web_site_button = gtk.LinkButton(web_site)
|
||||
web_site_button.connect("clicked", self._link_button_open)
|
||||
except AttributeError:
|
||||
# LinkButton was only introduced in PyGTK 2.10.
|
||||
web_site_button = gtk.Label(web_site)
|
||||
web_site_button.set_selectable(True)
|
||||
self.hbox.pack_start(web_site_button, False)
|
||||
web_site_button = Gtk.LinkButton.new(web_site)
|
||||
web_site_button.connect("clicked", self._link_button_open)
|
||||
self.hbox.pack_start(web_site_button, False, True, 0)
|
||||
|
||||
if description is not None:
|
||||
description_label = gtk.Label()
|
||||
description_label = Gtk.Label()
|
||||
description_label.set_alignment(0.0, 0.0)
|
||||
description_label.set_line_wrap(True)
|
||||
description_label.set_text(description)
|
||||
self.pack_start(description_label)
|
||||
self.pack_start(description_label, True, True, 0)
|
||||
|
||||
def _link_button_open(self, widget):
|
||||
webbrowser.open(widget.get_uri())
|
||||
@@ -128,7 +127,7 @@ class _program_entry(gtk.VBox):
|
||||
|
||||
class About(HIGDialog):
|
||||
"""An about dialog showing information about the program. It is meant to
|
||||
have roughly the same feel as gtk.AboutDialog."""
|
||||
have roughly the same feel as Gtk.AboutDialog."""
|
||||
def __init__(self):
|
||||
HIGDialog.__init__(self)
|
||||
self.set_title(_("About %s and %s") % (
|
||||
@@ -137,44 +136,43 @@ class About(HIGDialog):
|
||||
self.vbox.set_border_width(12)
|
||||
self.vbox.set_spacing(12)
|
||||
|
||||
label = gtk.Label()
|
||||
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)
|
||||
self.vbox.pack_start(label, True, True, 0)
|
||||
|
||||
label = gtk.Label()
|
||||
label = Gtk.Label()
|
||||
label.set_markup(
|
||||
'<span size="small">%s</span>' % (escape(APP_COPYRIGHT)))
|
||||
self.vbox.pack_start(label)
|
||||
self.vbox.pack_start(label, True, True, 0)
|
||||
|
||||
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)
|
||||
self.vbox.pack_start(entry, True, True, 0)
|
||||
|
||||
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)
|
||||
self.vbox.pack_start(entry, True, True, 0)
|
||||
|
||||
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 = Gtk.Button.new_with_label(_("%s credits") % UMIT_DISPLAY_NAME)
|
||||
button.connect("clicked", self._show_umit_credits)
|
||||
entry.hbox.pack_start(button, False)
|
||||
self.vbox.pack_start(entry)
|
||||
entry.hbox.pack_start(button, False, True, 0)
|
||||
self.vbox.pack_start(entry, True, True, 0)
|
||||
|
||||
self.vbox.show_all()
|
||||
|
||||
close_button = self.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CANCEL)
|
||||
self.set_default_response(gtk.RESPONSE_CANCEL)
|
||||
close_button = self.add_button(Gtk.STOCK_CLOSE, Gtk.ResponseType.CANCEL)
|
||||
self.set_default_response(Gtk.ResponseType.CANCEL)
|
||||
close_button.grab_focus()
|
||||
|
||||
self.set_has_separator(False)
|
||||
self.set_resizable(False)
|
||||
|
||||
self._umit_credits_dialog = None
|
||||
@@ -208,7 +206,7 @@ class UmitCredits(HIGWindow):
|
||||
HIGWindow.__init__(self)
|
||||
self.set_title(_("%s credits") % UMIT_DISPLAY_NAME)
|
||||
self.set_size_request(-1, 250)
|
||||
self.set_position(gtk.WIN_POS_CENTER)
|
||||
self.set_position(Gtk.WindowPosition.CENTER)
|
||||
|
||||
self.__create_widgets()
|
||||
self.__packing()
|
||||
@@ -218,7 +216,7 @@ class UmitCredits(HIGWindow):
|
||||
self.vbox = HIGVBox()
|
||||
self.hbox = HIGHBox()
|
||||
self.notebook = HIGNotebook()
|
||||
self.btn_close = HIGButton(stock=gtk.STOCK_CLOSE)
|
||||
self.btn_close = HIGButton(stock=Gtk.STOCK_CLOSE)
|
||||
|
||||
self.written_by_scroll = HIGScrolledWindow()
|
||||
self.written_by_text = HIGTextView()
|
||||
@@ -248,35 +246,35 @@ class UmitCredits(HIGWindow):
|
||||
self.hbox._pack_noexpand_nofill(self.btn_close)
|
||||
|
||||
self.notebook.append_page(
|
||||
self.written_by_scroll, gtk.Label(_("Written by")))
|
||||
self.written_by_scroll, Gtk.Label.new(_("Written by")))
|
||||
self.notebook.append_page(
|
||||
self.design_scroll, gtk.Label(_("Design")))
|
||||
self.design_scroll, Gtk.Label.new(_("Design")))
|
||||
self.notebook.append_page(
|
||||
self.soc2007_scroll, gtk.Label(_("SoC 2007")))
|
||||
self.soc2007_scroll, Gtk.Label.new(_("SoC 2007")))
|
||||
self.notebook.append_page(
|
||||
self.contributors_scroll, gtk.Label(_("Contributors")))
|
||||
self.contributors_scroll, Gtk.Label.new(_("Contributors")))
|
||||
self.notebook.append_page(
|
||||
self.translation_scroll, gtk.Label(_("Translation")))
|
||||
self.translation_scroll, Gtk.Label.new(_("Translation")))
|
||||
self.notebook.append_page(
|
||||
self.nokia_scroll, gtk.Label(_("Maemo")))
|
||||
self.nokia_scroll, Gtk.Label.new(_("Maemo")))
|
||||
|
||||
self.written_by_scroll.add(self.written_by_text)
|
||||
self.written_by_text.set_wrap_mode(gtk.WRAP_NONE)
|
||||
self.written_by_text.set_wrap_mode(Gtk.WrapMode.NONE)
|
||||
|
||||
self.design_scroll.add(self.design_text)
|
||||
self.design_text.set_wrap_mode(gtk.WRAP_NONE)
|
||||
self.design_text.set_wrap_mode(Gtk.WrapMode.NONE)
|
||||
|
||||
self.soc2007_scroll.add(self.soc2007_text)
|
||||
self.soc2007_text.set_wrap_mode(gtk.WRAP_NONE)
|
||||
self.soc2007_text.set_wrap_mode(Gtk.WrapMode.NONE)
|
||||
|
||||
self.contributors_scroll.add(self.contributors_text)
|
||||
self.contributors_text.set_wrap_mode(gtk.WRAP_NONE)
|
||||
self.contributors_text.set_wrap_mode(Gtk.WrapMode.NONE)
|
||||
|
||||
self.translation_scroll.add(self.translation_text)
|
||||
self.translation_text.set_wrap_mode(gtk.WRAP_NONE)
|
||||
self.translation_text.set_wrap_mode(Gtk.WrapMode.NONE)
|
||||
|
||||
self.nokia_scroll.add(self.nokia_text)
|
||||
self.nokia_text.set_wrap_mode(gtk.WRAP_NONE)
|
||||
self.nokia_text.set_wrap_mode(Gtk.WrapMode.NONE)
|
||||
|
||||
self.btn_close.connect('clicked', lambda x, y=None: self.destroy())
|
||||
|
||||
@@ -365,6 +363,6 @@ Adriano Monteiro Marques <py.adriano@gmail.com>""")
|
||||
if __name__ == '__main__':
|
||||
about = About()
|
||||
about.show()
|
||||
about.connect("response", lambda widget, response: gtk.main_quit())
|
||||
about.connect("response", lambda widget, response: Gtk.main_quit())
|
||||
|
||||
gtk.main()
|
||||
Gtk.main()
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -62,7 +61,7 @@ import imp
|
||||
import os
|
||||
import signal
|
||||
import sys
|
||||
import ConfigParser
|
||||
import configparser
|
||||
import shutil
|
||||
|
||||
# Cause an exception if PyGTK can't open a display. Normally this just
|
||||
@@ -74,7 +73,9 @@ import shutil
|
||||
import warnings
|
||||
warnings.filterwarnings("error", module="gtk", append="True")
|
||||
try:
|
||||
import gtk
|
||||
import gi
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, Gdk
|
||||
except Exception:
|
||||
# On Mac OS X 10.5, X11 is supposed to be automatically launched on demand.
|
||||
# It works by setting the DISPLAY environment variable to something like
|
||||
@@ -86,7 +87,9 @@ except Exception:
|
||||
# startup scripts, and for some reason the first connection (the one that
|
||||
# caused the launch) is rejected. But somehow subsequent connections work
|
||||
# fine! So if the import fails, try one more time.
|
||||
import gtk
|
||||
import gi
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, Gdk
|
||||
warnings.resetwarnings()
|
||||
|
||||
from zenmapGUI.higwidgets.higdialogs import HIGAlertDialog
|
||||
@@ -103,17 +106,17 @@ from zenmapCore.Name import APP_DISPLAY_NAME
|
||||
from zenmapGUI.higwidgets.higdialogs import HIGAlertDialog
|
||||
|
||||
# A global list of open scan windows. When the last one is destroyed, we call
|
||||
# gtk.main_quit.
|
||||
# Gtk.main_quit.
|
||||
open_windows = []
|
||||
|
||||
|
||||
def _destroy_callback(window):
|
||||
open_windows.remove(window)
|
||||
if len(open_windows) == 0:
|
||||
gtk.main_quit()
|
||||
Gtk.main_quit()
|
||||
try:
|
||||
from zenmapCore.UmitDB import UmitDB
|
||||
except ImportError, e:
|
||||
except ImportError as e:
|
||||
log.debug(">>> Not cleaning up database: %s." % str(e))
|
||||
else:
|
||||
# Cleaning up data base
|
||||
@@ -160,29 +163,31 @@ def install_excepthook():
|
||||
# produces a warning, but the lack of a display eventually causes a
|
||||
# segmentation fault. See http://live.gnome.org/PyGTK/WhatsNew210.
|
||||
warnings.filterwarnings("error", module="gtk")
|
||||
import gtk
|
||||
import gi
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, Gdk
|
||||
warnings.resetwarnings()
|
||||
|
||||
gtk.gdk.threads_enter()
|
||||
Gdk.threads_enter()
|
||||
|
||||
from zenmapGUI.higwidgets.higdialogs import HIGAlertDialog
|
||||
from zenmapGUI.CrashReport import CrashReport
|
||||
if type == ImportError:
|
||||
d = HIGAlertDialog(type=gtk.MESSAGE_ERROR,
|
||||
d = HIGAlertDialog(type=Gtk.MessageType.ERROR,
|
||||
message_format=_("Import error"),
|
||||
secondary_text=_("""A required module was not found.
|
||||
|
||||
""" + unicode(value)))
|
||||
""" + str(value)))
|
||||
d.run()
|
||||
d.destroy()
|
||||
else:
|
||||
c = CrashReport(type, value, tb)
|
||||
c.show_all()
|
||||
gtk.main()
|
||||
Gtk.main()
|
||||
|
||||
gtk.gdk.threads_leave()
|
||||
Gdk.threads_leave()
|
||||
|
||||
gtk.main_quit()
|
||||
Gtk.main_quit()
|
||||
|
||||
sys.excepthook = excepthook
|
||||
|
||||
@@ -215,7 +220,7 @@ def run():
|
||||
# template directory.
|
||||
create_user_config_dir(
|
||||
Path.user_config_dir, Path.config_dir)
|
||||
except (IOError, OSError), e:
|
||||
except (IOError, OSError) as e:
|
||||
error_dialog = HIGAlertDialog(
|
||||
message_format=_(
|
||||
"Error creating the per-user configuration directory"),
|
||||
@@ -239,7 +244,7 @@ scan profiles. Check for access to the directory and try again.""") % (
|
||||
try:
|
||||
# Read the ~/.zenmap/zenmap.conf configuration file.
|
||||
zenmapCore.UmitConf.config_parser.read(Path.user_config_file)
|
||||
except ConfigParser.ParsingError, e:
|
||||
except configparser.ParsingError as e:
|
||||
# ParsingError can leave some values as lists instead of strings. Just
|
||||
# blow it all away if we have this problem.
|
||||
zenmapCore.UmitConf.config_parser = zenmapCore.UmitConf.config_parser.__class__()
|
||||
@@ -258,7 +263,7 @@ until it is repaired.""") % (Path.user_config_file, str(e), APP_DISPLAY_NAME)
|
||||
error_dialog.destroy()
|
||||
global_config_path = os.path.join(Path.config_dir, APP_NAME + '.conf')
|
||||
repair_dialog = HIGAlertDialog(
|
||||
type=gtk.MESSAGE_QUESTION,
|
||||
type=Gtk.MessageType.QUESTION,
|
||||
message_format=_("Restore default configuration?"),
|
||||
secondary_text=_("""\
|
||||
To avoid further errors parsing the configuration file %s, \
|
||||
@@ -267,9 +272,9 @@ you can copy the default configuration from %s.
|
||||
Do this now? \
|
||||
""") % (Path.user_config_file, global_config_path),
|
||||
)
|
||||
repair_dialog.add_button(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)
|
||||
repair_dialog.set_default_response(gtk.RESPONSE_CANCEL)
|
||||
if repair_dialog.run() == gtk.RESPONSE_OK:
|
||||
repair_dialog.add_button(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL)
|
||||
repair_dialog.set_default_response(Gtk.ResponseType.CANCEL)
|
||||
if repair_dialog.run() == Gtk.ResponseType.OK:
|
||||
shutil.copyfile(global_config_path, Path.user_config_file)
|
||||
log.debug(">>> Copy %s to %s." % (global_config_path, Path.user_config_file))
|
||||
repair_dialog.destroy()
|
||||
@@ -316,13 +321,13 @@ Do this now? \
|
||||
|
||||
if main_is_frozen():
|
||||
# This is needed by py2exe
|
||||
gtk.gdk.threads_init()
|
||||
gtk.gdk.threads_enter()
|
||||
Gdk.threads_init()
|
||||
Gdk.threads_enter()
|
||||
|
||||
gtk.main()
|
||||
Gtk.main()
|
||||
|
||||
if main_is_frozen():
|
||||
gtk.gdk.threads_leave()
|
||||
Gdk.threads_leave()
|
||||
|
||||
|
||||
class NonRootWarning (HIGAlertDialog):
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -58,7 +57,10 @@
|
||||
# * *
|
||||
# ***************************************************************************/
|
||||
|
||||
import gtk
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk
|
||||
|
||||
from zenmapGUI.higwidgets.higboxes import HIGVBox
|
||||
|
||||
@@ -74,11 +76,12 @@ xml.__path__ = [x for x in xml.__path__ if "_xmlplus" not in x]
|
||||
from xml.sax.saxutils import escape
|
||||
|
||||
|
||||
class BugReport(gtk.Window, object):
|
||||
class BugReport(Gtk.Window, object):
|
||||
def __init__(self):
|
||||
gtk.Window.__init__(self)
|
||||
Gtk.Window.__init__(self)
|
||||
self.set_title(_('How to Report a Bug'))
|
||||
self.set_position(gtk.WIN_POS_CENTER_ALWAYS)
|
||||
self.set_position(Gtk.WindowPosition.CENTER_ALWAYS)
|
||||
self.set_resizable(False)
|
||||
|
||||
self._create_widgets()
|
||||
self._pack_widgets()
|
||||
@@ -86,16 +89,17 @@ class BugReport(gtk.Window, object):
|
||||
|
||||
def _create_widgets(self):
|
||||
self.vbox = HIGVBox()
|
||||
self.button_box = gtk.HButtonBox()
|
||||
self.button_box = Gtk.ButtonBox.new(Gtk.Orientation.HORIZONTAL)
|
||||
|
||||
self.text = gtk.Label()
|
||||
self.text = Gtk.Label()
|
||||
|
||||
self.btn_ok = gtk.Button(stock=gtk.STOCK_OK)
|
||||
self.btn_ok = Gtk.Button.new_from_stock(Gtk.STOCK_OK)
|
||||
|
||||
def _pack_widgets(self):
|
||||
self.vbox.set_border_width(6)
|
||||
|
||||
self.text.set_line_wrap(True)
|
||||
self.text.set_max_width_chars(50)
|
||||
self.text.set_markup(_("""\
|
||||
<big><b>How to report a bug</b></big>
|
||||
|
||||
@@ -124,8 +128,8 @@ https://nmap.org/data/HACKING. Patches may be sent to nmap-dev \
|
||||
})
|
||||
self.vbox.add(self.text)
|
||||
|
||||
self.button_box.set_layout(gtk.BUTTONBOX_END)
|
||||
self.button_box.pack_start(self.btn_ok)
|
||||
self.button_box.set_layout(Gtk.ButtonBoxStyle.END)
|
||||
self.button_box.pack_start(self.btn_ok, True, True, 0)
|
||||
|
||||
self.vbox._pack_noexpand_nofill(self.button_box)
|
||||
self.add(self.vbox)
|
||||
@@ -140,6 +144,6 @@ https://nmap.org/data/HACKING. Patches may be sent to nmap-dev \
|
||||
if __name__ == "__main__":
|
||||
w = BugReport()
|
||||
w.show_all()
|
||||
w.connect("delete-event", lambda x, y: gtk.main_quit())
|
||||
w.connect("delete-event", lambda x, y: Gtk.main_quit())
|
||||
|
||||
gtk.main()
|
||||
Gtk.main()
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -58,8 +57,12 @@
|
||||
# * *
|
||||
# ***************************************************************************/
|
||||
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, Gdk
|
||||
|
||||
import sys
|
||||
import gtk
|
||||
import traceback
|
||||
|
||||
from zenmapGUI.higwidgets.higdialogs import HIGDialog
|
||||
@@ -81,9 +84,9 @@ from xml.sax.saxutils import escape
|
||||
class CrashReport(HIGDialog):
|
||||
def __init__(self, type, value, tb):
|
||||
HIGDialog.__init__(self)
|
||||
gtk.Window.__init__(self)
|
||||
Gtk.Window.__init__(self)
|
||||
self.set_title(_('Crash Report'))
|
||||
self.set_position(gtk.WIN_POS_CENTER_ALWAYS)
|
||||
self.set_position(Gtk.WindowPosition.CENTER_ALWAYS)
|
||||
|
||||
self._create_widgets()
|
||||
self._pack_widgets()
|
||||
@@ -94,58 +97,59 @@ class CrashReport(HIGDialog):
|
||||
self.description_text.get_buffer().set_text(text)
|
||||
|
||||
def _create_widgets(self):
|
||||
self.button_box = gtk.HButtonBox()
|
||||
self.button_box_ok = gtk.HButtonBox()
|
||||
self.button_box = Gtk.ButtonBox.new(Gtk.Orientation.HORIZONTAL)
|
||||
self.button_box_ok = Gtk.ButtonBox.new(Gtk.Orientation.HORIZONTAL)
|
||||
|
||||
self.description_scrolled = gtk.ScrolledWindow()
|
||||
self.description_text = gtk.TextView()
|
||||
self.description_scrolled = Gtk.ScrolledWindow()
|
||||
self.description_text = Gtk.TextView()
|
||||
self.description_text.set_editable(False)
|
||||
|
||||
self.bug_text = gtk.Label()
|
||||
self.bug_text = Gtk.Label()
|
||||
self.bug_text.set_markup(_('An unexpected error has crashed '
|
||||
'%(app_name)s. Please copy the stack trace below and send it to '
|
||||
'the <a href="mailto:dev@nmap.org">dev@nmap.org</a> mailing list. '
|
||||
'(<a href="http://seclists.org/nmap-dev/">More about the list.</a>'
|
||||
') The developers will see your report and try to fix the problem.'
|
||||
) % {"app_name": escape(APP_DISPLAY_NAME)})
|
||||
self.email_frame = gtk.Frame()
|
||||
self.email_label = gtk.Label()
|
||||
self.email_frame = Gtk.Frame()
|
||||
self.email_label = Gtk.Label()
|
||||
self.email_label.set_markup(_('<b>Copy and email to '
|
||||
'<a href="mailto:dev@nmap.org">dev@nmap.org</a>:</b>'))
|
||||
self.btn_copy = gtk.Button(stock=gtk.STOCK_COPY)
|
||||
self.btn_ok = gtk.Button(stock=gtk.STOCK_OK)
|
||||
self.btn_copy = Gtk.Button.new_from_stock(Gtk.STOCK_COPY)
|
||||
self.btn_ok = Gtk.Button.new_from_stock(Gtk.STOCK_OK)
|
||||
|
||||
self.hbox = HIGHBox()
|
||||
|
||||
def _pack_widgets(self):
|
||||
self.description_scrolled.add(self.description_text)
|
||||
self.description_scrolled.set_policy(
|
||||
gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
|
||||
Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
|
||||
self.description_scrolled.set_size_request(400, 150)
|
||||
self.description_text.set_wrap_mode(gtk.WRAP_WORD)
|
||||
self.description_text.set_wrap_mode(Gtk.WrapMode.WORD)
|
||||
|
||||
self.bug_text.set_max_width_chars(60)
|
||||
self.bug_text.set_line_wrap(True)
|
||||
self.email_label.set_line_wrap(True)
|
||||
|
||||
self.email_frame.set_label_widget(self.email_label)
|
||||
self.email_frame.set_shadow_type(gtk.SHADOW_NONE)
|
||||
self.email_frame.set_shadow_type(Gtk.ShadowType.NONE)
|
||||
|
||||
self.hbox.set_border_width(6)
|
||||
self.vbox.set_border_width(6)
|
||||
|
||||
self.hbox._pack_expand_fill(self.bug_text)
|
||||
|
||||
self.button_box.set_layout(gtk.BUTTONBOX_START)
|
||||
self.button_box_ok.set_layout(gtk.BUTTONBOX_END)
|
||||
self.button_box.set_layout(Gtk.ButtonBoxStyle.START)
|
||||
self.button_box_ok.set_layout(Gtk.ButtonBoxStyle.END)
|
||||
|
||||
self.button_box.pack_start(self.btn_copy)
|
||||
self.button_box_ok.pack_start(self.btn_ok)
|
||||
self.button_box.pack_start(self.btn_copy, True, True, 0)
|
||||
self.button_box_ok.pack_start(self.btn_ok, True, True, 0)
|
||||
|
||||
self.vbox.pack_start(self.hbox)
|
||||
self.vbox.pack_start(self.email_frame)
|
||||
self.vbox.pack_start(self.description_scrolled)
|
||||
self.vbox.pack_start(self.button_box)
|
||||
self.action_area.pack_start(self.button_box_ok)
|
||||
self.vbox.pack_start(self.hbox, True, True, 0)
|
||||
self.vbox.pack_start(self.email_frame, True, True, 0)
|
||||
self.vbox.pack_start(self.description_scrolled, True, True, 0)
|
||||
self.vbox.pack_start(self.button_box, True, True, 0)
|
||||
self.action_area.pack_start(self.button_box_ok, True, True, 0)
|
||||
|
||||
def _connect_widgets(self):
|
||||
self.btn_ok.connect("clicked", self.close)
|
||||
@@ -154,21 +158,21 @@ class CrashReport(HIGDialog):
|
||||
|
||||
def get_description(self):
|
||||
buff = self.description_text.get_buffer()
|
||||
return buff.get_text(buff.get_start_iter(), buff.get_end_iter())
|
||||
return buff.get_text(buff.get_start_iter(), buff.get_end_iter(), include_hidden_chars=True)
|
||||
|
||||
def copy(self, widget=None, event=None):
|
||||
clipboard = gtk.clipboard_get()
|
||||
clipboard.set_text(self.get_description())
|
||||
clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
|
||||
clipboard.set_text(self.get_description(), -1)
|
||||
clipboard.store()
|
||||
|
||||
def close(self, widget=None, event=None):
|
||||
self.destroy()
|
||||
gtk.main_quit()
|
||||
Gtk.main_quit()
|
||||
sys.exit(0)
|
||||
|
||||
if __name__ == "__main__":
|
||||
c = CrashReport(None, None, None)
|
||||
c.show_all()
|
||||
c.connect("delete-event", lambda x, y: gtk.main_quit())
|
||||
c.connect("delete-event", lambda x, y: Gtk.main_quit())
|
||||
|
||||
gtk.main()
|
||||
Gtk.main()
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -58,8 +57,11 @@
|
||||
# * *
|
||||
# ***************************************************************************/
|
||||
|
||||
import gobject
|
||||
import gtk
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, GObject, GLib
|
||||
|
||||
import os
|
||||
import os.path
|
||||
import sys
|
||||
@@ -94,11 +96,12 @@ class ScanChooser(HIGVBox):
|
||||
has changed."""
|
||||
|
||||
__gsignals__ = {
|
||||
"changed": (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ())
|
||||
"changed": (GObject.SignalFlags.RUN_FIRST, GObject.TYPE_NONE, ())
|
||||
}
|
||||
|
||||
def __init__(self, scans, title):
|
||||
self.__gobject_init__()
|
||||
HIGVBox.__init__(self)
|
||||
|
||||
self.title = title
|
||||
self.scan_dict = {}
|
||||
|
||||
@@ -126,13 +129,12 @@ class ScanChooser(HIGVBox):
|
||||
self.lbl_scan = HIGSectionLabel(self.title)
|
||||
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 Output"))
|
||||
self.scrolled = gtk.ScrolledWindow()
|
||||
self.txt_scan_result = gtk.TextView()
|
||||
self.txg_tag = gtk.TextTag("scan_style")
|
||||
self.combo_scan = Gtk.ComboBoxText.new_with_entry()
|
||||
self.btn_open_scan = Gtk.Button.new_from_stock(Gtk.STOCK_OPEN)
|
||||
self.exp_scan = Gtk.Expander.new(_("Scan Output"))
|
||||
self.scrolled = Gtk.ScrolledWindow()
|
||||
self.txt_scan_result = Gtk.TextView()
|
||||
self.txg_tag = Gtk.TextTag.new("scan_style")
|
||||
|
||||
def get_buffer(self):
|
||||
return self.txt_scan_result.get_buffer()
|
||||
@@ -166,14 +168,14 @@ class ScanChooser(HIGVBox):
|
||||
self.scrolled.add_with_viewport(self.txt_scan_result)
|
||||
|
||||
# Setting scrolled window
|
||||
self.scrolled.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
|
||||
self.scrolled.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.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_wrap_mode(Gtk.WrapMode.WORD)
|
||||
self.txt_scan_result.set_editable(False)
|
||||
self.txt_scan_result.get_buffer().connect(
|
||||
"changed", self._text_changed_cb)
|
||||
@@ -187,7 +189,7 @@ class ScanChooser(HIGVBox):
|
||||
response = file_chooser.run()
|
||||
file_chosen = file_chooser.get_filename()
|
||||
file_chooser.destroy()
|
||||
if response == gtk.RESPONSE_OK:
|
||||
if response == Gtk.ResponseType.OK:
|
||||
try:
|
||||
parser = NmapParser()
|
||||
parser.parse_file(file_chosen)
|
||||
@@ -214,7 +216,7 @@ class ScanChooser(HIGVBox):
|
||||
scan_name = os.path.split(file_chosen)[-1]
|
||||
self.add_scan(scan_name, parser)
|
||||
|
||||
self.combo_scan.set_active(len(self.list_scan) - 1)
|
||||
self.combo_scan.set_active(len(self.combo_scan.get_model()) - 1)
|
||||
|
||||
def add_scan(self, scan_name, parser):
|
||||
scan_id = 1
|
||||
@@ -223,7 +225,7 @@ class ScanChooser(HIGVBox):
|
||||
new_scan_name = "%s (%s)" % (scan_name, scan_id)
|
||||
scan_id += 1
|
||||
|
||||
self.list_scan.append([new_scan_name])
|
||||
self.combo_scan.append_text(new_scan_name)
|
||||
self.scan_dict[new_scan_name] = parser
|
||||
|
||||
def _text_changed_cb(self, widget):
|
||||
@@ -234,7 +236,7 @@ class ScanChooser(HIGVBox):
|
||||
def get_parsed_scan(self):
|
||||
"""Return the currently selected scan's parsed output as an NmapParser
|
||||
object, or None if no valid scan is selected."""
|
||||
selected_scan = self.combo_scan.child.get_text()
|
||||
selected_scan = self.combo_scan.get_active_text()
|
||||
return self.scan_dict.get(selected_scan)
|
||||
|
||||
def get_nmap_output(self):
|
||||
@@ -249,9 +251,9 @@ class ScanChooser(HIGVBox):
|
||||
parsed_scan = property(get_parsed_scan)
|
||||
|
||||
|
||||
class DiffWindow(gtk.Window):
|
||||
class DiffWindow(Gtk.Window):
|
||||
def __init__(self, scans):
|
||||
gtk.Window.__init__(self)
|
||||
Gtk.Window.__init__(self)
|
||||
self.set_title(_("Compare Results"))
|
||||
self.ndiff_process = None
|
||||
# We allow the user to start a new diff before the old one has
|
||||
@@ -265,11 +267,11 @@ class DiffWindow(gtk.Window):
|
||||
self.diff_view = DiffView()
|
||||
self.diff_view.set_size_request(-1, 100)
|
||||
self.hbox_buttons = HIGHBox()
|
||||
self.progress = gtk.ProgressBar()
|
||||
self.btn_close = HIGButton(stock=gtk.STOCK_CLOSE)
|
||||
self.progress = Gtk.ProgressBar()
|
||||
self.btn_close = HIGButton(stock=Gtk.STOCK_CLOSE)
|
||||
self.hbox_selection = HIGHBox()
|
||||
self.scan_chooser_a = ScanChooser(scans, _(u"A Scan"))
|
||||
self.scan_chooser_b = ScanChooser(scans, _(u"B Scan"))
|
||||
self.scan_chooser_a = ScanChooser(scans, _("A Scan"))
|
||||
self.scan_chooser_b = ScanChooser(scans, _("B Scan"))
|
||||
|
||||
self._pack_widgets()
|
||||
self._connect_widgets()
|
||||
@@ -282,20 +284,20 @@ class DiffWindow(gtk.Window):
|
||||
def _pack_widgets(self):
|
||||
self.main_vbox.set_border_width(6)
|
||||
|
||||
self.hbox_selection.pack_start(self.scan_chooser_a, True, True)
|
||||
self.hbox_selection.pack_start(self.scan_chooser_b, True, True)
|
||||
self.hbox_selection.pack_start(self.scan_chooser_a, True, True, 0)
|
||||
self.hbox_selection.pack_start(self.scan_chooser_b, True, True, 0)
|
||||
|
||||
self.main_vbox.pack_start(self.hbox_selection, False)
|
||||
self.main_vbox.pack_start(self.hbox_selection, False, True, 0)
|
||||
|
||||
scroll = gtk.ScrolledWindow()
|
||||
scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
|
||||
scroll = Gtk.ScrolledWindow()
|
||||
scroll.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
|
||||
scroll.add(self.diff_view)
|
||||
self.main_vbox.pack_start(scroll, True, True)
|
||||
self.main_vbox.pack_start(scroll, True, True, 0)
|
||||
|
||||
self.progress.hide()
|
||||
self.progress.set_no_show_all(True)
|
||||
self.hbox_buttons.pack_start(self.progress, False)
|
||||
self.hbox_buttons.pack_end(self.btn_close, False)
|
||||
self.hbox_buttons.pack_start(self.progress, False, True, 0)
|
||||
self.hbox_buttons.pack_end(self.btn_close, False, True, 0)
|
||||
|
||||
self.main_vbox._pack_noexpand_nofill(self.hbox_buttons)
|
||||
|
||||
@@ -337,7 +339,7 @@ class DiffWindow(gtk.Window):
|
||||
else:
|
||||
self.progress.show()
|
||||
if self.timer_id is None:
|
||||
self.timer_id = gobject.timeout_add(
|
||||
self.timer_id = GLib.timeout_add(
|
||||
NDIFF_CHECK_TIMEOUT, self.check_ndiff_process)
|
||||
|
||||
def check_ndiff_process(self):
|
||||
@@ -362,7 +364,7 @@ class DiffWindow(gtk.Window):
|
||||
if status == 0 or status == 1:
|
||||
# Successful completion.
|
||||
try:
|
||||
diff = self.ndiff_process.get_scan_diff()
|
||||
diff = self.ndiff_process.get_scan_diff().decode("utf-8")
|
||||
except zenmapCore.Diff.NdiffParseException as e:
|
||||
alert = HIGAlertDialog(
|
||||
message_format=_("Error parsing ndiff output"),
|
||||
@@ -401,13 +403,13 @@ class DiffWindow(gtk.Window):
|
||||
self.destroy()
|
||||
|
||||
|
||||
class DiffView(gtk.TextView):
|
||||
class DiffView(Gtk.TextView):
|
||||
REMOVE_COLOR = "#ffaaaa"
|
||||
ADD_COLOR = "#ccffcc"
|
||||
|
||||
"""A widget displaying a zenmapCore.Diff.ScanDiff."""
|
||||
def __init__(self):
|
||||
gtk.TextView.__init__(self)
|
||||
Gtk.TextView.__init__(self)
|
||||
self.set_editable(False)
|
||||
|
||||
buff = self.get_buffer()
|
||||
@@ -418,7 +420,7 @@ class DiffView(gtk.TextView):
|
||||
buff.create_tag("+", font="Monospace", background=self.ADD_COLOR)
|
||||
|
||||
def clear(self):
|
||||
self.get_buffer().set_text(u"")
|
||||
self.get_buffer().set_text("")
|
||||
|
||||
def show_diff(self, diff):
|
||||
self.clear()
|
||||
@@ -451,6 +453,6 @@ if __name__ == "__main__":
|
||||
"Parsed 4": parsed4})
|
||||
|
||||
dw.show_all()
|
||||
dw.connect("delete-event", lambda x, y: gtk.main_quit())
|
||||
dw.connect("delete-event", lambda x, y: Gtk.main_quit())
|
||||
|
||||
gtk.main()
|
||||
Gtk.main()
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -58,27 +57,31 @@
|
||||
# * *
|
||||
# ***************************************************************************/
|
||||
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk
|
||||
|
||||
import os.path
|
||||
import sys
|
||||
import gtk
|
||||
|
||||
import zenmapCore.I18N # lgtm[py/unused-import]
|
||||
|
||||
RESPONSE_OPEN_DIRECTORY = 1
|
||||
|
||||
|
||||
class AllFilesFileFilter(gtk.FileFilter):
|
||||
class AllFilesFileFilter(Gtk.FileFilter):
|
||||
def __init__(self):
|
||||
gtk.FileFilter.__init__(self)
|
||||
Gtk.FileFilter.__init__(self)
|
||||
|
||||
pattern = "*"
|
||||
self.add_pattern(pattern)
|
||||
self.set_name(_("All files (%s)") % pattern)
|
||||
|
||||
|
||||
class ResultsFileFilter(gtk.FileFilter):
|
||||
class ResultsFileFilter(Gtk.FileFilter):
|
||||
def __init__(self):
|
||||
gtk.FileFilter.__init__(self)
|
||||
Gtk.FileFilter.__init__(self)
|
||||
|
||||
patterns = ["*.xml"]
|
||||
for pattern in patterns:
|
||||
@@ -86,9 +89,9 @@ class ResultsFileFilter(gtk.FileFilter):
|
||||
self.set_name(_("Nmap XML files (%s)") % ", ".join(patterns))
|
||||
|
||||
|
||||
class ScriptFileFilter(gtk.FileFilter):
|
||||
class ScriptFileFilter(Gtk.FileFilter):
|
||||
def __init__(self):
|
||||
gtk.FileFilter.__init__(self)
|
||||
Gtk.FileFilter.__init__(self)
|
||||
|
||||
patterns = ["*.nse"]
|
||||
for pattern in patterns:
|
||||
@@ -96,7 +99,7 @@ class ScriptFileFilter(gtk.FileFilter):
|
||||
self.set_name(_("NSE scripts (%s)") % ", ".join(patterns))
|
||||
|
||||
|
||||
class UnicodeFileChooserDialog(gtk.FileChooserDialog):
|
||||
class UnicodeFileChooserDialog(Gtk.FileChooserDialog):
|
||||
"""This is a base class for file choosers. It is designed to ease the
|
||||
retrieval of Unicode file names. On most platforms, the file names returned
|
||||
are encoded in the encoding given by sys.getfilesystemencoding(). On
|
||||
@@ -104,7 +107,7 @@ class UnicodeFileChooserDialog(gtk.FileChooserDialog):
|
||||
results in a file not found error. The get_filename method of this class
|
||||
handles the decoding automatically."""
|
||||
def get_filename(self):
|
||||
filename = gtk.FileChooserDialog.get_filename(self)
|
||||
filename = Gtk.FileChooserDialog.get_filename(self)
|
||||
if sys.platform == "win32":
|
||||
encoding = "UTF-8"
|
||||
else:
|
||||
@@ -118,13 +121,13 @@ class UnicodeFileChooserDialog(gtk.FileChooserDialog):
|
||||
|
||||
class AllFilesFileChooserDialog(UnicodeFileChooserDialog):
|
||||
def __init__(self, title="", parent=None,
|
||||
action=gtk.FILE_CHOOSER_ACTION_OPEN,
|
||||
buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
|
||||
gtk.STOCK_OPEN, gtk.RESPONSE_OK), backend=None):
|
||||
action=Gtk.FileChooserAction.OPEN,
|
||||
buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
|
||||
Gtk.STOCK_OPEN, Gtk.ResponseType.OK), backend=None):
|
||||
|
||||
gtk.FileChooserDialog.__init__(self, title, parent,
|
||||
action, buttons)
|
||||
self.set_default_response(gtk.RESPONSE_OK)
|
||||
UnicodeFileChooserDialog.__init__(self, title=title, parent=parent,
|
||||
action=action, buttons=buttons)
|
||||
self.set_default_response(Gtk.ResponseType.OK)
|
||||
self.add_filter(AllFilesFileFilter())
|
||||
|
||||
|
||||
@@ -132,40 +135,40 @@ class ResultsFileSingleChooserDialog(UnicodeFileChooserDialog):
|
||||
"""This results file choose only allows the selection of single files, not
|
||||
directories."""
|
||||
def __init__(self, title="", parent=None,
|
||||
action=gtk.FILE_CHOOSER_ACTION_OPEN,
|
||||
buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
|
||||
gtk.STOCK_OPEN, gtk.RESPONSE_OK), backend=None):
|
||||
action=Gtk.FileChooserAction.OPEN,
|
||||
buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
|
||||
Gtk.STOCK_OPEN, Gtk.ResponseType.OK), backend=None):
|
||||
|
||||
UnicodeFileChooserDialog.__init__(self, title, parent,
|
||||
action, buttons)
|
||||
self.set_default_response(gtk.RESPONSE_OK)
|
||||
UnicodeFileChooserDialog.__init__(self, title=title, parent=parent,
|
||||
action=action, buttons=buttons)
|
||||
self.set_default_response(Gtk.ResponseType.OK)
|
||||
for f in (ResultsFileFilter(), AllFilesFileFilter()):
|
||||
self.add_filter(f)
|
||||
|
||||
|
||||
class ResultsFileChooserDialog(UnicodeFileChooserDialog):
|
||||
def __init__(self, title="", parent=None,
|
||||
action=gtk.FILE_CHOOSER_ACTION_OPEN,
|
||||
buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
|
||||
action=Gtk.FileChooserAction.OPEN,
|
||||
buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
|
||||
"Open Directory", RESPONSE_OPEN_DIRECTORY,
|
||||
gtk.STOCK_OPEN, gtk.RESPONSE_OK), backend=None):
|
||||
Gtk.STOCK_OPEN, Gtk.ResponseType.OK), backend=None):
|
||||
|
||||
UnicodeFileChooserDialog.__init__(self, title, parent,
|
||||
action, buttons)
|
||||
self.set_default_response(gtk.RESPONSE_OK)
|
||||
UnicodeFileChooserDialog.__init__(self, title=title, parent=parent,
|
||||
action=action, buttons=buttons)
|
||||
self.set_default_response(Gtk.ResponseType.OK)
|
||||
for f in (ResultsFileFilter(), AllFilesFileFilter()):
|
||||
self.add_filter(f)
|
||||
|
||||
|
||||
class ScriptFileChooserDialog(UnicodeFileChooserDialog):
|
||||
def __init__(self, title="", parent=None,
|
||||
action=gtk.FILE_CHOOSER_ACTION_OPEN,
|
||||
buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
|
||||
gtk.STOCK_OPEN, gtk.RESPONSE_OK), backend=None):
|
||||
action=Gtk.FileChooserAction.OPEN,
|
||||
buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
|
||||
Gtk.STOCK_OPEN, Gtk.ResponseType.OK), backend=None):
|
||||
|
||||
UnicodeFileChooserDialog.__init__(self, title, parent,
|
||||
action, buttons)
|
||||
self.set_default_response(gtk.RESPONSE_OK)
|
||||
UnicodeFileChooserDialog.__init__(self, title=title, parent=parent,
|
||||
action=action, buttons=buttons)
|
||||
self.set_default_response(Gtk.ResponseType.OK)
|
||||
self.set_select_multiple(True)
|
||||
for f in (ScriptFileFilter(), AllFilesFileFilter()):
|
||||
self.add_filter(f)
|
||||
@@ -185,32 +188,33 @@ class SaveResultsFileChooserDialog(UnicodeFileChooserDialog):
|
||||
}
|
||||
|
||||
def __init__(self, title="", parent=None,
|
||||
action=gtk.FILE_CHOOSER_ACTION_SAVE,
|
||||
buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
|
||||
gtk.STOCK_SAVE, gtk.RESPONSE_OK), backend=None):
|
||||
action=Gtk.FileChooserAction.SAVE,
|
||||
buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
|
||||
Gtk.STOCK_SAVE, Gtk.ResponseType.OK), backend=None):
|
||||
|
||||
UnicodeFileChooserDialog.__init__(self, title, parent, action, buttons)
|
||||
UnicodeFileChooserDialog.__init__(self, title=title, parent=parent,
|
||||
action=action, buttons=buttons)
|
||||
|
||||
types_store = gtk.ListStore(str, str, str)
|
||||
types_store = Gtk.ListStore.new([str, str, str])
|
||||
for type in self.TYPES:
|
||||
types_store.append(type)
|
||||
|
||||
self.combo = gtk.ComboBox(types_store)
|
||||
cell = gtk.CellRendererText()
|
||||
self.combo = Gtk.ComboBox.new_with_model(types_store)
|
||||
cell = Gtk.CellRendererText()
|
||||
self.combo.pack_start(cell, True)
|
||||
self.combo.add_attribute(cell, "text", 0)
|
||||
self.combo.connect("changed", self.combo_changed_cb)
|
||||
self.combo.set_active(1)
|
||||
|
||||
hbox = gtk.HBox(False, 6)
|
||||
hbox.pack_end(self.combo, False)
|
||||
hbox.pack_end(gtk.Label(_("Select File Type:")), False)
|
||||
hbox = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, 6)
|
||||
hbox.pack_end(self.combo, False, True, 0)
|
||||
hbox.pack_end(Gtk.Label.new(_("Select File Type:")), False, True, 0)
|
||||
hbox.show_all()
|
||||
|
||||
self.set_extra_widget(hbox)
|
||||
self.set_do_overwrite_confirmation(True)
|
||||
|
||||
self.set_default_response(gtk.RESPONSE_OK)
|
||||
self.set_default_response(Gtk.ResponseType.OK)
|
||||
|
||||
def combo_changed_cb(self, combo):
|
||||
filename = self.get_filename() or ""
|
||||
@@ -243,19 +247,21 @@ class SaveResultsFileChooserDialog(UnicodeFileChooserDialog):
|
||||
|
||||
class DirectoryChooserDialog(UnicodeFileChooserDialog):
|
||||
def __init__(self, title="", parent=None,
|
||||
action=gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER,
|
||||
buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
|
||||
gtk.STOCK_OPEN, gtk.RESPONSE_OK), backend=None):
|
||||
action=Gtk.FileChooserAction.SELECT_FOLDER,
|
||||
buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
|
||||
Gtk.STOCK_OPEN, Gtk.ResponseType.OK), backend=None):
|
||||
|
||||
UnicodeFileChooserDialog.__init__(self, title, parent, action, buttons)
|
||||
self.set_default_response(gtk.RESPONSE_OK)
|
||||
UnicodeFileChooserDialog.__init__(self, title=title, parent=parent,
|
||||
action=action, buttons=buttons)
|
||||
self.set_default_response(Gtk.ResponseType.OK)
|
||||
|
||||
|
||||
class SaveToDirectoryChooserDialog(UnicodeFileChooserDialog):
|
||||
def __init__(self, title="", parent=None,
|
||||
action=gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER,
|
||||
buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
|
||||
gtk.STOCK_SAVE, gtk.RESPONSE_OK), backend=None):
|
||||
action=Gtk.FileChooserAction.SELECT_FOLDER,
|
||||
buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
|
||||
Gtk.STOCK_SAVE, Gtk.ResponseType.OK), backend=None):
|
||||
|
||||
UnicodeFileChooserDialog.__init__(self, title, parent, action, buttons)
|
||||
self.set_default_response(gtk.RESPONSE_OK)
|
||||
UnicodeFileChooserDialog.__init__(self, title=title, parent=parent,
|
||||
action=action, buttons=buttons)
|
||||
self.set_default_response(Gtk.ResponseType.OK)
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import gtk
|
||||
import gobject
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, GObject
|
||||
|
||||
from zenmapGUI.higwidgets.higboxes import HIGHBox
|
||||
from zenmapGUI.higwidgets.higlabels import HintWindow
|
||||
@@ -10,30 +12,30 @@ class FilterBar(HIGHBox):
|
||||
entering a string that restricts the set of visible hosts."""
|
||||
|
||||
__gsignals__ = {
|
||||
"changed": (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ())
|
||||
"changed": (GObject.SignalFlags.RUN_FIRST, GObject.TYPE_NONE, ())
|
||||
}
|
||||
|
||||
def __init__(self):
|
||||
HIGHBox.__init__(self)
|
||||
self.information_label = gtk.Label()
|
||||
self.entry = gtk.Entry()
|
||||
self.information_label = Gtk.Label()
|
||||
self.entry = Gtk.Entry()
|
||||
|
||||
self.pack_start(self.information_label, False)
|
||||
self.pack_start(self.information_label, False, True, 0)
|
||||
self.information_label.show()
|
||||
|
||||
label = gtk.Label(_("Host Filter:"))
|
||||
self.pack_start(label, False)
|
||||
label = Gtk.Label.new(_("Host Filter:"))
|
||||
self.pack_start(label, False, True, 0)
|
||||
label.show()
|
||||
|
||||
self.pack_start(self.entry, True, True)
|
||||
self.pack_start(self.entry, True, True, 0)
|
||||
self.entry.show()
|
||||
|
||||
help_button = gtk.Button()
|
||||
icon = gtk.Image()
|
||||
icon.set_from_stock(gtk.STOCK_INFO, gtk.ICON_SIZE_BUTTON)
|
||||
help_button = Gtk.Button()
|
||||
icon = Gtk.Image()
|
||||
icon.set_from_stock(Gtk.STOCK_INFO, Gtk.IconSize.BUTTON)
|
||||
help_button.add(icon)
|
||||
help_button.connect("clicked", self._help_button_clicked)
|
||||
self.pack_start(help_button, False)
|
||||
self.pack_start(help_button, False, True, 0)
|
||||
help_button.show_all()
|
||||
|
||||
self.entry.connect("changed", lambda x: self.emit("changed"))
|
||||
@@ -42,7 +44,7 @@ class FilterBar(HIGHBox):
|
||||
self.entry.grab_focus()
|
||||
|
||||
def get_filter_string(self):
|
||||
return self.entry.get_text().decode("UTF-8")
|
||||
return self.entry.get_text()
|
||||
|
||||
def set_filter_string(self, filter_string):
|
||||
return self.entry.set_text(filter_string)
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -58,8 +57,11 @@
|
||||
# * *
|
||||
# ***************************************************************************/
|
||||
|
||||
import gtk
|
||||
import gobject
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, GLib, GdkPixbuf
|
||||
|
||||
import re
|
||||
import os.path
|
||||
|
||||
@@ -93,7 +95,7 @@ if pixmap_path:
|
||||
def get_pixmap_file_names(icon_name, size):
|
||||
yield '%s_%s.png' % (icon_name, size)
|
||||
|
||||
iconfactory = gtk.IconFactory()
|
||||
iconfactory = Gtk.IconFactory()
|
||||
for icon_name in icon_names:
|
||||
for type, size in (('icon', '32'), ('logo', '75')):
|
||||
key = '%s_%s' % (icon_name, type)
|
||||
@@ -101,9 +103,9 @@ if pixmap_path:
|
||||
for file_name in get_pixmap_file_names(icon_name, size):
|
||||
file_path = os.path.join(pixmap_path, file_name)
|
||||
try:
|
||||
pixbuf = gtk.gdk.pixbuf_new_from_file(file_path)
|
||||
pixbuf = GdkPixbuf.Pixbuf.new_from_file(file_path)
|
||||
break
|
||||
except gobject.GError:
|
||||
except GLib.GError:
|
||||
# Try again.
|
||||
pass
|
||||
else:
|
||||
@@ -113,7 +115,7 @@ if pixmap_path:
|
||||
', '.join(get_pixmap_file_names(icon_name, size)),
|
||||
pixmap_path))
|
||||
continue
|
||||
iconset = gtk.IconSet(pixbuf)
|
||||
iconset = Gtk.IconSet(pixbuf=pixbuf)
|
||||
iconfactory.add(key, iconset)
|
||||
log.debug('Register %s icon name for file %s' % (key, file_path))
|
||||
iconfactory.add_default()
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -58,7 +57,10 @@
|
||||
# * *
|
||||
# ***************************************************************************/
|
||||
|
||||
import gtk
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk
|
||||
|
||||
import sys
|
||||
import os
|
||||
@@ -87,7 +89,6 @@ from zenmapGUI.SearchWindow import SearchWindow
|
||||
from zenmapGUI.BugReport import BugReport
|
||||
|
||||
from zenmapCore.Name import APP_DISPLAY_NAME, APP_DOCUMENTATION_SITE
|
||||
from zenmapCore.BasePaths import fs_enc
|
||||
from zenmapCore.Paths import Path
|
||||
from zenmapCore.RecentScans import recent_scans
|
||||
from zenmapCore.UmitLogging import log
|
||||
@@ -106,22 +107,21 @@ if is_maemo():
|
||||
hildon.Window.__init__(self)
|
||||
self.set_resizable(False)
|
||||
self.set_border_width(0)
|
||||
self.vbox = gtk.VBox()
|
||||
self.vbox = Gtk.Box.new(Gtk.Orientation.VERTICAL, 0)
|
||||
self.vbox.set_border_width(0)
|
||||
self.vbox.set_spacing(0)
|
||||
|
||||
else:
|
||||
class UmitScanWindow(HIGMainWindow):
|
||||
def __init__(self):
|
||||
HIGMainWindow.__init__(self)
|
||||
self.vbox = gtk.VBox()
|
||||
self.vbox = Gtk.Box.new(Gtk.Orientation.VERTICAL, 0)
|
||||
|
||||
|
||||
def can_print():
|
||||
"""Return true if we have printing operations (PyGTK 2.10 or later) or
|
||||
false otherwise."""
|
||||
try:
|
||||
gtk.PrintOperation
|
||||
Gtk.PrintOperation
|
||||
except AttributeError:
|
||||
return False
|
||||
else:
|
||||
@@ -140,7 +140,7 @@ class ScanWindow(UmitScanWindow):
|
||||
|
||||
self.scan_interface = ScanInterface()
|
||||
|
||||
self.main_accel_group = gtk.AccelGroup()
|
||||
self.main_accel_group = Gtk.AccelGroup()
|
||||
|
||||
self.add_accel_group(self.main_accel_group)
|
||||
|
||||
@@ -158,12 +158,12 @@ class ScanWindow(UmitScanWindow):
|
||||
def _create_ui_manager(self):
|
||||
"""Creates the UI Manager and a default set of actions, and builds
|
||||
the menus using those actions."""
|
||||
self.ui_manager = gtk.UIManager()
|
||||
self.ui_manager = Gtk.UIManager()
|
||||
|
||||
# See info on ActionGroup at:
|
||||
# * http://www.pygtk.org/pygtk2reference/class-gtkactiongroup.html
|
||||
# * http://www.gtk.org/api/2.6/gtk/GtkActionGroup.html
|
||||
self.main_action_group = gtk.ActionGroup('MainActionGroup')
|
||||
self.main_action_group = Gtk.ActionGroup.new('MainActionGroup')
|
||||
|
||||
# See info on Action at:
|
||||
# * http://www.pygtk.org/pygtk2reference/class-gtkaction.html
|
||||
@@ -177,39 +177,33 @@ class ScanWindow(UmitScanWindow):
|
||||
# _('Open the results of a previous scan'),
|
||||
# lambda x: True)
|
||||
|
||||
# gtk.STOCK_ABOUT is only available in PyGTK 2.6 and later.
|
||||
try:
|
||||
about_icon = gtk.STOCK_ABOUT
|
||||
except AttributeError:
|
||||
about_icon = None
|
||||
|
||||
self.main_actions = [
|
||||
# Top level
|
||||
('Scan', None, _('Sc_an'), None),
|
||||
|
||||
('Save Scan',
|
||||
gtk.STOCK_SAVE,
|
||||
Gtk.STOCK_SAVE,
|
||||
_('_Save Scan'),
|
||||
None,
|
||||
_('Save current scan results'),
|
||||
self._save_scan_results_cb),
|
||||
|
||||
('Save All Scans to Directory',
|
||||
gtk.STOCK_SAVE,
|
||||
Gtk.STOCK_SAVE,
|
||||
_('Save All Scans to _Directory'),
|
||||
"<Control><Alt>s",
|
||||
_('Save all scans into a directory'),
|
||||
self._save_to_directory_cb),
|
||||
|
||||
('Open Scan',
|
||||
gtk.STOCK_OPEN,
|
||||
Gtk.STOCK_OPEN,
|
||||
_('_Open Scan'),
|
||||
None,
|
||||
_('Open the results of a previous scan'),
|
||||
self._load_scan_results_cb),
|
||||
|
||||
('Append Scan',
|
||||
gtk.STOCK_ADD,
|
||||
Gtk.STOCK_ADD,
|
||||
_('_Open Scan in This Window'),
|
||||
None,
|
||||
_('Append a saved scan to the list of scans in this window.'),
|
||||
@@ -219,56 +213,56 @@ class ScanWindow(UmitScanWindow):
|
||||
('Tools', None, _('_Tools'), None),
|
||||
|
||||
('New Window',
|
||||
gtk.STOCK_NEW,
|
||||
Gtk.STOCK_NEW,
|
||||
_('_New Window'),
|
||||
"<Control>N",
|
||||
_('Open a new scan window'),
|
||||
self._new_scan_cb),
|
||||
|
||||
('Close Window',
|
||||
gtk.STOCK_CLOSE,
|
||||
Gtk.STOCK_CLOSE,
|
||||
_('Close Window'),
|
||||
"<Control>w",
|
||||
_('Close this scan window'),
|
||||
self._exit_cb),
|
||||
|
||||
('Print...',
|
||||
gtk.STOCK_PRINT,
|
||||
Gtk.STOCK_PRINT,
|
||||
_('Print...'),
|
||||
None,
|
||||
_('Print the current scan'),
|
||||
self._print_cb),
|
||||
|
||||
('Quit',
|
||||
gtk.STOCK_QUIT,
|
||||
Gtk.STOCK_QUIT,
|
||||
_('Quit'),
|
||||
"<Control>q",
|
||||
_('Quit the application'),
|
||||
self._quit_cb),
|
||||
|
||||
('New Profile',
|
||||
gtk.STOCK_JUSTIFY_LEFT,
|
||||
Gtk.STOCK_JUSTIFY_LEFT,
|
||||
_('New _Profile or Command'),
|
||||
'<Control>p',
|
||||
_('Create a new scan profile using the current command'),
|
||||
self._new_scan_profile_cb),
|
||||
|
||||
('Search Scan',
|
||||
gtk.STOCK_FIND,
|
||||
Gtk.STOCK_FIND,
|
||||
_('Search Scan Results'),
|
||||
'<Control>f',
|
||||
_('Search for a scan result'),
|
||||
self._search_scan_result),
|
||||
|
||||
('Filter Hosts',
|
||||
gtk.STOCK_FIND,
|
||||
Gtk.STOCK_FIND,
|
||||
_('Filter Hosts'),
|
||||
'<Control>l',
|
||||
_('Search for host by criteria'),
|
||||
self._filter_cb),
|
||||
|
||||
('Edit Profile',
|
||||
gtk.STOCK_PROPERTIES,
|
||||
Gtk.STOCK_PROPERTIES,
|
||||
_('_Edit Selected Profile'),
|
||||
'<Control>e',
|
||||
_('Edit selected scan profile'),
|
||||
@@ -278,7 +272,7 @@ class ScanWindow(UmitScanWindow):
|
||||
('Profile', None, _('_Profile'), None),
|
||||
|
||||
('Compare Results',
|
||||
gtk.STOCK_DND_MULTIPLE,
|
||||
Gtk.STOCK_DND_MULTIPLE,
|
||||
_('Compare Results'),
|
||||
"<Control>D",
|
||||
_('Compare Scan Results using Diffies'),
|
||||
@@ -289,7 +283,7 @@ class ScanWindow(UmitScanWindow):
|
||||
('Help', None, _('_Help'), None),
|
||||
|
||||
('Report a bug',
|
||||
gtk.STOCK_DIALOG_INFO,
|
||||
Gtk.STOCK_DIALOG_INFO,
|
||||
_('_Report a bug'),
|
||||
'<Control>b',
|
||||
_("Report a bug"),
|
||||
@@ -297,7 +291,7 @@ class ScanWindow(UmitScanWindow):
|
||||
),
|
||||
|
||||
('About',
|
||||
about_icon,
|
||||
Gtk.STOCK_ABOUT,
|
||||
_('_About'),
|
||||
None,
|
||||
_("About %s") % APP_DISPLAY_NAME,
|
||||
@@ -305,7 +299,7 @@ class ScanWindow(UmitScanWindow):
|
||||
),
|
||||
|
||||
('Show Help',
|
||||
gtk.STOCK_HELP,
|
||||
Gtk.STOCK_HELP,
|
||||
_('_Help'),
|
||||
None,
|
||||
_('Shows the application help'),
|
||||
@@ -410,7 +404,7 @@ class ScanWindow(UmitScanWindow):
|
||||
log.debug(">>> Saving result into database...")
|
||||
try:
|
||||
scan_interface.inventory.save_to_db()
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
alert = HIGAlertDialog(
|
||||
message_format=_("Can't save to database"),
|
||||
secondary_text=_("Can't store unsaved scans to the "
|
||||
@@ -445,7 +439,7 @@ class ScanWindow(UmitScanWindow):
|
||||
menubar = self.ui_manager.get_widget('/menubar')
|
||||
|
||||
if is_maemo():
|
||||
menu = gtk.Menu()
|
||||
menu = Gtk.Menu()
|
||||
for child in menubar.get_children():
|
||||
child.reparent(menu)
|
||||
self.set_menu(menu)
|
||||
@@ -474,7 +468,7 @@ class ScanWindow(UmitScanWindow):
|
||||
|
||||
filename = None
|
||||
response = self._results_filechooser_dialog.run()
|
||||
if response == gtk.RESPONSE_OK:
|
||||
if response == Gtk.ResponseType.OK:
|
||||
filename = self._results_filechooser_dialog.get_filename()
|
||||
elif response == RESPONSE_OPEN_DIRECTORY:
|
||||
filename = self._results_filechooser_dialog.get_filename()
|
||||
@@ -537,7 +531,7 @@ class ScanWindow(UmitScanWindow):
|
||||
try:
|
||||
# Parse result
|
||||
scan_interface.load_from_file(filename)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
alert = HIGAlertDialog(message_format=_('Error loading file'),
|
||||
secondary_text=str(e))
|
||||
alert.run()
|
||||
@@ -596,20 +590,20 @@ class ScanWindow(UmitScanWindow):
|
||||
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(
|
||||
flags=Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT,
|
||||
buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
|
||||
Gtk.STOCK_SAVE, Gtk.ResponseType.OK))
|
||||
dlg.vbox.pack_start(Gtk.Label.new(
|
||||
"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()
|
||||
False, True, 0)
|
||||
scan_combo = Gtk.ComboBoxText()
|
||||
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.pack_start(scan_combo, False, True, 0)
|
||||
dlg.vbox.show_all()
|
||||
if dlg.run() == gtk.RESPONSE_OK:
|
||||
if dlg.run() == Gtk.ResponseType.OK:
|
||||
selected = scan_combo.get_active()
|
||||
dlg.destroy()
|
||||
else:
|
||||
@@ -627,7 +621,7 @@ class ScanWindow(UmitScanWindow):
|
||||
response = self._save_results_filechooser_dialog.run()
|
||||
|
||||
filename = None
|
||||
if (response == gtk.RESPONSE_OK):
|
||||
if (response == Gtk.ResponseType.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
|
||||
@@ -664,12 +658,12 @@ This scan has not been run yet. Start the scan with the "Scan" button first.'))
|
||||
# display a directory chooser dialog
|
||||
dir_chooser = SaveToDirectoryChooserDialog(
|
||||
title=_("Choose a directory to save scans into"))
|
||||
if dir_chooser.run() == gtk.RESPONSE_OK:
|
||||
if dir_chooser.run() == Gtk.ResponseType.OK:
|
||||
self._save_all(self.scan_interface, dir_chooser.get_filename())
|
||||
dir_chooser.destroy()
|
||||
|
||||
def _about_cb_response(self, dialog, response_id):
|
||||
if response_id == gtk.RESPONSE_DELETE_EVENT:
|
||||
if response_id == Gtk.ResponseType.DELETE_EVENT:
|
||||
self._about_dialog = None
|
||||
else:
|
||||
self._about_dialog.hide()
|
||||
@@ -687,7 +681,7 @@ This scan has not been run yet. Start the scan with the "Scan" button first.'))
|
||||
filenames = scan_interface.inventory.save_to_dir(directory)
|
||||
for scan in scan_interface.inventory.get_scans():
|
||||
scan.unsaved = False
|
||||
except Exception, ex:
|
||||
except Exception as ex:
|
||||
alert = HIGAlertDialog(message_format=_('Can\'t save file'),
|
||||
secondary_text=str(ex))
|
||||
alert.run()
|
||||
@@ -700,7 +694,7 @@ This scan has not been run yet. Start the scan with the "Scan" button first.'))
|
||||
for filename in filenames:
|
||||
recent_scans.add_recent_scan(filename)
|
||||
recent_scans.save()
|
||||
except (OSError, IOError), e:
|
||||
except (OSError, IOError) as e:
|
||||
alert = HIGAlertDialog(
|
||||
message_format=_(
|
||||
"Can't save recent scan information"),
|
||||
@@ -718,7 +712,7 @@ This scan has not been run yet. Start the scan with the "Scan" button first.'))
|
||||
scan_interface.inventory.save_to_file(
|
||||
saved_filename, selected_index, format)
|
||||
scan_interface.inventory.get_scans()[selected_index].unsaved = False # noqa
|
||||
except (OSError, IOError), e:
|
||||
except (OSError, IOError) as e:
|
||||
alert = HIGAlertDialog(
|
||||
message_format=_("Can't save file"),
|
||||
secondary_text=_("Can't open file to write.\n%s") % str(e))
|
||||
@@ -735,7 +729,7 @@ This scan has not been run yet. Start the scan with the "Scan" button first.'))
|
||||
try:
|
||||
recent_scans.add_recent_scan(saved_filename)
|
||||
recent_scans.save()
|
||||
except (OSError, IOError), e:
|
||||
except (OSError, IOError) as e:
|
||||
alert = HIGAlertDialog(
|
||||
message_format=_(
|
||||
"Can't save recent scan information"),
|
||||
@@ -772,7 +766,7 @@ This scan has not been run yet. Start the scan with the "Scan" button first.'))
|
||||
pe.show_all()
|
||||
|
||||
def _help_cb(self, action):
|
||||
show_help()
|
||||
self.show_help()
|
||||
|
||||
def _exit_cb(self, *args):
|
||||
"""Closes the window, prompting for confirmation if necessary. If one
|
||||
@@ -781,9 +775,9 @@ This scan has not been run yet. Start the scan with the "Scan" button first.'))
|
||||
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))
|
||||
buttons=(_('Close anyway'),
|
||||
Gtk.ResponseType.CLOSE, Gtk.STOCK_CANCEL,
|
||||
Gtk.ResponseType.CANCEL))
|
||||
|
||||
alert = HIGEntryLabel('<b>%s</b>' % _("Unsaved changes"))
|
||||
|
||||
@@ -797,22 +791,22 @@ This scan has not been run yet. Start the scan with the "Scan" button first.'))
|
||||
vbox.set_border_width(5)
|
||||
vbox.set_spacing(12)
|
||||
|
||||
image = gtk.Image()
|
||||
image = Gtk.Image()
|
||||
image.set_from_stock(
|
||||
gtk.STOCK_DIALOG_QUESTION, gtk.ICON_SIZE_DIALOG)
|
||||
Gtk.STOCK_DIALOG_QUESTION, Gtk.IconSize.DIALOG)
|
||||
|
||||
vbox.pack_start(alert)
|
||||
vbox.pack_start(text)
|
||||
hbox.pack_start(image)
|
||||
hbox.pack_start(vbox)
|
||||
vbox.pack_start(alert, True, True, 0)
|
||||
vbox.pack_start(text, True, True, 0)
|
||||
hbox.pack_start(image, True, True, 0)
|
||||
hbox.pack_start(vbox, True, True, 0)
|
||||
|
||||
dialog.vbox.pack_start(hbox)
|
||||
dialog.vbox.pack_start(hbox, True, True, 0)
|
||||
dialog.vbox.show_all()
|
||||
|
||||
response = dialog.run()
|
||||
dialog.destroy()
|
||||
|
||||
if response == gtk.RESPONSE_CANCEL:
|
||||
if response == Gtk.ResponseType.CANCEL:
|
||||
return True
|
||||
|
||||
search_config = SearchConfig()
|
||||
@@ -822,9 +816,9 @@ This scan has not been run yet. Start the scan with the "Scan" button first.'))
|
||||
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))
|
||||
buttons=(_('Close anyway'),
|
||||
Gtk.ResponseType.CLOSE, Gtk.STOCK_CANCEL,
|
||||
Gtk.ResponseType.CANCEL))
|
||||
|
||||
alert = HIGEntryLabel('<b>%s</b>' % _("Trying to close"))
|
||||
|
||||
@@ -839,24 +833,24 @@ This scan has not been run yet. Start the scan with the "Scan" button first.'))
|
||||
vbox.set_border_width(5)
|
||||
vbox.set_spacing(12)
|
||||
|
||||
image = gtk.Image()
|
||||
image = Gtk.Image()
|
||||
image.set_from_stock(
|
||||
gtk.STOCK_DIALOG_WARNING, gtk.ICON_SIZE_DIALOG)
|
||||
Gtk.STOCK_DIALOG_WARNING, Gtk.IconSize.DIALOG)
|
||||
|
||||
vbox.pack_start(alert)
|
||||
vbox.pack_start(text)
|
||||
hbox.pack_start(image)
|
||||
hbox.pack_start(vbox)
|
||||
vbox.pack_start(alert, True, True, 0)
|
||||
vbox.pack_start(text, True, True, 0)
|
||||
hbox.pack_start(image, True, True, 0)
|
||||
hbox.pack_start(vbox, True, True, 0)
|
||||
|
||||
dialog.vbox.pack_start(hbox)
|
||||
dialog.vbox.pack_start(hbox, True, True, 0)
|
||||
dialog.vbox.show_all()
|
||||
|
||||
response = dialog.run()
|
||||
dialog.destroy()
|
||||
|
||||
if response == gtk.RESPONSE_CLOSE:
|
||||
if response == Gtk.ResponseType.CLOSE:
|
||||
self.scan_interface.kill_all_scans()
|
||||
elif response == gtk.RESPONSE_CANCEL:
|
||||
elif response == Gtk.ResponseType.CANCEL:
|
||||
return True
|
||||
|
||||
window = WindowConfig()
|
||||
@@ -902,29 +896,26 @@ This scan has not been run yet. Start the scan with the "Scan" button first.'))
|
||||
self.diff_window.show_all()
|
||||
|
||||
|
||||
def show_help():
|
||||
import urllib
|
||||
import webbrowser
|
||||
def show_help(self):
|
||||
import urllib.request
|
||||
import webbrowser
|
||||
|
||||
new = 0
|
||||
if sys.hexversion >= 0x2050000:
|
||||
new = 2
|
||||
doc_path = abspath(join(Path.docs_dir, "help.html"))
|
||||
url = "file:" + urllib.request.pathname2url(doc_path)
|
||||
|
||||
doc_path = abspath(join(Path.docs_dir, "help.html"))
|
||||
url = "file:" + urllib.pathname2url(fs_enc(doc_path))
|
||||
try:
|
||||
webbrowser.open(url, new=new)
|
||||
except OSError, e:
|
||||
d = HIGAlertDialog(parent=self,
|
||||
message_format=_("Can't find documentation files"),
|
||||
secondary_text=_("""\
|
||||
try:
|
||||
webbrowser.open(url, new=2)
|
||||
except OSError as e:
|
||||
d = HIGAlertDialog(parent=self,
|
||||
message_format=_("Can't find documentation files"),
|
||||
secondary_text=_("""\
|
||||
There was an error loading the documentation file %s (%s). See the \
|
||||
online documentation at %s.\
|
||||
""") % (doc_path, unicode(e), APP_DOCUMENTATION_SITE))
|
||||
d.run()
|
||||
d.destroy()
|
||||
""") % (doc_path, str(e), APP_DOCUMENTATION_SITE))
|
||||
d.run()
|
||||
d.destroy()
|
||||
|
||||
if __name__ == '__main__':
|
||||
w = ScanWindow()
|
||||
w.show_all()
|
||||
gtk.main()
|
||||
Gtk.main()
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -58,9 +57,10 @@
|
||||
# * *
|
||||
# ***************************************************************************/
|
||||
|
||||
import gtk
|
||||
import gtk.gdk
|
||||
import pango
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, Gdk
|
||||
|
||||
import zenmapCore.I18N # lgtm[py/unused-import]
|
||||
from zenmapCore.UmitConf import NmapOutputHighlight
|
||||
@@ -76,7 +76,7 @@ from zenmapGUI.higwidgets.higbuttons import HIGButton, HIGToggleButton
|
||||
class NmapOutputProperties(HIGDialog):
|
||||
def __init__(self, nmap_output_view):
|
||||
HIGDialog.__init__(self, _("Nmap Output Properties"),
|
||||
buttons=(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE))
|
||||
buttons=(Gtk.STOCK_CLOSE, Gtk.ResponseType.CLOSE))
|
||||
|
||||
self.nmap_highlight = NmapOutputHighlight()
|
||||
|
||||
@@ -90,7 +90,7 @@ class NmapOutputProperties(HIGDialog):
|
||||
self.properties_notebook = HIGNotebook()
|
||||
|
||||
def __pack_widgets(self):
|
||||
self.vbox.pack_start(self.properties_notebook)
|
||||
self.vbox.pack_start(self.properties_notebook, True, True, 0)
|
||||
|
||||
def highlight_tab(self):
|
||||
# Creating highlight tab main box
|
||||
@@ -121,8 +121,8 @@ class NmapOutputProperties(HIGDialog):
|
||||
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(Gdk.Color(*settings[3]))
|
||||
self.property_names[p].append(Gdk.Color(*settings[4]))
|
||||
self.property_names[p].append(settings[5])
|
||||
|
||||
# Creating properties and related widgets and attaching it to main
|
||||
@@ -152,12 +152,12 @@ class NmapOutputProperties(HIGDialog):
|
||||
y2 += 1
|
||||
|
||||
# Packing main table into main vbox
|
||||
self.highlight_main_vbox.pack_start(self.highlight_main_table)
|
||||
self.highlight_main_vbox.pack_start(self.highlight_main_table, True, True, 0)
|
||||
|
||||
# Adding color tab
|
||||
self.properties_notebook.append_page(
|
||||
self.highlight_main_vbox,
|
||||
gtk.Label(_("Highlight definitions")))
|
||||
Gtk.Label.new(_("Highlight definitions")))
|
||||
|
||||
|
||||
class HighlightProperty(object):
|
||||
@@ -180,13 +180,13 @@ class HighlightProperty(object):
|
||||
def __create_widgets(self):
|
||||
self.property_name_label = HIGEntryLabel("")
|
||||
self.example_label = HIGEntryLabel("")
|
||||
self.bold_tg_button = HIGToggleButton("", gtk.STOCK_BOLD)
|
||||
self.italic_tg_button = HIGToggleButton("", gtk.STOCK_ITALIC)
|
||||
self.underline_tg_button = HIGToggleButton("", gtk.STOCK_UNDERLINE)
|
||||
self.bold_tg_button = HIGToggleButton("", Gtk.STOCK_BOLD)
|
||||
self.italic_tg_button = HIGToggleButton("", Gtk.STOCK_ITALIC)
|
||||
self.underline_tg_button = HIGToggleButton("", Gtk.STOCK_UNDERLINE)
|
||||
self.text_color_button = HIGButton(
|
||||
_("Text"), stock=gtk.STOCK_SELECT_COLOR)
|
||||
_("Text"), stock=Gtk.STOCK_SELECT_COLOR)
|
||||
self.highlight_color_button = HIGButton(
|
||||
_("Highlight"), stock=gtk.STOCK_SELECT_COLOR)
|
||||
_("Highlight"), stock=Gtk.STOCK_SELECT_COLOR)
|
||||
|
||||
def __connect_buttons(self):
|
||||
self.bold_tg_button.connect("toggled", self.update_example)
|
||||
@@ -201,13 +201,13 @@ class HighlightProperty(object):
|
||||
# Text color dialog
|
||||
|
||||
def text_color_dialog(self, widget):
|
||||
color_dialog = gtk.ColorSelectionDialog(
|
||||
color_dialog = Gtk.ColorSelectionDialog.new(
|
||||
"%s %s" % (self.label, _("text color")))
|
||||
color_dialog.colorsel.set_current_color(self.text_color)
|
||||
color_dialog.get_color_selection().set_current_color(self.text_color)
|
||||
|
||||
color_dialog.ok_button.connect(
|
||||
color_dialog.props.ok_button.connect(
|
||||
"clicked", self.text_color_dialog_ok, color_dialog)
|
||||
color_dialog.cancel_button.connect(
|
||||
color_dialog.props.cancel_button.connect(
|
||||
"clicked", self.text_color_dialog_cancel, color_dialog)
|
||||
color_dialog.connect(
|
||||
"delete-event", self.text_color_dialog_close, color_dialog)
|
||||
@@ -215,7 +215,7 @@ class HighlightProperty(object):
|
||||
color_dialog.run()
|
||||
|
||||
def text_color_dialog_ok(self, widget, color_dialog):
|
||||
self.text_color = color_dialog.colorsel.get_current_color()
|
||||
self.text_color = color_dialog.get_color_selection().get_current_color()
|
||||
color_dialog.destroy()
|
||||
self.update_example()
|
||||
|
||||
@@ -228,13 +228,13 @@ class HighlightProperty(object):
|
||||
#########################################
|
||||
# Highlight color dialog
|
||||
def highlight_color_dialog(self, widget):
|
||||
color_dialog = gtk.ColorSelectionDialog(
|
||||
color_dialog = Gtk.ColorSelectionDialog.new(
|
||||
"%s %s" % (self.property_name, _("highlight color")))
|
||||
color_dialog.colorsel.set_current_color(self.highlight_color)
|
||||
color_dialog.get_color_selection().set_current_color(self.highlight_color)
|
||||
|
||||
color_dialog.ok_button.connect(
|
||||
color_dialog.props.ok_button.connect(
|
||||
"clicked", self.highlight_color_dialog_ok, color_dialog)
|
||||
color_dialog.cancel_button.connect(
|
||||
color_dialog.props.cancel_button.connect(
|
||||
"clicked", self.highlight_color_dialog_cancel,
|
||||
color_dialog)
|
||||
color_dialog.connect(
|
||||
@@ -244,7 +244,7 @@ class HighlightProperty(object):
|
||||
color_dialog.run()
|
||||
|
||||
def highlight_color_dialog_ok(self, widget, color_dialog):
|
||||
self.highlight_color = color_dialog.colorsel.get_current_color()
|
||||
self.highlight_color = color_dialog.get_color_selection().get_current_color()
|
||||
color_dialog.destroy()
|
||||
self.update_example()
|
||||
|
||||
@@ -255,41 +255,23 @@ class HighlightProperty(object):
|
||||
color_dialog.destroy()
|
||||
|
||||
def update_example(self, widget=None):
|
||||
start = 0
|
||||
end = len(self.example)
|
||||
|
||||
attributes = pango.AttrList()
|
||||
|
||||
attributes.insert(
|
||||
pango.AttrForeground(self.text_color.red,
|
||||
self.text_color.green, self.text_color.blue, start, end))
|
||||
attributes.insert(pango.AttrBackground(self.highlight_color.red,
|
||||
self.highlight_color.green,
|
||||
self.highlight_color.blue,
|
||||
start, end))
|
||||
label = self.example_label.get_text()
|
||||
|
||||
# Bold verification
|
||||
if self.bold_tg_button.get_active():
|
||||
attributes.insert(pango.AttrWeight(pango.WEIGHT_HEAVY, start, end))
|
||||
else:
|
||||
attributes.insert(
|
||||
pango.AttrWeight(pango.WEIGHT_NORMAL, start, end))
|
||||
label = "<b>" + label + "</b>"
|
||||
|
||||
# Italic verification
|
||||
if self.italic_tg_button.get_active():
|
||||
attributes.insert(pango.AttrStyle(pango.STYLE_ITALIC, start, end))
|
||||
else:
|
||||
attributes.insert(pango.AttrStyle(pango.STYLE_NORMAL, start, end))
|
||||
label = "<i>" + label + "</i>"
|
||||
|
||||
# Underline verification
|
||||
if self.underline_tg_button.get_active():
|
||||
attributes.insert(
|
||||
pango.AttrUnderline(pango.UNDERLINE_SINGLE, start, end))
|
||||
else:
|
||||
attributes.insert(
|
||||
pango.AttrUnderline(pango.UNDERLINE_NONE, start, end))
|
||||
label = "<u>" + label + "</u>"
|
||||
|
||||
self.example_label.set_attributes(attributes)
|
||||
self.example_label.modify_fg(Gtk.StateType.NORMAL, self.text_color)
|
||||
self.example_label.modify_bg(Gtk.StateType.NORMAL, self.highlight_color)
|
||||
self.example_label.set_markup(label)
|
||||
|
||||
def show_bold(self, widget):
|
||||
self.example_label.set_markup("<>")
|
||||
@@ -339,4 +321,4 @@ class HighlightProperty(object):
|
||||
if __name__ == "__main__":
|
||||
n = NmapOutputProperties(None)
|
||||
n.run()
|
||||
gtk.main()
|
||||
Gtk.main()
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -58,10 +57,12 @@
|
||||
# * *
|
||||
# ***************************************************************************/
|
||||
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, Gdk, Pango, GLib
|
||||
|
||||
import gobject
|
||||
import gtk
|
||||
import gtk.gdk
|
||||
import pango
|
||||
import re
|
||||
|
||||
import zenmapCore.I18N # lgtm[py/unused-import]
|
||||
@@ -71,13 +72,13 @@ from zenmapCore.UmitConf import NmapOutputHighlight
|
||||
from zenmapGUI.NmapOutputProperties import NmapOutputProperties
|
||||
|
||||
|
||||
class NmapOutputViewer (gtk.VBox):
|
||||
class NmapOutputViewer(Gtk.Box):
|
||||
HIGHLIGHT_PROPERTIES = ["details", "date", "hostname", "ip", "port_list",
|
||||
"open_port", "closed_port", "filtered_port"]
|
||||
|
||||
def __init__(self, refresh=1, stop=1):
|
||||
self.nmap_highlight = NmapOutputHighlight()
|
||||
gtk.VBox.__init__(self)
|
||||
Gtk.Box.__init__(self, orientation=Gtk.Orientation.VERTICAL)
|
||||
|
||||
# Creating widgets
|
||||
self.__create_widgets()
|
||||
@@ -95,7 +96,7 @@ class NmapOutputViewer (gtk.VBox):
|
||||
self.refreshing = True
|
||||
|
||||
# Adding widgets to the VBox
|
||||
self.pack_start(self.scrolled, expand=True, fill=True)
|
||||
self.pack_start(self.scrolled, True, True, 0)
|
||||
|
||||
# The NmapCommand instance, if any, whose output is shown in this
|
||||
# display.
|
||||
@@ -105,17 +106,17 @@ class NmapOutputViewer (gtk.VBox):
|
||||
|
||||
def __create_widgets(self):
|
||||
# Creating widgets
|
||||
self.scrolled = gtk.ScrolledWindow()
|
||||
self.text_view = gtk.TextView()
|
||||
self.scrolled = Gtk.ScrolledWindow()
|
||||
self.text_view = Gtk.TextView()
|
||||
|
||||
def __set_scrolled_window(self):
|
||||
# Seting scrolled window
|
||||
self.scrolled.set_border_width(5)
|
||||
self.scrolled.add(self.text_view)
|
||||
self.scrolled.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
|
||||
self.scrolled.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
|
||||
|
||||
def __set_text_view(self):
|
||||
self.text_view.set_wrap_mode(gtk.WRAP_WORD)
|
||||
self.text_view.set_wrap_mode(Gtk.WrapMode.WORD)
|
||||
self.text_view.set_editable(False)
|
||||
|
||||
self.tag_font = self.text_view.get_buffer().create_tag(None)
|
||||
@@ -125,29 +126,27 @@ class NmapOutputViewer (gtk.VBox):
|
||||
tag = self.text_view.get_buffer().create_tag(property)
|
||||
|
||||
if settings[0]:
|
||||
tag.set_property("weight", pango.WEIGHT_HEAVY)
|
||||
tag.set_property("weight", Pango.Weight.HEAVY)
|
||||
else:
|
||||
tag.set_property("weight", pango.WEIGHT_NORMAL)
|
||||
tag.set_property("weight", Pango.Weight.NORMAL)
|
||||
|
||||
if settings[1]:
|
||||
tag.set_property("style", pango.STYLE_ITALIC)
|
||||
tag.set_property("style", Pango.Style.ITALIC)
|
||||
else:
|
||||
tag.set_property("style", pango.STYLE_NORMAL)
|
||||
tag.set_property("style", Pango.Style.NORMAL)
|
||||
|
||||
if settings[2]:
|
||||
tag.set_property("underline", pango.UNDERLINE_SINGLE)
|
||||
tag.set_property("underline", Pango.Underline.SINGLE)
|
||||
else:
|
||||
tag.set_property("underline", pango.UNDERLINE_NONE)
|
||||
tag.set_property("underline", Pango.Underline.NONE)
|
||||
|
||||
text_color = settings[3]
|
||||
highlight_color = settings[4]
|
||||
|
||||
tag.set_property(
|
||||
"foreground", gtk.color_selection_palette_to_string(
|
||||
[gtk.gdk.Color(*text_color), ]))
|
||||
"foreground", Gdk.Color(*text_color).to_string())
|
||||
tag.set_property(
|
||||
"background", gtk.color_selection_palette_to_string(
|
||||
[gtk.gdk.Color(*highlight_color), ]))
|
||||
"background", Gdk.Color(*highlight_color).to_string())
|
||||
|
||||
def go_to_host(self, host):
|
||||
"""Go to host line on nmap output result"""
|
||||
@@ -155,7 +154,7 @@ class NmapOutputViewer (gtk.VBox):
|
||||
start_iter = buff.get_start_iter()
|
||||
|
||||
found_tuple = start_iter.forward_search(
|
||||
"\nNmap scan report for %s\n" % host, gtk.TEXT_SEARCH_TEXT_ONLY
|
||||
"\nNmap scan report for %s\n" % host, Gtk.TextSearchFlags.TEXT_ONLY
|
||||
)
|
||||
if found_tuple is None:
|
||||
return
|
||||
@@ -219,7 +218,7 @@ class NmapOutputViewer (gtk.VBox):
|
||||
if not self.nmap_highlight.enable:
|
||||
return
|
||||
|
||||
text = buf.get_text(start_iter, end_iter)
|
||||
text = buf.get_text(start_iter, end_iter, include_hidden_chars=True)
|
||||
|
||||
for property in self.HIGHLIGHT_PROPERTIES:
|
||||
settings = self.nmap_highlight.__getattribute__(property)
|
||||
@@ -243,7 +242,7 @@ class NmapOutputViewer (gtk.VBox):
|
||||
The current output is extracted from the command object."""
|
||||
self.command_execution = command
|
||||
if command is not None:
|
||||
self.text_view.get_buffer().set_text(u"")
|
||||
self.text_view.get_buffer().set_text("")
|
||||
self.output_file_pointer = 0
|
||||
else:
|
||||
self.output_file_pointer = None
|
||||
@@ -297,7 +296,7 @@ class NmapOutputViewer (gtk.VBox):
|
||||
v_adj = self.scrolled.get_vadjustment()
|
||||
if new_output and v_adj is not None:
|
||||
# Find out if the view is already scrolled to the bottom.
|
||||
at_end = (v_adj.value >= v_adj.upper - v_adj.page_size)
|
||||
at_end = (v_adj.get_value() >= v_adj.get_upper() - v_adj.get_page_size())
|
||||
|
||||
buf = self.text_view.get_buffer()
|
||||
prev_end_mark = buf.create_mark(
|
||||
@@ -318,6 +317,6 @@ class NmapOutputViewer (gtk.VBox):
|
||||
# text causes a scroll bar to appear and reflow the text,
|
||||
# making the text a bit taller.
|
||||
self.text_view.scroll_mark_onscreen(self.end_mark)
|
||||
gobject.idle_add(
|
||||
GLib.idle_add(
|
||||
lambda: self.text_view.scroll_mark_onscreen(
|
||||
self.end_mark))
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -58,8 +57,10 @@
|
||||
# * *
|
||||
# ***************************************************************************/
|
||||
|
||||
import gobject
|
||||
import gtk
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, GObject
|
||||
|
||||
|
||||
# Prevent loading PyXML
|
||||
@@ -101,9 +102,9 @@ def get_option_check_auxiliary_widget(option, ops, check):
|
||||
assert False, "Unknown option %s" % option
|
||||
|
||||
|
||||
class OptionEntry(gtk.Entry):
|
||||
class OptionEntry(Gtk.Entry):
|
||||
def __init__(self, option, ops, check):
|
||||
gtk.Entry.__init__(self)
|
||||
Gtk.Entry.__init__(self)
|
||||
self.option = option
|
||||
self.ops = ops
|
||||
self.check = check
|
||||
@@ -121,18 +122,18 @@ class OptionEntry(gtk.Entry):
|
||||
|
||||
def check_toggled_cb(self, check):
|
||||
if check.get_active():
|
||||
self.ops[self.option] = self.get_text().decode("UTF-8")
|
||||
self.ops[self.option] = self.get_text()
|
||||
else:
|
||||
self.ops[self.option] = None
|
||||
|
||||
def changed_cb(self, widget):
|
||||
self.check.set_active(True)
|
||||
self.ops[self.option] = self.get_text().decode("UTF-8")
|
||||
self.ops[self.option] = self.get_text()
|
||||
|
||||
|
||||
class OptionExtras(gtk.Entry):
|
||||
class OptionExtras(Gtk.Entry):
|
||||
def __init__(self, option, ops, check):
|
||||
gtk.Entry.__init__(self)
|
||||
Gtk.Entry.__init__(self)
|
||||
self.ops = ops
|
||||
self.check = check
|
||||
self.connect("changed", self.changed_cb)
|
||||
@@ -149,18 +150,19 @@ class OptionExtras(gtk.Entry):
|
||||
|
||||
def check_toggled_cb(self, check):
|
||||
if check.get_active():
|
||||
self.ops.extras = [self.get_text().decode("UTF-8")]
|
||||
self.ops.extras = [self.get_text()]
|
||||
else:
|
||||
self.ops.extras = []
|
||||
|
||||
def changed_cb(self, widget):
|
||||
self.check.set_active(True)
|
||||
self.ops.extras = [self.get_text().decode("UTF-8")]
|
||||
self.ops.extras = [self.get_text()]
|
||||
|
||||
|
||||
class OptionLevel(gtk.SpinButton):
|
||||
class OptionLevel(Gtk.SpinButton):
|
||||
def __init__(self, option, ops, check):
|
||||
gtk.SpinButton.__init__(self, gtk.Adjustment(0, 0, 10, 1), 0.0, 0)
|
||||
adjustment = Gtk.Adjustment.new(0, 0, 10, 1, 0, 0)
|
||||
Gtk.SpinButton.__init__(self, adjustment=adjustment, climb_rate=0.0, digits=0)
|
||||
self.option = option
|
||||
self.ops = ops
|
||||
self.check = check
|
||||
@@ -188,22 +190,22 @@ class OptionLevel(gtk.SpinButton):
|
||||
self.ops[self.option] = int(self.get_adjustment().get_value())
|
||||
|
||||
|
||||
class OptionFile(gtk.HBox):
|
||||
class OptionFile(Gtk.Box):
|
||||
__gsignals__ = {
|
||||
"changed": (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ())
|
||||
"changed": (GObject.SignalFlags.RUN_FIRST, GObject.TYPE_NONE, ())
|
||||
}
|
||||
|
||||
def __init__(self, option, ops, check):
|
||||
gtk.HBox.__init__(self)
|
||||
Gtk.Box.__init__(self, orientation=Gtk.Orientation.HORIZONTAL)
|
||||
|
||||
self.option = option
|
||||
self.ops = ops
|
||||
self.check = check
|
||||
|
||||
self.entry = gtk.Entry()
|
||||
self.pack_start(self.entry, True, True)
|
||||
button = HIGButton(stock=gtk.STOCK_OPEN)
|
||||
self.pack_start(button, False)
|
||||
self.entry = Gtk.Entry()
|
||||
self.pack_start(self.entry, True, True, 0)
|
||||
button = HIGButton(stock=Gtk.STOCK_OPEN)
|
||||
self.pack_start(button, False, True, 0)
|
||||
|
||||
button.connect("clicked", self.clicked_cb)
|
||||
|
||||
@@ -222,36 +224,36 @@ class OptionFile(gtk.HBox):
|
||||
|
||||
def check_toggled_cb(self, check):
|
||||
if check.get_active():
|
||||
self.ops[self.option] = self.entry.get_text().decode("UTF-8")
|
||||
self.ops[self.option] = self.entry.get_text()
|
||||
else:
|
||||
self.ops[self.option] = None
|
||||
|
||||
def changed_cb(self, widget):
|
||||
self.check.set_active(True)
|
||||
self.ops[self.option] = self.entry.get_text().decode("UTF-8")
|
||||
self.ops[self.option] = self.entry.get_text()
|
||||
|
||||
def clicked_cb(self, button):
|
||||
dialog = AllFilesFileChooserDialog(_("Choose file"))
|
||||
if dialog.run() == gtk.RESPONSE_OK:
|
||||
if dialog.run() == Gtk.ResponseType.OK:
|
||||
self.entry.set_text(dialog.get_filename())
|
||||
dialog.destroy()
|
||||
|
||||
|
||||
class TargetEntry(gtk.Entry):
|
||||
class TargetEntry(Gtk.Entry):
|
||||
def __init__(self, ops):
|
||||
gtk.Entry.__init__(self)
|
||||
Gtk.Entry.__init__(self)
|
||||
self.ops = ops
|
||||
self.connect("changed", self.changed_cb)
|
||||
self.update()
|
||||
|
||||
def update(self):
|
||||
self.set_text(u" ".join(self.ops.target_specs))
|
||||
self.set_text(" ".join(self.ops.target_specs))
|
||||
|
||||
def changed_cb(self, widget):
|
||||
self.ops.target_specs = self.get_targets()
|
||||
|
||||
def get_targets(self):
|
||||
return split_quoted(self.get_text().decode("UTF-8"))
|
||||
return split_quoted(self.get_text())
|
||||
|
||||
|
||||
class OptionTab(object):
|
||||
@@ -275,29 +277,29 @@ class OptionTab(object):
|
||||
self.widgets_list.append(widget)
|
||||
|
||||
def __parse_target(self, target_element):
|
||||
label = _(target_element.getAttribute(u'label'))
|
||||
label = _(target_element.getAttribute('label'))
|
||||
label_widget = HIGEntryLabel(label)
|
||||
target_widget = TargetEntry(self.ops)
|
||||
target_widget.connect("changed", self.update_target)
|
||||
return label_widget, target_widget
|
||||
|
||||
def __parse_option_list(self, option_list_element):
|
||||
children = option_list_element.getElementsByTagName(u'option')
|
||||
children = option_list_element.getElementsByTagName('option')
|
||||
|
||||
label_widget = HIGEntryLabel(
|
||||
_(option_list_element.getAttribute(u'label')))
|
||||
_(option_list_element.getAttribute('label')))
|
||||
option_list_widget = OptionList(self.ops)
|
||||
|
||||
for child in children:
|
||||
option = child.getAttribute(u'option')
|
||||
argument = child.getAttribute(u'argument')
|
||||
label = _(child.getAttribute(u'label'))
|
||||
option = child.getAttribute('option')
|
||||
argument = child.getAttribute('argument')
|
||||
label = _(child.getAttribute('label'))
|
||||
option_list_widget.append(option, argument, label)
|
||||
self.profilehelp.add_label(option, label)
|
||||
self.profilehelp.add_shortdesc(
|
||||
option, _(child.getAttribute(u'short_desc')))
|
||||
option, _(child.getAttribute('short_desc')))
|
||||
self.profilehelp.add_example(
|
||||
option, child.getAttribute(u'example'))
|
||||
option, child.getAttribute('example'))
|
||||
|
||||
option_list_widget.update()
|
||||
|
||||
@@ -306,10 +308,10 @@ class OptionTab(object):
|
||||
return label_widget, option_list_widget
|
||||
|
||||
def __parse_option_check(self, option_check):
|
||||
option = option_check.getAttribute(u'option')
|
||||
label = _(option_check.getAttribute(u'label'))
|
||||
short_desc = _(option_check.getAttribute(u'short_desc'))
|
||||
example = option_check.getAttribute(u'example')
|
||||
option = option_check.getAttribute('option')
|
||||
label = _(option_check.getAttribute('label'))
|
||||
short_desc = _(option_check.getAttribute('short_desc'))
|
||||
example = option_check.getAttribute('example')
|
||||
|
||||
self.profilehelp.add_label(option, label)
|
||||
self.profilehelp.add_shortdesc(option, short_desc)
|
||||
@@ -331,7 +333,7 @@ class OptionTab(object):
|
||||
return check, auxiliary_widget
|
||||
|
||||
def fill_table(self, table, expand_fill=True):
|
||||
yopt = (0, gtk.EXPAND | gtk.FILL)[expand_fill]
|
||||
yopt = (0, Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL)[expand_fill]
|
||||
for y, widget in enumerate(self.widgets_list):
|
||||
if widget[1] is None:
|
||||
table.attach(widget[0], 0, 2, y, y + 1, yoptions=yopt)
|
||||
@@ -427,12 +429,12 @@ class OptionBuilder(object):
|
||||
dic = {}
|
||||
for group in self.groups:
|
||||
grp = self.xml.getElementsByTagName(group)[0]
|
||||
dic[group] = grp.getAttribute(u'label')
|
||||
dic[group] = grp.getAttribute('label')
|
||||
return dic
|
||||
|
||||
def __parse_groups(self):
|
||||
return [g_name.getAttribute(u'name') for g_name in
|
||||
self.xml.getElementsByTagName(u'groups')[0].getElementsByTagName(u'group')] # noqa
|
||||
return [g_name.getAttribute('name') for g_name in
|
||||
self.xml.getElementsByTagName('groups')[0].getElementsByTagName('group')] # noqa
|
||||
|
||||
def __parse_tabs(self):
|
||||
dic = {}
|
||||
@@ -448,14 +450,14 @@ class OptionBuilder(object):
|
||||
return dic
|
||||
|
||||
|
||||
class OptionList(gtk.ComboBox):
|
||||
class OptionList(Gtk.ComboBox):
|
||||
def __init__(self, ops):
|
||||
self.ops = ops
|
||||
|
||||
self.list = gtk.ListStore(str, str, str)
|
||||
gtk.ComboBox.__init__(self, self.list)
|
||||
self.list = Gtk.ListStore.new([str, str, str])
|
||||
Gtk.ComboBox.__init__(self, model=self.list)
|
||||
|
||||
cell = gtk.CellRendererText()
|
||||
cell = Gtk.CellRendererText()
|
||||
self.pack_start(cell, True)
|
||||
self.add_attribute(cell, 'text', 2)
|
||||
|
||||
@@ -487,12 +489,12 @@ class OptionList(gtk.ComboBox):
|
||||
self.options.append(option)
|
||||
|
||||
|
||||
class OptionCheck(gtk.CheckButton):
|
||||
class OptionCheck(Gtk.CheckButton):
|
||||
def __init__(self, option, label):
|
||||
opt = label
|
||||
if option is not None and option != "":
|
||||
opt += " (%s)" % option
|
||||
|
||||
gtk.CheckButton.__init__(self, opt, use_underline=False)
|
||||
Gtk.CheckButton.__init__(self, label=opt, use_underline=False)
|
||||
|
||||
self.option = option
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -71,15 +70,17 @@
|
||||
# Add options to the print dialog to control the font, coloring, and anything
|
||||
# else. This might go in a separate Print Setup dialog.
|
||||
|
||||
import gtk
|
||||
import gobject
|
||||
import pango
|
||||
import gi
|
||||
|
||||
MONOSPACE_FONT_DESC = pango.FontDescription("Monospace 12")
|
||||
gi.require_version("Gtk", "3.0")
|
||||
gi.require_version("PangoCairo", "1.0")
|
||||
from gi.repository import Gtk, GLib, Pango, PangoCairo
|
||||
|
||||
MONOSPACE_FONT_DESC = Pango.FontDescription("Monospace 12")
|
||||
|
||||
|
||||
class PrintState (object):
|
||||
"""This is the userdatum passed to gtk.PrintOperation callbacks."""
|
||||
class PrintState(object):
|
||||
"""This is the userdatum passed to Gtk.PrintOperation callbacks."""
|
||||
|
||||
def __init__(self, inventory, entry):
|
||||
"""entry is a ScansListStoreEntry."""
|
||||
@@ -90,7 +91,7 @@ class PrintState (object):
|
||||
# Still running, failed, or cancelled.
|
||||
output = entry.command.get_output()
|
||||
if not output:
|
||||
output = u"\n"
|
||||
output = "\n"
|
||||
self.lines = output.splitlines()
|
||||
|
||||
def begin_print(self, op, context):
|
||||
@@ -98,14 +99,14 @@ class PrintState (object):
|
||||
# Typeset a dummy line to get the exact line height.
|
||||
layout = context.create_pango_layout()
|
||||
layout.set_font_description(MONOSPACE_FONT_DESC)
|
||||
layout.set_text("dummy")
|
||||
layout.set_text("dummy", -1)
|
||||
line = layout.get_line(0)
|
||||
# get_extents()[1][3] is the height of the logical rectangle.
|
||||
line_height = line.get_extents()[1][3] / float(pango.SCALE)
|
||||
# get_extents()[1].height is the height of the logical rectangle.
|
||||
line_height = line.get_extents()[1].height / Pango.SCALE
|
||||
|
||||
page_height = context.get_height()
|
||||
self.lines_per_page = int(page_height / line_height)
|
||||
op.set_n_pages((len(self.lines) - 1) / self.lines_per_page + 1)
|
||||
op.set_n_pages((len(self.lines) - 1) // self.lines_per_page + 1)
|
||||
|
||||
def draw_page(self, op, context, page_nr):
|
||||
this_page_lines = self.lines[
|
||||
@@ -115,21 +116,21 @@ class PrintState (object):
|
||||
# Do no wrapping.
|
||||
layout.set_width(-1)
|
||||
layout.set_font_description(MONOSPACE_FONT_DESC)
|
||||
text = "\n".join(this_page_lines).encode("utf8")
|
||||
layout.set_text(text)
|
||||
text = "\n".join(this_page_lines)
|
||||
layout.set_text(text, -1)
|
||||
|
||||
cr = context.get_cairo_context()
|
||||
cr.show_layout(layout)
|
||||
PangoCairo.show_layout(cr, layout)
|
||||
|
||||
|
||||
def run_print_operation(inventory, entry):
|
||||
op = gtk.PrintOperation()
|
||||
op = Gtk.PrintOperation()
|
||||
state = PrintState(inventory, entry)
|
||||
op.connect("begin-print", state.begin_print)
|
||||
op.connect("draw-page", state.draw_page)
|
||||
try:
|
||||
op.run(gtk.PRINT_OPERATION_ACTION_PRINT_DIALOG, None)
|
||||
except gobject.GError:
|
||||
op.run(Gtk.PrintOperationAction.PRINT_DIALOG, None)
|
||||
except GLib.GError:
|
||||
# Canceling the print operation can result in the error
|
||||
# GError: Error from StartDoc
|
||||
# http://seclists.org/nmap-dev/2012/q4/161
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -58,31 +57,31 @@
|
||||
# * *
|
||||
# ***************************************************************************/
|
||||
|
||||
import gtk
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk
|
||||
|
||||
from zenmapCore.UmitConf import CommandProfile
|
||||
import zenmapCore.I18N # lgtm[py/unused-import]
|
||||
|
||||
|
||||
class ProfileCombo(gtk.ComboBoxEntry, object):
|
||||
class ProfileCombo(Gtk.ComboBoxText, object):
|
||||
def __init__(self):
|
||||
gtk.ComboBoxEntry.__init__(self, gtk.ListStore(str), 0)
|
||||
Gtk.ComboBoxText.__init__(self, has_entry=True)
|
||||
|
||||
self.completion = gtk.EntryCompletion()
|
||||
self.child.set_completion(self.completion)
|
||||
self.completion = Gtk.EntryCompletion()
|
||||
self.get_child().set_completion(self.completion)
|
||||
self.completion.set_model(self.get_model())
|
||||
self.completion.set_text_column(0)
|
||||
|
||||
self.update()
|
||||
|
||||
def set_profiles(self, profiles):
|
||||
list = self.get_model()
|
||||
for i in range(len(list)):
|
||||
iter = list.get_iter_root()
|
||||
del(list[iter])
|
||||
self.remove_all()
|
||||
|
||||
for command in profiles:
|
||||
list.append([command])
|
||||
self.append_text(command)
|
||||
|
||||
def update(self):
|
||||
profile = CommandProfile()
|
||||
@@ -93,18 +92,19 @@ class ProfileCombo(gtk.ComboBoxEntry, object):
|
||||
self.set_profiles(profiles)
|
||||
|
||||
def get_selected_profile(self):
|
||||
return self.child.get_text()
|
||||
return self.get_child().get_text()
|
||||
|
||||
def set_selected_profile(self, profile):
|
||||
self.child.set_text(profile)
|
||||
self.get_child().set_text(profile)
|
||||
|
||||
selected_profile = property(get_selected_profile, set_selected_profile)
|
||||
|
||||
if __name__ == "__main__":
|
||||
w = gtk.Window()
|
||||
w = Gtk.Window()
|
||||
p = ProfileCombo()
|
||||
p.update()
|
||||
w.add(p)
|
||||
w.show_all()
|
||||
|
||||
gtk.main()
|
||||
w.connect("delete-event", lambda x, y: Gtk.main_quit())
|
||||
w.show_all()
|
||||
Gtk.main()
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -58,7 +57,10 @@
|
||||
# * *
|
||||
# ***************************************************************************/
|
||||
|
||||
import gtk
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk
|
||||
|
||||
from zenmapGUI.higwidgets.higwindows import HIGWindow
|
||||
from zenmapGUI.higwidgets.higboxes import HIGVBox, HIGHBox, HIGSpacer, \
|
||||
@@ -83,7 +85,7 @@ class ProfileEditor(HIGWindow):
|
||||
HIGWindow.__init__(self)
|
||||
self.connect("delete_event", self.exit)
|
||||
self.set_title(_('Profile Editor'))
|
||||
self.set_position(gtk.WIN_POS_CENTER)
|
||||
self.set_position(Gtk.WindowPosition.CENTER)
|
||||
|
||||
self.deletable = deletable
|
||||
self.profile_name = profile_name
|
||||
@@ -130,7 +132,7 @@ class ProfileEditor(HIGWindow):
|
||||
self.update_command()
|
||||
|
||||
def command_entry_changed_cb(self, widget):
|
||||
command_string = self.command_entry.get_text().decode("UTF-8")
|
||||
command_string = self.command_entry.get_text()
|
||||
self.ops.parse_string(command_string)
|
||||
self.inhibit_command_update = True
|
||||
self.option_builder.update()
|
||||
@@ -167,20 +169,21 @@ class ProfileEditor(HIGWindow):
|
||||
self.lower_box = HIGHBox()
|
||||
|
||||
#self.main_vbox = HIGVBox()
|
||||
self.command_entry = gtk.Entry()
|
||||
self.command_entry = Gtk.Entry()
|
||||
self.command_entry_changed_cb_id = self.command_entry.connect(
|
||||
"changed", self.command_entry_changed_cb)
|
||||
|
||||
self.scan_button = HIGButton(_("Scan"))
|
||||
self.scan_button.connect("clicked", self.run_scan)
|
||||
|
||||
self.notebook = gtk.Notebook()
|
||||
self.notebook = Gtk.Notebook()
|
||||
|
||||
# Profile info page
|
||||
self.profile_info_vbox = HIGVBox()
|
||||
self.profile_info_label = HIGSectionLabel(_('Profile Information'))
|
||||
self.profile_name_label = HIGEntryLabel(_('Profile name'))
|
||||
self.profile_name_entry = gtk.Entry()
|
||||
self.profile_name_label.set_line_wrap(False)
|
||||
self.profile_name_entry = Gtk.Entry()
|
||||
self.profile_name_entry.connect(
|
||||
'enter-notify-event', self.update_help_name)
|
||||
self.profile_description_label = HIGEntryLabel(_('Description'))
|
||||
@@ -193,13 +196,13 @@ class ProfileEditor(HIGWindow):
|
||||
# Buttons
|
||||
self.buttons_hbox = HIGHBox()
|
||||
|
||||
self.cancel_button = HIGButton(stock=gtk.STOCK_CANCEL)
|
||||
self.cancel_button = HIGButton(stock=Gtk.STOCK_CANCEL)
|
||||
self.cancel_button.connect('clicked', self.exit)
|
||||
|
||||
self.delete_button = HIGButton(stock=gtk.STOCK_DELETE)
|
||||
self.delete_button = HIGButton(stock=Gtk.STOCK_DELETE)
|
||||
self.delete_button.connect('clicked', self.delete_profile)
|
||||
|
||||
self.save_button = HIGButton(_("Save Changes"), stock=gtk.STOCK_SAVE)
|
||||
self.save_button = HIGButton(_("Save Changes"), stock=Gtk.STOCK_SAVE)
|
||||
self.save_button.connect('clicked', self.save_profile)
|
||||
|
||||
###
|
||||
@@ -228,7 +231,7 @@ class ProfileEditor(HIGWindow):
|
||||
self.middle_box._pack_expand_fill(self.help_vbox)
|
||||
|
||||
# Packing buttons to lower box
|
||||
self.lower_box.pack_end(self.buttons_hbox)
|
||||
self.lower_box.pack_end(self.buttons_hbox, True, True, 0)
|
||||
|
||||
# Packing the three vertical boxes to the main box
|
||||
self.main_whole_box._pack_noexpand_nofill(self.upper_box)
|
||||
@@ -238,7 +241,7 @@ class ProfileEditor(HIGWindow):
|
||||
|
||||
# Packing profile information tab on notebook
|
||||
self.notebook.append_page(
|
||||
self.profile_info_vbox, gtk.Label(_('Profile')))
|
||||
self.profile_info_vbox, Gtk.Label.new(_('Profile')))
|
||||
self.profile_info_vbox.set_border_width(5)
|
||||
table = HIGTable()
|
||||
self.profile_info_vbox._pack_noexpand_nofill(self.profile_info_label)
|
||||
@@ -292,7 +295,7 @@ class ProfileEditor(HIGWindow):
|
||||
else:
|
||||
hbox = tab.get_hmain_box()
|
||||
vbox.pack_start(hbox, True, True, 0)
|
||||
self.notebook.append_page(vbox, gtk.Label(tab_name))
|
||||
self.notebook.append_page(vbox, Gtk.Label.new(tab_name))
|
||||
|
||||
def save_profile(self, widget):
|
||||
if self.overwrite:
|
||||
@@ -314,7 +317,7 @@ class ProfileEditor(HIGWindow):
|
||||
|
||||
buf = self.profile_description_text.get_buffer()
|
||||
description = buf.get_text(
|
||||
buf.get_start_iter(), buf.get_end_iter())
|
||||
buf.get_start_iter(), buf.get_end_iter(), include_hidden_chars=True)
|
||||
|
||||
try:
|
||||
self.profile.add_profile(
|
||||
@@ -347,11 +350,11 @@ class ProfileEditor(HIGWindow):
|
||||
|
||||
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))
|
||||
dialog = HIGDialog(buttons=(Gtk.STOCK_OK, Gtk.ResponseType.OK,
|
||||
Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL))
|
||||
alert = HIGEntryLabel('<b>' + _("Deleting Profile") + '</b>')
|
||||
text = HIGEntryLabel(_(
|
||||
'Your profile is going to be deleted! ClickOk to continue, '
|
||||
'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)
|
||||
@@ -361,21 +364,21 @@ class ProfileEditor(HIGWindow):
|
||||
vbox.set_border_width(5)
|
||||
vbox.set_spacing(12)
|
||||
|
||||
image = gtk.Image()
|
||||
image = Gtk.Image()
|
||||
image.set_from_stock(
|
||||
gtk.STOCK_DIALOG_WARNING, gtk.ICON_SIZE_DIALOG)
|
||||
Gtk.STOCK_DIALOG_WARNING, Gtk.IconSize.DIALOG)
|
||||
|
||||
vbox.pack_start(alert)
|
||||
vbox.pack_start(text)
|
||||
hbox.pack_start(image)
|
||||
hbox.pack_start(vbox)
|
||||
vbox.pack_start(alert, True, True, 0)
|
||||
vbox.pack_start(text, True, True, 0)
|
||||
hbox.pack_start(image, True, True, 0)
|
||||
hbox.pack_start(vbox, True, True, 0)
|
||||
|
||||
dialog.vbox.pack_start(hbox)
|
||||
dialog.vbox.pack_start(hbox, True, True, 0)
|
||||
dialog.vbox.show_all()
|
||||
|
||||
response = dialog.run()
|
||||
dialog.destroy()
|
||||
if response == gtk.RESPONSE_CANCEL:
|
||||
if response == Gtk.ResponseType.CANCEL:
|
||||
return True
|
||||
self.profile.remove_profile(self.profile_name)
|
||||
|
||||
@@ -383,7 +386,7 @@ class ProfileEditor(HIGWindow):
|
||||
self.destroy()
|
||||
|
||||
def run_scan(self, widget=None):
|
||||
command_string = self.command_entry.get_text().decode("UTF-8")
|
||||
command_string = self.command_entry.get_text()
|
||||
self.scan_interface.command_toolbar.command = command_string
|
||||
self.scan_interface.start_scan_cb()
|
||||
self.exit()
|
||||
@@ -399,4 +402,4 @@ class ProfileEditor(HIGWindow):
|
||||
if __name__ == '__main__':
|
||||
p = ProfileEditor()
|
||||
p.show_all()
|
||||
gtk.main()
|
||||
Gtk.main()
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -58,7 +57,10 @@
|
||||
# * *
|
||||
# ***************************************************************************/
|
||||
|
||||
import gtk
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk
|
||||
|
||||
from zenmapGUI.higwidgets.higexpanders import HIGExpander
|
||||
from zenmapGUI.higwidgets.higboxes import HIGVBox, HIGHBox,\
|
||||
@@ -121,21 +123,21 @@ class HostDetails(HIGVBox):
|
||||
self.set_comment(host.comment)
|
||||
|
||||
def __create_widgets(self):
|
||||
self.host_status_expander = gtk.Expander(
|
||||
self.host_status_expander = Gtk.Expander.new(
|
||||
'<b>' + _('Host Status') + '</b>')
|
||||
self.address_expander = gtk.Expander('<b>' + _('Addresses') + '</b>')
|
||||
self.hostnames_expander = gtk.Expander('<b>' + _('Hostnames') + '</b>')
|
||||
self.os_expander = gtk.Expander('<b>' + _('Operating System') + '</b>')
|
||||
self.portsused_expander = gtk.Expander(
|
||||
self.address_expander = Gtk.Expander.new('<b>' + _('Addresses') + '</b>')
|
||||
self.hostnames_expander = Gtk.Expander.new('<b>' + _('Hostnames') + '</b>')
|
||||
self.os_expander = Gtk.Expander.new('<b>' + _('Operating System') + '</b>')
|
||||
self.portsused_expander = Gtk.Expander.new(
|
||||
'<b>' + _('Ports used') + '</b>')
|
||||
self.osclass_expander = gtk.Expander('<b>' + _('OS Classes') + '</b>')
|
||||
self.tcp_expander = gtk.Expander('<b>' + _('TCP Sequence') + '</b>')
|
||||
self.ip_expander = gtk.Expander('<b>' + _('IP ID Sequence') + '</b>')
|
||||
self.tcpts_expander = gtk.Expander(
|
||||
self.osclass_expander = Gtk.Expander.new('<b>' + _('OS Classes') + '</b>')
|
||||
self.tcp_expander = Gtk.Expander.new('<b>' + _('TCP Sequence') + '</b>')
|
||||
self.ip_expander = Gtk.Expander.new('<b>' + _('IP ID Sequence') + '</b>')
|
||||
self.tcpts_expander = Gtk.Expander.new(
|
||||
'<b>' + _('TCP TS Sequence') + '</b>')
|
||||
self.comment_expander = gtk.Expander('<b>' + _('Comments') + '</b>')
|
||||
self.os_image = gtk.Image()
|
||||
self.vulnerability_image = gtk.Image()
|
||||
self.comment_expander = Gtk.Expander.new('<b>' + _('Comments') + '</b>')
|
||||
self.os_image = Gtk.Image()
|
||||
self.vulnerability_image = Gtk.Image()
|
||||
|
||||
# Host Status expander
|
||||
self.host_state_label = HIGEntryLabel(_('State:'))
|
||||
@@ -235,9 +237,9 @@ class HostDetails(HIGVBox):
|
||||
table.attach(self.lastboot_label, 0, 1, 6, 7)
|
||||
table.attach(self.info_lastboot_label, 1, 2, 6, 7)
|
||||
|
||||
table.attach(self.os_image, 2, 4, 0, 3, xoptions=1, yoptions=0)
|
||||
table.attach(self.os_image, 2, 4, 0, 3, xoptions=Gtk.AttachOptions.EXPAND)
|
||||
table.attach(
|
||||
self.vulnerability_image, 2, 4, 4, 7, xoptions=1, yoptions=0)
|
||||
self.vulnerability_image, 2, 4, 4, 7, xoptions=Gtk.AttachOptions.EXPAND)
|
||||
|
||||
table.set_col_spacing(1, 50)
|
||||
|
||||
@@ -245,10 +247,10 @@ class HostDetails(HIGVBox):
|
||||
self._pack_noexpand_nofill(self.host_status_expander)
|
||||
|
||||
def set_os_image(self, image):
|
||||
self.os_image.set_from_stock(image, gtk.ICON_SIZE_DIALOG)
|
||||
self.os_image.set_from_stock(image, Gtk.IconSize.DIALOG)
|
||||
|
||||
def set_vulnerability_image(self, image):
|
||||
self.vulnerability_image.set_from_stock(image, gtk.ICON_SIZE_DIALOG)
|
||||
self.vulnerability_image.set_from_stock(image, Gtk.IconSize.DIALOG)
|
||||
|
||||
def set_addresses(self, address):
|
||||
self.address_expander.set_use_markup(True)
|
||||
@@ -306,7 +308,7 @@ class HostDetails(HIGVBox):
|
||||
self.os_expander.set_use_markup(True)
|
||||
self.os_expander.set_expanded(True)
|
||||
table, hbox = self.create_table_hbox()
|
||||
progress = gtk.ProgressBar()
|
||||
progress = Gtk.ProgressBar()
|
||||
|
||||
if 'accuracy' in os:
|
||||
progress.set_fraction(float(os['accuracy']) / 100.0)
|
||||
@@ -375,7 +377,7 @@ class HostDetails(HIGVBox):
|
||||
table.attach(HIGEntryLabel(o['osfamily']), 2, 3, y1, y2)
|
||||
table.attach(HIGEntryLabel(o['osgen']), 3, 4, y1, y2)
|
||||
|
||||
progress = gtk.ProgressBar()
|
||||
progress = Gtk.ProgressBar()
|
||||
progress.set_text(o['accuracy'] + '%')
|
||||
progress.set_fraction(float(o['accuracy']) / 100.0)
|
||||
table.attach(progress, 4, 5, y1, y2)
|
||||
@@ -389,7 +391,7 @@ class HostDetails(HIGVBox):
|
||||
self.tcp_expander.set_use_markup(True)
|
||||
table, hbox = self.create_table_hbox()
|
||||
|
||||
combo = gtk.combo_box_new_text()
|
||||
combo = Gtk.ComboBoxText()
|
||||
for v in tcpseq['values'].split(','):
|
||||
combo.append_text(v)
|
||||
|
||||
@@ -410,7 +412,7 @@ class HostDetails(HIGVBox):
|
||||
self.ip_expander.set_use_markup(True)
|
||||
table, hbox = self.create_table_hbox()
|
||||
|
||||
combo = gtk.combo_box_new_text()
|
||||
combo = Gtk.ComboBoxText()
|
||||
|
||||
for i in ipseq['values'].split(','):
|
||||
combo.append_text(i)
|
||||
@@ -429,7 +431,7 @@ class HostDetails(HIGVBox):
|
||||
self.tcpts_expander.set_use_markup(True)
|
||||
table, hbox = self.create_table_hbox()
|
||||
|
||||
combo = gtk.combo_box_new_text()
|
||||
combo = Gtk.ComboBoxText()
|
||||
|
||||
for i in tcptsseq['values'].split(','):
|
||||
combo.append_text(i)
|
||||
@@ -450,13 +452,13 @@ class HostDetails(HIGVBox):
|
||||
|
||||
hbox = HIGHBox()
|
||||
|
||||
self.comment_scrolled = gtk.ScrolledWindow()
|
||||
self.comment_scrolled = Gtk.ScrolledWindow()
|
||||
self.comment_scrolled.set_border_width(5)
|
||||
self.comment_scrolled.set_policy(
|
||||
gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
|
||||
Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
|
||||
|
||||
self.comment_txt_vw = gtk.TextView()
|
||||
self.comment_txt_vw.set_wrap_mode(gtk.WRAP_WORD)
|
||||
self.comment_txt_vw = Gtk.TextView()
|
||||
self.comment_txt_vw.set_wrap_mode(Gtk.WrapMode.WORD)
|
||||
self.comment_txt_vw.get_buffer().set_text(comment)
|
||||
|
||||
self.comment_scrolled.add(self.comment_txt_vw)
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -58,7 +57,10 @@
|
||||
# * *
|
||||
# ***************************************************************************/
|
||||
|
||||
import gtk
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk
|
||||
|
||||
from zenmapGUI.higwidgets.higboxes import HIGVBox
|
||||
from zenmapGUI.Icons import get_os_icon
|
||||
@@ -71,14 +73,16 @@ def treemodel_get_addrs_for_sort(model, iter):
|
||||
|
||||
|
||||
# Used to sort hosts by address.
|
||||
def cmp_treemodel_addr(model, iter_a, iter_b):
|
||||
def cmp_treemodel_addr(model, iter_a, iter_b, *_):
|
||||
def cmp(a, b):
|
||||
return (a > b) - (a < b)
|
||||
addrs_a = treemodel_get_addrs_for_sort(model, iter_a)
|
||||
addrs_b = treemodel_get_addrs_for_sort(model, iter_b)
|
||||
return cmp(addrs_a, addrs_b)
|
||||
|
||||
|
||||
class ScanHostsView(HIGVBox, object):
|
||||
HOST_MODE, SERVICE_MODE = range(2)
|
||||
class ScanHostsView(HIGVBox):
|
||||
HOST_MODE, SERVICE_MODE = list(range(2))
|
||||
|
||||
def __init__(self, scan_interface):
|
||||
HIGVBox.__init__(self)
|
||||
@@ -103,31 +107,31 @@ class ScanHostsView(HIGVBox, object):
|
||||
|
||||
def _create_widgets(self):
|
||||
# Mode buttons
|
||||
self.host_mode_button = gtk.ToggleButton(_("Hosts"))
|
||||
self.service_mode_button = gtk.ToggleButton(_("Services"))
|
||||
self.buttons_box = gtk.HBox()
|
||||
self.host_mode_button = Gtk.ToggleButton.new_with_label(_("Hosts"))
|
||||
self.service_mode_button = Gtk.ToggleButton.new_with_label(_("Services"))
|
||||
self.buttons_box = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, 0)
|
||||
|
||||
# Main window vbox
|
||||
self.main_vbox = HIGVBox()
|
||||
|
||||
# Host list
|
||||
self.host_list = gtk.ListStore(object, str, str)
|
||||
self.host_list = Gtk.ListStore.new([object, str, str])
|
||||
self.host_list.set_sort_func(1000, cmp_treemodel_addr)
|
||||
self.host_list.set_sort_column_id(1000, gtk.SORT_ASCENDING)
|
||||
self.host_view = gtk.TreeView(self.host_list)
|
||||
self.pic_column = gtk.TreeViewColumn(_('OS'))
|
||||
self.host_column = gtk.TreeViewColumn(_('Host'))
|
||||
self.os_cell = gtk.CellRendererPixbuf()
|
||||
self.host_cell = gtk.CellRendererText()
|
||||
self.host_list.set_sort_column_id(1000, Gtk.SortType.ASCENDING)
|
||||
self.host_view = Gtk.TreeView.new_with_model(self.host_list)
|
||||
self.pic_column = Gtk.TreeViewColumn(title=_('OS'))
|
||||
self.host_column = Gtk.TreeViewColumn(title=_('Host'))
|
||||
self.os_cell = Gtk.CellRendererPixbuf()
|
||||
self.host_cell = Gtk.CellRendererText()
|
||||
|
||||
# Service list
|
||||
self.service_list = gtk.ListStore(str)
|
||||
self.service_list.set_sort_column_id(0, gtk.SORT_ASCENDING)
|
||||
self.service_view = gtk.TreeView(self.service_list)
|
||||
self.service_column = gtk.TreeViewColumn(_('Service'))
|
||||
self.service_cell = gtk.CellRendererText()
|
||||
self.service_list = Gtk.ListStore.new([str])
|
||||
self.service_list.set_sort_column_id(0, Gtk.SortType.ASCENDING)
|
||||
self.service_view = Gtk.TreeView.new_with_model(self.service_list)
|
||||
self.service_column = Gtk.TreeViewColumn(title=_('Service'))
|
||||
self.service_cell = Gtk.CellRendererText()
|
||||
|
||||
self.scrolled = gtk.ScrolledWindow()
|
||||
self.scrolled = Gtk.ScrolledWindow()
|
||||
|
||||
def _pack_widgets(self):
|
||||
self.main_vbox.set_spacing(0)
|
||||
@@ -138,8 +142,8 @@ class ScanHostsView(HIGVBox, object):
|
||||
self.host_mode_button.set_active(True)
|
||||
|
||||
self.buttons_box.set_border_width(5)
|
||||
self.buttons_box.pack_start(self.host_mode_button)
|
||||
self.buttons_box.pack_start(self.service_mode_button)
|
||||
self.buttons_box.pack_start(self.host_mode_button, True, True, 0)
|
||||
self.buttons_box.pack_start(self.service_mode_button, True, True, 0)
|
||||
|
||||
def _connect_widgets(self):
|
||||
self.host_mode_button.connect("toggled", self.host_mode)
|
||||
@@ -173,14 +177,14 @@ class ScanHostsView(HIGVBox, object):
|
||||
def _set_scrolled(self):
|
||||
self.scrolled.set_border_width(5)
|
||||
self.scrolled.set_size_request(150, -1)
|
||||
self.scrolled.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
|
||||
self.scrolled.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
|
||||
|
||||
def _set_service_list(self):
|
||||
self.service_view.set_enable_search(True)
|
||||
self.service_view.set_search_column(0)
|
||||
|
||||
selection = self.service_view.get_selection()
|
||||
selection.set_mode(gtk.SELECTION_MULTIPLE)
|
||||
selection.set_mode(Gtk.SelectionMode.MULTIPLE)
|
||||
self.service_view.append_column(self.service_column)
|
||||
|
||||
self.service_column.set_resizable(True)
|
||||
@@ -194,7 +198,7 @@ class ScanHostsView(HIGVBox, object):
|
||||
self.host_view.set_search_column(1)
|
||||
|
||||
selection = self.host_view.get_selection()
|
||||
selection.set_mode(gtk.SELECTION_MULTIPLE)
|
||||
selection.set_mode(Gtk.SelectionMode.MULTIPLE)
|
||||
|
||||
self.host_view.append_column(self.pic_column)
|
||||
self.host_view.append_column(self.host_column)
|
||||
@@ -228,7 +232,7 @@ class ScanHostsView(HIGVBox, object):
|
||||
# Treeview?"
|
||||
sort_column_id = self.host_list.get_sort_column_id()
|
||||
self.host_list.set_default_sort_func(lambda *args: -1)
|
||||
self.host_list.set_sort_column_id(-1, gtk.SORT_ASCENDING)
|
||||
self.host_list.set_sort_column_id(-1, Gtk.SortType.ASCENDING)
|
||||
self.host_view.freeze_child_notify()
|
||||
self.host_view.set_model(None)
|
||||
|
||||
@@ -275,8 +279,10 @@ class ScanHostsView(HIGVBox, object):
|
||||
self.service_list.append([service])
|
||||
|
||||
if __name__ == "__main__":
|
||||
w = gtk.Window()
|
||||
w = Gtk.Window()
|
||||
h = ScanHostsView(None)
|
||||
w.add(h)
|
||||
|
||||
w.connect("delete-event", lambda x, y: Gtk.main_quit())
|
||||
w.show_all()
|
||||
gtk.main()
|
||||
Gtk.main()
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -58,9 +57,12 @@
|
||||
# * *
|
||||
# ***************************************************************************/
|
||||
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, GLib
|
||||
|
||||
import errno
|
||||
import gtk
|
||||
import gobject
|
||||
import os
|
||||
import time
|
||||
import sys
|
||||
@@ -220,19 +222,19 @@ class ScanInterface(HIGVBox):
|
||||
def filter_changed(self, filter_bar):
|
||||
# Restart the timer to start the filter.
|
||||
if self.filter_timeout_id:
|
||||
gobject.source_remove(self.filter_timeout_id)
|
||||
self.filter_timeout_id = gobject.timeout_add(
|
||||
GLib.source_remove(self.filter_timeout_id)
|
||||
self.filter_timeout_id = GLib.timeout_add(
|
||||
self.FILTER_DELAY, self.filter_hosts,
|
||||
filter_bar.get_filter_string())
|
||||
|
||||
def filter_hosts(self, filter_string):
|
||||
start = time.clock()
|
||||
start = time.perf_counter()
|
||||
self.inventory.apply_filter(filter_string)
|
||||
filter_time = time.clock() - start
|
||||
filter_time = time.perf_counter() - start
|
||||
# Update the gui
|
||||
start = time.clock()
|
||||
start = time.perf_counter()
|
||||
self.update_ui()
|
||||
gui_time = time.clock() - start
|
||||
gui_time = time.perf_counter() - start
|
||||
|
||||
if filter_time + gui_time > 0.0:
|
||||
log.debug("apply_filter %g ms update_ui %g ms (%.0f%% filter)" %
|
||||
@@ -368,7 +370,7 @@ class ScanInterface(HIGVBox):
|
||||
if target != '':
|
||||
try:
|
||||
self.toolbar.add_new_target(target)
|
||||
except IOError, e:
|
||||
except IOError as e:
|
||||
# We failed to save target_list.txt; treat it as read-only.
|
||||
# Probably it's owned by root and this is a normal user.
|
||||
log.debug(">>> Error saving %s: %s" % (
|
||||
@@ -381,7 +383,7 @@ class ScanInterface(HIGVBox):
|
||||
"Maybe the selected/typed profile doesn't exist. "
|
||||
"Please check the profile name or type the nmap "
|
||||
"command you would like to execute."),
|
||||
type=gtk.MESSAGE_ERROR)
|
||||
type=Gtk.MessageType.ERROR)
|
||||
warn_dialog.run()
|
||||
warn_dialog.destroy()
|
||||
return
|
||||
@@ -431,7 +433,7 @@ class ScanInterface(HIGVBox):
|
||||
pass
|
||||
# Create TreeRowReferences because those persist while we change
|
||||
# the model.
|
||||
selected_refs.append(gtk.TreeRowReference(model, path))
|
||||
selected_refs.append(Gtk.TreeRowReference.new(model, path))
|
||||
# Delete the entries from the ScansListStore.
|
||||
for ref in selected_refs:
|
||||
model.remove(model.get_iter(ref.get_path()))
|
||||
@@ -463,11 +465,11 @@ class ScanInterface(HIGVBox):
|
||||
completion."""
|
||||
try:
|
||||
command_execution = NmapCommand(command)
|
||||
except IOError, e:
|
||||
except IOError as e:
|
||||
warn_dialog = HIGAlertDialog(
|
||||
message_format=_("Error building command"),
|
||||
secondary_text=_("Error message: %s") % str(e),
|
||||
type=gtk.MESSAGE_ERROR)
|
||||
type=Gtk.MessageType.ERROR)
|
||||
warn_dialog.run()
|
||||
warn_dialog.destroy()
|
||||
return
|
||||
@@ -475,8 +477,8 @@ class ScanInterface(HIGVBox):
|
||||
|
||||
try:
|
||||
command_execution.run_scan()
|
||||
except OSError, e:
|
||||
text = unicode(e.strerror, errors='replace')
|
||||
except OSError as e:
|
||||
text = str(e.strerror, errors='replace')
|
||||
# Handle ENOENT specially.
|
||||
if e.errno == errno.ENOENT:
|
||||
# nmap_command_path comes from zenmapCore.NmapCommand.
|
||||
@@ -488,7 +490,7 @@ class ScanInterface(HIGVBox):
|
||||
if fsencoding:
|
||||
path_env = path_env.decode(fsencoding, 'replace')
|
||||
default_paths = path_env.split(os.pathsep)
|
||||
text += u"\n\n{}\n\n{}".format(
|
||||
text += "\n\n{}\n\n{}".format(
|
||||
_("This means that the nmap executable was "
|
||||
"not found in your system PATH, which is"),
|
||||
path_env or _("<undefined>")
|
||||
@@ -498,23 +500,23 @@ class ScanInterface(HIGVBox):
|
||||
p not in default_paths)]
|
||||
if len(extra_paths) > 0:
|
||||
if len(extra_paths) == 1:
|
||||
text += u"\n\n" + _("plus the extra directory")
|
||||
text += "\n\n" + _("plus the extra directory")
|
||||
else:
|
||||
text += u"\n\n" + _("plus the extra directories")
|
||||
text += u"\n\n" + os.pathsep.join(extra_paths)
|
||||
text += "\n\n" + _("plus the extra directories")
|
||||
text += "\n\n" + os.pathsep.join(extra_paths)
|
||||
else:
|
||||
text += u" (%d)" % e.errno
|
||||
text += " (%d)" % e.errno
|
||||
warn_dialog = HIGAlertDialog(
|
||||
message_format=_("Error executing command"),
|
||||
secondary_text=text, type=gtk.MESSAGE_ERROR)
|
||||
secondary_text=text, type=Gtk.MessageType.ERROR)
|
||||
warn_dialog.run()
|
||||
warn_dialog.destroy()
|
||||
return
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
warn_dialog = HIGAlertDialog(
|
||||
message_format=_("Error executing command"),
|
||||
secondary_text=unicode(str(e), errors='replace'),
|
||||
type=gtk.MESSAGE_ERROR)
|
||||
secondary_text=str(e),
|
||||
type=Gtk.MessageType.ERROR)
|
||||
warn_dialog.run()
|
||||
warn_dialog.destroy()
|
||||
return
|
||||
@@ -530,7 +532,7 @@ class ScanInterface(HIGVBox):
|
||||
self.scan_result.refresh_nmap_output()
|
||||
|
||||
# Add a timeout function
|
||||
self.verify_thread_timeout_id = gobject.timeout_add(
|
||||
self.verify_thread_timeout_id = GLib.timeout_add(
|
||||
NMAP_OUTPUT_REFRESH_INTERVAL, self.verify_execution)
|
||||
|
||||
def verify_execution(self):
|
||||
@@ -569,12 +571,12 @@ class ScanInterface(HIGVBox):
|
||||
parsed = NmapParser()
|
||||
try:
|
||||
parsed.parse_file(command.get_xml_output_filename())
|
||||
except IOError, e:
|
||||
except IOError as e:
|
||||
# It's possible to run Nmap without generating an XML output file,
|
||||
# like with "nmap -V".
|
||||
if e.errno != errno.ENOENT:
|
||||
raise
|
||||
except xml.sax.SAXParseException, e:
|
||||
except xml.sax.SAXParseException as e:
|
||||
try:
|
||||
# Some options like --iflist cause Nmap to emit an empty XML
|
||||
# file. Ignore the exception in this case.
|
||||
@@ -587,7 +589,7 @@ class ScanInterface(HIGVBox):
|
||||
secondary_text=_(
|
||||
"There was an error while parsing the XML file "
|
||||
"generated from the scan:\n\n%s""") % str(e),
|
||||
type=gtk.MESSAGE_ERROR)
|
||||
type=Gtk.MessageType.ERROR)
|
||||
warn_dialog.run()
|
||||
warn_dialog.destroy()
|
||||
else:
|
||||
@@ -596,13 +598,13 @@ class ScanInterface(HIGVBox):
|
||||
self.scan_result.refresh_nmap_output()
|
||||
try:
|
||||
self.inventory.add_scan(parsed)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
warn_dialog = HIGAlertDialog(
|
||||
message_format=_("Cannot merge scan"),
|
||||
secondary_text=_(
|
||||
"There was an error while merging the new scan's "
|
||||
"XML:\n\n%s") % str(e),
|
||||
type=gtk.MESSAGE_ERROR)
|
||||
type=Gtk.MessageType.ERROR)
|
||||
warn_dialog.run()
|
||||
warn_dialog.destroy()
|
||||
parsed.set_xml_is_temp(command.xml_is_temp)
|
||||
@@ -864,20 +866,20 @@ class ScanInterface(HIGVBox):
|
||||
host_page.thaw()
|
||||
|
||||
|
||||
class ScanResult(gtk.HPaned):
|
||||
class ScanResult(Gtk.Paned):
|
||||
"""This is the pane that has the "Host"/"Service" column (ScanHostsView) on
|
||||
the left and the "Nmap Output"/"Ports / Hosts"/etc. (ScanResultNotebook) on
|
||||
the right. It's the part of the interface below the toolbar."""
|
||||
def __init__(self, inventory, scans_store, scan_interface=None):
|
||||
gtk.HPaned.__init__(self)
|
||||
Gtk.Paned.__init__(self, orientation=Gtk.Orientation.HORIZONTAL)
|
||||
|
||||
self.scan_host_view = ScanHostsView(scan_interface)
|
||||
self.scan_result_notebook = ScanResultNotebook(inventory, scans_store)
|
||||
self.filter_toggle_button = gtk.ToggleButton(_("Filter Hosts"))
|
||||
self.filter_toggle_button = Gtk.ToggleButton.new_with_label(_("Filter Hosts"))
|
||||
|
||||
vbox = gtk.VBox()
|
||||
vbox.pack_start(self.scan_host_view, True, True)
|
||||
vbox.pack_start(self.filter_toggle_button, False)
|
||||
vbox = Gtk.Box.new(Gtk.Orientation.VERTICAL, 0)
|
||||
vbox.pack_start(self.scan_host_view, True, True, 0)
|
||||
vbox.pack_start(self.filter_toggle_button, False, True, 0)
|
||||
self.pack1(vbox)
|
||||
self.pack2(self.scan_result_notebook, True, False)
|
||||
|
||||
@@ -923,11 +925,11 @@ class ScanResultNotebook(HIGNotebook):
|
||||
self.scans_list.scans_list.connect(
|
||||
"row-activated", self._scan_row_activated)
|
||||
|
||||
self.append_page(self.nmap_output_page, gtk.Label(_('Nmap Output')))
|
||||
self.append_page(self.open_ports_page, gtk.Label(_('Ports / Hosts')))
|
||||
self.append_page(self.topology_page, gtk.Label(_('Topology')))
|
||||
self.append_page(self.host_details_page, gtk.Label(_('Host Details')))
|
||||
self.append_page(self.scans_list_page, gtk.Label(_('Scans')))
|
||||
self.append_page(self.nmap_output_page, Gtk.Label.new(_('Nmap Output')))
|
||||
self.append_page(self.open_ports_page, Gtk.Label.new(_('Ports / Hosts')))
|
||||
self.append_page(self.topology_page, Gtk.Label.new(_('Topology')))
|
||||
self.append_page(self.host_details_page, Gtk.Label.new(_('Host Details')))
|
||||
self.append_page(self.scans_list_page, Gtk.Label.new(_('Scans')))
|
||||
|
||||
def host_mode(self):
|
||||
self.open_ports.host.host_mode()
|
||||
@@ -948,7 +950,7 @@ class ScanResultNotebook(HIGNotebook):
|
||||
self.topology = TopologyPage(inventory)
|
||||
self.scans_list = ScanScanListPage(scans_store)
|
||||
|
||||
self.no_selected = gtk.Label(_('No host selected.'))
|
||||
self.no_selected = Gtk.Label.new(_('No host selected.'))
|
||||
self.host_details = self.no_selected
|
||||
|
||||
self.open_ports_page.add(self.open_ports)
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -58,9 +57,11 @@
|
||||
# * *
|
||||
# ***************************************************************************/
|
||||
|
||||
import gtk
|
||||
import gobject
|
||||
import pango
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, GObject, GdkPixbuf, Pango
|
||||
|
||||
import os
|
||||
|
||||
from zenmapGUI.higwidgets.higboxes import HIGHBox, HIGVBox
|
||||
@@ -74,14 +75,14 @@ import zenmapCore.I18N # lgtm[py/unused-import]
|
||||
|
||||
def scan_entry_data_func(widget, cell_renderer, model, iter):
|
||||
"""Set the properties of a cell renderer for a scan entry."""
|
||||
cell_renderer.set_property("ellipsize", pango.ELLIPSIZE_END)
|
||||
cell_renderer.set_property("style", pango.STYLE_NORMAL)
|
||||
cell_renderer.set_property("ellipsize", Pango.EllipsizeMode.END)
|
||||
cell_renderer.set_property("style", Pango.Style.NORMAL)
|
||||
cell_renderer.set_property("strikethrough", False)
|
||||
entry = model.get_value(iter, 0)
|
||||
if entry is None:
|
||||
return
|
||||
if entry.running:
|
||||
cell_renderer.set_property("style", pango.STYLE_ITALIC)
|
||||
cell_renderer.set_property("style", Pango.Style.ITALIC)
|
||||
elif entry.finished:
|
||||
pass
|
||||
elif entry.failed or entry.canceled:
|
||||
@@ -89,21 +90,21 @@ def scan_entry_data_func(widget, cell_renderer, model, iter):
|
||||
cell_renderer.set_property("text", entry.get_command_string())
|
||||
|
||||
|
||||
class Throbber(gtk.Image):
|
||||
class Throbber(Gtk.Image):
|
||||
"""This is a little progress indicator that animates while a scan is
|
||||
running."""
|
||||
try:
|
||||
still = gtk.gdk.pixbuf_new_from_file(
|
||||
still = GdkPixbuf.Pixbuf.new_from_file(
|
||||
os.path.join(Path.pixmaps_dir, "throbber.png"))
|
||||
anim = gtk.gdk.PixbufAnimation(
|
||||
anim = GdkPixbuf.PixbufAnimation(
|
||||
os.path.join(Path.pixmaps_dir, "throbber.gif"))
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
log.debug("Error loading throbber images: %s." % str(e))
|
||||
still = None
|
||||
anim = None
|
||||
|
||||
def __init__(self):
|
||||
gtk.Image.__init__(self)
|
||||
Gtk.Image.__init__(self)
|
||||
self.set_from_pixbuf(self.still)
|
||||
self.animating = False
|
||||
|
||||
@@ -127,7 +128,7 @@ class ScanNmapOutputPage(HIGVBox):
|
||||
the combo box selection changes."""
|
||||
|
||||
__gsignals__ = {
|
||||
"changed": (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ())
|
||||
"changed": (GObject.SignalFlags.RUN_FIRST, GObject.TYPE_NONE, ())
|
||||
}
|
||||
|
||||
def __init__(self, scans_store):
|
||||
@@ -140,8 +141,8 @@ class ScanNmapOutputPage(HIGVBox):
|
||||
|
||||
hbox = HIGHBox()
|
||||
|
||||
self.scans_list = gtk.ComboBox(scans_store)
|
||||
cell = gtk.CellRendererText()
|
||||
self.scans_list = Gtk.ComboBox.new_with_model(scans_store)
|
||||
cell = Gtk.CellRendererText()
|
||||
self.scans_list.pack_start(cell, True)
|
||||
self.scans_list.set_cell_data_func(cell, scan_entry_data_func)
|
||||
hbox._pack_expand_fill(self.scans_list)
|
||||
@@ -153,7 +154,7 @@ class ScanNmapOutputPage(HIGVBox):
|
||||
self.throbber = Throbber()
|
||||
hbox._pack_noexpand_nofill(self.throbber)
|
||||
|
||||
self.details_button = gtk.Button(_("Details"))
|
||||
self.details_button = Gtk.Button.new_with_label(_("Details"))
|
||||
self.details_button.connect("clicked", self._show_details)
|
||||
hbox._pack_noexpand_nofill(self.details_button)
|
||||
|
||||
@@ -227,7 +228,7 @@ class ScanNmapOutputPage(HIGVBox):
|
||||
if not entry.finished:
|
||||
return
|
||||
if self._details_windows.get(entry) is None:
|
||||
window = gtk.Window()
|
||||
window = Gtk.Window()
|
||||
window.add(ScanRunDetailsPage(entry.parsed))
|
||||
|
||||
def close_details(details, event, entry):
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -58,7 +57,10 @@
|
||||
# * *
|
||||
# ***************************************************************************/
|
||||
|
||||
import gtk
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk
|
||||
|
||||
from zenmapGUI.higwidgets.higboxes import HIGVBox
|
||||
|
||||
@@ -68,9 +70,9 @@ import zenmapCore.I18N # lgtm[py/unused-import]
|
||||
|
||||
def findout_service_icon(port_info):
|
||||
if port_info["port_state"] in ["open", "open|filtered"]:
|
||||
return gtk.STOCK_YES
|
||||
return Gtk.STOCK_YES
|
||||
else:
|
||||
return gtk.STOCK_NO
|
||||
return Gtk.STOCK_NO
|
||||
|
||||
|
||||
def get_version_string(d):
|
||||
@@ -90,42 +92,44 @@ def get_version_string(d):
|
||||
|
||||
def get_addrs(host):
|
||||
if host is None:
|
||||
return None
|
||||
return []
|
||||
return host.get_addrs_for_sort()
|
||||
|
||||
|
||||
def cmp_addrs(host_a, host_b):
|
||||
def cmp(a, b):
|
||||
return (a > b) - (a < b)
|
||||
return cmp(get_addrs(host_a), get_addrs(host_b))
|
||||
|
||||
|
||||
def cmp_port_list_addr(model, iter_a, iter_b):
|
||||
def cmp_port_list_addr(model, iter_a, iter_b, *_):
|
||||
host_a = model.get_value(iter_a, 0)
|
||||
host_b = model.get_value(iter_b, 0)
|
||||
return cmp_addrs(host_a, host_b)
|
||||
|
||||
|
||||
def cmp_port_tree_addr(model, iter_a, iter_b):
|
||||
def cmp_port_tree_addr(model, iter_a, iter_b, *_):
|
||||
host_a = model.get_value(iter_a, 0)
|
||||
host_b = model.get_value(iter_b, 0)
|
||||
return cmp_addrs(host_a, host_b)
|
||||
|
||||
|
||||
def cmp_host_list_addr(model, iter_a, iter_b):
|
||||
def cmp_host_list_addr(model, iter_a, iter_b, *_):
|
||||
host_a = model.get_value(iter_a, 2)
|
||||
host_b = model.get_value(iter_b, 2)
|
||||
return cmp_addrs(host_a, host_b)
|
||||
|
||||
|
||||
def cmp_host_tree_addr(model, iter_a, iter_b):
|
||||
def cmp_host_tree_addr(model, iter_a, iter_b, *_):
|
||||
host_a = model.get_value(iter_a, 2)
|
||||
host_b = model.get_value(iter_b, 2)
|
||||
return cmp_addrs(host_a, host_b)
|
||||
|
||||
|
||||
class ScanOpenPortsPage(gtk.ScrolledWindow):
|
||||
class ScanOpenPortsPage(Gtk.ScrolledWindow):
|
||||
def __init__(self):
|
||||
gtk.ScrolledWindow.__init__(self)
|
||||
self.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
|
||||
Gtk.ScrolledWindow.__init__(self)
|
||||
self.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
|
||||
|
||||
self.__create_widgets()
|
||||
|
||||
@@ -150,65 +154,65 @@ class HostOpenPorts(HIGVBox):
|
||||
# host hostname icon port protocol state service version
|
||||
# The hostname column is shown only when more than one host is selected
|
||||
# (hence port_tree not port_list is used).
|
||||
self.port_list = gtk.ListStore(
|
||||
object, str, str, int, str, str, str, str)
|
||||
self.port_tree = gtk.TreeStore(
|
||||
object, str, str, int, str, str, str, str)
|
||||
self.port_list = Gtk.ListStore.new([
|
||||
object, str, str, int, str, str, str, str])
|
||||
self.port_tree = Gtk.TreeStore.new([
|
||||
object, str, str, int, str, str, str, str])
|
||||
|
||||
self.port_list.set_sort_func(1000, cmp_port_list_addr)
|
||||
self.port_list.set_sort_column_id(1000, gtk.SORT_ASCENDING)
|
||||
self.port_list.set_sort_column_id(1000, Gtk.SortType.ASCENDING)
|
||||
self.port_tree.set_sort_func(1000, cmp_port_tree_addr)
|
||||
self.port_tree.set_sort_column_id(1000, gtk.SORT_ASCENDING)
|
||||
self.port_tree.set_sort_column_id(1000, Gtk.SortType.ASCENDING)
|
||||
|
||||
self.port_view = gtk.TreeView(self.port_list)
|
||||
self.port_view = Gtk.TreeView.new_with_model(self.port_list)
|
||||
|
||||
self.cell_icon = gtk.CellRendererPixbuf()
|
||||
self.cell_port = gtk.CellRendererText()
|
||||
self.cell_icon = Gtk.CellRendererPixbuf()
|
||||
self.cell_port = Gtk.CellRendererText()
|
||||
|
||||
self.port_columns['hostname'] = gtk.TreeViewColumn(_('Host'))
|
||||
self.port_columns['icon'] = gtk.TreeViewColumn('')
|
||||
self.port_columns['port_number'] = gtk.TreeViewColumn(_('Port'))
|
||||
self.port_columns['protocol'] = gtk.TreeViewColumn(_('Protocol'))
|
||||
self.port_columns['state'] = gtk.TreeViewColumn(_('State'))
|
||||
self.port_columns['service'] = gtk.TreeViewColumn(_('Service'))
|
||||
self.port_columns['version'] = gtk.TreeViewColumn(_('Version'))
|
||||
self.port_columns['hostname'] = Gtk.TreeViewColumn(title=_('Host'))
|
||||
self.port_columns['icon'] = Gtk.TreeViewColumn(title='')
|
||||
self.port_columns['port_number'] = Gtk.TreeViewColumn(title=_('Port'))
|
||||
self.port_columns['protocol'] = Gtk.TreeViewColumn(title=_('Protocol'))
|
||||
self.port_columns['state'] = Gtk.TreeViewColumn(title=_('State'))
|
||||
self.port_columns['service'] = Gtk.TreeViewColumn(title=_('Service'))
|
||||
self.port_columns['version'] = Gtk.TreeViewColumn(title=_('Version'))
|
||||
|
||||
# Host services view
|
||||
self.host_columns = {}
|
||||
# service icon host hostname port protocol state version
|
||||
# service is shown only when more than one service is selected (hence
|
||||
# host_tree not host_list is used).
|
||||
self.host_list = gtk.ListStore(
|
||||
str, str, object, str, int, str, str, str)
|
||||
self.host_tree = gtk.TreeStore(
|
||||
str, str, object, str, int, str, str, str)
|
||||
self.host_list = Gtk.ListStore.new([
|
||||
str, str, object, str, int, str, str, str])
|
||||
self.host_tree = Gtk.TreeStore.new([
|
||||
str, str, object, str, int, str, str, str])
|
||||
|
||||
self.host_list.set_sort_func(1000, cmp_host_list_addr)
|
||||
self.host_list.set_sort_column_id(1000, gtk.SORT_ASCENDING)
|
||||
self.host_list.set_sort_column_id(1000, Gtk.SortType.ASCENDING)
|
||||
self.host_tree.set_sort_func(1000, cmp_host_tree_addr)
|
||||
self.host_tree.set_sort_column_id(1000, gtk.SORT_ASCENDING)
|
||||
self.host_tree.set_sort_column_id(1000, Gtk.SortType.ASCENDING)
|
||||
|
||||
self.host_view = gtk.TreeView(self.host_list)
|
||||
self.host_view = Gtk.TreeView.new_with_model(self.host_list)
|
||||
|
||||
self.cell_host_icon = gtk.CellRendererPixbuf()
|
||||
self.cell_host = gtk.CellRendererText()
|
||||
self.cell_host_icon = Gtk.CellRendererPixbuf()
|
||||
self.cell_host = Gtk.CellRendererText()
|
||||
|
||||
self.host_columns['service'] = gtk.TreeViewColumn(_('Service'))
|
||||
self.host_columns['icon'] = gtk.TreeViewColumn('')
|
||||
self.host_columns['hostname'] = gtk.TreeViewColumn(_('Hostname'))
|
||||
self.host_columns['protocol'] = gtk.TreeViewColumn(_('Protocol'))
|
||||
self.host_columns['port_number'] = gtk.TreeViewColumn(_('Port'))
|
||||
self.host_columns['state'] = gtk.TreeViewColumn(_('State'))
|
||||
self.host_columns['version'] = gtk.TreeViewColumn(_('Version'))
|
||||
self.host_columns['service'] = Gtk.TreeViewColumn(title=_('Service'))
|
||||
self.host_columns['icon'] = Gtk.TreeViewColumn(title='')
|
||||
self.host_columns['hostname'] = Gtk.TreeViewColumn(title=_('Hostname'))
|
||||
self.host_columns['protocol'] = Gtk.TreeViewColumn(title=_('Protocol'))
|
||||
self.host_columns['port_number'] = Gtk.TreeViewColumn(title=_('Port'))
|
||||
self.host_columns['state'] = Gtk.TreeViewColumn(title=_('State'))
|
||||
self.host_columns['version'] = Gtk.TreeViewColumn(title=_('Version'))
|
||||
|
||||
self.scroll_ports_hosts = gtk.ScrolledWindow()
|
||||
self.scroll_ports_hosts = Gtk.ScrolledWindow()
|
||||
|
||||
def _set_host_list(self):
|
||||
self.host_view.set_enable_search(True)
|
||||
self.host_view.set_search_column(2)
|
||||
|
||||
selection = self.host_view.get_selection()
|
||||
selection.set_mode(gtk.SELECTION_MULTIPLE)
|
||||
selection.set_mode(Gtk.SelectionMode.MULTIPLE)
|
||||
|
||||
columns = ["service", "icon", "hostname", "port_number",
|
||||
"protocol", "state", "version"]
|
||||
@@ -247,14 +251,14 @@ class HostOpenPorts(HIGVBox):
|
||||
self.host_columns['service'].set_visible(False)
|
||||
|
||||
self.scroll_ports_hosts.set_policy(
|
||||
gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
|
||||
Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
|
||||
|
||||
def _set_port_list(self):
|
||||
self.port_view.set_enable_search(True)
|
||||
self.port_view.set_search_column(3)
|
||||
|
||||
selection = self.port_view.get_selection()
|
||||
selection.set_mode(gtk.SELECTION_MULTIPLE)
|
||||
selection.set_mode(Gtk.SelectionMode.MULTIPLE)
|
||||
|
||||
self.port_view.append_column(self.port_columns['hostname'])
|
||||
self.port_view.append_column(self.port_columns['icon'])
|
||||
@@ -297,7 +301,7 @@ class HostOpenPorts(HIGVBox):
|
||||
self.port_columns['hostname'].set_visible(False)
|
||||
|
||||
self.scroll_ports_hosts.set_policy(
|
||||
gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
|
||||
Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
|
||||
|
||||
def port_mode(self):
|
||||
child = self.scroll_ports_hosts.get_child()
|
||||
@@ -425,28 +429,29 @@ class HostOpenPorts(HIGVBox):
|
||||
|
||||
def clear_port_list(self):
|
||||
for i in range(len(self.port_list)):
|
||||
iter = self.port_list.get_iter_root()
|
||||
iter = self.port_list.get_iter_first()
|
||||
del(self.port_list[iter])
|
||||
|
||||
def clear_host_list(self):
|
||||
for i in range(len(self.host_list)):
|
||||
iter = self.host_list.get_iter_root()
|
||||
iter = self.host_list.get_iter_first()
|
||||
del(self.host_list[iter])
|
||||
|
||||
def clear_port_tree(self):
|
||||
for i in range(len(self.port_tree)):
|
||||
iter = self.port_tree.get_iter_root()
|
||||
iter = self.port_tree.get_iter_first()
|
||||
del(self.port_tree[iter])
|
||||
|
||||
def clear_host_tree(self):
|
||||
for i in range(len(self.host_tree)):
|
||||
iter = self.host_tree.get_iter_root()
|
||||
iter = self.host_tree.get_iter_first()
|
||||
del(self.host_tree[iter])
|
||||
|
||||
if __name__ == "__main__":
|
||||
w = gtk.Window()
|
||||
w = Gtk.Window()
|
||||
h = HostOpenPorts()
|
||||
w.add(h)
|
||||
w.show_all()
|
||||
|
||||
gtk.main()
|
||||
w.connect("delete-event", lambda x, y: Gtk.main_quit())
|
||||
w.show_all()
|
||||
Gtk.main()
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -58,7 +57,11 @@
|
||||
# * *
|
||||
# ***************************************************************************/
|
||||
|
||||
import gtk
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk
|
||||
|
||||
from zenmapGUI.higwidgets.higboxes import HIGVBox, HIGHBox,\
|
||||
hig_box_space_holder
|
||||
from zenmapGUI.higwidgets.higtables import HIGTable
|
||||
@@ -86,7 +89,7 @@ class ScanRunDetailsPage(HIGVBox):
|
||||
self.debug_label = HIGEntryLabel(_('Debug level:'))
|
||||
self.info_debug_label = HIGEntryLabel(na)
|
||||
|
||||
self.command_expander = gtk.Expander(
|
||||
self.command_expander = Gtk.Expander.new(
|
||||
"<b>" + _("Command Info") + "</b>")
|
||||
self.command_expander.set_use_markup(True)
|
||||
|
||||
@@ -140,7 +143,7 @@ class ScanRunDetailsPage(HIGVBox):
|
||||
self.closed_label = HIGEntryLabel(_('Closed ports:'))
|
||||
self.info_closed_label = HIGEntryLabel(na)
|
||||
|
||||
self.general_expander = gtk.Expander(
|
||||
self.general_expander = Gtk.Expander.new(
|
||||
"<b>" + _("General Info") + "</b>")
|
||||
self.general_expander.set_use_markup(True)
|
||||
|
||||
@@ -202,7 +205,7 @@ class ScanRunDetailsPage(HIGVBox):
|
||||
self.info_closed_label.set_text(str(scan.get_closed_ports()))
|
||||
|
||||
for scaninfo in scan.get_scaninfo():
|
||||
exp = gtk.Expander('<b>%s - %s</b>' % (
|
||||
exp = Gtk.Expander.new('<b>%s - %s</b>' % (
|
||||
_('Scan Info'), scaninfo['type'].capitalize()))
|
||||
exp.set_use_markup(True)
|
||||
|
||||
@@ -241,7 +244,7 @@ class ScanRunDetailsPage(HIGVBox):
|
||||
def make_services_display(self, services):
|
||||
"""Return a widget displaying a list of services like
|
||||
1-1027,1029-1033,1040,1043,1050,1058-1059,1067-1068,1076,1080"""
|
||||
combo = gtk.combo_box_new_text()
|
||||
combo = Gtk.ComboBoxText()
|
||||
|
||||
for i in services.split(","):
|
||||
combo.append_text(i)
|
||||
@@ -256,8 +259,8 @@ if __name__ == "__main__":
|
||||
parsed = NmapParser()
|
||||
parsed.parse_file(filename)
|
||||
run_details = ScanRunDetailsPage(parsed)
|
||||
window = gtk.Window()
|
||||
window = Gtk.Window()
|
||||
window.add(run_details)
|
||||
window.connect("delete-event", lambda *args: gtk.main_quit())
|
||||
window.connect("delete-event", lambda *args: Gtk.main_quit())
|
||||
window.show_all()
|
||||
gtk.main()
|
||||
Gtk.main()
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -58,8 +57,10 @@
|
||||
# * *
|
||||
# ***************************************************************************/
|
||||
|
||||
import gtk
|
||||
import pango
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, Pango
|
||||
|
||||
from zenmapGUI.higwidgets.higboxes import HIGHBox, HIGVBox
|
||||
from zenmapGUI.higwidgets.higbuttons import HIGButton
|
||||
@@ -67,7 +68,7 @@ from zenmapGUI.higwidgets.higscrollers import HIGScrolledWindow
|
||||
import zenmapCore.I18N # lgtm[py/unused-import]
|
||||
|
||||
|
||||
def status_data_func(widget, cell_renderer, model, iter):
|
||||
def status_data_func(widget, cell_renderer, model, iter, data):
|
||||
entry = model.get_value(iter, 0)
|
||||
if entry.running:
|
||||
status = _("Running")
|
||||
@@ -83,9 +84,9 @@ def status_data_func(widget, cell_renderer, model, iter):
|
||||
cell_renderer.set_property("text", status)
|
||||
|
||||
|
||||
def command_data_func(widget, cell_renderer, model, iter):
|
||||
def command_data_func(widget, cell_renderer, model, iter, data):
|
||||
entry = model.get_value(iter, 0)
|
||||
cell_renderer.set_property("ellipsize", pango.ELLIPSIZE_END)
|
||||
cell_renderer.set_property("ellipsize", Pango.EllipsizeMode.END)
|
||||
cell_renderer.set_property("text", entry.get_command_string())
|
||||
|
||||
|
||||
@@ -100,19 +101,19 @@ class ScanScanListPage(HIGVBox):
|
||||
|
||||
scans_store.connect("row-changed", self._row_changed)
|
||||
|
||||
self.scans_list = gtk.TreeView(scans_store)
|
||||
self.scans_list = Gtk.TreeView.new_with_model(scans_store)
|
||||
self.scans_list.get_selection().connect(
|
||||
"changed", self._selection_changed)
|
||||
|
||||
status_col = gtk.TreeViewColumn(_("Status"))
|
||||
cell = gtk.CellRendererText()
|
||||
status_col.pack_start(cell)
|
||||
status_col = Gtk.TreeViewColumn(title=_("Status"))
|
||||
cell = Gtk.CellRendererText()
|
||||
status_col.pack_start(cell, True)
|
||||
status_col.set_cell_data_func(cell, status_data_func)
|
||||
self.scans_list.append_column(status_col)
|
||||
|
||||
command_col = gtk.TreeViewColumn(_("Command"))
|
||||
cell = gtk.CellRendererText()
|
||||
command_col.pack_start(cell)
|
||||
command_col = Gtk.TreeViewColumn(title=_("Command"))
|
||||
cell = Gtk.CellRendererText()
|
||||
command_col.pack_start(cell, True)
|
||||
command_col.set_cell_data_func(cell, command_data_func)
|
||||
self.scans_list.append_column(command_col)
|
||||
|
||||
@@ -120,25 +121,25 @@ class ScanScanListPage(HIGVBox):
|
||||
scrolled_window.set_border_width(0)
|
||||
scrolled_window.add(self.scans_list)
|
||||
|
||||
self.pack_start(scrolled_window, True, True)
|
||||
self.pack_start(scrolled_window, True, True, 0)
|
||||
|
||||
hbox = HIGHBox()
|
||||
buttonbox = gtk.HButtonBox()
|
||||
buttonbox.set_layout(gtk.BUTTONBOX_START)
|
||||
buttonbox = Gtk.ButtonBox.new(Gtk.Orientation.HORIZONTAL)
|
||||
buttonbox.set_layout(Gtk.ButtonBoxStyle.START)
|
||||
buttonbox.set_spacing(4)
|
||||
|
||||
self.append_button = HIGButton(_("Append Scan"), gtk.STOCK_ADD)
|
||||
buttonbox.pack_start(self.append_button, False)
|
||||
self.append_button = HIGButton(_("Append Scan"), Gtk.STOCK_ADD)
|
||||
buttonbox.pack_start(self.append_button, False, True, 0)
|
||||
|
||||
self.remove_button = HIGButton(_("Remove Scan"), gtk.STOCK_REMOVE)
|
||||
buttonbox.pack_start(self.remove_button, False)
|
||||
self.remove_button = HIGButton(_("Remove Scan"), Gtk.STOCK_REMOVE)
|
||||
buttonbox.pack_start(self.remove_button, False, True, 0)
|
||||
|
||||
self.cancel_button = HIGButton(_("Cancel Scan"), gtk.STOCK_CANCEL)
|
||||
buttonbox.pack_start(self.cancel_button, False)
|
||||
self.cancel_button = HIGButton(_("Cancel Scan"), Gtk.STOCK_CANCEL)
|
||||
buttonbox.pack_start(self.cancel_button, False, True, 0)
|
||||
|
||||
hbox.pack_start(buttonbox, padding=4)
|
||||
hbox.pack_start(buttonbox, True, True, 4)
|
||||
|
||||
self.pack_start(hbox, False, padding=4)
|
||||
self.pack_start(hbox, False, True, 4)
|
||||
|
||||
self._update()
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -58,7 +57,10 @@
|
||||
# * *
|
||||
# ***************************************************************************/
|
||||
|
||||
import gtk
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk
|
||||
|
||||
from zenmapGUI.higwidgets.higboxes import HIGHBox
|
||||
from zenmapGUI.higwidgets.higlabels import HIGEntryLabel
|
||||
@@ -77,14 +79,14 @@ class ScanCommandToolbar(HIGHBox):
|
||||
HIGHBox.__init__(self)
|
||||
|
||||
self.command_label = HIGEntryLabel(_("Command:"))
|
||||
self.command_entry = gtk.Entry()
|
||||
self.command_entry = Gtk.Entry()
|
||||
|
||||
self._pack_noexpand_nofill(self.command_label)
|
||||
self._pack_expand_fill(self.command_entry)
|
||||
|
||||
def get_command(self):
|
||||
"""Retrieve command entry"""
|
||||
return self.command_entry.get_text().decode("UTF-8")
|
||||
return self.command_entry.get_text()
|
||||
|
||||
def set_command(self, command):
|
||||
"""Set a command entry"""
|
||||
@@ -108,10 +110,8 @@ class ScanToolbar(HIGHBox):
|
||||
self._create_target()
|
||||
self._create_profile()
|
||||
|
||||
self.scan_button = gtk.Button(_("Scan"))
|
||||
#self.scan_button = HIGButton(_("Scan "), gtk.STOCK_MEDIA_PLAY)
|
||||
self.cancel_button = gtk.Button(_("Cancel"))
|
||||
#self.cancel_button = HIGButton(_("Cancel "), gtk.STOCK_CANCEL)
|
||||
self.scan_button = Gtk.Button.new_with_label(_("Scan"))
|
||||
self.cancel_button = Gtk.Button.new_with_label(_("Cancel"))
|
||||
|
||||
self._pack_noexpand_nofill(self.target_label)
|
||||
self._pack_expand_fill(self.target_entry)
|
||||
@@ -123,11 +123,11 @@ class ScanToolbar(HIGHBox):
|
||||
self._pack_noexpand_nofill(self.cancel_button)
|
||||
|
||||
# Skip over the dropdown arrow so you can tab to the profile entry.
|
||||
self.target_entry.set_focus_chain((self.target_entry.child,))
|
||||
self.target_entry.set_focus_chain((self.target_entry.get_child(),))
|
||||
|
||||
self.target_entry.child.connect('activate',
|
||||
self.target_entry.get_child().connect('activate',
|
||||
lambda x: self.profile_entry.grab_focus())
|
||||
self.profile_entry.child.connect('activate',
|
||||
self.profile_entry.get_child().connect('activate',
|
||||
lambda x: self.scan_button.clicked())
|
||||
|
||||
def _create_target(self):
|
||||
@@ -152,7 +152,7 @@ class ScanToolbar(HIGHBox):
|
||||
|
||||
def get_selected_target(self):
|
||||
"""Return currently selected target"""
|
||||
return self.target_entry.selected_target.decode("UTF-8")
|
||||
return self.target_entry.selected_target
|
||||
|
||||
def set_selected_target(self, target):
|
||||
"""Modify currently selected target"""
|
||||
@@ -177,16 +177,16 @@ class ScanToolbar(HIGHBox):
|
||||
selected_target = property(get_selected_target, set_selected_target)
|
||||
|
||||
if __name__ == "__main__":
|
||||
w = gtk.Window()
|
||||
box = gtk.VBox()
|
||||
w = Gtk.Window()
|
||||
box = Gtk.Box.new(Gtk.Orientation.VERTICAL, 0)
|
||||
w.add(box)
|
||||
|
||||
stool = ScanToolbar()
|
||||
sctool = ScanCommandToolbar()
|
||||
|
||||
box.pack_start(stool)
|
||||
box.pack_start(sctool)
|
||||
box.pack_start(stool, True, True, 0)
|
||||
box.pack_start(sctool, True, True, 0)
|
||||
|
||||
w.connect("delete-event", lambda x, y: gtk.main_quit())
|
||||
w.connect("delete-event", lambda x, y: Gtk.main_quit())
|
||||
w.show_all()
|
||||
gtk.main()
|
||||
Gtk.main()
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -58,7 +57,10 @@
|
||||
# * *
|
||||
# ***************************************************************************/
|
||||
|
||||
import gtk
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk
|
||||
|
||||
|
||||
class ScansListStoreEntry(object):
|
||||
@@ -66,7 +68,7 @@ class ScansListStoreEntry(object):
|
||||
otherwise represented by very different classes."""
|
||||
|
||||
# Possible states for the scan to be in.
|
||||
UNINITIALIZED, RUNNING, FINISHED, FAILED, CANCELED = range(5)
|
||||
UNINITIALIZED, RUNNING, FINISHED, FAILED, CANCELED = list(range(5))
|
||||
|
||||
def __init__(self):
|
||||
self.state = self.UNINITIALIZED
|
||||
@@ -101,11 +103,11 @@ class ScansListStoreEntry(object):
|
||||
canceled = property(lambda self: self.state == self.CANCELED)
|
||||
|
||||
|
||||
class ScansListStore(gtk.ListStore):
|
||||
"""This is a specialization of a gtk.ListStore that holds running,
|
||||
class ScansListStore(Gtk.ListStore):
|
||||
"""This is a specialization of a Gtk.ListStore that holds running,
|
||||
completed, and failed scans."""
|
||||
def __init__(self):
|
||||
gtk.ListStore.__init__(self, object)
|
||||
Gtk.ListStore.__init__(self, object)
|
||||
|
||||
def add_running_scan(self, command):
|
||||
"""Add a running NmapCommand object to the list of scans."""
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -59,11 +59,14 @@
|
||||
|
||||
# This module is responsible for interface present under "Scripting" tab.
|
||||
|
||||
import gobject
|
||||
import gtk
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, GLib
|
||||
|
||||
import os
|
||||
import sys
|
||||
import tempfile
|
||||
import os
|
||||
|
||||
# Prevent loading PyXML
|
||||
import xml
|
||||
@@ -90,7 +93,7 @@ paths_config = PathsConfig()
|
||||
def text_buffer_insert_nsedoc(buf, nsedoc):
|
||||
"""Inserts NSEDoc at the end of the buffer, with markup turned into proper
|
||||
tags."""
|
||||
if not buf.tag_table.lookup("NSEDOC_CODE_TAG"):
|
||||
if not buf.get_tag_table().lookup("NSEDOC_CODE_TAG"):
|
||||
buf.create_tag("NSEDOC_CODE_TAG", font="Monospace")
|
||||
for event in zenmapCore.NSEDocParser.nsedoc_parse(nsedoc):
|
||||
if event.type == "paragraph_start":
|
||||
@@ -102,7 +105,7 @@ def text_buffer_insert_nsedoc(buf, nsedoc):
|
||||
elif event.type == "list_end":
|
||||
pass
|
||||
elif event.type == "list_item_start":
|
||||
buf.insert(buf.get_end_iter(), u"\u2022\u00a0") # bullet nbsp
|
||||
buf.insert(buf.get_end_iter(), "\u2022\u00a0") # bullet nbsp
|
||||
elif event.type == "list_item_end":
|
||||
buf.insert(buf.get_end_iter(), "\n")
|
||||
elif event.type == "text":
|
||||
@@ -123,28 +126,28 @@ class ScriptHelpXMLContentHandler (xml.sax.handler.ContentHandler):
|
||||
self.nselib_dir = None
|
||||
|
||||
def startElement(self, name, attrs):
|
||||
if name == u"directory":
|
||||
if u"name" not in attrs:
|
||||
if name == "directory":
|
||||
if "name" not in attrs:
|
||||
raise ValueError(
|
||||
u'"directory" element did not have "name" attribute')
|
||||
dirname = attrs[u"name"]
|
||||
if u"path" not in attrs:
|
||||
'"directory" element did not have "name" attribute')
|
||||
dirname = attrs["name"]
|
||||
if "path" not in attrs:
|
||||
raise ValueError(
|
||||
u'"directory" element did not have "path" attribute')
|
||||
path = attrs[u"path"].encode("raw_unicode_escape").decode(
|
||||
'"directory" element did not have "path" attribute')
|
||||
path = attrs["path"].encode("raw_unicode_escape").decode(
|
||||
sys.getfilesystemencoding())
|
||||
if dirname == u"scripts":
|
||||
if dirname == "scripts":
|
||||
self.scripts_dir = path
|
||||
elif dirname == u"nselib":
|
||||
elif dirname == "nselib":
|
||||
self.nselib_dir = path
|
||||
else:
|
||||
# Ignore.
|
||||
pass
|
||||
elif name == u"script":
|
||||
if u"filename" not in attrs:
|
||||
elif name == "script":
|
||||
if "filename" not in attrs:
|
||||
raise ValueError(
|
||||
u'"script" element did not have "filename" attribute')
|
||||
self.script_filenames.append(attrs[u"filename"])
|
||||
'"script" element did not have "filename" attribute')
|
||||
self.script_filenames.append(attrs["filename"])
|
||||
|
||||
@staticmethod
|
||||
def parse_nmap_script_help(f):
|
||||
@@ -179,21 +182,21 @@ class ScriptInterface:
|
||||
self.prev_script_spec = None
|
||||
self.focusedentry = None
|
||||
|
||||
self.liststore = gtk.ListStore(str, "gboolean", object)
|
||||
self.liststore = Gtk.ListStore.new([str, bool, object])
|
||||
|
||||
self.file_liststore = gtk.ListStore(str, "gboolean")
|
||||
self.file_liststore = Gtk.ListStore.new([str, bool])
|
||||
|
||||
# Arg name, arg value, (name, desc) tuple.
|
||||
self.arg_liststore = gtk.ListStore(str, str, object)
|
||||
self.arg_liststore = Gtk.ListStore.new([str, str, object])
|
||||
|
||||
# This is what is shown initially. After the initial Nmap run to get
|
||||
# the list of script is finished, this will be replaced with a TreeView
|
||||
# showing the scripts or an error message.
|
||||
self.script_list_container = gtk.VBox()
|
||||
self.script_list_container.pack_start(self.make_please_wait_widget())
|
||||
self.script_list_container = Gtk.Box.new(Gtk.Orientation.VERTICAL, 0)
|
||||
self.script_list_container.pack_start(self.make_please_wait_widget(), True, True, 0)
|
||||
self.hmainbox.pack_start(self.script_list_container, False, False, 0)
|
||||
|
||||
self.nmap_error_widget = gtk.Label(_(
|
||||
self.nmap_error_widget = Gtk.Label.new(_(
|
||||
"There was an error getting the list of scripts from Nmap. "
|
||||
"Try upgrading Nmap."))
|
||||
self.nmap_error_widget.set_line_wrap(True)
|
||||
@@ -231,7 +234,7 @@ class ScriptInterface:
|
||||
nmap_process = NmapCommand(command_string)
|
||||
try:
|
||||
nmap_process.run_scan(stderr=stderr)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
callback(False, None)
|
||||
stderr.close()
|
||||
return
|
||||
@@ -239,7 +242,7 @@ class ScriptInterface:
|
||||
|
||||
self.script_list_widget.set_sensitive(False)
|
||||
|
||||
gobject.timeout_add(
|
||||
GLib.timeout_add(
|
||||
self.NMAP_DELAY, self.script_list_timer_callback,
|
||||
nmap_process, callback)
|
||||
|
||||
@@ -269,16 +272,16 @@ class ScriptInterface:
|
||||
for child in self.script_list_container.get_children():
|
||||
self.script_list_container.remove(child)
|
||||
if status and self.handle_initial_script_list_output(process):
|
||||
self.script_list_container.pack_start(self.script_list_widget)
|
||||
self.script_list_container.pack_start(self.script_list_widget, True, True, 0)
|
||||
else:
|
||||
self.script_list_container.pack_start(self.nmap_error_widget)
|
||||
self.script_list_container.pack_start(self.nmap_error_widget, True, True, 0)
|
||||
|
||||
def handle_initial_script_list_output(self, process):
|
||||
process.stdout_file.seek(0)
|
||||
try:
|
||||
handler = ScriptHelpXMLContentHandler.parse_nmap_script_help(
|
||||
process.stdout_file)
|
||||
except (ValueError, xml.sax.SAXParseException), e:
|
||||
except (ValueError, xml.sax.SAXParseException) as e:
|
||||
log.debug("--script-help parse exception: %s" % str(e))
|
||||
return False
|
||||
|
||||
@@ -339,7 +342,7 @@ class ScriptInterface:
|
||||
try:
|
||||
handler = ScriptHelpXMLContentHandler.parse_nmap_script_help(
|
||||
process.stdout_file)
|
||||
except (ValueError, xml.sax.SAXParseException), e:
|
||||
except (ValueError, xml.sax.SAXParseException) as e:
|
||||
log.debug("--script-help parse exception: %s" % str(e))
|
||||
return False
|
||||
|
||||
@@ -375,8 +378,8 @@ class ScriptInterface:
|
||||
involving the creation of a subprocess, we don't do it for every typed
|
||||
character."""
|
||||
if self.script_list_timeout_id:
|
||||
gobject.source_remove(self.script_list_timeout_id)
|
||||
self.script_list_timeout_id = gobject.timeout_add(
|
||||
GLib.source_remove(self.script_list_timeout_id)
|
||||
self.script_list_timeout_id = GLib.timeout_add(
|
||||
self.SCRIPT_LIST_DELAY,
|
||||
self.update_script_list_from_spec, spec)
|
||||
|
||||
@@ -413,34 +416,34 @@ A list of arguments that affect the selected script. Enter a value by \
|
||||
clicking in the value field beside the argument name.""")
|
||||
|
||||
def make_please_wait_widget(self):
|
||||
vbox = gtk.VBox()
|
||||
label = gtk.Label(_("Please wait."))
|
||||
vbox = Gtk.Box.new(Gtk.Orientation.VERTICAL, 0)
|
||||
label = Gtk.Label.new(_("Please wait."))
|
||||
label.set_line_wrap(True)
|
||||
vbox.pack_start(label)
|
||||
vbox.pack_start(label, True, True, 0)
|
||||
return vbox
|
||||
|
||||
def make_script_list_widget(self):
|
||||
"""Creates and packs widgets associated with left hand side of
|
||||
Interface."""
|
||||
vbox = gtk.VBox()
|
||||
vbox = Gtk.Box.new(Gtk.Orientation.VERTICAL, 0)
|
||||
|
||||
scrolled_window = HIGScrolledWindow()
|
||||
scrolled_window.set_policy(gtk.POLICY_ALWAYS, gtk.POLICY_ALWAYS)
|
||||
scrolled_window.set_policy(Gtk.PolicyType.ALWAYS, Gtk.PolicyType.ALWAYS)
|
||||
# Expand only vertically.
|
||||
scrolled_window.set_size_request(175, -1)
|
||||
listview = gtk.TreeView(self.liststore)
|
||||
listview = Gtk.TreeView.new_with_model(self.liststore)
|
||||
listview.set_headers_visible(False)
|
||||
listview.connect("enter-notify-event", self.update_help_ls_cb)
|
||||
selection = listview.get_selection()
|
||||
selection.connect("changed", self.selection_changed_cb)
|
||||
cell = gtk.CellRendererText()
|
||||
togglecell = gtk.CellRendererToggle()
|
||||
cell = Gtk.CellRendererText()
|
||||
togglecell = Gtk.CellRendererToggle()
|
||||
togglecell.set_property("activatable", True)
|
||||
togglecell.connect("toggled", self.toggled_cb, self.liststore)
|
||||
col = gtk.TreeViewColumn(_('Names'))
|
||||
col.set_sizing(gtk.TREE_VIEW_COLUMN_GROW_ONLY)
|
||||
col = Gtk.TreeViewColumn(title=_('Names'))
|
||||
col.set_sizing(Gtk.TreeViewColumnSizing.GROW_ONLY)
|
||||
col.set_resizable(True)
|
||||
togglecol = gtk.TreeViewColumn(None, togglecell)
|
||||
togglecol = Gtk.TreeViewColumn(title=None, cell_renderer=togglecell)
|
||||
togglecol.add_attribute(togglecell, "active", 1)
|
||||
listview.append_column(togglecol)
|
||||
listview.append_column(col)
|
||||
@@ -452,40 +455,40 @@ clicking in the value field beside the argument name.""")
|
||||
|
||||
self.file_scrolled_window = HIGScrolledWindow()
|
||||
self.file_scrolled_window.set_policy(
|
||||
gtk.POLICY_ALWAYS, gtk.POLICY_ALWAYS)
|
||||
Gtk.PolicyType.ALWAYS, Gtk.PolicyType.ALWAYS)
|
||||
self.file_scrolled_window.set_size_request(175, -1)
|
||||
self.file_scrolled_window.hide()
|
||||
self.file_scrolled_window.set_no_show_all(True)
|
||||
|
||||
self.file_listview = gtk.TreeView(self.file_liststore)
|
||||
self.file_listview = Gtk.TreeView.new_with_model(self.file_liststore)
|
||||
self.file_listview.set_headers_visible(False)
|
||||
col = gtk.TreeViewColumn(None)
|
||||
col = Gtk.TreeViewColumn(title=None)
|
||||
self.file_listview.append_column(col)
|
||||
cell = gtk.CellRendererToggle()
|
||||
cell = Gtk.CellRendererToggle()
|
||||
col.pack_start(cell, True)
|
||||
cell.set_property("activatable", True)
|
||||
col.add_attribute(cell, "active", 1)
|
||||
cell.connect("toggled", self.toggled_cb, self.file_liststore)
|
||||
|
||||
col = gtk.TreeViewColumn(None)
|
||||
col = Gtk.TreeViewColumn(title=None)
|
||||
self.file_listview.append_column(col)
|
||||
cell = gtk.CellRendererText()
|
||||
col.pack_start(cell)
|
||||
cell = Gtk.CellRendererText()
|
||||
col.pack_start(cell, True)
|
||||
col.add_attribute(cell, "text", 0)
|
||||
|
||||
self.file_listview.show_all()
|
||||
self.file_scrolled_window.add(self.file_listview)
|
||||
vbox.pack_start(self.file_scrolled_window, False)
|
||||
vbox.pack_start(self.file_scrolled_window, False, True, 0)
|
||||
|
||||
hbox = HIGHBox(False, 2)
|
||||
self.remove_file_button = HIGButton(stock=gtk.STOCK_REMOVE)
|
||||
self.remove_file_button = HIGButton(stock=Gtk.STOCK_REMOVE)
|
||||
self.remove_file_button.connect(
|
||||
"clicked", self.remove_file_button_clicked_cb)
|
||||
self.remove_file_button.set_sensitive(False)
|
||||
hbox.pack_end(self.remove_file_button)
|
||||
add_file_button = HIGButton(stock=gtk.STOCK_ADD)
|
||||
hbox.pack_end(self.remove_file_button, True, True, 0)
|
||||
add_file_button = HIGButton(stock=Gtk.STOCK_ADD)
|
||||
add_file_button.connect("clicked", self.add_file_button_clicked_cb)
|
||||
hbox.pack_end(add_file_button)
|
||||
hbox.pack_end(add_file_button, True, True, 0)
|
||||
|
||||
vbox.pack_start(hbox, False, False, 0)
|
||||
|
||||
@@ -541,35 +544,35 @@ clicking in the value field beside the argument name.""")
|
||||
"""Creates and packs widgets related to displaying the description
|
||||
box."""
|
||||
sw = HIGScrolledWindow()
|
||||
sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_ALWAYS)
|
||||
sw.set_shadow_type(gtk.SHADOW_OUT)
|
||||
sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.ALWAYS)
|
||||
sw.set_shadow_type(Gtk.ShadowType.OUT)
|
||||
sw.set_border_width(5)
|
||||
text_view = gtk.TextView()
|
||||
text_view = Gtk.TextView()
|
||||
text_view.connect("enter-notify-event", self.update_help_desc_cb)
|
||||
self.text_buffer = text_view.get_buffer()
|
||||
self.text_buffer.create_tag("Usage", font="Monospace")
|
||||
self.text_buffer.create_tag("Output", font="Monospace")
|
||||
text_view.set_wrap_mode(gtk.WRAP_WORD)
|
||||
text_view.set_wrap_mode(Gtk.WrapMode.WORD)
|
||||
text_view.set_editable(False)
|
||||
text_view.set_justification(gtk.JUSTIFY_LEFT)
|
||||
text_view.set_justification(Gtk.Justification.LEFT)
|
||||
sw.add(text_view)
|
||||
return sw
|
||||
|
||||
def make_arguments_widget(self):
|
||||
"""Creates and packs widgets related to arguments box."""
|
||||
vbox = gtk.VBox()
|
||||
vbox.pack_start(gtk.Label(_("Arguments")), False, False, 0)
|
||||
vbox = Gtk.Box.new(Gtk.Orientation.VERTICAL, 0)
|
||||
vbox.pack_start(Gtk.Label.new(_("Arguments")), False, False, 0)
|
||||
arg_window = HIGScrolledWindow()
|
||||
arg_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_ALWAYS)
|
||||
arg_window.set_shadow_type(gtk.SHADOW_OUT)
|
||||
arg_window.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.ALWAYS)
|
||||
arg_window.set_shadow_type(Gtk.ShadowType.OUT)
|
||||
|
||||
arg_listview = gtk.TreeView(self.arg_liststore)
|
||||
arg_listview = Gtk.TreeView.new_with_model(self.arg_liststore)
|
||||
arg_listview.connect("motion-notify-event", self.update_help_arg_cb)
|
||||
argument = gtk.CellRendererText()
|
||||
self.value = gtk.CellRendererText()
|
||||
argument = Gtk.CellRendererText()
|
||||
self.value = Gtk.CellRendererText()
|
||||
self.value.connect("edited", self.value_edited_cb, self.arg_liststore)
|
||||
arg_col = gtk.TreeViewColumn("Arguments\t")
|
||||
val_col = gtk.TreeViewColumn("values")
|
||||
arg_col = Gtk.TreeViewColumn(title="Arguments\t")
|
||||
val_col = Gtk.TreeViewColumn(title="values")
|
||||
arg_listview.append_column(arg_col)
|
||||
arg_listview.append_column(val_col)
|
||||
arg_col.pack_start(argument, True)
|
||||
@@ -626,11 +629,7 @@ clicking in the value field beside the argument name.""")
|
||||
def update_help_arg_cb(self, treeview, event):
|
||||
"""Callback method for displaying argument help."""
|
||||
wx, wy = treeview.get_pointer()
|
||||
try:
|
||||
x, y = treeview.convert_widget_to_bin_window_coords(wx, wy)
|
||||
except AttributeError:
|
||||
# convert_widget_to_bin_window_coords was introduced in PyGTK 2.12.
|
||||
return
|
||||
x, y = treeview.convert_widget_to_bin_window_coords(wx, wy)
|
||||
path = treeview.get_path_at_pos(x, y)
|
||||
if not path or not self.focusedentry:
|
||||
self.help_buf.set_text("")
|
||||
@@ -654,7 +653,7 @@ clicking in the value field beside the argument name.""")
|
||||
response = self.script_file_chooser.run()
|
||||
filenames = self.script_file_chooser.get_filenames()
|
||||
self.script_file_chooser.hide()
|
||||
if response != gtk.RESPONSE_OK:
|
||||
if response != Gtk.ResponseType.OK:
|
||||
return
|
||||
for filename in filenames:
|
||||
self.file_liststore.append([filename, True])
|
||||
@@ -675,7 +674,7 @@ clicking in the value field beside the argument name.""")
|
||||
|
||||
def set_description(self, entry):
|
||||
"""Sets the content that is to be displayed in the description box."""
|
||||
self.text_buffer.set_text(u"")
|
||||
self.text_buffer.set_text("")
|
||||
|
||||
self.text_buffer.insert(self.text_buffer.get_end_iter(), """\
|
||||
Categories: %(cats)s
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -58,7 +57,11 @@
|
||||
# * *
|
||||
# ***************************************************************************/
|
||||
|
||||
import gtk
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk
|
||||
|
||||
import re
|
||||
import copy
|
||||
|
||||
@@ -140,12 +143,12 @@ class SearchParser(object):
|
||||
self.search_gui.init_search_dirs(self.search_dict.pop("dir", []))
|
||||
|
||||
|
||||
class SearchGUI(gtk.VBox, object):
|
||||
class SearchGUI(Gtk.Box, object):
|
||||
"""This class is a VBox that holds the search entry field and buttons on
|
||||
top, and the results list on the bottom. The "Cancel" and "Open" buttons
|
||||
are a part of the SearchWindow class, not SearchGUI."""
|
||||
def __init__(self, search_window):
|
||||
gtk.VBox.__init__(self)
|
||||
Gtk.Box.__init__(self, orientation=Gtk.Orientation.VERTICAL)
|
||||
|
||||
self._create_widgets()
|
||||
self._pack_widgets()
|
||||
@@ -168,7 +171,7 @@ class SearchGUI(gtk.VBox, object):
|
||||
if self.options["search_db"]:
|
||||
try:
|
||||
self.search_db = SearchDB()
|
||||
except ImportError, e:
|
||||
except ImportError as e:
|
||||
self.search_db = SearchDummy()
|
||||
self.no_db_warning.show()
|
||||
self.no_db_warning.set_text(
|
||||
@@ -250,25 +253,26 @@ class SearchGUI(gtk.VBox, object):
|
||||
# Search box and buttons
|
||||
self.search_top_hbox = HIGHBox()
|
||||
self.search_label = HIGSectionLabel(_("Search:"))
|
||||
self.search_entry = gtk.Entry()
|
||||
self.search_entry = Gtk.Entry()
|
||||
self.expressions_btn = HIGToggleButton(
|
||||
_("Expressions "), gtk.STOCK_EDIT)
|
||||
_("Expressions "), Gtk.STOCK_EDIT)
|
||||
|
||||
# The quick reference tooltip button
|
||||
self.search_tooltip_btn = HIGButton(" ", gtk.STOCK_INFO)
|
||||
self.search_tooltip_btn = HIGButton(" ", Gtk.STOCK_INFO)
|
||||
|
||||
# The expression VBox. This is only visible once the user clicks on
|
||||
# "Expressions"
|
||||
self.expr_vbox = gtk.VBox()
|
||||
# "Expressions". The expressions (if any) should be tightly packed so
|
||||
# that they don't take too much screen real-estate
|
||||
self.expr_vbox = Gtk.Box.new(Gtk.Orientation.VERTICAL, 0)
|
||||
|
||||
# Results section
|
||||
self.result_list = gtk.ListStore(str, str, int) # title, date, id
|
||||
self.result_view = gtk.TreeView(self.result_list)
|
||||
self.result_scrolled = gtk.ScrolledWindow()
|
||||
self.result_title_column = gtk.TreeViewColumn(_("Scan"))
|
||||
self.result_date_column = gtk.TreeViewColumn(_("Date"))
|
||||
self.result_list = Gtk.ListStore.new([str, str, int]) # title, date, id
|
||||
self.result_view = Gtk.TreeView.new_with_model(self.result_list)
|
||||
self.result_scrolled = Gtk.ScrolledWindow()
|
||||
self.result_title_column = Gtk.TreeViewColumn(title=_("Scan"))
|
||||
self.result_date_column = Gtk.TreeViewColumn(title=_("Date"))
|
||||
|
||||
self.no_db_warning = gtk.Label()
|
||||
self.no_db_warning = Gtk.Label()
|
||||
self.no_db_warning.set_line_wrap(True)
|
||||
self.no_db_warning.set_no_show_all(True)
|
||||
|
||||
@@ -277,26 +281,22 @@ class SearchGUI(gtk.VBox, object):
|
||||
def _pack_widgets(self):
|
||||
# Packing label, search box and buttons
|
||||
self.search_top_hbox.set_spacing(4)
|
||||
self.search_top_hbox.pack_start(self.search_label, False)
|
||||
self.search_top_hbox.pack_start(self.search_entry, True)
|
||||
self.search_top_hbox.pack_start(self.expressions_btn, False)
|
||||
self.search_top_hbox.pack_start(self.search_tooltip_btn, False)
|
||||
|
||||
# The expressions (if any) should be tightly packed so that they don't
|
||||
# take too much screen real-estate
|
||||
self.expr_vbox.set_spacing(0)
|
||||
self.search_top_hbox.pack_start(self.search_label, False, True, 0)
|
||||
self.search_top_hbox.pack_start(self.search_entry, True, True, 0)
|
||||
self.search_top_hbox.pack_start(self.expressions_btn, False, True, 0)
|
||||
self.search_top_hbox.pack_start(self.search_tooltip_btn, False, True, 0)
|
||||
|
||||
# Packing the result section
|
||||
self.result_scrolled.add(self.result_view)
|
||||
self.result_scrolled.set_policy(
|
||||
gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
|
||||
Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
|
||||
|
||||
# Packing it all together
|
||||
self.set_spacing(4)
|
||||
self.pack_start(self.search_top_hbox, False)
|
||||
self.pack_start(self.expr_vbox, False)
|
||||
self.pack_start(self.result_scrolled, True)
|
||||
self.pack_start(self.no_db_warning, False)
|
||||
self.pack_start(self.search_top_hbox, False, True, 0)
|
||||
self.pack_start(self.expr_vbox, False, True, 0)
|
||||
self.pack_start(self.result_scrolled, True, True, 0)
|
||||
self.pack_start(self.no_db_warning, False, True, 0)
|
||||
|
||||
def _connect_events(self):
|
||||
self.search_entry.connect("changed", self.update_search_entry)
|
||||
@@ -313,7 +313,7 @@ class SearchGUI(gtk.VBox, object):
|
||||
# This is the first time the user has clicked on "Show Expressions"
|
||||
# and the search entry box is empty, so we add a single Criterion
|
||||
# row
|
||||
self.expr_vbox.pack_start(Criterion(self))
|
||||
self.expr_vbox.pack_start(Criterion(self), True, True, 0)
|
||||
|
||||
if self.expressions_btn.get_active():
|
||||
# The Expressions GUI is about to be displayed. It needs to reflect
|
||||
@@ -336,12 +336,12 @@ class SearchGUI(gtk.VBox, object):
|
||||
# We compare the search entry field to the Expressions GUI. Every
|
||||
# (operator, value) pair must be present in the GUI after this loop
|
||||
# is done.
|
||||
for op, args in self.search_dict.iteritems():
|
||||
for op, args in self.search_dict.items():
|
||||
for arg in args:
|
||||
if (op not in gui_ops) or (arg not in gui_ops[op]):
|
||||
# We need to add this pair to the GUI
|
||||
self.expr_vbox.pack_start(
|
||||
Criterion(self, op, arg), False)
|
||||
Criterion(self, op, arg), False, True, 0)
|
||||
|
||||
# Now we check if there are any leftover criterion rows that aren't
|
||||
# present in the search_dict (for example, if a user has deleted
|
||||
@@ -353,7 +353,7 @@ class SearchGUI(gtk.VBox, object):
|
||||
criterion.destroy()
|
||||
# If we have deleted all rows, add an empty one
|
||||
if len(self.expr_vbox.get_children()) == 0:
|
||||
self.expr_vbox.pack_start(Criterion(self))
|
||||
self.expr_vbox.pack_start(Criterion(self), True, True, 0)
|
||||
|
||||
# Display all elements
|
||||
self.expr_vbox.show_all()
|
||||
@@ -361,7 +361,7 @@ class SearchGUI(gtk.VBox, object):
|
||||
# The Expressions GUI is about to be hidden. No updates to the
|
||||
# search entry field are necessary, since it gets updated on every
|
||||
# change in one of the criterion rows.
|
||||
self.expr_vbox.hide_all()
|
||||
self.expr_vbox.hide()
|
||||
self.search_entry.set_sensitive(True)
|
||||
|
||||
def close(self):
|
||||
@@ -375,7 +375,7 @@ class SearchGUI(gtk.VBox, object):
|
||||
|
||||
# Make a new Criteria row and insert it after the calling row
|
||||
criteria = Criterion(self, "keyword")
|
||||
self.expr_vbox.pack_start(criteria, False)
|
||||
self.expr_vbox.pack_start(criteria, False, True, 0)
|
||||
self.expr_vbox.reorder_child(criteria, caller_index + 1)
|
||||
criteria.show_all()
|
||||
|
||||
@@ -431,7 +431,7 @@ class SearchGUI(gtk.VBox, object):
|
||||
self.append_result(result)
|
||||
matched += 1
|
||||
|
||||
for search_dir in self.search_dirs.itervalues():
|
||||
for search_dir in self.search_dirs.values():
|
||||
total += len(search_dir.get_scan_results())
|
||||
for result in search_dir.search(**self.search_dict):
|
||||
self.append_result(result)
|
||||
@@ -448,7 +448,7 @@ class SearchGUI(gtk.VBox, object):
|
||||
|
||||
def clear_result_list(self):
|
||||
for i in range(len(self.result_list)):
|
||||
iter = self.result_list.get_iter_root()
|
||||
iter = self.result_list.get_iter_first()
|
||||
del(self.result_list[iter])
|
||||
|
||||
def append_result(self, parsed_result):
|
||||
@@ -481,7 +481,7 @@ class SearchGUI(gtk.VBox, object):
|
||||
self.result_view.set_search_column(0)
|
||||
|
||||
selection = self.result_view.get_selection()
|
||||
selection.set_mode(gtk.SELECTION_MULTIPLE)
|
||||
selection.set_mode(Gtk.SelectionMode.MULTIPLE)
|
||||
|
||||
self.result_view.append_column(self.result_title_column)
|
||||
self.result_view.append_column(self.result_date_column)
|
||||
@@ -496,7 +496,7 @@ class SearchGUI(gtk.VBox, object):
|
||||
self.result_title_column.set_reorderable(True)
|
||||
self.result_date_column.set_reorderable(True)
|
||||
|
||||
cell = gtk.CellRendererText()
|
||||
cell = Gtk.CellRendererText()
|
||||
|
||||
self.result_title_column.pack_start(cell, True)
|
||||
self.result_date_column.pack_start(cell, True)
|
||||
@@ -507,7 +507,7 @@ class SearchGUI(gtk.VBox, object):
|
||||
selected_results = property(get_selected_results)
|
||||
|
||||
|
||||
class Criterion(gtk.HBox):
|
||||
class Criterion(Gtk.Box):
|
||||
"""This class holds one criterion row, represented as an HBox. It holds a
|
||||
ComboBox and a Subcriterion's subclass instance, depending on the selected
|
||||
entry in the ComboBox. For example, when the 'Target' option is selected, a
|
||||
@@ -517,7 +517,7 @@ class Criterion(gtk.HBox):
|
||||
def __init__(self, search_window, operator="keyword", argument=""):
|
||||
"""A reference to the search window is passed so that we can call
|
||||
add_criterion and remove_criterion."""
|
||||
gtk.HBox.__init__(self)
|
||||
Gtk.Box.__init__(self, orientation=Gtk.Orientation.HORIZONTAL)
|
||||
|
||||
self.search_window = search_window
|
||||
self.default_operator = operator
|
||||
@@ -544,17 +544,17 @@ class Criterion(gtk.HBox):
|
||||
|
||||
def _create_widgets(self):
|
||||
# A ComboBox containing the list of operators
|
||||
self.operator_combo = gtk.combo_box_new_text()
|
||||
self.operator_combo = Gtk.ComboBoxText()
|
||||
|
||||
# Sort all the keys from combo_entries and make an entry for each of
|
||||
# them
|
||||
sorted_entries = self.combo_entries.keys()
|
||||
sorted_entries = list(self.combo_entries.keys())
|
||||
sorted_entries.sort()
|
||||
for name in sorted_entries:
|
||||
self.operator_combo.append_text(name)
|
||||
|
||||
# Select the default operator
|
||||
for entry, operators in self.combo_entries.iteritems():
|
||||
for entry, operators in self.combo_entries.items():
|
||||
for operator in operators:
|
||||
if operator == self.default_operator:
|
||||
self.operator_combo.set_active(sorted_entries.index(entry))
|
||||
@@ -565,14 +565,14 @@ class Criterion(gtk.HBox):
|
||||
self.default_operator, self.default_argument)
|
||||
|
||||
# The "add" and "remove" buttons
|
||||
self.add_btn = HIGButton(" ", gtk.STOCK_ADD)
|
||||
self.remove_btn = HIGButton(" ", gtk.STOCK_REMOVE)
|
||||
self.add_btn = HIGButton(" ", Gtk.STOCK_ADD)
|
||||
self.remove_btn = HIGButton(" ", Gtk.STOCK_REMOVE)
|
||||
|
||||
def _pack_widgets(self):
|
||||
self.pack_start(self.operator_combo, False)
|
||||
self.pack_start(self.subcriterion, True, True)
|
||||
self.pack_start(self.add_btn, False)
|
||||
self.pack_start(self.remove_btn, False)
|
||||
self.pack_start(self.operator_combo, False, True, 0)
|
||||
self.pack_start(self.subcriterion, True, True, 0)
|
||||
self.pack_start(self.add_btn, False, True, 0)
|
||||
self.pack_start(self.remove_btn, False, True, 0)
|
||||
|
||||
def _connect_events(self):
|
||||
self.operator_combo.connect("changed", self.operator_changed)
|
||||
@@ -619,7 +619,7 @@ class Criterion(gtk.HBox):
|
||||
self.subcriterion = self.new_subcriterion(operator)
|
||||
|
||||
# Pack it, and place it on the right side of the ComboBox
|
||||
self.pack_start(self.subcriterion, True, True)
|
||||
self.pack_start(self.subcriterion, True, True, 0)
|
||||
self.reorder_child(self.subcriterion, 1)
|
||||
|
||||
# Notify the search window about the change
|
||||
@@ -632,12 +632,12 @@ class Criterion(gtk.HBox):
|
||||
argument = property(get_argument)
|
||||
|
||||
|
||||
class Subcriterion(gtk.HBox):
|
||||
class Subcriterion(Gtk.Box):
|
||||
"""This class is a base class for all subcriterion types. Depending on the
|
||||
criterion selected in the Criterion's ComboBox, a subclass of Subcriterion
|
||||
is created to display the appropriate GUI."""
|
||||
def __init__(self):
|
||||
gtk.HBox.__init__(self)
|
||||
Gtk.Box.__init__(self, orientation=Gtk.Orientation.HORIZONTAL)
|
||||
|
||||
self.operator = ""
|
||||
self.argument = ""
|
||||
@@ -662,12 +662,12 @@ class SimpleSubcriterion(Subcriterion):
|
||||
self._connect_widgets()
|
||||
|
||||
def _create_widgets(self):
|
||||
self.entry = gtk.Entry()
|
||||
self.entry = Gtk.Entry()
|
||||
if self.argument:
|
||||
self.entry.set_text(self.argument)
|
||||
|
||||
def _pack_widgets(self):
|
||||
self.pack_start(self.entry, True)
|
||||
self.pack_start(self.entry, True, True, 0)
|
||||
|
||||
def _connect_widgets(self):
|
||||
self.entry.connect("changed", self.entry_changed)
|
||||
@@ -690,13 +690,13 @@ class PortSubcriterion(Subcriterion):
|
||||
self._connect_widgets()
|
||||
|
||||
def _create_widgets(self):
|
||||
self.entry = gtk.Entry()
|
||||
self.entry = Gtk.Entry()
|
||||
if self.argument:
|
||||
self.entry.set_text(self.argument)
|
||||
|
||||
self.label = gtk.Label(" is ")
|
||||
self.label = Gtk.Label.new(" is ")
|
||||
|
||||
self.port_state_combo = gtk.combo_box_new_text()
|
||||
self.port_state_combo = Gtk.ComboBoxText()
|
||||
states = ["open", "scanned", "closed", "filtered", "unfiltered",
|
||||
"open|filtered", "closed|filtered"]
|
||||
for state in states:
|
||||
@@ -705,9 +705,9 @@ class PortSubcriterion(Subcriterion):
|
||||
states.index(self.operator.replace("_", "|")))
|
||||
|
||||
def _pack_widgets(self):
|
||||
self.pack_start(self.entry, True)
|
||||
self.pack_start(self.label, False)
|
||||
self.pack_start(self.port_state_combo, False)
|
||||
self.pack_start(self.entry, True, True, 0)
|
||||
self.pack_start(self.label, False, True, 0)
|
||||
self.pack_start(self.port_state_combo, False, True, 0)
|
||||
|
||||
def _connect_widgets(self):
|
||||
self.entry.connect("changed", self.entry_changed)
|
||||
@@ -734,14 +734,14 @@ class DirSubcriterion(Subcriterion):
|
||||
self._connect_widgets()
|
||||
|
||||
def _create_widgets(self):
|
||||
self.dir_entry = gtk.Entry()
|
||||
self.dir_entry = Gtk.Entry()
|
||||
if self.argument:
|
||||
self.dir_entry.set_text(self.argument)
|
||||
self.chooser_btn = HIGButton("Choose...", gtk.STOCK_OPEN)
|
||||
self.chooser_btn = HIGButton("Choose...", Gtk.STOCK_OPEN)
|
||||
|
||||
def _pack_widgets(self):
|
||||
self.pack_start(self.dir_entry, True)
|
||||
self.pack_start(self.chooser_btn, False)
|
||||
self.pack_start(self.dir_entry, True, True, 0)
|
||||
self.pack_start(self.chooser_btn, False, True, 0)
|
||||
|
||||
def _connect_widgets(self):
|
||||
self.chooser_btn.connect("clicked", self.choose_clicked)
|
||||
@@ -751,7 +751,7 @@ class DirSubcriterion(Subcriterion):
|
||||
# Display a directory chooser dialog
|
||||
chooser_dlg = DirectoryChooserDialog("Include folder in search")
|
||||
|
||||
if chooser_dlg.run() == gtk.RESPONSE_OK:
|
||||
if chooser_dlg.run() == Gtk.ResponseType.OK:
|
||||
self.dir_entry.set_text(chooser_dlg.get_filename())
|
||||
|
||||
chooser_dlg.destroy()
|
||||
@@ -801,7 +801,7 @@ class DateSubcriterion(Subcriterion):
|
||||
self.argument += "~" * self.fuzzies
|
||||
|
||||
def _create_widgets(self):
|
||||
self.date_criterion_combo = gtk.combo_box_new_text()
|
||||
self.date_criterion_combo = Gtk.ComboBoxText()
|
||||
self.date_criterion_combo.append_text("is")
|
||||
self.date_criterion_combo.append_text("after")
|
||||
self.date_criterion_combo.append_text("before")
|
||||
@@ -814,8 +814,8 @@ class DateSubcriterion(Subcriterion):
|
||||
self.date_button = HIGButton()
|
||||
|
||||
def _pack_widgets(self):
|
||||
self.pack_start(self.date_criterion_combo, False)
|
||||
self.pack_start(self.date_button, True)
|
||||
self.pack_start(self.date_criterion_combo, False, True, 0)
|
||||
self.pack_start(self.date_button, True, True, 0)
|
||||
|
||||
def _connect_widgets(self):
|
||||
self.date_criterion_combo.connect(
|
||||
@@ -835,7 +835,7 @@ class DateSubcriterion(Subcriterion):
|
||||
|
||||
def update_button(self, widget):
|
||||
cal_date = widget.get_date()
|
||||
# Add 1 to month because gtk.Calendar date is zero-based.
|
||||
# Add 1 to month because Gtk.Calendar date is zero-based.
|
||||
self.date = datetime.date(cal_date[0], cal_date[1] + 1, cal_date[2])
|
||||
|
||||
# Set the argument, using the search format
|
||||
@@ -866,12 +866,12 @@ class DateSubcriterion(Subcriterion):
|
||||
_date = datetime.date.today()
|
||||
|
||||
|
||||
class DateCalendar(gtk.Window, object):
|
||||
class DateCalendar(Gtk.Window, object):
|
||||
def __init__(self):
|
||||
gtk.Window.__init__(self, gtk.WINDOW_POPUP)
|
||||
self.set_position(gtk.WIN_POS_MOUSE)
|
||||
Gtk.Window.__init__(self, type=Gtk.WindowType.POPUP)
|
||||
self.set_position(Gtk.WindowPosition.MOUSE)
|
||||
|
||||
self.calendar = gtk.Calendar()
|
||||
self.calendar = Gtk.Calendar()
|
||||
self.add(self.calendar)
|
||||
|
||||
def connect_calendar(self, update_button_cb):
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -58,7 +57,10 @@
|
||||
# * *
|
||||
# ***************************************************************************/
|
||||
|
||||
import gtk
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk
|
||||
|
||||
from zenmapGUI.SearchGUI import SearchGUI
|
||||
|
||||
@@ -81,17 +83,17 @@ if is_maemo():
|
||||
def _pack_widgets(self):
|
||||
pass
|
||||
else:
|
||||
class BaseSearchWindow(gtk.Window):
|
||||
class BaseSearchWindow(Gtk.Window):
|
||||
def __init__(self):
|
||||
gtk.Window.__init__(self)
|
||||
Gtk.Window.__init__(self)
|
||||
self.set_title(_("Search Scans"))
|
||||
self.set_position(gtk.WIN_POS_CENTER)
|
||||
self.set_position(Gtk.WindowPosition.CENTER)
|
||||
|
||||
def _pack_widgets(self):
|
||||
self.vbox.set_border_width(4)
|
||||
|
||||
|
||||
class SearchWindow(BaseSearchWindow, object):
|
||||
class SearchWindow(BaseSearchWindow):
|
||||
def __init__(self, load_method, append_method):
|
||||
BaseSearchWindow.__init__(self)
|
||||
|
||||
@@ -107,34 +109,33 @@ class SearchWindow(BaseSearchWindow, object):
|
||||
def _create_widgets(self):
|
||||
self.vbox = HIGVBox()
|
||||
|
||||
self.bottom_hbox = gtk.HBox()
|
||||
self.bottom_label = gtk.Label()
|
||||
self.btn_box = gtk.HButtonBox()
|
||||
self.btn_open = HIGButton(stock=gtk.STOCK_OPEN)
|
||||
self.btn_append = HIGButton(_("Append"), gtk.STOCK_ADD)
|
||||
self.btn_close = HIGButton(stock=gtk.STOCK_CLOSE)
|
||||
self.bottom_hbox = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, 4)
|
||||
self.bottom_label = Gtk.Label()
|
||||
self.btn_box = Gtk.ButtonBox.new(Gtk.Orientation.HORIZONTAL)
|
||||
self.btn_open = HIGButton(stock=Gtk.STOCK_OPEN)
|
||||
self.btn_append = HIGButton(_("Append"), Gtk.STOCK_ADD)
|
||||
self.btn_close = HIGButton(stock=Gtk.STOCK_CLOSE)
|
||||
|
||||
self.search_gui = SearchGUI(self)
|
||||
|
||||
def _pack_widgets(self):
|
||||
BaseSearchWindow._pack_widgets(self)
|
||||
|
||||
self.btn_box.set_layout(gtk.BUTTONBOX_END)
|
||||
self.btn_box.set_layout(Gtk.ButtonBoxStyle.END)
|
||||
self.btn_box.set_spacing(4)
|
||||
self.btn_box.pack_start(self.btn_close)
|
||||
self.btn_box.pack_start(self.btn_append)
|
||||
self.btn_box.pack_start(self.btn_open)
|
||||
self.btn_box.pack_start(self.btn_close, True, True, 0)
|
||||
self.btn_box.pack_start(self.btn_append, True, True, 0)
|
||||
self.btn_box.pack_start(self.btn_open, True, True, 0)
|
||||
|
||||
self.bottom_label.set_alignment(0.0, 0.5)
|
||||
self.bottom_label.set_use_markup(True)
|
||||
|
||||
self.bottom_hbox.set_spacing(4)
|
||||
self.bottom_hbox.pack_start(self.bottom_label, True)
|
||||
self.bottom_hbox.pack_start(self.btn_box, False)
|
||||
self.bottom_hbox.pack_start(self.bottom_label, True, True, 0)
|
||||
self.bottom_hbox.pack_start(self.btn_box, False, True, 0)
|
||||
|
||||
self.vbox.set_spacing(4)
|
||||
self.vbox.pack_start(self.search_gui, True, True)
|
||||
self.vbox.pack_start(self.bottom_hbox, False)
|
||||
self.vbox.pack_start(self.search_gui, True, True, 0)
|
||||
self.vbox.pack_start(self.bottom_hbox, False, True, 0)
|
||||
|
||||
self.add(self.vbox)
|
||||
|
||||
@@ -179,6 +180,6 @@ class SearchWindow(BaseSearchWindow, object):
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
search = SearchWindow(lambda x: gtk.main_quit(), lambda x: gtk.main_quit())
|
||||
search = SearchWindow(lambda x: Gtk.main_quit(), lambda x: Gtk.main_quit())
|
||||
search.show_all()
|
||||
gtk.main()
|
||||
Gtk.main()
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -58,48 +57,49 @@
|
||||
# * *
|
||||
# ***************************************************************************/
|
||||
|
||||
import gtk
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk
|
||||
|
||||
from zenmapCore.TargetList import target_list
|
||||
|
||||
|
||||
class TargetCombo(gtk.ComboBoxEntry):
|
||||
class TargetCombo(Gtk.ComboBoxText):
|
||||
def __init__(self):
|
||||
gtk.ComboBoxEntry.__init__(self, gtk.ListStore(str), 0)
|
||||
Gtk.ComboBoxText.__init__(self, has_entry=True)
|
||||
|
||||
self.completion = gtk.EntryCompletion()
|
||||
self.child.set_completion(self.completion)
|
||||
self.completion = Gtk.EntryCompletion()
|
||||
self.get_child().set_completion(self.completion)
|
||||
self.completion.set_model(self.get_model())
|
||||
self.completion.set_text_column(0)
|
||||
|
||||
self.update()
|
||||
|
||||
def update(self):
|
||||
t_model = self.get_model()
|
||||
for i in range(len(t_model)):
|
||||
iter = t_model.get_iter_root()
|
||||
del(t_model[iter])
|
||||
self.remove_all()
|
||||
|
||||
t_list = target_list.get_target_list()
|
||||
for target in t_list[:15]:
|
||||
t_model.append([target.replace('\n', '')])
|
||||
self.append_text(target.replace('\n', ''))
|
||||
|
||||
def add_new_target(self, target):
|
||||
target_list.add_target(target)
|
||||
self.update()
|
||||
|
||||
def get_selected_target(self):
|
||||
return self.child.get_text()
|
||||
return self.get_child().get_text()
|
||||
|
||||
def set_selected_target(self, target):
|
||||
self.child.set_text(target)
|
||||
self.get_child().set_text(target)
|
||||
|
||||
selected_target = property(get_selected_target, set_selected_target)
|
||||
|
||||
if __name__ == "__main__":
|
||||
w = gtk.Window()
|
||||
w = Gtk.Window()
|
||||
t = TargetCombo()
|
||||
w.add(t)
|
||||
w.show_all()
|
||||
|
||||
gtk.main()
|
||||
w.connect("delete-event", lambda x, y: Gtk.main_quit())
|
||||
w.show_all()
|
||||
Gtk.main()
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -58,7 +57,10 @@
|
||||
# * *
|
||||
# ***************************************************************************/
|
||||
|
||||
import gtk
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk
|
||||
|
||||
from zenmapGUI.higwidgets.higboxes import HIGVBox
|
||||
|
||||
@@ -84,9 +86,8 @@ class TopologyPage(HIGVBox):
|
||||
self._pack_widgets()
|
||||
|
||||
def _create_widgets(self):
|
||||
self.rn_hbox = gtk.HBox()
|
||||
self.rn_hbox.set_spacing(4)
|
||||
self.rn_vbox = gtk.VBox()
|
||||
self.rn_hbox = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, 4)
|
||||
self.rn_vbox = Gtk.Box.new(Gtk.Orientation.VERTICAL, 0)
|
||||
|
||||
# RadialNet's widgets
|
||||
self.radialnet = RadialNet.RadialNet(RadialNet.LAYOUT_WEIGHTED)
|
||||
@@ -102,11 +103,11 @@ class TopologyPage(HIGVBox):
|
||||
self.radialnet.set_no_show_all(True)
|
||||
|
||||
self.slow_vbox = HIGVBox()
|
||||
self.slow_label = gtk.Label()
|
||||
self.slow_vbox.pack_start(self.slow_label, False, False)
|
||||
show_button = gtk.Button(_("Show the topology anyway"))
|
||||
self.slow_label = Gtk.Label()
|
||||
self.slow_vbox.pack_start(self.slow_label, False, False, 0)
|
||||
show_button = Gtk.Button.new_with_label(_("Show the topology anyway"))
|
||||
show_button.connect("clicked", self.show_anyway)
|
||||
self.slow_vbox.pack_start(show_button, False, False)
|
||||
self.slow_vbox.pack_start(show_button, False, False, 0)
|
||||
self.slow_vbox.show_all()
|
||||
self.slow_vbox.set_no_show_all(True)
|
||||
self.slow_vbox.hide()
|
||||
@@ -114,17 +115,17 @@ class TopologyPage(HIGVBox):
|
||||
self.radialnet.show()
|
||||
|
||||
def _pack_widgets(self):
|
||||
self.rn_hbox.pack_start(self.display_panel, True, True)
|
||||
self.rn_hbox.pack_start(self.control, False)
|
||||
self.rn_hbox.pack_start(self.display_panel, True, True, 0)
|
||||
self.rn_hbox.pack_start(self.control, False, True, 0)
|
||||
|
||||
self.rn_vbox.pack_start(self.rn_hbox, True, True)
|
||||
self.rn_vbox.pack_start(self.fisheye, False)
|
||||
self.rn_vbox.pack_start(self.rn_hbox, True, True, 0)
|
||||
self.rn_vbox.pack_start(self.fisheye, False, True, 0)
|
||||
|
||||
self.pack_start(self.rn_toolbar, False, False)
|
||||
self.pack_start(self.rn_vbox, True, True)
|
||||
self.pack_start(self.rn_toolbar, False, False, 0)
|
||||
self.pack_start(self.rn_vbox, True, True, 0)
|
||||
|
||||
self.display_panel.pack_start(self.slow_vbox, True, False)
|
||||
self.display_panel.pack_start(self.radialnet, True, True)
|
||||
self.display_panel.pack_start(self.slow_vbox, True, False, 0)
|
||||
self.display_panel.pack_start(self.radialnet, True, True, 0)
|
||||
|
||||
def add_scan(self, scan):
|
||||
"""Parses a given XML file and adds the parsed result to the network
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -68,17 +67,17 @@ This is mostly implemented by subclassing from the GTK classes, and
|
||||
providing defaults that better match the HIG specifications/recommendations.
|
||||
"""
|
||||
|
||||
from gtkutils import *
|
||||
from higboxes import *
|
||||
from higbuttons import *
|
||||
from higdialogs import *
|
||||
from higentries import *
|
||||
from higexpanders import *
|
||||
from higlabels import *
|
||||
from higlogindialogs import *
|
||||
from higprogressbars import *
|
||||
from higscrollers import *
|
||||
from higspinner import *
|
||||
from higtables import *
|
||||
from higtextviewers import *
|
||||
from higwindows import *
|
||||
from .gtkutils import *
|
||||
from .higboxes import *
|
||||
from .higbuttons import *
|
||||
from .higdialogs import *
|
||||
from .higentries import *
|
||||
from .higexpanders import *
|
||||
from .higlabels import *
|
||||
from .higlogindialogs import *
|
||||
from .higprogressbars import *
|
||||
from .higscrollers import *
|
||||
from .higspinner import *
|
||||
from .higtables import *
|
||||
from .higtextviewers import *
|
||||
from .higwindows import *
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -65,43 +64,34 @@ higwidgets/gtkutils.py
|
||||
"""
|
||||
|
||||
__all__ = ['gtk_version_major', 'gtk_version_minor', 'gtk_version_release',
|
||||
'gtk_constant_name', 'gobject_register']
|
||||
'gtk_constant_name']
|
||||
|
||||
import gtk
|
||||
import gobject
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk
|
||||
|
||||
# version information
|
||||
gtk_version_major, gtk_version_minor, gtk_version_release = gtk.gtk_version
|
||||
assert gtk_version_major == 2
|
||||
gtk_version_major, gtk_version_minor, gtk_version_release = gi.version_info
|
||||
assert gtk_version_major == 3
|
||||
|
||||
|
||||
def gtk_constant_name(group, value):
|
||||
"""
|
||||
Returns the (py)GTK+ name of a constant, given its group name
|
||||
"""
|
||||
group_response = {-1: 'gtk.RESPONSE_NONE',
|
||||
-2: 'gtk.RESPONSE_REJECT',
|
||||
-3: 'gtk.RESPONSE_ACCEPT',
|
||||
-4: 'gtk.RESPONSE_DELETE_EVENT',
|
||||
-5: 'gtk.RESPONSE_OK',
|
||||
-6: 'gtk.RESPONSE_CANCEL',
|
||||
-7: 'gtk.RESPONSE_CLOSE',
|
||||
-8: 'gtk.RESPONSE_YES',
|
||||
-9: 'gtk.RESPONSE_NO',
|
||||
-10: 'gtk.RESPONSE_APPLY',
|
||||
-11: 'gtk.RESPONSE_HELP'}
|
||||
group_response = {-1: 'Gtk.ResponseType.NONE',
|
||||
-2: 'Gtk.ResponseType.REJECT',
|
||||
-3: 'Gtk.ResponseType.ACCEPT',
|
||||
-4: 'Gtk.ResponseType.DELETE_EVENT',
|
||||
-5: 'Gtk.ResponseType.OK',
|
||||
-6: 'Gtk.ResponseType.CANCEL',
|
||||
-7: 'Gtk.ResponseType.CLOSE',
|
||||
-8: 'Gtk.ResponseType.YES',
|
||||
-9: 'Gtk.ResponseType.NO',
|
||||
-10: 'Gtk.ResponseType.APPLY',
|
||||
-11: 'Gtk.ResponseType.HELP'}
|
||||
|
||||
groups = {'response': group_response}
|
||||
|
||||
return groups.get(group, {}).get(value, 'Error: constant value not found')
|
||||
|
||||
|
||||
def gobject_register(klass):
|
||||
"""
|
||||
Register a given object by calling gobject.type_register.
|
||||
|
||||
Actually gobject.type_register is only called if the pygtk version in use
|
||||
is not 2.8 at least.
|
||||
"""
|
||||
if gtk_version_minor < 8:
|
||||
gobject.type_register(klass)
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -66,29 +65,39 @@ higwidgets/higboxes.py
|
||||
|
||||
__all__ = ['HIGHBox', 'HIGVBox']
|
||||
|
||||
import gtk
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk
|
||||
|
||||
|
||||
class HIGBox(gtk.Box):
|
||||
class HIGBox(Gtk.Box):
|
||||
def _pack_noexpand_nofill(self, widget):
|
||||
self.pack_start(widget, expand=False, fill=False)
|
||||
self.pack_start(widget, False, False, 0)
|
||||
|
||||
def _pack_expand_fill(self, widget):
|
||||
self.pack_start(widget, expand=True, fill=True)
|
||||
self.pack_start(widget, True, True, 0)
|
||||
|
||||
def add(self, widget):
|
||||
# Make default packing arguments same as before (Gtk.Box has expand
|
||||
# set to False by default).
|
||||
self.pack_start(widget, True, True, 0)
|
||||
|
||||
|
||||
class HIGHBox(gtk.HBox, HIGBox):
|
||||
class HIGHBox(HIGBox):
|
||||
def __init__(self, homogeneous=False, spacing=12):
|
||||
gtk.HBox.__init__(self, homogeneous, spacing)
|
||||
Gtk.Box.__init__(self, orientation=Gtk.Orientation.HORIZONTAL,
|
||||
homogeneous=homogeneous, spacing=spacing)
|
||||
|
||||
pack_section_label = HIGBox._pack_noexpand_nofill
|
||||
pack_label = HIGBox._pack_noexpand_nofill
|
||||
pack_entry = HIGBox._pack_expand_fill
|
||||
|
||||
|
||||
class HIGVBox(gtk.VBox, HIGBox):
|
||||
class HIGVBox(HIGBox):
|
||||
def __init__(self, homogeneous=False, spacing=12):
|
||||
gtk.VBox.__init__(self, homogeneous, spacing)
|
||||
Gtk.Box.__init__(self, orientation=Gtk.Orientation.VERTICAL,
|
||||
homogeneous=homogeneous, spacing=spacing)
|
||||
|
||||
# Packs a widget as a line, so it doesn't expand vertically
|
||||
pack_line = HIGBox._pack_noexpand_nofill
|
||||
@@ -110,4 +119,4 @@ class HIGSpacer(HIGHBox):
|
||||
|
||||
|
||||
def hig_box_space_holder():
|
||||
return gtk.Label(" ")
|
||||
return Gtk.Label.new(" ")
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -64,52 +63,57 @@ higwidgets/higbuttons.py
|
||||
button related classes
|
||||
"""
|
||||
|
||||
__all__ = ['HIGMixButton', 'HIGButton']
|
||||
__all__ = ['HIGButton', 'HIGToggleButton']
|
||||
|
||||
import gtk
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk
|
||||
|
||||
|
||||
class HIGMixButton (gtk.HBox):
|
||||
class HIGMixButton(Gtk.Box):
|
||||
def __init__(self, title, stock):
|
||||
gtk.HBox.__init__(self, False, 4)
|
||||
self.img = gtk.Image()
|
||||
self.img.set_from_stock(stock, gtk.ICON_SIZE_BUTTON)
|
||||
Gtk.Box.__init__(self, orientation=Gtk.Orientation.HORIZONTAL,
|
||||
homogeneous=False, spacing=4)
|
||||
self.img = Gtk.Image()
|
||||
self.img.set_from_stock(stock, Gtk.IconSize.BUTTON)
|
||||
|
||||
self.lbl = gtk.Label(title)
|
||||
self.lbl = Gtk.Label.new(title)
|
||||
|
||||
self.hbox1 = gtk.HBox(False, 2)
|
||||
self.hbox1 = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, 2)
|
||||
self.hbox1.set_homogeneous(False)
|
||||
self.hbox1.pack_start(self.img, False, False, 0)
|
||||
self.hbox1.pack_start(self.lbl, False, False, 0)
|
||||
|
||||
self.align = gtk.Alignment(0.5, 0.5, 0, 0)
|
||||
self.pack_start(self.align)
|
||||
self.pack_start(self.hbox1)
|
||||
self.align = Gtk.Alignment.new(0.5, 0.5, 0, 0)
|
||||
self.pack_start(self.align, True, True, 0)
|
||||
self.pack_start(self.hbox1, True, True, 0)
|
||||
|
||||
|
||||
class HIGButton (gtk.Button):
|
||||
class HIGButton(Gtk.Button):
|
||||
def __init__(self, title="", stock=None):
|
||||
if title and stock:
|
||||
gtk.Button.__init__(self)
|
||||
Gtk.Button.__init__(self)
|
||||
content = HIGMixButton(title, stock)
|
||||
self.add(content)
|
||||
elif title and not stock:
|
||||
gtk.Button.__init__(self, title)
|
||||
Gtk.Button.__init__(self, label=title)
|
||||
elif stock:
|
||||
gtk.Button.__init__(self, stock=stock)
|
||||
Gtk.Button.__init__(self, stock=stock)
|
||||
else:
|
||||
gtk.Button.__init__(self)
|
||||
Gtk.Button.__init__(self)
|
||||
|
||||
|
||||
class HIGToggleButton(gtk.ToggleButton):
|
||||
class HIGToggleButton(Gtk.ToggleButton):
|
||||
def __init__(self, title="", stock=None):
|
||||
if title and stock:
|
||||
gtk.ToggleButton.__init__(self)
|
||||
Gtk.ToggleButton.__init__(self)
|
||||
content = HIGMixButton(title, stock)
|
||||
self.add(content)
|
||||
elif title and not stock:
|
||||
gtk.ToggleButton.__init__(self, title)
|
||||
Gtk.ToggleButton.__init__(self, label=title)
|
||||
elif stock:
|
||||
gtk.ToggleButton.__init__(self, stock)
|
||||
Gtk.ToggleButton.__init__(self, stock=stock)
|
||||
self.set_use_stock(True)
|
||||
else:
|
||||
gtk.ToggleButton.__init__(self)
|
||||
Gtk.ToggleButton.__init__(self)
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -66,23 +65,27 @@ higwidgets/higdialogs.py
|
||||
|
||||
__all__ = ['HIGDialog', 'HIGAlertDialog']
|
||||
|
||||
import gtk
|
||||
import gi
|
||||
|
||||
from gtkutils import gtk_version_minor
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk
|
||||
|
||||
|
||||
class HIGDialog(gtk.Dialog):
|
||||
class HIGDialog(Gtk.Dialog):
|
||||
"""
|
||||
HIGFied Dialog
|
||||
"""
|
||||
def __init__(self, title='', parent=None, flags=0, buttons=()):
|
||||
gtk.Dialog.__init__(self, title, parent, flags, buttons)
|
||||
Gtk.Dialog.__init__(self, title=title, parent=parent, flags=flags)
|
||||
self.set_border_width(5)
|
||||
self.vbox.set_border_width(2)
|
||||
self.vbox.set_spacing(6)
|
||||
|
||||
if buttons:
|
||||
self.add_buttons(*buttons)
|
||||
|
||||
class HIGAlertDialog(gtk.MessageDialog):
|
||||
|
||||
class HIGAlertDialog(Gtk.MessageDialog):
|
||||
"""
|
||||
HIGfied Alert Dialog.
|
||||
|
||||
@@ -90,15 +93,16 @@ class HIGAlertDialog(gtk.MessageDialog):
|
||||
http://developer.gnome.org/projects/gup/hig/2.0/windows-alert.html
|
||||
"""
|
||||
|
||||
def __init__(self, parent=None, flags=0, type=gtk.MESSAGE_INFO,
|
||||
def __init__(self, parent=None, flags=0, type=Gtk.MessageType.INFO,
|
||||
# HIG mandates that every Alert should have an "affirmative
|
||||
# button that dismisses the alert and performs the action
|
||||
# suggested"
|
||||
buttons=gtk.BUTTONS_OK,
|
||||
buttons=Gtk.ButtonsType.OK,
|
||||
message_format=None,
|
||||
secondary_text=None):
|
||||
|
||||
gtk.MessageDialog.__init__(self, parent, flags, type, buttons)
|
||||
Gtk.MessageDialog.__init__(self, parent=parent, flags=flags,
|
||||
message_type=type, buttons=buttons)
|
||||
|
||||
self.set_resizable(False)
|
||||
|
||||
@@ -109,11 +113,7 @@ class HIGAlertDialog(gtk.MessageDialog):
|
||||
self.set_markup(
|
||||
"<span weight='bold'size='larger'>%s</span>" % message_format)
|
||||
if secondary_text:
|
||||
# GTK up to version 2.4 does not have secondary_text
|
||||
try:
|
||||
self.format_secondary_text(secondary_text)
|
||||
except Exception:
|
||||
pass
|
||||
self.format_secondary_text(secondary_text)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
@@ -122,14 +122,14 @@ if __name__ == '__main__':
|
||||
|
||||
# HIGDialog
|
||||
d = HIGDialog(title='HIGDialog',
|
||||
buttons=(gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))
|
||||
buttons=(Gtk.STOCK_OK, Gtk.ResponseType.ACCEPT))
|
||||
dialog_label = HIGDialogLabel('A HIGDialogLabel on a HIGDialog')
|
||||
dialog_label.show()
|
||||
d.vbox.pack_start(dialog_label)
|
||||
d.vbox.pack_start(dialog_label, True, True, 0)
|
||||
|
||||
entry_label = HIGEntryLabel('A HIGEntryLabel on a HIGDialog')
|
||||
entry_label.show()
|
||||
d.vbox.pack_start(entry_label)
|
||||
d.vbox.pack_start(entry_label, True, True, 0)
|
||||
|
||||
d.run()
|
||||
d.destroy()
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -64,11 +63,14 @@ higwidgets/higentries.py
|
||||
entries related classes
|
||||
"""
|
||||
|
||||
import gtk
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk
|
||||
|
||||
__all__ = ('HIGTextEntry', 'HIGPasswordEntry')
|
||||
|
||||
HIGTextEntry = gtk.Entry
|
||||
HIGTextEntry = Gtk.Entry
|
||||
|
||||
|
||||
class HIGPasswordEntry(HIGTextEntry):
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -66,14 +65,17 @@ higwidgets/higexpanders.py
|
||||
|
||||
__all__ = ['HIGExpander']
|
||||
|
||||
import gtk
|
||||
import gi
|
||||
|
||||
from higboxes import HIGHBox, hig_box_space_holder
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk
|
||||
|
||||
from .higboxes import HIGHBox, hig_box_space_holder
|
||||
|
||||
|
||||
class HIGExpander(gtk.Expander):
|
||||
class HIGExpander(Gtk.Expander):
|
||||
def __init__(self, label):
|
||||
gtk.Expander.__init__(self)
|
||||
Gtk.Expander.__init__(self)
|
||||
|
||||
self.set_use_markup(True)
|
||||
self.set_label(label)
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -66,18 +65,21 @@ higwidgets/higframe.py
|
||||
|
||||
__all__ = ['HIGFrame']
|
||||
|
||||
import gtk
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk
|
||||
|
||||
|
||||
class HIGFrame(gtk.Frame):
|
||||
class HIGFrame(Gtk.Frame):
|
||||
"""
|
||||
Frame without border with bold label.
|
||||
"""
|
||||
def __init__(self, label=None):
|
||||
gtk.Frame.__init__(self)
|
||||
Gtk.Frame.__init__(self)
|
||||
|
||||
self.set_shadow_type(gtk.SHADOW_NONE)
|
||||
self._flabel = gtk.Label()
|
||||
self.set_shadow_type(Gtk.ShadowType.NONE)
|
||||
self._flabel = Gtk.Label()
|
||||
self._set_label(label)
|
||||
self.set_label_widget(self._flabel)
|
||||
|
||||
@@ -86,20 +88,20 @@ class HIGFrame(gtk.Frame):
|
||||
|
||||
# Demo
|
||||
if __name__ == "__main__":
|
||||
w = gtk.Window()
|
||||
w = Gtk.Window()
|
||||
|
||||
hframe = HIGFrame("Sample HIGFrame")
|
||||
aalign = gtk.Alignment(0, 0, 0, 0)
|
||||
aalign = Gtk.Alignment.new(0, 0, 0, 0)
|
||||
aalign.set_padding(12, 0, 24, 0)
|
||||
abox = gtk.VBox()
|
||||
abox = Gtk.Box.new(Gtk.Orientation.VERTICAL, 0)
|
||||
aalign.add(abox)
|
||||
hframe.add(aalign)
|
||||
w.add(hframe)
|
||||
|
||||
for i in xrange(5):
|
||||
abox.pack_start(gtk.Label("Sample %d" % i), False, False, 3)
|
||||
for i in range(5):
|
||||
abox.pack_start(Gtk.Label.new("Sample %d" % i), False, False, 3)
|
||||
|
||||
w.connect('destroy', lambda d: gtk.main_quit())
|
||||
w.connect('destroy', lambda d: Gtk.main_quit())
|
||||
w.show_all()
|
||||
|
||||
gtk.main()
|
||||
Gtk.main()
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -68,45 +67,49 @@ __all__ = [
|
||||
'HIGSectionLabel', 'HIGHintSectionLabel', 'HIGEntryLabel', 'HIGDialogLabel'
|
||||
]
|
||||
|
||||
import gtk
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, Gdk
|
||||
|
||||
|
||||
class HIGSectionLabel(gtk.Label):
|
||||
class HIGSectionLabel(Gtk.Label):
|
||||
"""
|
||||
Bold label, used to define sections
|
||||
"""
|
||||
def __init__(self, text=None):
|
||||
gtk.Label.__init__(self)
|
||||
Gtk.Label.__init__(self)
|
||||
if text:
|
||||
self.set_markup("<b>%s</b>" % (text))
|
||||
self.set_justify(gtk.JUSTIFY_LEFT)
|
||||
self.set_alignment(0, 0.50)
|
||||
self.set_justify(Gtk.Justification.LEFT)
|
||||
self.props.xalign = 0
|
||||
self.props.yalign = 0.5
|
||||
self.set_line_wrap(True)
|
||||
|
||||
|
||||
class HIGHintSectionLabel(gtk.HBox, object):
|
||||
class HIGHintSectionLabel(Gtk.Box, object):
|
||||
"""
|
||||
Bold label used to define sections, with a little icon that shows up a hint
|
||||
when mouse is over it.
|
||||
"""
|
||||
def __init__(self, text=None, hint=None):
|
||||
gtk.HBox.__init__(self)
|
||||
Gtk.Box.__init__(self, orientation=Gtk.Orientation.HORIZONTAL)
|
||||
|
||||
self.label = HIGSectionLabel(text)
|
||||
self.hint = Hint(hint)
|
||||
|
||||
self.pack_start(self.label, False, False)
|
||||
self.pack_start(self.label, False, False, 0)
|
||||
self.pack_start(self.hint, False, False, 5)
|
||||
|
||||
|
||||
class Hint(gtk.EventBox, object):
|
||||
class Hint(Gtk.EventBox, object):
|
||||
def __init__(self, hint):
|
||||
gtk.EventBox.__init__(self)
|
||||
Gtk.EventBox.__init__(self)
|
||||
self.hint = hint
|
||||
|
||||
self.hint_image = gtk.Image()
|
||||
self.hint_image.set_from_stock(
|
||||
gtk.STOCK_DIALOG_INFO, gtk.ICON_SIZE_SMALL_TOOLBAR)
|
||||
self.hint_image = Gtk.Image()
|
||||
self.hint_image.set_from_icon_name(
|
||||
"dialog-information", Gtk.IconSize.SMALL_TOOLBAR)
|
||||
|
||||
self.add(self.hint_image)
|
||||
|
||||
@@ -117,23 +120,27 @@ class Hint(gtk.EventBox, object):
|
||||
hint_window.show_all()
|
||||
|
||||
|
||||
class HintWindow(gtk.Window):
|
||||
class HintWindow(Gtk.Window):
|
||||
def __init__(self, hint):
|
||||
gtk.Window.__init__(self, gtk.WINDOW_POPUP)
|
||||
self.set_position(gtk.WIN_POS_MOUSE)
|
||||
bg_color = gtk.gdk.color_parse("#fbff99")
|
||||
Gtk.Window.__init__(self, type=Gtk.WindowType.POPUP)
|
||||
self.set_position(Gtk.WindowPosition.MOUSE)
|
||||
self.set_resizable(False)
|
||||
|
||||
self.modify_bg(gtk.STATE_NORMAL, bg_color)
|
||||
bg_color = Gdk.RGBA()
|
||||
bg_color.parse("#fbff99")
|
||||
self.override_background_color(Gtk.StateFlags.NORMAL, bg_color)
|
||||
|
||||
self.event = gtk.EventBox()
|
||||
self.event.modify_bg(gtk.STATE_NORMAL, bg_color)
|
||||
self.event = Gtk.EventBox()
|
||||
self.event.override_background_color(Gtk.StateFlags.NORMAL, bg_color)
|
||||
self.event.set_border_width(10)
|
||||
self.event.connect("button-press-event", self.close)
|
||||
|
||||
self.hint_label = gtk.Label(hint)
|
||||
self.hint_label = Gtk.Label.new(hint)
|
||||
self.hint_label.set_use_markup(True)
|
||||
self.hint_label.set_line_wrap(True)
|
||||
self.hint_label.set_alignment(0.0, 0.5)
|
||||
self.hint_label.set_max_width_chars(52)
|
||||
self.hint_label.props.xalign = 0
|
||||
self.hint_label.props.yalign = 0.5
|
||||
|
||||
self.event.add(self.hint_label)
|
||||
self.add(self.event)
|
||||
@@ -142,33 +149,34 @@ class HintWindow(gtk.Window):
|
||||
self.destroy()
|
||||
|
||||
|
||||
class HIGEntryLabel(gtk.Label):
|
||||
class HIGEntryLabel(Gtk.Label):
|
||||
"""
|
||||
Simple label, like the ones used to label entries
|
||||
"""
|
||||
def __init__(self, text=None):
|
||||
gtk.Label.__init__(self, text)
|
||||
self.set_justify(gtk.JUSTIFY_LEFT)
|
||||
self.set_alignment(0, 0.50)
|
||||
Gtk.Label.__init__(self, label=text)
|
||||
self.set_justify(Gtk.Justification.LEFT)
|
||||
self.props.xalign = 0
|
||||
self.props.yalign = 0.5
|
||||
self.set_use_markup(True)
|
||||
self.set_line_wrap(True)
|
||||
|
||||
|
||||
class HIGDialogLabel(gtk.Label):
|
||||
class HIGDialogLabel(Gtk.Label):
|
||||
"""
|
||||
Centered, line-wrappable label, usually used on dialogs.
|
||||
"""
|
||||
def __init__(self, text=None):
|
||||
gtk.Label.__init__(self, text)
|
||||
self.set_justify(gtk.JUSTIFY_CENTER)
|
||||
Gtk.Label.__init__(self, label=text)
|
||||
self.set_justify(Gtk.Justification.CENTER)
|
||||
self.set_use_markup(True)
|
||||
self.set_line_wrap(True)
|
||||
|
||||
if __name__ == "__main__":
|
||||
w = gtk.Window()
|
||||
w = Gtk.Window()
|
||||
h = HIGHintSectionLabel("Label", "Hint")
|
||||
w.add(h)
|
||||
w.connect("delete-event", lambda x, y: gtk.main_quit())
|
||||
w.connect("delete-event", lambda x, y: Gtk.main_quit())
|
||||
w.show_all()
|
||||
|
||||
gtk.main()
|
||||
Gtk.main()
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -66,12 +65,15 @@ higwidgets/higlogindialog.py
|
||||
|
||||
__all__ = ['HIGLoginDialog']
|
||||
|
||||
import gtk
|
||||
import gi
|
||||
|
||||
from higdialogs import HIGDialog
|
||||
from higlabels import HIGEntryLabel
|
||||
from higtables import HIGTable
|
||||
from higentries import HIGTextEntry, HIGPasswordEntry
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk
|
||||
|
||||
from .higdialogs import HIGDialog
|
||||
from .higlabels import HIGEntryLabel
|
||||
from .higtables import HIGTable
|
||||
from .higentries import HIGTextEntry, HIGPasswordEntry
|
||||
|
||||
|
||||
class HIGLoginDialog(HIGDialog):
|
||||
@@ -79,8 +81,8 @@ class HIGLoginDialog(HIGDialog):
|
||||
A dialog that asks for basic login information (username / password)
|
||||
"""
|
||||
def __init__(self, title='Login',
|
||||
buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
|
||||
gtk.STOCK_OK, gtk.RESPONSE_ACCEPT)):
|
||||
buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
|
||||
Gtk.STOCK_OK, Gtk.ResponseType.ACCEPT)):
|
||||
HIGDialog.__init__(self, title, buttons=buttons)
|
||||
|
||||
self.username_label = HIGEntryLabel("Username:")
|
||||
@@ -98,8 +100,8 @@ class HIGLoginDialog(HIGDialog):
|
||||
self.username_password_table.attach_entry(self.password_entry,
|
||||
1, 2, 1, 2)
|
||||
|
||||
self.vbox.pack_start(self.username_password_table, False, False)
|
||||
self.set_default_response(gtk.RESPONSE_ACCEPT)
|
||||
self.vbox.pack_start(self.username_password_table, False, False, 0)
|
||||
self.set_default_response(Gtk.ResponseType.ACCEPT)
|
||||
|
||||
def run(self):
|
||||
self.show_all()
|
||||
@@ -112,5 +114,5 @@ if __name__ == '__main__':
|
||||
# HIGLoginDialog
|
||||
d = HIGLoginDialog()
|
||||
response_value = d.run()
|
||||
print gtk_constant_name('response', response_value)
|
||||
print(gtk_constant_name('response', response_value))
|
||||
d.destroy()
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -58,26 +57,28 @@
|
||||
# * *
|
||||
# ***************************************************************************/
|
||||
|
||||
import gtk
|
||||
import gobject
|
||||
import gi
|
||||
|
||||
from higboxes import HIGHBox
|
||||
from higbuttons import HIGButton
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, GObject
|
||||
|
||||
from .higboxes import HIGHBox
|
||||
from .higbuttons import HIGButton
|
||||
|
||||
|
||||
class HIGNotebook(gtk.Notebook):
|
||||
class HIGNotebook(Gtk.Notebook):
|
||||
def __init__(self):
|
||||
gtk.Notebook.__init__(self)
|
||||
Gtk.Notebook.__init__(self)
|
||||
self.popup_enable()
|
||||
|
||||
|
||||
class HIGClosableTabLabel(HIGHBox):
|
||||
__gsignals__ = {
|
||||
'close-clicked': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ())
|
||||
'close-clicked': (GObject.SignalFlags.RUN_LAST, GObject.TYPE_NONE, ())
|
||||
}
|
||||
|
||||
def __init__(self, label_text=""):
|
||||
gobject.GObject.__init__(self)
|
||||
GObject.GObject.__init__(self)
|
||||
#HIGHBox.__init__(self, spacing=4)
|
||||
|
||||
self.label_text = label_text
|
||||
@@ -86,12 +87,12 @@ class HIGClosableTabLabel(HIGHBox):
|
||||
#self.property_map = {"label_text" : self.label.get_label}
|
||||
|
||||
def __create_widgets(self):
|
||||
self.label = gtk.Label(self.label_text)
|
||||
self.close_image = gtk.Image()
|
||||
self.close_image.set_from_stock(gtk.STOCK_CLOSE, gtk.ICON_SIZE_BUTTON)
|
||||
self.label = Gtk.Label.new(self.label_text)
|
||||
self.close_image = Gtk.Image()
|
||||
self.close_image.set_from_stock(Gtk.STOCK_CLOSE, Gtk.IconSize.BUTTON)
|
||||
self.close_button = HIGButton()
|
||||
self.close_button.set_size_request(20, 20)
|
||||
self.close_button.set_relief(gtk.RELIEF_NONE)
|
||||
self.close_button.set_relief(Gtk.ReliefStyle.NONE)
|
||||
self.close_button.set_focus_on_click(False)
|
||||
self.close_button.add(self.close_image)
|
||||
|
||||
@@ -124,6 +125,6 @@ class HIGClosableTabLabel(HIGHBox):
|
||||
def set_label(self, label):
|
||||
self.label.set_text(label)
|
||||
|
||||
gobject.type_register(HIGClosableTabLabel)
|
||||
GObject.type_register(HIGClosableTabLabel)
|
||||
|
||||
HIGAnimatedTabLabel = HIGClosableTabLabel
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -66,9 +65,12 @@ higwidgets/higprogressbars.py
|
||||
|
||||
__all__ = ['HIGLabeledProgressBar']
|
||||
|
||||
import gtk
|
||||
import gi
|
||||
|
||||
from higboxes import HIGHBox
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk
|
||||
|
||||
from .higboxes import HIGHBox
|
||||
|
||||
|
||||
class HIGLabeledProgressBar(HIGHBox):
|
||||
@@ -77,7 +79,7 @@ class HIGLabeledProgressBar(HIGHBox):
|
||||
if label:
|
||||
self.label = HIGEntryLabel(label)
|
||||
self.pack_label(self.label)
|
||||
self.progress_bar = gtk.ProgressBar()
|
||||
self.progress_bar = Gtk.ProgressBar()
|
||||
self.progress_bar.set_size_request(80, 16)
|
||||
self.pack_label(self.progress_bar)
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -66,11 +65,14 @@ higwidgets/higscrollers.py
|
||||
|
||||
__all__ = ['HIGScrolledWindow']
|
||||
|
||||
import gtk
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk
|
||||
|
||||
|
||||
class HIGScrolledWindow(gtk.ScrolledWindow):
|
||||
class HIGScrolledWindow(Gtk.ScrolledWindow):
|
||||
def __init__(self):
|
||||
gtk.ScrolledWindow.__init__(self)
|
||||
self.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
|
||||
Gtk.ScrolledWindow.__init__(self)
|
||||
self.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
|
||||
self.set_border_width(5)
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -66,10 +65,10 @@ higwidgets/higspinner.py
|
||||
|
||||
__all__ = ['HIGSpinner']
|
||||
|
||||
import gtk
|
||||
import gobject
|
||||
import gi
|
||||
|
||||
from gtkutils import gobject_register
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, GLib, Gdk, GdkPixbuf
|
||||
|
||||
|
||||
class HIGSpinnerImages:
|
||||
@@ -132,15 +131,15 @@ class HIGSpinnerImages:
|
||||
new_animated = []
|
||||
for p in self.animated_pixbufs:
|
||||
new_animated.append(p.scale_simple(width, height,
|
||||
gtk.gdk.INTERP_BILINEAR))
|
||||
GdkPixbuf.InterpType.BILINEAR))
|
||||
self.animated_pixbufs = new_animated
|
||||
|
||||
for k in self.static_pixbufs:
|
||||
self.static_pixbufs[k] = self.static_pixbufs[k].scale_simple(
|
||||
width, height, gtk.gdk.INTERP_BILINEAR)
|
||||
width, height, GdkPixbuf.InterpType.BILINEAR)
|
||||
|
||||
self.rest_pixbuf = self.rest_pixbuf.scale_simple(
|
||||
width, height, gtk.gdk.INTERP_BILINEAR)
|
||||
width, height, GdkPixbuf.InterpType.BILINEAR)
|
||||
|
||||
self.images_width = width
|
||||
self.images_height = height
|
||||
@@ -156,7 +155,7 @@ class HIGSpinnerCache:
|
||||
self.spinner_images = HIGSpinnerImages()
|
||||
|
||||
# These are on Private member in the C implementation
|
||||
self.icon_theme = gtk.IconTheme()
|
||||
self.icon_theme = Gtk.IconTheme()
|
||||
self.originals = None
|
||||
self.images = None
|
||||
|
||||
@@ -203,7 +202,7 @@ class HIGSpinnerCache:
|
||||
|
||||
def load_animated_from_filename(self, filename, size):
|
||||
# grid_pixbuf is a pixbuf that holds the entire
|
||||
grid_pixbuf = gtk.gdk.pixbuf_new_from_file(filename)
|
||||
grid_pixbuf = GdkPixbuf.Pixbuf.new_from_file(filename)
|
||||
grid_width = grid_pixbuf.get_width()
|
||||
grid_height = grid_pixbuf.get_height()
|
||||
|
||||
@@ -221,7 +220,7 @@ class HIGSpinnerCache:
|
||||
self.load_static_from_filename(filename)
|
||||
|
||||
def load_static_from_filename(self, filename, key_name=None):
|
||||
icon_pixbuf = gtk.gdk.pixbuf_new_from_file(filename)
|
||||
icon_pixbuf = GdkPixbuf.Pixbuf.new_from_file(filename)
|
||||
|
||||
if key_name is None:
|
||||
key_name = filename.split(".")[0]
|
||||
@@ -257,7 +256,7 @@ class HIGSpinnerCache:
|
||||
image_format)
|
||||
|
||||
|
||||
class HIGSpinner(gtk.EventBox):
|
||||
class HIGSpinner(Gtk.EventBox):
|
||||
"""Simple spinner, such as the one found in webbrowsers and file managers.
|
||||
|
||||
You can construct it with the optional parameters:
|
||||
@@ -266,11 +265,11 @@ class HIGSpinner(gtk.EventBox):
|
||||
* height, the height that will be set for the images
|
||||
"""
|
||||
|
||||
__gsignals__ = {'expose-event': 'override',
|
||||
'size-request': 'override'}
|
||||
#__gsignals__ = {'expose-event': 'override',
|
||||
# 'size-request': 'override'}
|
||||
|
||||
def __init__(self):
|
||||
gtk.EventBox.__init__(self)
|
||||
Gtk.EventBox.__init__(self)
|
||||
|
||||
#self.set_events(self.get_events())
|
||||
|
||||
@@ -325,13 +324,13 @@ class HIGSpinner(gtk.EventBox):
|
||||
def start(self):
|
||||
"""Starts the animation"""
|
||||
if self.timer_task == 0:
|
||||
self.timer_task = gobject.timeout_add(self.timeout,
|
||||
self.timer_task = GLib.timeout_add(self.timeout,
|
||||
self.__bump_frame)
|
||||
|
||||
def pause(self):
|
||||
"""Pauses the animation"""
|
||||
if self.timer_task != 0:
|
||||
gobject.source_remove(self.timer_task)
|
||||
GLib.source_remove(self.timer_task)
|
||||
|
||||
self.timer_task = 0
|
||||
self.queue_draw()
|
||||
@@ -359,26 +358,29 @@ class HIGSpinner(gtk.EventBox):
|
||||
|
||||
width = self.current_pixbuf.get_width()
|
||||
height = self.current_pixbuf.get_height()
|
||||
x_offset = (self.allocation.width - width) / 2
|
||||
y_offset = (self.allocation.height - height) / 2
|
||||
x_offset = (self.allocation.width - width) // 2
|
||||
y_offset = (self.allocation.height - height) // 2
|
||||
|
||||
pix_area = gtk.gdk.Rectangle(x_offset + self.allocation.x,
|
||||
y_offset + self.allocation.y,
|
||||
width, height)
|
||||
pix_area = Gdk.Rectangle(x_offset + self.allocation.x,
|
||||
y_offset + self.allocation.y,
|
||||
width, height)
|
||||
|
||||
dest = event.area.intersect(pix_area)
|
||||
|
||||
# If a graphic context doesn't not exist yet, create one
|
||||
if self.gc is None:
|
||||
self.gc = gtk.gdk.GC(self.window)
|
||||
#gc = self.gc
|
||||
|
||||
self.window.draw_pixbuf(self.gc,
|
||||
self.current_pixbuf,
|
||||
dest.x - x_offset - self.allocation.x,
|
||||
dest.y - y_offset - self.allocation.y,
|
||||
dest.x, dest.y,
|
||||
dest.width, dest.height)
|
||||
# # If a graphic context doesn't not exist yet, create one
|
||||
# if self.gc is None:
|
||||
# self.gc = gtk.gdk.GC(self.window)
|
||||
# #gc = self.gc
|
||||
#
|
||||
# cairo = self.window.cairo_create()
|
||||
#
|
||||
#
|
||||
# self.window.draw_pixbuf(self.gc,
|
||||
# self.current_pixbuf,
|
||||
# dest.x - x_offset - self.allocation.x,
|
||||
# dest.y - y_offset - self.allocation.y,
|
||||
# dest.x, dest.y,
|
||||
# dest.width, dest.height)
|
||||
|
||||
def do_size_request(self, requisition):
|
||||
# http://www.pygtk.org/pygtk2reference/class-gtkrequisition.html
|
||||
@@ -386,5 +388,3 @@ class HIGSpinner(gtk.EventBox):
|
||||
# FIXME, this should really come from the pixbuf size + margins
|
||||
requisition.width = self.cache.spinner_images.images_width
|
||||
requisition.height = self.cache.spinner_images.images_height
|
||||
|
||||
gobject_register(HIGSpinner)
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -66,13 +65,16 @@ higwidgets/higlogindialog.py
|
||||
|
||||
__all__ = ['HIGTable']
|
||||
|
||||
import gtk
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk
|
||||
|
||||
#from higlabels import *
|
||||
#from higentries import *
|
||||
|
||||
|
||||
class HIGTable(gtk.Table):
|
||||
class HIGTable(Gtk.Table):
|
||||
"""
|
||||
A HIGFied table
|
||||
"""
|
||||
@@ -82,7 +84,7 @@ class HIGTable(gtk.Table):
|
||||
# - Generic attach function that detects the widget type
|
||||
|
||||
def __init__(self, rows=1, columns=1, homogeneous=False):
|
||||
gtk.Table.__init__(self, rows, columns, homogeneous)
|
||||
Gtk.Table.__init__(self, n_rows=rows, n_columns=columns, homogeneous=homogeneous)
|
||||
self.set_row_spacings(6)
|
||||
self.set_col_spacings(12)
|
||||
|
||||
@@ -90,7 +92,7 @@ class HIGTable(gtk.Table):
|
||||
self.columns = columns
|
||||
|
||||
def attach_label(self, widget, x0, x, y0, y):
|
||||
self.attach(widget, x0, x, y0, y, xoptions=gtk.FILL)
|
||||
self.attach(widget, x0, x, y0, y, xoptions=Gtk.AttachOptions.FILL)
|
||||
|
||||
def attach_entry(self, widget, x0, x, y0, y):
|
||||
self.attach(widget, x0, x, y0, y, xoptions=gtk.FILL | gtk.EXPAND)
|
||||
self.attach(widget, x0, x, y0, y, xoptions=Gtk.AttachOptions.FILL | Gtk.AttachOptions.EXPAND)
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -66,11 +65,14 @@ higwidgets/higtextviewers.py
|
||||
|
||||
__all__ = ['HIGTextView']
|
||||
|
||||
import gtk
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk
|
||||
|
||||
|
||||
class HIGTextView(gtk.TextView):
|
||||
class HIGTextView(Gtk.TextView):
|
||||
def __init__(self, text=''):
|
||||
gtk.TextView.__init__(self)
|
||||
self.set_wrap_mode(gtk.WRAP_WORD)
|
||||
Gtk.TextView.__init__(self)
|
||||
self.set_wrap_mode(Gtk.WrapMode.WORD)
|
||||
self.get_buffer().set_text(text)
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -64,17 +63,20 @@ higwidgets/higwindows.py
|
||||
window related classes
|
||||
"""
|
||||
|
||||
import gtk
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk
|
||||
|
||||
__all__ = ('HIGWindow', 'HIGMainWindow')
|
||||
|
||||
|
||||
class HIGWindow(gtk.Window):
|
||||
class HIGWindow(Gtk.Window):
|
||||
"""HIGFied Window"""
|
||||
def __init__(self, type=gtk.WINDOW_TOPLEVEL):
|
||||
gtk.Window.__init__(self, type)
|
||||
def __init__(self, type=Gtk.WindowType.TOPLEVEL):
|
||||
Gtk.Window.__init__(self, type=type)
|
||||
self.set_border_width(5)
|
||||
|
||||
# The Application main window should have no borders...
|
||||
# so it should be really a gtk.Window
|
||||
HIGMainWindow = gtk.Window
|
||||
HIGMainWindow = Gtk.Window
|
||||
|
||||
Reference in New Issue
Block a user