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