mirror of
https://github.com/nmap/nmap.git
synced 2025-12-09 22:21: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************************
|
||||
# * *
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user