summaryrefslogtreecommitdiffstats
path: root/zenmap/zenmapGUI/higwidgets
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--zenmap/zenmapGUI/higwidgets/__init__.py81
-rw-r--r--zenmap/zenmapGUI/higwidgets/gtkutils.py95
-rw-r--r--zenmap/zenmapGUI/higwidgets/higboxes.py120
-rw-r--r--zenmap/zenmapGUI/higwidgets/higbuttons.py117
-rw-r--r--zenmap/zenmapGUI/higwidgets/higdialogs.py140
-rw-r--r--zenmap/zenmapGUI/higwidgets/higentries.py80
-rw-r--r--zenmap/zenmapGUI/higwidgets/higexpanders.py88
-rw-r--r--zenmap/zenmapGUI/higwidgets/higframe.py105
-rw-r--r--zenmap/zenmapGUI/higwidgets/higlabels.py180
-rw-r--r--zenmap/zenmapGUI/higwidgets/higlogindialogs.py116
-rw-r--r--zenmap/zenmapGUI/higwidgets/hignotebooks.py128
-rw-r--r--zenmap/zenmapGUI/higwidgets/higprogressbars.py85
-rw-r--r--zenmap/zenmapGUI/higwidgets/higscrollers.py76
-rw-r--r--zenmap/zenmapGUI/higwidgets/higspinner.py388
-rw-r--r--zenmap/zenmapGUI/higwidgets/higtables.py96
-rw-r--r--zenmap/zenmapGUI/higwidgets/higtextviewers.py76
-rw-r--r--zenmap/zenmapGUI/higwidgets/higwindows.py80
17 files changed, 2051 insertions, 0 deletions
diff --git a/zenmap/zenmapGUI/higwidgets/__init__.py b/zenmap/zenmapGUI/higwidgets/__init__.py
new file mode 100644
index 0000000..bfb7866
--- /dev/null
+++ b/zenmap/zenmapGUI/higwidgets/__init__.py
@@ -0,0 +1,81 @@
+#!/usr/bin/env python3
+
+# ***********************IMPORTANT NMAP LICENSE TERMS************************
+# *
+# * The Nmap Security Scanner is (C) 1996-2023 Nmap Software LLC ("The Nmap
+# * Project"). Nmap is also a registered trademark of the Nmap Project.
+# *
+# * This program is distributed under the terms of the Nmap Public Source
+# * License (NPSL). The exact license text applying to a particular Nmap
+# * release or source code control revision is contained in the LICENSE
+# * file distributed with that version of Nmap or source code control
+# * revision. More Nmap copyright/legal information is available from
+# * https://nmap.org/book/man-legal.html, and further information on the
+# * NPSL license itself can be found at https://nmap.org/npsl/ . This
+# * header summarizes some key points from the Nmap license, but is no
+# * substitute for the actual license text.
+# *
+# * Nmap is generally free for end users to download and use themselves,
+# * including commercial use. It is available from https://nmap.org.
+# *
+# * The Nmap license generally prohibits companies from using and
+# * redistributing Nmap in commercial products, but we sell a special Nmap
+# * OEM Edition with a more permissive license and special features for
+# * this purpose. See https://nmap.org/oem/
+# *
+# * If you have received a written Nmap license agreement or contract
+# * stating terms other than these (such as an Nmap OEM license), you may
+# * choose to use and redistribute Nmap under those terms instead.
+# *
+# * The official Nmap Windows builds include the Npcap software
+# * (https://npcap.com) for packet capture and transmission. It is under
+# * separate license terms which forbid redistribution without special
+# * permission. So the official Nmap Windows builds may not be redistributed
+# * without special permission (such as an Nmap OEM license).
+# *
+# * Source is provided to this software because we believe users have a
+# * right to know exactly what a program is going to do before they run it.
+# * This also allows you to audit the software for security holes.
+# *
+# * Source code also allows you to port Nmap to new platforms, fix bugs, and add
+# * new features. You are highly encouraged to submit your changes as a Github PR
+# * or by email to the dev@nmap.org mailing list for possible incorporation into
+# * the main distribution. Unless you specify otherwise, it is understood that
+# * you are offering us very broad rights to use your submissions as described in
+# * the Nmap Public Source License Contributor Agreement. This is important
+# * because we fund the project by selling licenses with various terms, and also
+# * because the inability to relicense code has caused devastating problems for
+# * other Free Software projects (such as KDE and NASM).
+# *
+# * The free version of Nmap is distributed in the hope that it will be
+# * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Warranties,
+# * indemnification and commercial support are all available through the
+# * Npcap OEM program--see https://nmap.org/oem/
+# *
+# ***************************************************************************/
+
+"""
+higwidgets/__init__.py
+
+This module implements GTK Widgets that try their best to adhere to the
+GNOME Human Interface Guidelines (aka HIG).
+
+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 *
diff --git a/zenmap/zenmapGUI/higwidgets/gtkutils.py b/zenmap/zenmapGUI/higwidgets/gtkutils.py
new file mode 100644
index 0000000..1a89acb
--- /dev/null
+++ b/zenmap/zenmapGUI/higwidgets/gtkutils.py
@@ -0,0 +1,95 @@
+#!/usr/bin/env python3
+
+# ***********************IMPORTANT NMAP LICENSE TERMS************************
+# *
+# * The Nmap Security Scanner is (C) 1996-2023 Nmap Software LLC ("The Nmap
+# * Project"). Nmap is also a registered trademark of the Nmap Project.
+# *
+# * This program is distributed under the terms of the Nmap Public Source
+# * License (NPSL). The exact license text applying to a particular Nmap
+# * release or source code control revision is contained in the LICENSE
+# * file distributed with that version of Nmap or source code control
+# * revision. More Nmap copyright/legal information is available from
+# * https://nmap.org/book/man-legal.html, and further information on the
+# * NPSL license itself can be found at https://nmap.org/npsl/ . This
+# * header summarizes some key points from the Nmap license, but is no
+# * substitute for the actual license text.
+# *
+# * Nmap is generally free for end users to download and use themselves,
+# * including commercial use. It is available from https://nmap.org.
+# *
+# * The Nmap license generally prohibits companies from using and
+# * redistributing Nmap in commercial products, but we sell a special Nmap
+# * OEM Edition with a more permissive license and special features for
+# * this purpose. See https://nmap.org/oem/
+# *
+# * If you have received a written Nmap license agreement or contract
+# * stating terms other than these (such as an Nmap OEM license), you may
+# * choose to use and redistribute Nmap under those terms instead.
+# *
+# * The official Nmap Windows builds include the Npcap software
+# * (https://npcap.com) for packet capture and transmission. It is under
+# * separate license terms which forbid redistribution without special
+# * permission. So the official Nmap Windows builds may not be redistributed
+# * without special permission (such as an Nmap OEM license).
+# *
+# * Source is provided to this software because we believe users have a
+# * right to know exactly what a program is going to do before they run it.
+# * This also allows you to audit the software for security holes.
+# *
+# * Source code also allows you to port Nmap to new platforms, fix bugs, and add
+# * new features. You are highly encouraged to submit your changes as a Github PR
+# * or by email to the dev@nmap.org mailing list for possible incorporation into
+# * the main distribution. Unless you specify otherwise, it is understood that
+# * you are offering us very broad rights to use your submissions as described in
+# * the Nmap Public Source License Contributor Agreement. This is important
+# * because we fund the project by selling licenses with various terms, and also
+# * because the inability to relicense code has caused devastating problems for
+# * other Free Software projects (such as KDE and NASM).
+# *
+# * The free version of Nmap is distributed in the hope that it will be
+# * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Warranties,
+# * indemnification and commercial support are all available through the
+# * Npcap OEM program--see https://nmap.org/oem/
+# *
+# ***************************************************************************/
+
+"""
+higwidgets/gtkutils.py
+
+ gtk related functions
+"""
+
+__all__ = ['gtk_version_major', 'gtk_version_minor', 'gtk_version_release',
+ 'gtk_constant_name']
+
+import gi
+
+gi.require_version("Gtk", "3.0")
+from gi.repository import Gtk
+
+# version information
+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.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')
diff --git a/zenmap/zenmapGUI/higwidgets/higboxes.py b/zenmap/zenmapGUI/higwidgets/higboxes.py
new file mode 100644
index 0000000..bb76472
--- /dev/null
+++ b/zenmap/zenmapGUI/higwidgets/higboxes.py
@@ -0,0 +1,120 @@
+#!/usr/bin/env python3
+
+# ***********************IMPORTANT NMAP LICENSE TERMS************************
+# *
+# * The Nmap Security Scanner is (C) 1996-2023 Nmap Software LLC ("The Nmap
+# * Project"). Nmap is also a registered trademark of the Nmap Project.
+# *
+# * This program is distributed under the terms of the Nmap Public Source
+# * License (NPSL). The exact license text applying to a particular Nmap
+# * release or source code control revision is contained in the LICENSE
+# * file distributed with that version of Nmap or source code control
+# * revision. More Nmap copyright/legal information is available from
+# * https://nmap.org/book/man-legal.html, and further information on the
+# * NPSL license itself can be found at https://nmap.org/npsl/ . This
+# * header summarizes some key points from the Nmap license, but is no
+# * substitute for the actual license text.
+# *
+# * Nmap is generally free for end users to download and use themselves,
+# * including commercial use. It is available from https://nmap.org.
+# *
+# * The Nmap license generally prohibits companies from using and
+# * redistributing Nmap in commercial products, but we sell a special Nmap
+# * OEM Edition with a more permissive license and special features for
+# * this purpose. See https://nmap.org/oem/
+# *
+# * If you have received a written Nmap license agreement or contract
+# * stating terms other than these (such as an Nmap OEM license), you may
+# * choose to use and redistribute Nmap under those terms instead.
+# *
+# * The official Nmap Windows builds include the Npcap software
+# * (https://npcap.com) for packet capture and transmission. It is under
+# * separate license terms which forbid redistribution without special
+# * permission. So the official Nmap Windows builds may not be redistributed
+# * without special permission (such as an Nmap OEM license).
+# *
+# * Source is provided to this software because we believe users have a
+# * right to know exactly what a program is going to do before they run it.
+# * This also allows you to audit the software for security holes.
+# *
+# * Source code also allows you to port Nmap to new platforms, fix bugs, and add
+# * new features. You are highly encouraged to submit your changes as a Github PR
+# * or by email to the dev@nmap.org mailing list for possible incorporation into
+# * the main distribution. Unless you specify otherwise, it is understood that
+# * you are offering us very broad rights to use your submissions as described in
+# * the Nmap Public Source License Contributor Agreement. This is important
+# * because we fund the project by selling licenses with various terms, and also
+# * because the inability to relicense code has caused devastating problems for
+# * other Free Software projects (such as KDE and NASM).
+# *
+# * The free version of Nmap is distributed in the hope that it will be
+# * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Warranties,
+# * indemnification and commercial support are all available through the
+# * Npcap OEM program--see https://nmap.org/oem/
+# *
+# ***************************************************************************/
+
+"""
+higwidgets/higboxes.py
+
+ box related classes
+"""
+
+__all__ = ['HIGHBox', 'HIGVBox']
+
+import gi
+
+gi.require_version("Gtk", "3.0")
+from gi.repository import Gtk
+
+
+class HIGBox(Gtk.Box):
+ def _pack_noexpand_nofill(self, widget):
+ self.pack_start(widget, False, False, 0)
+
+ def _pack_expand_fill(self, widget):
+ 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(HIGBox):
+ def __init__(self, homogeneous=False, spacing=12):
+ 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(HIGBox):
+ def __init__(self, homogeneous=False, spacing=12):
+ 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
+
+
+class HIGSpacer(HIGHBox):
+ def __init__(self, widget=None):
+ HIGHBox.__init__(self)
+ self.set_spacing(6)
+
+ self._pack_noexpand_nofill(hig_box_space_holder())
+
+ if widget:
+ self._pack_expand_fill(widget)
+ self.child = widget
+
+ def get_child(self):
+ return self.child
+
+
+def hig_box_space_holder():
+ return Gtk.Label.new(" ")
diff --git a/zenmap/zenmapGUI/higwidgets/higbuttons.py b/zenmap/zenmapGUI/higwidgets/higbuttons.py
new file mode 100644
index 0000000..1f47c6d
--- /dev/null
+++ b/zenmap/zenmapGUI/higwidgets/higbuttons.py
@@ -0,0 +1,117 @@
+#!/usr/bin/env python3
+
+# ***********************IMPORTANT NMAP LICENSE TERMS************************
+# *
+# * The Nmap Security Scanner is (C) 1996-2023 Nmap Software LLC ("The Nmap
+# * Project"). Nmap is also a registered trademark of the Nmap Project.
+# *
+# * This program is distributed under the terms of the Nmap Public Source
+# * License (NPSL). The exact license text applying to a particular Nmap
+# * release or source code control revision is contained in the LICENSE
+# * file distributed with that version of Nmap or source code control
+# * revision. More Nmap copyright/legal information is available from
+# * https://nmap.org/book/man-legal.html, and further information on the
+# * NPSL license itself can be found at https://nmap.org/npsl/ . This
+# * header summarizes some key points from the Nmap license, but is no
+# * substitute for the actual license text.
+# *
+# * Nmap is generally free for end users to download and use themselves,
+# * including commercial use. It is available from https://nmap.org.
+# *
+# * The Nmap license generally prohibits companies from using and
+# * redistributing Nmap in commercial products, but we sell a special Nmap
+# * OEM Edition with a more permissive license and special features for
+# * this purpose. See https://nmap.org/oem/
+# *
+# * If you have received a written Nmap license agreement or contract
+# * stating terms other than these (such as an Nmap OEM license), you may
+# * choose to use and redistribute Nmap under those terms instead.
+# *
+# * The official Nmap Windows builds include the Npcap software
+# * (https://npcap.com) for packet capture and transmission. It is under
+# * separate license terms which forbid redistribution without special
+# * permission. So the official Nmap Windows builds may not be redistributed
+# * without special permission (such as an Nmap OEM license).
+# *
+# * Source is provided to this software because we believe users have a
+# * right to know exactly what a program is going to do before they run it.
+# * This also allows you to audit the software for security holes.
+# *
+# * Source code also allows you to port Nmap to new platforms, fix bugs, and add
+# * new features. You are highly encouraged to submit your changes as a Github PR
+# * or by email to the dev@nmap.org mailing list for possible incorporation into
+# * the main distribution. Unless you specify otherwise, it is understood that
+# * you are offering us very broad rights to use your submissions as described in
+# * the Nmap Public Source License Contributor Agreement. This is important
+# * because we fund the project by selling licenses with various terms, and also
+# * because the inability to relicense code has caused devastating problems for
+# * other Free Software projects (such as KDE and NASM).
+# *
+# * The free version of Nmap is distributed in the hope that it will be
+# * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Warranties,
+# * indemnification and commercial support are all available through the
+# * Npcap OEM program--see https://nmap.org/oem/
+# *
+# ***************************************************************************/
+
+"""
+higwidgets/higbuttons.py
+
+ button related classes
+"""
+
+__all__ = ['HIGButton', 'HIGToggleButton']
+
+import gi
+
+gi.require_version("Gtk", "3.0")
+from gi.repository import Gtk
+
+
+class HIGMixButton(Gtk.Box):
+ def __init__(self, title, stock):
+ 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.new(title)
+
+ 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.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):
+ def __init__(self, title="", stock=None):
+ if title and stock:
+ Gtk.Button.__init__(self)
+ content = HIGMixButton(title, stock)
+ self.add(content)
+ elif title and not stock:
+ Gtk.Button.__init__(self, label=title)
+ elif stock:
+ Gtk.Button.__init__(self, stock=stock)
+ else:
+ Gtk.Button.__init__(self)
+
+
+class HIGToggleButton(Gtk.ToggleButton):
+ def __init__(self, title="", stock=None):
+ if title and stock:
+ Gtk.ToggleButton.__init__(self)
+ content = HIGMixButton(title, stock)
+ self.add(content)
+ elif title and not stock:
+ Gtk.ToggleButton.__init__(self, label=title)
+ elif stock:
+ Gtk.ToggleButton.__init__(self, stock=stock)
+ self.set_use_stock(True)
+ else:
+ Gtk.ToggleButton.__init__(self)
diff --git a/zenmap/zenmapGUI/higwidgets/higdialogs.py b/zenmap/zenmapGUI/higwidgets/higdialogs.py
new file mode 100644
index 0000000..bb64614
--- /dev/null
+++ b/zenmap/zenmapGUI/higwidgets/higdialogs.py
@@ -0,0 +1,140 @@
+#!/usr/bin/env python3
+
+# ***********************IMPORTANT NMAP LICENSE TERMS************************
+# *
+# * The Nmap Security Scanner is (C) 1996-2023 Nmap Software LLC ("The Nmap
+# * Project"). Nmap is also a registered trademark of the Nmap Project.
+# *
+# * This program is distributed under the terms of the Nmap Public Source
+# * License (NPSL). The exact license text applying to a particular Nmap
+# * release or source code control revision is contained in the LICENSE
+# * file distributed with that version of Nmap or source code control
+# * revision. More Nmap copyright/legal information is available from
+# * https://nmap.org/book/man-legal.html, and further information on the
+# * NPSL license itself can be found at https://nmap.org/npsl/ . This
+# * header summarizes some key points from the Nmap license, but is no
+# * substitute for the actual license text.
+# *
+# * Nmap is generally free for end users to download and use themselves,
+# * including commercial use. It is available from https://nmap.org.
+# *
+# * The Nmap license generally prohibits companies from using and
+# * redistributing Nmap in commercial products, but we sell a special Nmap
+# * OEM Edition with a more permissive license and special features for
+# * this purpose. See https://nmap.org/oem/
+# *
+# * If you have received a written Nmap license agreement or contract
+# * stating terms other than these (such as an Nmap OEM license), you may
+# * choose to use and redistribute Nmap under those terms instead.
+# *
+# * The official Nmap Windows builds include the Npcap software
+# * (https://npcap.com) for packet capture and transmission. It is under
+# * separate license terms which forbid redistribution without special
+# * permission. So the official Nmap Windows builds may not be redistributed
+# * without special permission (such as an Nmap OEM license).
+# *
+# * Source is provided to this software because we believe users have a
+# * right to know exactly what a program is going to do before they run it.
+# * This also allows you to audit the software for security holes.
+# *
+# * Source code also allows you to port Nmap to new platforms, fix bugs, and add
+# * new features. You are highly encouraged to submit your changes as a Github PR
+# * or by email to the dev@nmap.org mailing list for possible incorporation into
+# * the main distribution. Unless you specify otherwise, it is understood that
+# * you are offering us very broad rights to use your submissions as described in
+# * the Nmap Public Source License Contributor Agreement. This is important
+# * because we fund the project by selling licenses with various terms, and also
+# * because the inability to relicense code has caused devastating problems for
+# * other Free Software projects (such as KDE and NASM).
+# *
+# * The free version of Nmap is distributed in the hope that it will be
+# * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Warranties,
+# * indemnification and commercial support are all available through the
+# * Npcap OEM program--see https://nmap.org/oem/
+# *
+# ***************************************************************************/
+
+"""
+higwidgets/higdialogs.py
+
+ dialog related classes
+"""
+
+__all__ = ['HIGDialog', 'HIGAlertDialog']
+
+import gi
+
+gi.require_version("Gtk", "3.0")
+from gi.repository import Gtk
+
+
+class HIGDialog(Gtk.Dialog):
+ """
+ HIGFied Dialog
+ """
+ def __init__(self, title='', parent=None, flags=0, 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):
+ """
+ HIGfied Alert Dialog.
+
+ Implements the suggestions documented in:
+ http://developer.gnome.org/projects/gup/hig/2.0/windows-alert.html
+ """
+
+ 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.ButtonsType.OK,
+ message_format=None,
+ secondary_text=None):
+
+ Gtk.MessageDialog.__init__(self, parent=parent, flags=flags,
+ message_type=type, buttons=buttons)
+
+ self.set_resizable(False)
+
+ # HIG mandates that Message Dialogs should have no title:
+ # "Alert windows have no titles, as the title would usually
+ # unnecessarily duplicate the alert's primary text"
+ self.set_title("")
+ self.set_markup(
+ "<span weight='bold'size='larger'>%s</span>" % message_format)
+ if secondary_text:
+ self.format_secondary_text(secondary_text)
+
+
+if __name__ == '__main__':
+
+ from higlabels import HIGEntryLabel, HIGDialogLabel
+
+ # HIGDialog
+ d = HIGDialog(title='HIGDialog',
+ buttons=(Gtk.STOCK_OK, Gtk.ResponseType.ACCEPT))
+ dialog_label = HIGDialogLabel('A HIGDialogLabel on a HIGDialog')
+ dialog_label.show()
+ 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, True, True, 0)
+
+ d.run()
+ d.destroy()
+
+ # HIGAlertDialog
+ d = HIGAlertDialog(message_format="You Have and Appointment in 15 minutes",
+ secondary_text="You shouldn't be late this time. "
+ "Oh, and there's a huge traffic jam on your way!")
+ d.run()
+ d.destroy()
diff --git a/zenmap/zenmapGUI/higwidgets/higentries.py b/zenmap/zenmapGUI/higwidgets/higentries.py
new file mode 100644
index 0000000..54fe75f
--- /dev/null
+++ b/zenmap/zenmapGUI/higwidgets/higentries.py
@@ -0,0 +1,80 @@
+#!/usr/bin/env python3
+
+# ***********************IMPORTANT NMAP LICENSE TERMS************************
+# *
+# * The Nmap Security Scanner is (C) 1996-2023 Nmap Software LLC ("The Nmap
+# * Project"). Nmap is also a registered trademark of the Nmap Project.
+# *
+# * This program is distributed under the terms of the Nmap Public Source
+# * License (NPSL). The exact license text applying to a particular Nmap
+# * release or source code control revision is contained in the LICENSE
+# * file distributed with that version of Nmap or source code control
+# * revision. More Nmap copyright/legal information is available from
+# * https://nmap.org/book/man-legal.html, and further information on the
+# * NPSL license itself can be found at https://nmap.org/npsl/ . This
+# * header summarizes some key points from the Nmap license, but is no
+# * substitute for the actual license text.
+# *
+# * Nmap is generally free for end users to download and use themselves,
+# * including commercial use. It is available from https://nmap.org.
+# *
+# * The Nmap license generally prohibits companies from using and
+# * redistributing Nmap in commercial products, but we sell a special Nmap
+# * OEM Edition with a more permissive license and special features for
+# * this purpose. See https://nmap.org/oem/
+# *
+# * If you have received a written Nmap license agreement or contract
+# * stating terms other than these (such as an Nmap OEM license), you may
+# * choose to use and redistribute Nmap under those terms instead.
+# *
+# * The official Nmap Windows builds include the Npcap software
+# * (https://npcap.com) for packet capture and transmission. It is under
+# * separate license terms which forbid redistribution without special
+# * permission. So the official Nmap Windows builds may not be redistributed
+# * without special permission (such as an Nmap OEM license).
+# *
+# * Source is provided to this software because we believe users have a
+# * right to know exactly what a program is going to do before they run it.
+# * This also allows you to audit the software for security holes.
+# *
+# * Source code also allows you to port Nmap to new platforms, fix bugs, and add
+# * new features. You are highly encouraged to submit your changes as a Github PR
+# * or by email to the dev@nmap.org mailing list for possible incorporation into
+# * the main distribution. Unless you specify otherwise, it is understood that
+# * you are offering us very broad rights to use your submissions as described in
+# * the Nmap Public Source License Contributor Agreement. This is important
+# * because we fund the project by selling licenses with various terms, and also
+# * because the inability to relicense code has caused devastating problems for
+# * other Free Software projects (such as KDE and NASM).
+# *
+# * The free version of Nmap is distributed in the hope that it will be
+# * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Warranties,
+# * indemnification and commercial support are all available through the
+# * Npcap OEM program--see https://nmap.org/oem/
+# *
+# ***************************************************************************/
+
+"""
+higwidgets/higentries.py
+
+ entries related classes
+"""
+
+import gi
+
+gi.require_version("Gtk", "3.0")
+from gi.repository import Gtk
+
+__all__ = ('HIGTextEntry', 'HIGPasswordEntry')
+
+HIGTextEntry = Gtk.Entry
+
+
+class HIGPasswordEntry(HIGTextEntry):
+ """
+ An entry that masks its text
+ """
+ def __init__(self):
+ HIGTextEntry.__init__(self)
+ self.set_visibility(False)
diff --git a/zenmap/zenmapGUI/higwidgets/higexpanders.py b/zenmap/zenmapGUI/higwidgets/higexpanders.py
new file mode 100644
index 0000000..9c27cdc
--- /dev/null
+++ b/zenmap/zenmapGUI/higwidgets/higexpanders.py
@@ -0,0 +1,88 @@
+#!/usr/bin/env python3
+
+# ***********************IMPORTANT NMAP LICENSE TERMS************************
+# *
+# * The Nmap Security Scanner is (C) 1996-2023 Nmap Software LLC ("The Nmap
+# * Project"). Nmap is also a registered trademark of the Nmap Project.
+# *
+# * This program is distributed under the terms of the Nmap Public Source
+# * License (NPSL). The exact license text applying to a particular Nmap
+# * release or source code control revision is contained in the LICENSE
+# * file distributed with that version of Nmap or source code control
+# * revision. More Nmap copyright/legal information is available from
+# * https://nmap.org/book/man-legal.html, and further information on the
+# * NPSL license itself can be found at https://nmap.org/npsl/ . This
+# * header summarizes some key points from the Nmap license, but is no
+# * substitute for the actual license text.
+# *
+# * Nmap is generally free for end users to download and use themselves,
+# * including commercial use. It is available from https://nmap.org.
+# *
+# * The Nmap license generally prohibits companies from using and
+# * redistributing Nmap in commercial products, but we sell a special Nmap
+# * OEM Edition with a more permissive license and special features for
+# * this purpose. See https://nmap.org/oem/
+# *
+# * If you have received a written Nmap license agreement or contract
+# * stating terms other than these (such as an Nmap OEM license), you may
+# * choose to use and redistribute Nmap under those terms instead.
+# *
+# * The official Nmap Windows builds include the Npcap software
+# * (https://npcap.com) for packet capture and transmission. It is under
+# * separate license terms which forbid redistribution without special
+# * permission. So the official Nmap Windows builds may not be redistributed
+# * without special permission (such as an Nmap OEM license).
+# *
+# * Source is provided to this software because we believe users have a
+# * right to know exactly what a program is going to do before they run it.
+# * This also allows you to audit the software for security holes.
+# *
+# * Source code also allows you to port Nmap to new platforms, fix bugs, and add
+# * new features. You are highly encouraged to submit your changes as a Github PR
+# * or by email to the dev@nmap.org mailing list for possible incorporation into
+# * the main distribution. Unless you specify otherwise, it is understood that
+# * you are offering us very broad rights to use your submissions as described in
+# * the Nmap Public Source License Contributor Agreement. This is important
+# * because we fund the project by selling licenses with various terms, and also
+# * because the inability to relicense code has caused devastating problems for
+# * other Free Software projects (such as KDE and NASM).
+# *
+# * The free version of Nmap is distributed in the hope that it will be
+# * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Warranties,
+# * indemnification and commercial support are all available through the
+# * Npcap OEM program--see https://nmap.org/oem/
+# *
+# ***************************************************************************/
+
+"""
+higwidgets/higexpanders.py
+
+ expanders related classes
+"""
+
+__all__ = ['HIGExpander']
+
+import gi
+
+gi.require_version("Gtk", "3.0")
+from gi.repository import Gtk
+
+from .higboxes import HIGHBox, hig_box_space_holder
+
+
+class HIGExpander(Gtk.Expander):
+ def __init__(self, label):
+ Gtk.Expander.__init__(self)
+
+ self.set_use_markup(True)
+ self.set_label(label)
+
+ self.hbox = HIGHBox()
+ self.hbox.set_border_width(5)
+ self.hbox._pack_noexpand_nofill(hig_box_space_holder())
+
+ self.add(self.hbox)
+
+ def get_container(self):
+ return self.hbox
diff --git a/zenmap/zenmapGUI/higwidgets/higframe.py b/zenmap/zenmapGUI/higwidgets/higframe.py
new file mode 100644
index 0000000..293f819
--- /dev/null
+++ b/zenmap/zenmapGUI/higwidgets/higframe.py
@@ -0,0 +1,105 @@
+#!/usr/bin/env python3
+
+# ***********************IMPORTANT NMAP LICENSE TERMS************************
+# *
+# * The Nmap Security Scanner is (C) 1996-2023 Nmap Software LLC ("The Nmap
+# * Project"). Nmap is also a registered trademark of the Nmap Project.
+# *
+# * This program is distributed under the terms of the Nmap Public Source
+# * License (NPSL). The exact license text applying to a particular Nmap
+# * release or source code control revision is contained in the LICENSE
+# * file distributed with that version of Nmap or source code control
+# * revision. More Nmap copyright/legal information is available from
+# * https://nmap.org/book/man-legal.html, and further information on the
+# * NPSL license itself can be found at https://nmap.org/npsl/ . This
+# * header summarizes some key points from the Nmap license, but is no
+# * substitute for the actual license text.
+# *
+# * Nmap is generally free for end users to download and use themselves,
+# * including commercial use. It is available from https://nmap.org.
+# *
+# * The Nmap license generally prohibits companies from using and
+# * redistributing Nmap in commercial products, but we sell a special Nmap
+# * OEM Edition with a more permissive license and special features for
+# * this purpose. See https://nmap.org/oem/
+# *
+# * If you have received a written Nmap license agreement or contract
+# * stating terms other than these (such as an Nmap OEM license), you may
+# * choose to use and redistribute Nmap under those terms instead.
+# *
+# * The official Nmap Windows builds include the Npcap software
+# * (https://npcap.com) for packet capture and transmission. It is under
+# * separate license terms which forbid redistribution without special
+# * permission. So the official Nmap Windows builds may not be redistributed
+# * without special permission (such as an Nmap OEM license).
+# *
+# * Source is provided to this software because we believe users have a
+# * right to know exactly what a program is going to do before they run it.
+# * This also allows you to audit the software for security holes.
+# *
+# * Source code also allows you to port Nmap to new platforms, fix bugs, and add
+# * new features. You are highly encouraged to submit your changes as a Github PR
+# * or by email to the dev@nmap.org mailing list for possible incorporation into
+# * the main distribution. Unless you specify otherwise, it is understood that
+# * you are offering us very broad rights to use your submissions as described in
+# * the Nmap Public Source License Contributor Agreement. This is important
+# * because we fund the project by selling licenses with various terms, and also
+# * because the inability to relicense code has caused devastating problems for
+# * other Free Software projects (such as KDE and NASM).
+# *
+# * The free version of Nmap is distributed in the hope that it will be
+# * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Warranties,
+# * indemnification and commercial support are all available through the
+# * Npcap OEM program--see https://nmap.org/oem/
+# *
+# ***************************************************************************/
+
+"""
+higwidgets/higframe.py
+
+ hig frame
+"""
+
+__all__ = ['HIGFrame']
+
+import gi
+
+gi.require_version("Gtk", "3.0")
+from gi.repository import Gtk
+
+
+class HIGFrame(Gtk.Frame):
+ """
+ Frame without border with bold label.
+ """
+ def __init__(self, label=None):
+ Gtk.Frame.__init__(self)
+
+ self.set_shadow_type(Gtk.ShadowType.NONE)
+ self._flabel = Gtk.Label()
+ self._set_label(label)
+ self.set_label_widget(self._flabel)
+
+ def _set_label(self, label):
+ self._flabel.set_markup("<b>%s</b>" % label)
+
+# Demo
+if __name__ == "__main__":
+ w = Gtk.Window()
+
+ hframe = HIGFrame("Sample HIGFrame")
+ aalign = Gtk.Alignment.new(0, 0, 0, 0)
+ aalign.set_padding(12, 0, 24, 0)
+ abox = Gtk.Box.new(Gtk.Orientation.VERTICAL, 0)
+ aalign.add(abox)
+ hframe.add(aalign)
+ w.add(hframe)
+
+ 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.show_all()
+
+ Gtk.main()
diff --git a/zenmap/zenmapGUI/higwidgets/higlabels.py b/zenmap/zenmapGUI/higwidgets/higlabels.py
new file mode 100644
index 0000000..ac2dcfc
--- /dev/null
+++ b/zenmap/zenmapGUI/higwidgets/higlabels.py
@@ -0,0 +1,180 @@
+#!/usr/bin/env python3
+
+# ***********************IMPORTANT NMAP LICENSE TERMS************************
+# *
+# * The Nmap Security Scanner is (C) 1996-2023 Nmap Software LLC ("The Nmap
+# * Project"). Nmap is also a registered trademark of the Nmap Project.
+# *
+# * This program is distributed under the terms of the Nmap Public Source
+# * License (NPSL). The exact license text applying to a particular Nmap
+# * release or source code control revision is contained in the LICENSE
+# * file distributed with that version of Nmap or source code control
+# * revision. More Nmap copyright/legal information is available from
+# * https://nmap.org/book/man-legal.html, and further information on the
+# * NPSL license itself can be found at https://nmap.org/npsl/ . This
+# * header summarizes some key points from the Nmap license, but is no
+# * substitute for the actual license text.
+# *
+# * Nmap is generally free for end users to download and use themselves,
+# * including commercial use. It is available from https://nmap.org.
+# *
+# * The Nmap license generally prohibits companies from using and
+# * redistributing Nmap in commercial products, but we sell a special Nmap
+# * OEM Edition with a more permissive license and special features for
+# * this purpose. See https://nmap.org/oem/
+# *
+# * If you have received a written Nmap license agreement or contract
+# * stating terms other than these (such as an Nmap OEM license), you may
+# * choose to use and redistribute Nmap under those terms instead.
+# *
+# * The official Nmap Windows builds include the Npcap software
+# * (https://npcap.com) for packet capture and transmission. It is under
+# * separate license terms which forbid redistribution without special
+# * permission. So the official Nmap Windows builds may not be redistributed
+# * without special permission (such as an Nmap OEM license).
+# *
+# * Source is provided to this software because we believe users have a
+# * right to know exactly what a program is going to do before they run it.
+# * This also allows you to audit the software for security holes.
+# *
+# * Source code also allows you to port Nmap to new platforms, fix bugs, and add
+# * new features. You are highly encouraged to submit your changes as a Github PR
+# * or by email to the dev@nmap.org mailing list for possible incorporation into
+# * the main distribution. Unless you specify otherwise, it is understood that
+# * you are offering us very broad rights to use your submissions as described in
+# * the Nmap Public Source License Contributor Agreement. This is important
+# * because we fund the project by selling licenses with various terms, and also
+# * because the inability to relicense code has caused devastating problems for
+# * other Free Software projects (such as KDE and NASM).
+# *
+# * The free version of Nmap is distributed in the hope that it will be
+# * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Warranties,
+# * indemnification and commercial support are all available through the
+# * Npcap OEM program--see https://nmap.org/oem/
+# *
+# ***************************************************************************/
+
+"""
+higwidgets/higlabels.py
+
+ labels related classes
+"""
+
+__all__ = [
+ 'HIGSectionLabel', 'HIGHintSectionLabel', 'HIGEntryLabel', 'HIGDialogLabel'
+ ]
+
+import gi
+
+gi.require_version("Gtk", "3.0")
+from gi.repository import Gtk, Gdk
+
+
+class HIGSectionLabel(Gtk.Label):
+ """
+ Bold label, used to define sections
+ """
+ def __init__(self, text=None):
+ Gtk.Label.__init__(self)
+ if text:
+ self.set_markup("<b>%s</b>" % (text))
+ self.set_justify(Gtk.Justification.LEFT)
+ self.props.xalign = 0
+ self.props.yalign = 0.5
+ self.set_line_wrap(True)
+
+
+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.Box.__init__(self, orientation=Gtk.Orientation.HORIZONTAL)
+
+ self.label = HIGSectionLabel(text)
+ self.hint = Hint(hint)
+
+ self.pack_start(self.label, False, False, 0)
+ self.pack_start(self.hint, False, False, 5)
+
+
+class Hint(Gtk.EventBox, object):
+ def __init__(self, hint):
+ Gtk.EventBox.__init__(self)
+ self.hint = hint
+
+ self.hint_image = Gtk.Image()
+ self.hint_image.set_from_icon_name(
+ "dialog-information", Gtk.IconSize.SMALL_TOOLBAR)
+
+ self.add(self.hint_image)
+
+ self.connect("button-press-event", self.show_hint)
+
+ def show_hint(self, widget, event=None):
+ hint_window = HintWindow(self.hint)
+ hint_window.show_all()
+
+
+class HintWindow(Gtk.Window):
+ def __init__(self, hint):
+ Gtk.Window.__init__(self, type=Gtk.WindowType.POPUP)
+ self.set_position(Gtk.WindowPosition.MOUSE)
+ self.set_resizable(False)
+
+ bg_color = Gdk.RGBA()
+ bg_color.parse("#fbff99")
+ self.override_background_color(Gtk.StateFlags.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.new(hint)
+ self.hint_label.set_use_markup(True)
+ self.hint_label.set_line_wrap(True)
+ 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)
+
+ def close(self, widget, event=None):
+ self.destroy()
+
+
+class HIGEntryLabel(Gtk.Label):
+ """
+ Simple label, like the ones used to label entries
+ """
+ def __init__(self, text=None):
+ 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):
+ """
+ Centered, line-wrappable label, usually used on dialogs.
+ """
+ def __init__(self, text=None):
+ 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()
+ h = HIGHintSectionLabel("Label", "Hint")
+ w.add(h)
+ w.connect("delete-event", lambda x, y: Gtk.main_quit())
+ w.show_all()
+
+ Gtk.main()
diff --git a/zenmap/zenmapGUI/higwidgets/higlogindialogs.py b/zenmap/zenmapGUI/higwidgets/higlogindialogs.py
new file mode 100644
index 0000000..a940c60
--- /dev/null
+++ b/zenmap/zenmapGUI/higwidgets/higlogindialogs.py
@@ -0,0 +1,116 @@
+#!/usr/bin/env python3
+
+# ***********************IMPORTANT NMAP LICENSE TERMS************************
+# *
+# * The Nmap Security Scanner is (C) 1996-2023 Nmap Software LLC ("The Nmap
+# * Project"). Nmap is also a registered trademark of the Nmap Project.
+# *
+# * This program is distributed under the terms of the Nmap Public Source
+# * License (NPSL). The exact license text applying to a particular Nmap
+# * release or source code control revision is contained in the LICENSE
+# * file distributed with that version of Nmap or source code control
+# * revision. More Nmap copyright/legal information is available from
+# * https://nmap.org/book/man-legal.html, and further information on the
+# * NPSL license itself can be found at https://nmap.org/npsl/ . This
+# * header summarizes some key points from the Nmap license, but is no
+# * substitute for the actual license text.
+# *
+# * Nmap is generally free for end users to download and use themselves,
+# * including commercial use. It is available from https://nmap.org.
+# *
+# * The Nmap license generally prohibits companies from using and
+# * redistributing Nmap in commercial products, but we sell a special Nmap
+# * OEM Edition with a more permissive license and special features for
+# * this purpose. See https://nmap.org/oem/
+# *
+# * If you have received a written Nmap license agreement or contract
+# * stating terms other than these (such as an Nmap OEM license), you may
+# * choose to use and redistribute Nmap under those terms instead.
+# *
+# * The official Nmap Windows builds include the Npcap software
+# * (https://npcap.com) for packet capture and transmission. It is under
+# * separate license terms which forbid redistribution without special
+# * permission. So the official Nmap Windows builds may not be redistributed
+# * without special permission (such as an Nmap OEM license).
+# *
+# * Source is provided to this software because we believe users have a
+# * right to know exactly what a program is going to do before they run it.
+# * This also allows you to audit the software for security holes.
+# *
+# * Source code also allows you to port Nmap to new platforms, fix bugs, and add
+# * new features. You are highly encouraged to submit your changes as a Github PR
+# * or by email to the dev@nmap.org mailing list for possible incorporation into
+# * the main distribution. Unless you specify otherwise, it is understood that
+# * you are offering us very broad rights to use your submissions as described in
+# * the Nmap Public Source License Contributor Agreement. This is important
+# * because we fund the project by selling licenses with various terms, and also
+# * because the inability to relicense code has caused devastating problems for
+# * other Free Software projects (such as KDE and NASM).
+# *
+# * The free version of Nmap is distributed in the hope that it will be
+# * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Warranties,
+# * indemnification and commercial support are all available through the
+# * Npcap OEM program--see https://nmap.org/oem/
+# *
+# ***************************************************************************/
+
+"""
+higwidgets/higlogindialog.py
+
+ a basic login/authentication dialog
+"""
+
+__all__ = ['HIGLoginDialog']
+
+import gi
+
+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):
+ """
+ A dialog that asks for basic login information (username / password)
+ """
+ def __init__(self, title='Login',
+ buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
+ Gtk.STOCK_OK, Gtk.ResponseType.ACCEPT)):
+ HIGDialog.__init__(self, title, buttons=buttons)
+
+ self.username_label = HIGEntryLabel("Username:")
+ self.username_entry = HIGTextEntry()
+ self.password_label = HIGEntryLabel("Password:")
+ self.password_entry = HIGPasswordEntry()
+
+ self.username_password_table = HIGTable(2, 2)
+ self.username_password_table.attach_label(self.username_label,
+ 0, 1, 0, 1)
+ self.username_password_table.attach_entry(self.username_entry,
+ 1, 2, 0, 1)
+ self.username_password_table.attach_label(self.password_label,
+ 0, 1, 1, 2)
+ self.username_password_table.attach_entry(self.password_entry,
+ 1, 2, 1, 2)
+
+ self.vbox.pack_start(self.username_password_table, False, False, 0)
+ self.set_default_response(Gtk.ResponseType.ACCEPT)
+
+ def run(self):
+ self.show_all()
+ return HIGDialog.run(self)
+
+if __name__ == '__main__':
+
+ from gtkutils import gtk_constant_name
+
+ # HIGLoginDialog
+ d = HIGLoginDialog()
+ response_value = d.run()
+ print(gtk_constant_name('response', response_value))
+ d.destroy()
diff --git a/zenmap/zenmapGUI/higwidgets/hignotebooks.py b/zenmap/zenmapGUI/higwidgets/hignotebooks.py
new file mode 100644
index 0000000..0f4b262
--- /dev/null
+++ b/zenmap/zenmapGUI/higwidgets/hignotebooks.py
@@ -0,0 +1,128 @@
+#!/usr/bin/env python3
+
+# ***********************IMPORTANT NMAP LICENSE TERMS************************
+# *
+# * The Nmap Security Scanner is (C) 1996-2023 Nmap Software LLC ("The Nmap
+# * Project"). Nmap is also a registered trademark of the Nmap Project.
+# *
+# * This program is distributed under the terms of the Nmap Public Source
+# * License (NPSL). The exact license text applying to a particular Nmap
+# * release or source code control revision is contained in the LICENSE
+# * file distributed with that version of Nmap or source code control
+# * revision. More Nmap copyright/legal information is available from
+# * https://nmap.org/book/man-legal.html, and further information on the
+# * NPSL license itself can be found at https://nmap.org/npsl/ . This
+# * header summarizes some key points from the Nmap license, but is no
+# * substitute for the actual license text.
+# *
+# * Nmap is generally free for end users to download and use themselves,
+# * including commercial use. It is available from https://nmap.org.
+# *
+# * The Nmap license generally prohibits companies from using and
+# * redistributing Nmap in commercial products, but we sell a special Nmap
+# * OEM Edition with a more permissive license and special features for
+# * this purpose. See https://nmap.org/oem/
+# *
+# * If you have received a written Nmap license agreement or contract
+# * stating terms other than these (such as an Nmap OEM license), you may
+# * choose to use and redistribute Nmap under those terms instead.
+# *
+# * The official Nmap Windows builds include the Npcap software
+# * (https://npcap.com) for packet capture and transmission. It is under
+# * separate license terms which forbid redistribution without special
+# * permission. So the official Nmap Windows builds may not be redistributed
+# * without special permission (such as an Nmap OEM license).
+# *
+# * Source is provided to this software because we believe users have a
+# * right to know exactly what a program is going to do before they run it.
+# * This also allows you to audit the software for security holes.
+# *
+# * Source code also allows you to port Nmap to new platforms, fix bugs, and add
+# * new features. You are highly encouraged to submit your changes as a Github PR
+# * or by email to the dev@nmap.org mailing list for possible incorporation into
+# * the main distribution. Unless you specify otherwise, it is understood that
+# * you are offering us very broad rights to use your submissions as described in
+# * the Nmap Public Source License Contributor Agreement. This is important
+# * because we fund the project by selling licenses with various terms, and also
+# * because the inability to relicense code has caused devastating problems for
+# * other Free Software projects (such as KDE and NASM).
+# *
+# * The free version of Nmap is distributed in the hope that it will be
+# * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Warranties,
+# * indemnification and commercial support are all available through the
+# * Npcap OEM program--see https://nmap.org/oem/
+# *
+# ***************************************************************************/
+
+import gi
+
+gi.require_version("Gtk", "3.0")
+from gi.repository import Gtk, GObject
+
+from .higboxes import HIGHBox
+from .higbuttons import HIGButton
+
+
+class HIGNotebook(Gtk.Notebook):
+ def __init__(self):
+ Gtk.Notebook.__init__(self)
+ self.popup_enable()
+
+
+class HIGClosableTabLabel(HIGHBox):
+ __gsignals__ = {
+ 'close-clicked': (GObject.SignalFlags.RUN_LAST, GObject.TYPE_NONE, ())
+ }
+
+ def __init__(self, label_text=""):
+ GObject.GObject.__init__(self)
+ #HIGHBox.__init__(self, spacing=4)
+
+ self.label_text = label_text
+ self.__create_widgets()
+
+ #self.property_map = {"label_text" : self.label.get_label}
+
+ def __create_widgets(self):
+ 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.ReliefStyle.NONE)
+ self.close_button.set_focus_on_click(False)
+ self.close_button.add(self.close_image)
+
+ self.close_button.connect('clicked', self.__close_button_clicked)
+
+ for w in (self.label, self.close_button):
+ self.pack_start(w, False, False, 0)
+
+ self.show_all()
+
+ # def do_get_property(self, property):
+ # func = self.property_map.get(property, None)
+ # if func:
+ # return func()
+ # else:
+ # raise
+
+ def __close_button_clicked(self, data):
+ self.emit('close-clicked')
+
+ def get_text(self):
+ return self.label.get_text()
+
+ def set_text(self, text):
+ self.label.set_text(text)
+
+ def get_label(self):
+ return self.label.get_label()
+
+ def set_label(self, label):
+ self.label.set_text(label)
+
+GObject.type_register(HIGClosableTabLabel)
+
+HIGAnimatedTabLabel = HIGClosableTabLabel
diff --git a/zenmap/zenmapGUI/higwidgets/higprogressbars.py b/zenmap/zenmapGUI/higwidgets/higprogressbars.py
new file mode 100644
index 0000000..edd2d1b
--- /dev/null
+++ b/zenmap/zenmapGUI/higwidgets/higprogressbars.py
@@ -0,0 +1,85 @@
+#!/usr/bin/env python3
+
+# ***********************IMPORTANT NMAP LICENSE TERMS************************
+# *
+# * The Nmap Security Scanner is (C) 1996-2023 Nmap Software LLC ("The Nmap
+# * Project"). Nmap is also a registered trademark of the Nmap Project.
+# *
+# * This program is distributed under the terms of the Nmap Public Source
+# * License (NPSL). The exact license text applying to a particular Nmap
+# * release or source code control revision is contained in the LICENSE
+# * file distributed with that version of Nmap or source code control
+# * revision. More Nmap copyright/legal information is available from
+# * https://nmap.org/book/man-legal.html, and further information on the
+# * NPSL license itself can be found at https://nmap.org/npsl/ . This
+# * header summarizes some key points from the Nmap license, but is no
+# * substitute for the actual license text.
+# *
+# * Nmap is generally free for end users to download and use themselves,
+# * including commercial use. It is available from https://nmap.org.
+# *
+# * The Nmap license generally prohibits companies from using and
+# * redistributing Nmap in commercial products, but we sell a special Nmap
+# * OEM Edition with a more permissive license and special features for
+# * this purpose. See https://nmap.org/oem/
+# *
+# * If you have received a written Nmap license agreement or contract
+# * stating terms other than these (such as an Nmap OEM license), you may
+# * choose to use and redistribute Nmap under those terms instead.
+# *
+# * The official Nmap Windows builds include the Npcap software
+# * (https://npcap.com) for packet capture and transmission. It is under
+# * separate license terms which forbid redistribution without special
+# * permission. So the official Nmap Windows builds may not be redistributed
+# * without special permission (such as an Nmap OEM license).
+# *
+# * Source is provided to this software because we believe users have a
+# * right to know exactly what a program is going to do before they run it.
+# * This also allows you to audit the software for security holes.
+# *
+# * Source code also allows you to port Nmap to new platforms, fix bugs, and add
+# * new features. You are highly encouraged to submit your changes as a Github PR
+# * or by email to the dev@nmap.org mailing list for possible incorporation into
+# * the main distribution. Unless you specify otherwise, it is understood that
+# * you are offering us very broad rights to use your submissions as described in
+# * the Nmap Public Source License Contributor Agreement. This is important
+# * because we fund the project by selling licenses with various terms, and also
+# * because the inability to relicense code has caused devastating problems for
+# * other Free Software projects (such as KDE and NASM).
+# *
+# * The free version of Nmap is distributed in the hope that it will be
+# * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Warranties,
+# * indemnification and commercial support are all available through the
+# * Npcap OEM program--see https://nmap.org/oem/
+# *
+# ***************************************************************************/
+
+"""
+higwidgets/higprogressbars.py
+
+ progress bars classes
+"""
+
+__all__ = ['HIGLabeledProgressBar']
+
+import gi
+
+gi.require_version("Gtk", "3.0")
+from gi.repository import Gtk
+
+from .higboxes import HIGHBox
+
+
+class HIGLabeledProgressBar(HIGHBox):
+ def __init__(self, label=None):
+ HIGHBox.__init__(self)
+ if label:
+ self.label = HIGEntryLabel(label)
+ self.pack_label(self.label)
+ self.progress_bar = Gtk.ProgressBar()
+ self.progress_bar.set_size_request(80, 16)
+ self.pack_label(self.progress_bar)
+
+ def show(self):
+ HIGHBox.show_all(self)
diff --git a/zenmap/zenmapGUI/higwidgets/higscrollers.py b/zenmap/zenmapGUI/higwidgets/higscrollers.py
new file mode 100644
index 0000000..83e6b16
--- /dev/null
+++ b/zenmap/zenmapGUI/higwidgets/higscrollers.py
@@ -0,0 +1,76 @@
+#!/usr/bin/env python3
+
+# ***********************IMPORTANT NMAP LICENSE TERMS************************
+# *
+# * The Nmap Security Scanner is (C) 1996-2023 Nmap Software LLC ("The Nmap
+# * Project"). Nmap is also a registered trademark of the Nmap Project.
+# *
+# * This program is distributed under the terms of the Nmap Public Source
+# * License (NPSL). The exact license text applying to a particular Nmap
+# * release or source code control revision is contained in the LICENSE
+# * file distributed with that version of Nmap or source code control
+# * revision. More Nmap copyright/legal information is available from
+# * https://nmap.org/book/man-legal.html, and further information on the
+# * NPSL license itself can be found at https://nmap.org/npsl/ . This
+# * header summarizes some key points from the Nmap license, but is no
+# * substitute for the actual license text.
+# *
+# * Nmap is generally free for end users to download and use themselves,
+# * including commercial use. It is available from https://nmap.org.
+# *
+# * The Nmap license generally prohibits companies from using and
+# * redistributing Nmap in commercial products, but we sell a special Nmap
+# * OEM Edition with a more permissive license and special features for
+# * this purpose. See https://nmap.org/oem/
+# *
+# * If you have received a written Nmap license agreement or contract
+# * stating terms other than these (such as an Nmap OEM license), you may
+# * choose to use and redistribute Nmap under those terms instead.
+# *
+# * The official Nmap Windows builds include the Npcap software
+# * (https://npcap.com) for packet capture and transmission. It is under
+# * separate license terms which forbid redistribution without special
+# * permission. So the official Nmap Windows builds may not be redistributed
+# * without special permission (such as an Nmap OEM license).
+# *
+# * Source is provided to this software because we believe users have a
+# * right to know exactly what a program is going to do before they run it.
+# * This also allows you to audit the software for security holes.
+# *
+# * Source code also allows you to port Nmap to new platforms, fix bugs, and add
+# * new features. You are highly encouraged to submit your changes as a Github PR
+# * or by email to the dev@nmap.org mailing list for possible incorporation into
+# * the main distribution. Unless you specify otherwise, it is understood that
+# * you are offering us very broad rights to use your submissions as described in
+# * the Nmap Public Source License Contributor Agreement. This is important
+# * because we fund the project by selling licenses with various terms, and also
+# * because the inability to relicense code has caused devastating problems for
+# * other Free Software projects (such as KDE and NASM).
+# *
+# * The free version of Nmap is distributed in the hope that it will be
+# * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Warranties,
+# * indemnification and commercial support are all available through the
+# * Npcap OEM program--see https://nmap.org/oem/
+# *
+# ***************************************************************************/
+
+"""
+higwidgets/higscrollers.py
+
+ scrollers related classes
+"""
+
+__all__ = ['HIGScrolledWindow']
+
+import gi
+
+gi.require_version("Gtk", "3.0")
+from gi.repository import Gtk
+
+
+class HIGScrolledWindow(Gtk.ScrolledWindow):
+ def __init__(self):
+ Gtk.ScrolledWindow.__init__(self)
+ self.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
+ self.set_border_width(5)
diff --git a/zenmap/zenmapGUI/higwidgets/higspinner.py b/zenmap/zenmapGUI/higwidgets/higspinner.py
new file mode 100644
index 0000000..977bfb5
--- /dev/null
+++ b/zenmap/zenmapGUI/higwidgets/higspinner.py
@@ -0,0 +1,388 @@
+#!/usr/bin/env python3
+
+# ***********************IMPORTANT NMAP LICENSE TERMS************************
+# *
+# * The Nmap Security Scanner is (C) 1996-2023 Nmap Software LLC ("The Nmap
+# * Project"). Nmap is also a registered trademark of the Nmap Project.
+# *
+# * This program is distributed under the terms of the Nmap Public Source
+# * License (NPSL). The exact license text applying to a particular Nmap
+# * release or source code control revision is contained in the LICENSE
+# * file distributed with that version of Nmap or source code control
+# * revision. More Nmap copyright/legal information is available from
+# * https://nmap.org/book/man-legal.html, and further information on the
+# * NPSL license itself can be found at https://nmap.org/npsl/ . This
+# * header summarizes some key points from the Nmap license, but is no
+# * substitute for the actual license text.
+# *
+# * Nmap is generally free for end users to download and use themselves,
+# * including commercial use. It is available from https://nmap.org.
+# *
+# * The Nmap license generally prohibits companies from using and
+# * redistributing Nmap in commercial products, but we sell a special Nmap
+# * OEM Edition with a more permissive license and special features for
+# * this purpose. See https://nmap.org/oem/
+# *
+# * If you have received a written Nmap license agreement or contract
+# * stating terms other than these (such as an Nmap OEM license), you may
+# * choose to use and redistribute Nmap under those terms instead.
+# *
+# * The official Nmap Windows builds include the Npcap software
+# * (https://npcap.com) for packet capture and transmission. It is under
+# * separate license terms which forbid redistribution without special
+# * permission. So the official Nmap Windows builds may not be redistributed
+# * without special permission (such as an Nmap OEM license).
+# *
+# * Source is provided to this software because we believe users have a
+# * right to know exactly what a program is going to do before they run it.
+# * This also allows you to audit the software for security holes.
+# *
+# * Source code also allows you to port Nmap to new platforms, fix bugs, and add
+# * new features. You are highly encouraged to submit your changes as a Github PR
+# * or by email to the dev@nmap.org mailing list for possible incorporation into
+# * the main distribution. Unless you specify otherwise, it is understood that
+# * you are offering us very broad rights to use your submissions as described in
+# * the Nmap Public Source License Contributor Agreement. This is important
+# * because we fund the project by selling licenses with various terms, and also
+# * because the inability to relicense code has caused devastating problems for
+# * other Free Software projects (such as KDE and NASM).
+# *
+# * The free version of Nmap is distributed in the hope that it will be
+# * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Warranties,
+# * indemnification and commercial support are all available through the
+# * Npcap OEM program--see https://nmap.org/oem/
+# *
+# ***************************************************************************/
+
+"""
+higwidgets/higspinner.py
+
+ a pygtk spinner, based on the epiphany/nautilus implementation
+"""
+
+__all__ = ['HIGSpinner']
+
+import gi
+
+gi.require_version("Gtk", "3.0")
+from gi.repository import Gtk, GLib, Gdk, GdkPixbuf
+
+
+class HIGSpinnerImages:
+ def __init__(self):
+ """This class holds list of GDK Pixbuffers.
+
+ - static_pixbufs is used for multiple static pixbuffers
+ - self.animated_pixbufs is used for the pixbuffers that make up the
+ animation
+ """
+
+ dprint('HIGSpinnerImages::__init__')
+
+ # The Nautilus/Epiphany implementation uses a single "rest/quiescent"
+ # static pixbuffer. We'd rather allow the developer to choose from
+ # multiple static states, such as "done" or "failed".
+ # Index it by a name like that.
+ self.static_pixbufs = {}
+
+ # We should have a default rest pixbuf, set it with set_rest_pixbuf()
+ self.rest_pixbuf = None
+
+ # This is a list of pixbufs to be used on the animation
+ # For now, we're only implementing a single animation. Inconsistent!
+ self.animated_pixbufs = []
+
+ def add_static_pixbuf(self, name, pixbuf, default_on_rest=False):
+ """Add a static pixbuf.
+
+ If this is the first one, make it the default pixbuffer on rest.
+ The user can make some other pixbuf the new default on rest, by setting
+ default_on_rest to True.
+ """
+
+ dprint('HIGSpinnerImages::add_static_pixbuf')
+
+ self.static_pixbufs[name] = pixbuf
+ if (len(self.static_pixbufs) == 1) or default_on_rest:
+ self.set_rest_pixbuf(name)
+
+ def add_animated_pixbuf(self, pixbuf):
+
+ dprint('HIGSpinnerImages::add_animated_pixbuf')
+
+ self.animated_pixbufs.append(pixbuf)
+
+ def set_rest_pixbuf(self, name):
+ """Sets the pixbuf that will be used on the default, 'rest' state. """
+
+ dprint('HIGSpinnerImages::set_rest_pixbuf')
+
+ if name not in self.static_pixbufs:
+ raise StaticPixbufNotFound
+
+ # self.rest_pixbuf holds the *real* pixbuf, not its name
+ self.rest_pixbuf = self.static_pixbufs[name]
+
+ def set_size(self, width, height):
+ """Sets the size of each pixbuf (static and animated)"""
+ new_animated = []
+ for p in self.animated_pixbufs:
+ new_animated.append(p.scale_simple(width, height,
+ 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, GdkPixbuf.InterpType.BILINEAR)
+
+ self.rest_pixbuf = self.rest_pixbuf.scale_simple(
+ width, height, GdkPixbuf.InterpType.BILINEAR)
+
+ self.images_width = width
+ self.images_height = height
+
+
+class HIGSpinnerCache:
+ """This hols a copy of the images used on the HIGSpinners instances."""
+ def __init__(self):
+
+ dprint('HIGSpinnerCache::__init__')
+
+ # Our own instance of a HIGSpinnerImages
+ self.spinner_images = HIGSpinnerImages()
+
+ # These are on Private member in the C implementation
+ self.icon_theme = Gtk.IconTheme()
+ self.originals = None
+ self.images = None
+
+ # We might have access to a "default" animated icon.
+ # For example, if we're on a GNOME desktop, and have the (default)
+ # "gnome-icon-theme" package installed, we might have access
+ # to "gnome-spinner". Check it before using, though
+ if (self.icon_theme.lookup_icon("gnome-spinner", -1, 0)):
+ self.default_animated_icon_name = "gnome-spinner"
+ else:
+ self.default_animated_icon_name = None
+
+ def load_animated_from_lookup(self, icon_name=None):
+ """Loads an animated icon by doing a lookup on the icon theme."""
+
+ # If user do not choose a icon_name, use the default one
+ if icon_name is None:
+ icon_name = self.default_animated_icon_name
+
+ # Even the default one (now on icon_name) might not be available
+ if icon_name is None:
+ raise AnimatedIconNotFound
+
+ # Try to lookup the icon
+ icon_info = self.icon_theme.lookup_icon(icon_name, -1, 0)
+ # Even if icon_name exists, it might not be found by lookup
+ if icon_info is None:
+ raise AnimatedIconNotFound
+
+ # Base size is, according to PyGTK docs:
+ # "a size for the icon that was specified by the icon theme creator,
+ # This may be different than the actual size of image."
+ # Ouch! We are acting on blind faith here...
+ size = icon_info.get_base_size()
+
+ # NOTE: If the icon is a builtin, it will not have a filename, see:
+ # http://www.pygtk.org/pygtk2reference/class-gtkicontheme.html
+ # But, we are not using the gtk.ICON_LOOKUP_USE_BUILTIN flag, nor does
+ # GTK+ has a builtin animation, so we are safe ;-)
+ filename = icon_info.get_filename()
+
+ # Now that we have a filename, call load_animated_from_filename()
+ self.load_animated_from_filename(filename, size)
+
+ def load_animated_from_filename(self, filename, size):
+ # grid_pixbuf is a pixbuf that holds the entire
+ grid_pixbuf = GdkPixbuf.Pixbuf.new_from_file(filename)
+ grid_width = grid_pixbuf.get_width()
+ grid_height = grid_pixbuf.get_height()
+
+ for x in range(0, grid_width, size):
+ for y in range(0, grid_height, size):
+ self.spinner_images.add_animated_pixbuf(
+ self.__extract_frame(grid_pixbuf, x, y, size, size))
+
+ def load_static_from_lookup(self, icon_name="gnome-spinner-rest",
+ key_name=None):
+ icon_info = self.icon_theme.lookup_icon(icon_name, -1, 0)
+ filename = icon_info.get_filename()
+
+ # Now that we have a filename, call load_static_from_filename()
+ self.load_static_from_filename(filename)
+
+ def load_static_from_filename(self, filename, key_name=None):
+ icon_pixbuf = GdkPixbuf.Pixbuf.new_from_file(filename)
+
+ if key_name is None:
+ key_name = filename.split(".")[0]
+
+ self.spinner_images.add_static_pixbuf(key_name, icon_pixbuf)
+
+ def __extract_frame(self, pixbuf, x, y, w, h):
+ """Cuts a sub pixbuffer, usually a frame of an animation.
+
+ - pixbuf is the complete pixbuf, from which a frame will be cut off
+ - x/y are the position
+ - w (width) is the is the number of pixels to move right
+ - h (height) is the is the number of pixels to move down
+ """
+ if (x + w > pixbuf.get_width()) or (y + h > pixbuf.get_height()):
+ raise PixbufSmallerThanRequiredError
+ return pixbuf.subpixbuf(x, y, w, h)
+
+ def _write_animated_pixbuf_to_files(self, path_format, image_format):
+ """Writes image files from self.spinner_images.animated_pixbufs
+
+ - path_format should be a format string with one occurrence of a
+ string substitution, such as '/tmp/animation_%s.png'
+ - image_format can be either 'png' or 'jpeg'
+ """
+ counter = 0
+ for i in self.spinner_images.animated_pixbufs:
+ i.save(path_format % counter, "png")
+ counter += 1
+
+ def _write_static_pixbuf_to_file(self, key_name, path_name, image_format):
+ self.spinner_images.static_pixbufs[key_name].save(path_name,
+ image_format)
+
+
+class HIGSpinner(Gtk.EventBox):
+ """Simple spinner, such as the one found in webbrowsers and file managers.
+
+ You can construct it with the optional parameters:
+ * images, a list of images that will make up the animation
+ * width, the width that will be set for the images
+ * height, the height that will be set for the images
+ """
+
+ #__gsignals__ = {'expose-event': 'override',
+ # 'size-request': 'override'}
+
+ def __init__(self):
+ Gtk.EventBox.__init__(self)
+
+ #self.set_events(self.get_events())
+
+ # This holds a GDK Graphic Context
+ self.gc = None
+
+ # These are sane defaults, but should really come from the images
+ self.images_width = 32
+ self.images_height = 32
+
+ # Timeout set to 100 milliseconds per frame, just as the
+ # Nautilus/Epiphany implementation
+ self.timeout = 120
+
+ # Initialize a cache for ourselves
+ self.cache = HIGSpinnerCache()
+ self.cache.load_static_from_lookup()
+ self.cache.load_animated_from_lookup()
+
+ # timer_task it the gobject.timeout_add identifier (when the animation
+ # is in progress, and __bump_frame is being continually called). If the
+ # spinner is static, timer_task is 0
+ self.timer_task = 0
+ # animated_pixbuf_index is a index on
+ self.animated_pixbuf_index = 0
+ # current_pixbuf is initially the default rest_pixbuf
+ self.current_pixbuf = self.cache.spinner_images.rest_pixbuf
+
+ def __bump_frame(self):
+ """This function moves the animated frame to the next one, or, if it's
+ currently the last one, back to the first one"""
+ animated_list = self.cache.spinner_images.animated_pixbufs
+ if self.animated_pixbuf_index == (len(animated_list) - 1):
+ # back to the first one
+ self.animated_pixbuf_index = 0
+ else:
+ # go the next one
+ self.animated_pixbuf_index += 1
+
+ self.queue_draw()
+ return True
+
+ def __select_pixbuf(self):
+ """This selects either a rest pixbuf or a animation frame based on the
+ status of timer_task."""
+ if self.timer_task == 0:
+ self.current_pixbuf = self.cache.spinner_images.rest_pixbuf
+ else:
+ self.current_pixbuf = self.cache.spinner_images.animated_pixbufs[
+ self.animated_pixbuf_index]
+
+ def start(self):
+ """Starts the animation"""
+ if self.timer_task == 0:
+ self.timer_task = GLib.timeout_add(self.timeout,
+ self.__bump_frame)
+
+ def pause(self):
+ """Pauses the animation"""
+ if self.timer_task != 0:
+ GLib.source_remove(self.timer_task)
+
+ self.timer_task = 0
+ self.queue_draw()
+
+ def stop(self):
+ """Stops the animation
+
+ Do the same stuff as pause, but returns the animation to the
+ beginning."""
+ self.pause()
+ self.animated_pixbuf_index = 0
+
+ def set_speed(speed_in_milliseconds):
+ self.timeout = speed_in_milliseconds
+ self.pause()
+ self.start()
+
+ def do_expose_event(self, event):
+ #self.chain(event)
+
+ if self.cache.spinner_images.rest_pixbuf is None:
+ raise RestPixbufNotFound
+
+ self.__select_pixbuf()
+
+ 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
+
+ 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
+#
+# 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
+
+ # 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
diff --git a/zenmap/zenmapGUI/higwidgets/higtables.py b/zenmap/zenmapGUI/higwidgets/higtables.py
new file mode 100644
index 0000000..0337cf6
--- /dev/null
+++ b/zenmap/zenmapGUI/higwidgets/higtables.py
@@ -0,0 +1,96 @@
+#!/usr/bin/env python3
+
+# ***********************IMPORTANT NMAP LICENSE TERMS************************
+# *
+# * The Nmap Security Scanner is (C) 1996-2023 Nmap Software LLC ("The Nmap
+# * Project"). Nmap is also a registered trademark of the Nmap Project.
+# *
+# * This program is distributed under the terms of the Nmap Public Source
+# * License (NPSL). The exact license text applying to a particular Nmap
+# * release or source code control revision is contained in the LICENSE
+# * file distributed with that version of Nmap or source code control
+# * revision. More Nmap copyright/legal information is available from
+# * https://nmap.org/book/man-legal.html, and further information on the
+# * NPSL license itself can be found at https://nmap.org/npsl/ . This
+# * header summarizes some key points from the Nmap license, but is no
+# * substitute for the actual license text.
+# *
+# * Nmap is generally free for end users to download and use themselves,
+# * including commercial use. It is available from https://nmap.org.
+# *
+# * The Nmap license generally prohibits companies from using and
+# * redistributing Nmap in commercial products, but we sell a special Nmap
+# * OEM Edition with a more permissive license and special features for
+# * this purpose. See https://nmap.org/oem/
+# *
+# * If you have received a written Nmap license agreement or contract
+# * stating terms other than these (such as an Nmap OEM license), you may
+# * choose to use and redistribute Nmap under those terms instead.
+# *
+# * The official Nmap Windows builds include the Npcap software
+# * (https://npcap.com) for packet capture and transmission. It is under
+# * separate license terms which forbid redistribution without special
+# * permission. So the official Nmap Windows builds may not be redistributed
+# * without special permission (such as an Nmap OEM license).
+# *
+# * Source is provided to this software because we believe users have a
+# * right to know exactly what a program is going to do before they run it.
+# * This also allows you to audit the software for security holes.
+# *
+# * Source code also allows you to port Nmap to new platforms, fix bugs, and add
+# * new features. You are highly encouraged to submit your changes as a Github PR
+# * or by email to the dev@nmap.org mailing list for possible incorporation into
+# * the main distribution. Unless you specify otherwise, it is understood that
+# * you are offering us very broad rights to use your submissions as described in
+# * the Nmap Public Source License Contributor Agreement. This is important
+# * because we fund the project by selling licenses with various terms, and also
+# * because the inability to relicense code has caused devastating problems for
+# * other Free Software projects (such as KDE and NASM).
+# *
+# * The free version of Nmap is distributed in the hope that it will be
+# * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Warranties,
+# * indemnification and commercial support are all available through the
+# * Npcap OEM program--see https://nmap.org/oem/
+# *
+# ***************************************************************************/
+
+"""
+higwidgets/higlogindialog.py
+
+ a basic login/authentication dialog
+"""
+
+__all__ = ['HIGTable']
+
+import gi
+
+gi.require_version("Gtk", "3.0")
+from gi.repository import Gtk
+
+#from higlabels import *
+#from higentries import *
+
+
+class HIGTable(Gtk.Table):
+ """
+ A HIGFied table
+ """
+
+ # TODO:
+ # - Automatic position packing,
+ # - Generic attach function that detects the widget type
+
+ def __init__(self, rows=1, columns=1, homogeneous=False):
+ Gtk.Table.__init__(self, n_rows=rows, n_columns=columns, homogeneous=homogeneous)
+ self.set_row_spacings(6)
+ self.set_col_spacings(12)
+
+ self.rows = rows
+ self.columns = columns
+
+ def attach_label(self, widget, x0, x, y0, y):
+ 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.AttachOptions.FILL | Gtk.AttachOptions.EXPAND)
diff --git a/zenmap/zenmapGUI/higwidgets/higtextviewers.py b/zenmap/zenmapGUI/higwidgets/higtextviewers.py
new file mode 100644
index 0000000..1b2d2f0
--- /dev/null
+++ b/zenmap/zenmapGUI/higwidgets/higtextviewers.py
@@ -0,0 +1,76 @@
+#!/usr/bin/env python3
+
+# ***********************IMPORTANT NMAP LICENSE TERMS************************
+# *
+# * The Nmap Security Scanner is (C) 1996-2023 Nmap Software LLC ("The Nmap
+# * Project"). Nmap is also a registered trademark of the Nmap Project.
+# *
+# * This program is distributed under the terms of the Nmap Public Source
+# * License (NPSL). The exact license text applying to a particular Nmap
+# * release or source code control revision is contained in the LICENSE
+# * file distributed with that version of Nmap or source code control
+# * revision. More Nmap copyright/legal information is available from
+# * https://nmap.org/book/man-legal.html, and further information on the
+# * NPSL license itself can be found at https://nmap.org/npsl/ . This
+# * header summarizes some key points from the Nmap license, but is no
+# * substitute for the actual license text.
+# *
+# * Nmap is generally free for end users to download and use themselves,
+# * including commercial use. It is available from https://nmap.org.
+# *
+# * The Nmap license generally prohibits companies from using and
+# * redistributing Nmap in commercial products, but we sell a special Nmap
+# * OEM Edition with a more permissive license and special features for
+# * this purpose. See https://nmap.org/oem/
+# *
+# * If you have received a written Nmap license agreement or contract
+# * stating terms other than these (such as an Nmap OEM license), you may
+# * choose to use and redistribute Nmap under those terms instead.
+# *
+# * The official Nmap Windows builds include the Npcap software
+# * (https://npcap.com) for packet capture and transmission. It is under
+# * separate license terms which forbid redistribution without special
+# * permission. So the official Nmap Windows builds may not be redistributed
+# * without special permission (such as an Nmap OEM license).
+# *
+# * Source is provided to this software because we believe users have a
+# * right to know exactly what a program is going to do before they run it.
+# * This also allows you to audit the software for security holes.
+# *
+# * Source code also allows you to port Nmap to new platforms, fix bugs, and add
+# * new features. You are highly encouraged to submit your changes as a Github PR
+# * or by email to the dev@nmap.org mailing list for possible incorporation into
+# * the main distribution. Unless you specify otherwise, it is understood that
+# * you are offering us very broad rights to use your submissions as described in
+# * the Nmap Public Source License Contributor Agreement. This is important
+# * because we fund the project by selling licenses with various terms, and also
+# * because the inability to relicense code has caused devastating problems for
+# * other Free Software projects (such as KDE and NASM).
+# *
+# * The free version of Nmap is distributed in the hope that it will be
+# * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Warranties,
+# * indemnification and commercial support are all available through the
+# * Npcap OEM program--see https://nmap.org/oem/
+# *
+# ***************************************************************************/
+
+"""
+higwidgets/higtextviewers.py
+
+ text viewers related classes
+"""
+
+__all__ = ['HIGTextView']
+
+import gi
+
+gi.require_version("Gtk", "3.0")
+from gi.repository import Gtk
+
+
+class HIGTextView(Gtk.TextView):
+ def __init__(self, text=''):
+ Gtk.TextView.__init__(self)
+ self.set_wrap_mode(Gtk.WrapMode.WORD)
+ self.get_buffer().set_text(text)
diff --git a/zenmap/zenmapGUI/higwidgets/higwindows.py b/zenmap/zenmapGUI/higwidgets/higwindows.py
new file mode 100644
index 0000000..0ec4df3
--- /dev/null
+++ b/zenmap/zenmapGUI/higwidgets/higwindows.py
@@ -0,0 +1,80 @@
+#!/usr/bin/env python3
+
+# ***********************IMPORTANT NMAP LICENSE TERMS************************
+# *
+# * The Nmap Security Scanner is (C) 1996-2023 Nmap Software LLC ("The Nmap
+# * Project"). Nmap is also a registered trademark of the Nmap Project.
+# *
+# * This program is distributed under the terms of the Nmap Public Source
+# * License (NPSL). The exact license text applying to a particular Nmap
+# * release or source code control revision is contained in the LICENSE
+# * file distributed with that version of Nmap or source code control
+# * revision. More Nmap copyright/legal information is available from
+# * https://nmap.org/book/man-legal.html, and further information on the
+# * NPSL license itself can be found at https://nmap.org/npsl/ . This
+# * header summarizes some key points from the Nmap license, but is no
+# * substitute for the actual license text.
+# *
+# * Nmap is generally free for end users to download and use themselves,
+# * including commercial use. It is available from https://nmap.org.
+# *
+# * The Nmap license generally prohibits companies from using and
+# * redistributing Nmap in commercial products, but we sell a special Nmap
+# * OEM Edition with a more permissive license and special features for
+# * this purpose. See https://nmap.org/oem/
+# *
+# * If you have received a written Nmap license agreement or contract
+# * stating terms other than these (such as an Nmap OEM license), you may
+# * choose to use and redistribute Nmap under those terms instead.
+# *
+# * The official Nmap Windows builds include the Npcap software
+# * (https://npcap.com) for packet capture and transmission. It is under
+# * separate license terms which forbid redistribution without special
+# * permission. So the official Nmap Windows builds may not be redistributed
+# * without special permission (such as an Nmap OEM license).
+# *
+# * Source is provided to this software because we believe users have a
+# * right to know exactly what a program is going to do before they run it.
+# * This also allows you to audit the software for security holes.
+# *
+# * Source code also allows you to port Nmap to new platforms, fix bugs, and add
+# * new features. You are highly encouraged to submit your changes as a Github PR
+# * or by email to the dev@nmap.org mailing list for possible incorporation into
+# * the main distribution. Unless you specify otherwise, it is understood that
+# * you are offering us very broad rights to use your submissions as described in
+# * the Nmap Public Source License Contributor Agreement. This is important
+# * because we fund the project by selling licenses with various terms, and also
+# * because the inability to relicense code has caused devastating problems for
+# * other Free Software projects (such as KDE and NASM).
+# *
+# * The free version of Nmap is distributed in the hope that it will be
+# * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Warranties,
+# * indemnification and commercial support are all available through the
+# * Npcap OEM program--see https://nmap.org/oem/
+# *
+# ***************************************************************************/
+
+"""
+higwidgets/higwindows.py
+
+ window related classes
+"""
+
+import gi
+
+gi.require_version("Gtk", "3.0")
+from gi.repository import Gtk
+
+__all__ = ('HIGWindow', 'HIGMainWindow')
+
+
+class HIGWindow(Gtk.Window):
+ """HIGFied Window"""
+ 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