diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 07:42:04 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 07:42:04 +0000 |
commit | 0d47952611198ef6b1163f366dc03922d20b1475 (patch) | |
tree | 3d840a3b8c0daef0754707bfb9f5e873b6b1ac13 /zenmap/radialnet/bestwidgets | |
parent | Initial commit. (diff) | |
download | nmap-0d47952611198ef6b1163f366dc03922d20b1475.tar.xz nmap-0d47952611198ef6b1163f366dc03922d20b1475.zip |
Adding upstream version 7.94+git20230807.3be01efb1+dfsg.upstream/7.94+git20230807.3be01efb1+dfsgupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | zenmap/radialnet/bestwidgets/__init__.py | 72 | ||||
-rw-r--r-- | zenmap/radialnet/bestwidgets/boxes.py | 202 | ||||
-rw-r--r-- | zenmap/radialnet/bestwidgets/buttons.py | 91 | ||||
-rw-r--r-- | zenmap/radialnet/bestwidgets/comboboxes.py | 135 | ||||
-rw-r--r-- | zenmap/radialnet/bestwidgets/expanders.py | 97 | ||||
-rw-r--r-- | zenmap/radialnet/bestwidgets/frames.py | 96 | ||||
-rw-r--r-- | zenmap/radialnet/bestwidgets/labels.py | 94 | ||||
-rw-r--r-- | zenmap/radialnet/bestwidgets/textview.py | 209 | ||||
-rw-r--r-- | zenmap/radialnet/bestwidgets/windows.py | 103 |
9 files changed, 1099 insertions, 0 deletions
diff --git a/zenmap/radialnet/bestwidgets/__init__.py b/zenmap/radialnet/bestwidgets/__init__.py new file mode 100644 index 0000000..03877f0 --- /dev/null +++ b/zenmap/radialnet/bestwidgets/__init__.py @@ -0,0 +1,72 @@ +# vim: set fileencoding=utf-8 : + +# ***********************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 + +gtk_version_major, gtk_version_minor, gtk_version_release = gi.version_info + +#from boxes import BWHBox, BWVBox, BWTable, BWStatusbar, BWScrolledWindow +#from buttons import BWStockButton, BWToggleStockButton +#from comboboxes import BWChangeableComboBoxEntry +#from expanders import BWExpander +#from frames import BWFrame +#from labels import BWLabel, BWSectionLabel +#from textview import BWTextView, BWTextEditor +#from windows import BWWindow, BWMainWindow, BWAlertDialog diff --git a/zenmap/radialnet/bestwidgets/boxes.py b/zenmap/radialnet/bestwidgets/boxes.py new file mode 100644 index 0000000..5b43a90 --- /dev/null +++ b/zenmap/radialnet/bestwidgets/boxes.py @@ -0,0 +1,202 @@ +# vim: set fileencoding=utf-8 : + +# ***********************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 + +__all__ = ('BWBox', 'BWHBox', 'BWVBox', + 'BWStatusbar', 'BWTable', 'BWScrolledWindow') + + +class BWBox(Gtk.Box): + """ + """ + def bw_pack_start_expand_fill(self, widget, padding=0): + """ + """ + self.pack_start(widget, True, True, padding) + + def bw_pack_start_expand_nofill(self, widget, padding=0): + """ + """ + self.pack_start(widget, True, False, padding) + + def bw_pack_start_noexpand_nofill(self, widget, padding=0): + """ + """ + self.pack_start(widget, False, False, padding) + + def bw_pack_end_expand_fill(self, widget, padding=0): + """ + """ + self.pack_end(widget, True, True, padding) + + def bw_pack_end_expand_nofill(self, widget, padding=0): + """ + """ + self.pack_end(widget, True, False, padding) + + def bw_pack_end_noexpand_nofill(self, widget, padding=0): + """ + """ + self.pack_end(widget, False, False, padding) + + +class BWHBox(BWBox): + """ + """ + def __init__(self, homogeneous=False, spacing=12): + """ + """ + Gtk.Box.__init__(self, orientation=Gtk.Orientation.HORIZONTAL, + homogeneous=homogeneous, spacing=spacing) + + +class BWVBox(BWBox): + """ + """ + def __init__(self, homogeneous=False, spacing=12): + """ + """ + Gtk.Box.__init__(self, orientation=Gtk.Orientation.VERTICAL, + homogeneous=homogeneous, spacing=spacing) + + +class BWStatusbar(Gtk.Statusbar, BWBox): + """ + """ + def __init__(self, homogeneous=False, spacing=12): + """ + """ + Gtk.Box.__init__(self, orientation=Gtk.Orientation.HORIZONTAL, + homogeneous=homogeneous, spacing=spacing) + + +class BWTable(Gtk.Table, BWBox): + """ + """ + def __init__(self, rows=1, columns=1, homogeneous=False): + """ + """ + Gtk.Table.__init__(self, n_rows=rows, n_columns=columns, + homogeneous=homogeneous) + self.bw_set_spacing(12) + + self.__rows = rows + self.__columns = columns + + self.__last_point = (0, 0) + + def bw_set_spacing(self, spacing): + """ + """ + self.set_row_spacings(spacing) + self.set_col_spacings(spacing) + + def bw_resize(self, rows, columns): + """ + """ + self.__rows = rows + self.__columns = columns + + self.resize(rows, columns) + + def bw_attach_next(self, + child, + xoptions=Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL, + yoptions=Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL, + xpadding=0, + ypadding=0): + """ + """ + row, column = self.__last_point + + if row != self.__rows: + + self.attach(child, + column, + column + 1, + row, + row + 1, + xoptions, + yoptions, + xpadding, + ypadding) + + if column + 1 == self.__columns: + + column = 0 + row += 1 + + else: + column += 1 + + self.__last_point = (row, column) + + +class BWScrolledWindow(Gtk.ScrolledWindow): + """ + """ + def __init__(self): + """ + """ + Gtk.ScrolledWindow.__init__(self) + self.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) + self.set_shadow_type(Gtk.ShadowType.NONE) + self.set_border_width(6) diff --git a/zenmap/radialnet/bestwidgets/buttons.py b/zenmap/radialnet/bestwidgets/buttons.py new file mode 100644 index 0000000..3d3239d --- /dev/null +++ b/zenmap/radialnet/bestwidgets/buttons.py @@ -0,0 +1,91 @@ +# vim: set fileencoding=utf-8 : + +# ***********************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 + + +class BWStockButton(Gtk.Button): + """ + """ + def __init__(self, stock, text=None, size=Gtk.IconSize.BUTTON): + """ + """ + Gtk.Button.__init__(self, label=text) + + self.__size = size + + self.__image = Gtk.Image() + self.__image.set_from_stock(stock, self.__size) + self.set_image(self.__image) + + +class BWToggleStockButton(Gtk.ToggleButton): + """ + """ + def __init__(self, stock, text=None, size=Gtk.IconSize.BUTTON): + """ + """ + Gtk.ToggleButton.__init__(self, label=text) + + self.__size = size + + self.__image = Gtk.Image() + self.__image.set_from_stock(stock, self.__size) + self.set_image(self.__image) diff --git a/zenmap/radialnet/bestwidgets/comboboxes.py b/zenmap/radialnet/bestwidgets/comboboxes.py new file mode 100644 index 0000000..e10d7e6 --- /dev/null +++ b/zenmap/radialnet/bestwidgets/comboboxes.py @@ -0,0 +1,135 @@ +# vim: set fileencoding=utf-8 : + +# ***********************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 + + +class BWChangeableComboBoxEntry(Gtk.ComboBoxText): + """ + """ + def __init__(self): + """ + """ + self.__liststore = Gtk.ListStore.new([str]) + + Gtk.ComboBoxText.__init__(self, model=self.__liststore, has_entry=True) + + self.connect("changed", self.__changed) + self.get_child().connect("changed", self.__entry_changed) + + self.__last_active = None + + def __changed(self, widget): + """ + """ + if self.get_active() != -1: + self.__last_active = self.get_active() + + def bw_get_length(self): + """ + """ + return len(self.__liststore) + + def __entry_changed(self, widget): + """ + """ + if len(self.__liststore) > 0 and\ + self.__last_active is not None and\ + self.get_active() == -1: + + iter = self.get_model().get_iter((self.__last_active,)) + self.__liststore.set_value(iter, 0, widget.get_text().strip()) + + def bw_get_active(self): + """ + """ + if self.get_active() == -1: + return self.__last_active + + return self.get_active() + + +# testing widget +if __name__ == "__main__": + + def button_clicked(widget, combo): + """ + """ + combo.append_text('New') + + window = Gtk.Window() + window.connect("destroy", lambda w: Gtk.main_quit()) + + box = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, 0) + + combo = BWChangeableComboBoxEntry() + combo.append_text('New') + combo.set_active(0) + + button = Gtk.Button.new_with_label('More') + button.connect("clicked", button_clicked, combo) + + box.pack_start(button, False, False, 0) + box.pack_start(combo, True, True, 0) + + window.add(box) + window.show_all() + + Gtk.main() diff --git a/zenmap/radialnet/bestwidgets/expanders.py b/zenmap/radialnet/bestwidgets/expanders.py new file mode 100644 index 0000000..a89e08b --- /dev/null +++ b/zenmap/radialnet/bestwidgets/expanders.py @@ -0,0 +1,97 @@ +# vim: set fileencoding=utf-8 : + +# ***********************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 +from radialnet.bestwidgets.labels import BWSectionLabel + + +class BWExpander(Gtk.Expander): + """ + """ + def __init__(self, label=''): + """ + """ + Gtk.Expander.__init__(self) + + self.__label = BWSectionLabel(label) + self.set_label_widget(self.__label) + + self.__alignment = Gtk.Alignment.new(0, 0, 1, 1) + self.__alignment.set_padding(12, 0, 24, 0) + + self.add(self.__alignment) + + def bw_set_label_text(self, text): + """ + """ + self.__label.bw_set_text(text) + + def bw_add(self, widget): + """ + """ + if len(self.__alignment.get_children()) > 0: + self.__alignment.remove(self.__alignment.get_children()[0]) + + self.__alignment.add(widget) + + def bw_no_padding(self): + """ + """ + self.__alignment.set_padding(0, 0, 0, 0) diff --git a/zenmap/radialnet/bestwidgets/frames.py b/zenmap/radialnet/bestwidgets/frames.py new file mode 100644 index 0000000..3a35021 --- /dev/null +++ b/zenmap/radialnet/bestwidgets/frames.py @@ -0,0 +1,96 @@ +# vim: set fileencoding=utf-8 : + +# ***********************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, Gdk + + +class BWFrame(Gtk.Frame): + """ + """ + def __init__(self, label=''): + """ + """ + Gtk.Frame.__init__(self) + + self.set_border_width(3) + self.set_shadow_type(Gtk.ShadowType.NONE) + + self.__alignment = Gtk.Alignment.new(0, 0, 1, 1) + self.__alignment.set_padding(12, 0, 24, 0) + + self.add(self.__alignment) + + self.bw_set_label(label) + + def bw_set_label(self, label): + """ + """ + self.set_label("<b>" + label + "</b>") + self.get_label_widget().set_use_markup(True) + + def bw_add(self, widget): + """ + """ + self.__alignment.add(widget) + + def bw_remove(self, widget): + """ + """ + self.__alignment.remove(widget) diff --git a/zenmap/radialnet/bestwidgets/labels.py b/zenmap/radialnet/bestwidgets/labels.py new file mode 100644 index 0000000..c3ec94f --- /dev/null +++ b/zenmap/radialnet/bestwidgets/labels.py @@ -0,0 +1,94 @@ +# vim: set fileencoding=utf-8 : + +# ***********************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 + + +class BWLabel(Gtk.Label): + """ + """ + def __init__(self, text=''): + """ + """ + Gtk.Label.__init__(self) + + self.set_text(text) + self.set_justify(Gtk.Justification.LEFT) + self.set_alignment(0, 0.50) + self.set_line_wrap(True) + + +class BWSectionLabel(Gtk.Label): + """ + """ + def __init__(self, text=''): + """ + """ + Gtk.Label.__init__(self) + + self.set_markup('<b>' + text + '</b>') + self.set_justify(Gtk.Justification.LEFT) + self.set_alignment(0, 0.50) + self.set_line_wrap(True) + + def bw_set_text(self, text): + """ + """ + self.set_markup('<b>' + text + '</b>') diff --git a/zenmap/radialnet/bestwidgets/textview.py b/zenmap/radialnet/bestwidgets/textview.py new file mode 100644 index 0000000..9deda93 --- /dev/null +++ b/zenmap/radialnet/bestwidgets/textview.py @@ -0,0 +1,209 @@ +# vim: set fileencoding=utf-8 : + +# ***********************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 +from radialnet.bestwidgets.boxes import * + + +class BWTextView(BWScrolledWindow): + """ + """ + def __init__(self): + """ + """ + BWScrolledWindow.__init__(self) + + self.__auto_scroll = False + + self.__create_widgets() + + def __create_widgets(self): + """ + """ + self.__textbuffer = Gtk.TextBuffer() + self.__textview = Gtk.TextView.new_with_buffer(self.__textbuffer) + + self.add_with_viewport(self.__textview) + + def bw_set_auto_scroll(self, value): + """ + """ + self.__auto_scroll = value + + def bw_set_editable(self, editable): + """ + """ + self.__textview.set_editable(False) + + def bw_modify_font(self, font): + """ + """ + self.__textview.modify_font(font) + + def bw_set_text(self, text): + """ + """ + self.__textbuffer.set_text(text) + + if self.__auto_scroll: + self.bw_set_scroll_down() + + def bw_get_text(self): + """ + """ + return self.__textbuffer.get_text(self.__textbuffer.get_start_iter(), + self.__textbuffer.get_end_iter()) + + def bw_set_scroll_down(self): + """ + """ + self.get_vadjustment().set_value(self.get_vadjustment().upper) + + def bw_get_textbuffer(self): + """ + """ + return self.__textbuffer + + +class BWTextEditor(BWScrolledWindow): + """ + """ + def __init__(self): + """ + """ + BWScrolledWindow.__init__(self) + self.connect('draw', self.__draw) + + self.__auto_scroll = False + + self.__create_widgets() + + def __create_widgets(self): + """ + """ + self.__hbox = BWHBox(spacing=6) + + self.__textbuffer = Gtk.TextBuffer() + self.__textview = Gtk.TextView.new_with_buffer(self.__textbuffer) + + self.__linebuffer = Gtk.TextBuffer() + self.__lineview = Gtk.TextView.new_with_buffer(self.__linebuffer) + self.__lineview.set_justification(Gtk.Justification.RIGHT) + self.__lineview.set_editable(False) + self.__lineview.set_sensitive(False) + + self.__hbox.bw_pack_start_noexpand_nofill(self.__lineview) + self.__hbox.bw_pack_start_expand_fill(self.__textview) + + self.add_with_viewport(self.__hbox) + + def __draw(self, widget, event): + """ + """ + # code to fix a gtk issue that don't show text correctly + self.__hbox.check_resize() + + def bw_set_auto_scroll(self, value): + """ + """ + self.__auto_scroll = value + + def bw_set_editable(self, editable): + """ + """ + self.__textview.set_editable(False) + + def bw_modify_font(self, font): + """ + """ + self.__textview.modify_font(font) + self.__lineview.modify_font(font) + + def bw_set_text(self, text): + """ + """ + if text != "": + + count = text.count('\n') + text.count('\r') + + lines = range(1, count + 2) + lines = [str(i).strip() for i in lines] + + self.__textbuffer.set_text(text) + self.__linebuffer.set_text('\n'.join(lines)) + + if self.__auto_scroll: + self.bw_set_scroll_down() + + else: + + self.__textbuffer.set_text("") + self.__linebuffer.set_text("") + + def bw_get_text(self): + """ + """ + return self.__textbuffer.get_text(self.__textbuffer.get_start_iter(), + self.__textbuffer.get_end_iter()) + + def bw_set_scroll_down(self): + """ + """ + self.get_vadjustment().set_value(self.get_vadjustment().upper) diff --git a/zenmap/radialnet/bestwidgets/windows.py b/zenmap/radialnet/bestwidgets/windows.py new file mode 100644 index 0000000..fe61162 --- /dev/null +++ b/zenmap/radialnet/bestwidgets/windows.py @@ -0,0 +1,103 @@ +# vim: set fileencoding=utf-8 : + +# ***********************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 + +PRIMARY_TEXT_MARKUP = '<span weight="bold" size="larger">%s</span>' + + +class BWAlertDialog(Gtk.MessageDialog): + """ + """ + def __init__(self, parent=None, flags=0, type=Gtk.MessageType.INFO, + buttons=Gtk.ButtonsType.OK, + primary_text=None, + secondary_text=None): + + Gtk.MessageDialog.__init__(self, parent=parent, flags=flags, + message_type=type, buttons=buttons) + + self.connect('response', self.__destroy) + + self.set_resizable(False) + + self.set_title(_("Alert")) + self.set_markup(PRIMARY_TEXT_MARKUP % primary_text) + + if secondary_text: + self.format_secondary_text(secondary_text) + + def __destroy(self, dialog, id): + """ + """ + self.destroy() + + +class BWWindow(Gtk.Window): + """ + """ + def __init__(self, type=Gtk.WindowType.TOPLEVEL): + """ + """ + Gtk.Window.__init__(self, type=type) + self.set_border_width(5) + + +BWMainWindow = Gtk.Window |