mirror of
https://github.com/nmap/nmap.git
synced 2025-12-07 13:11:28 +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()
|
||||
|
||||
Reference in New Issue
Block a user