1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-24 16:39:03 +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:
dmiller
2022-12-07 20:34:03 +00:00
parent e2e55660c3
commit 24b26317c7
104 changed files with 5381 additions and 4383 deletions

View File

@@ -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 *

View File

@@ -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)

View File

@@ -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(" ")

View File

@@ -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)

View File

@@ -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()

View File

@@ -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):

View File

@@ -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)

View File

@@ -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()

View File

@@ -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()

View File

@@ -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()

View File

@@ -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

View File

@@ -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)

View File

@@ -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)

View File

@@ -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)

View File

@@ -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)

View File

@@ -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)

View File

@@ -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