Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python 3 and pygobject port of Zenmap #2088

Closed
wants to merge 33 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
2e3c2ab
Initial Python 3 & GTK-3.0 changes
kulikjak Jul 23, 2020
109820c
Additional changes to make it run
kulikjak Jul 23, 2020
0edaec2
Mostly packing and several other fixes
kulikjak Jul 23, 2020
81e3460
Revert higboxes.py changes because of broken layout
kulikjak Jul 23, 2020
328aa46
More GTK 3 related fixes
kulikjak Jul 24, 2020
3a11a4c
More fixes
kulikjak Jul 24, 2020
9e35bc0
Minor layout fix
kulikjak Jul 24, 2020
d14a468
Fixed DiffCompare
kulikjak Jul 24, 2020
e1cbd81
Fix radialnet Image array
kulikjak Jul 25, 2020
0c5f672
Fix division changes
kulikjak Jul 25, 2020
c422e22
Fix radialnet gui
kulikjak Jul 25, 2020
2f5a17b
Update higwidgets, fix some deprecations and visual issues
kulikjak Jul 26, 2020
6618230
Fix small search GUI bug
kulikjak Jul 26, 2020
4df9142
Minor fixes
kulikjak Jul 26, 2020
2a9fa5d
Fix rebase related issues
kulikjak Jul 27, 2020
eb181e5
Remove deprecated positional arguments from GObject constructors
kulikjak Jul 28, 2020
b2ac2c6
Use named functions rather than overloaded initializers
kulikjak Jul 28, 2020
b36528f
Replace deprecated Gtk.Arrow with Gtk.Image and appropriate icon
kulikjak Jul 28, 2020
939b9d4
Replace deprecated Gtk.HButtonBox and Gtk.HPaned
kulikjak Jul 28, 2020
74fc6d9
Replace deprecated Gtk.HBox and Gtk.VBox
kulikjak Jul 28, 2020
5a227d9
Remove now obsolete code branches
kulikjak Jul 28, 2020
5abb5f1
Fix CrashReport window width
kulikjak Jul 30, 2020
d26cedd
Fix and update help functionality
kulikjak Jul 30, 2020
c488b5f
Clean up the database interface
kulikjak Jul 30, 2020
ef948e5
Fix NmapOutputProperties example update
kulikjak Jul 30, 2020
60e936f
Clean radialnet draw signal handlers
kulikjak Jul 30, 2020
ab3094c
Revert unnecessary property changes
kulikjak Jul 30, 2020
df54b73
Fix minor MainWindow regression
kulikjak Jul 31, 2020
8609f2c
Remove deprecated time.clock()
kulikjak Aug 25, 2022
228d38d
Change shebangs to python3
kulikjak Aug 25, 2022
876ff36
Remove now unnecessary utf-8 source file encoding
kulikjak Aug 25, 2022
d0badb6
Rebase and fix minor issues
kulikjak Aug 25, 2022
8beebdd
Fix TypeError reported on Nmap GitHub PR
kulikjak Aug 25, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions zenmap/install_scripts/utils/version_update.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#!/usr/bin/env python3

# ***********************IMPORTANT NMAP LICENSE TERMS************************
# * *
Expand Down Expand Up @@ -75,7 +74,7 @@

def update_date(base_dir):
name_file = os.path.join(base_dir, NAME_PY)
print ">>> Updating %s" % name_file
print(">>> Updating %s" % name_file)
nf = open(name_file, "r")
ncontent = nf.read()
nf.close()
Expand All @@ -89,22 +88,22 @@ def update_date(base_dir):


def update_version(base_dir, version):
print ">>> Updating %s" % os.path.join(base_dir, VERSION)
print(">>> Updating %s" % os.path.join(base_dir, VERSION))
vf = open(os.path.join(base_dir, VERSION), "wb")
print >> vf, version
print(version, file=vf)
vf.close()
print ">>> Updating %s" % os.path.join(base_dir, VERSION_PY)
print(">>> Updating %s" % os.path.join(base_dir, VERSION_PY))
vf = open(os.path.join(base_dir, VERSION_PY), "w")
print >> vf, "VERSION = \"%s\"" % version
print("VERSION = \"%s\"" % version, file=vf)
vf.close()


if __name__ == "__main__":
if len(sys.argv) != 2:
print >> sys.stderr, "Usage: %s <version>" % sys.argv[0]
print("Usage: %s <version>" % sys.argv[0], file=sys.stderr)
sys.exit(1)

version = sys.argv[1]
print ">>> Updating version number to \"%s\"" % version
print(">>> Updating version number to \"%s\"" % version)
update_version(".", version)
update_date(".")
7 changes: 5 additions & 2 deletions zenmap/radialnet/bestwidgets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,12 @@
# * *
# ***************************************************************************/

import gtk
import gi

gtk_version_major, gtk_version_minor, gtk_version_release = gtk.gtk_version
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
Expand Down
39 changes: 23 additions & 16 deletions zenmap/radialnet/bestwidgets/boxes.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,16 @@
# * *
# ***************************************************************************/

import gtk
import gi

gi.require_version("Gtk", "3.0")
from gi.repository import Gtk

__all__ = ('BWBox', 'BWHBox', 'BWVBox',
'BWStatusbar', 'BWTable', 'BWScrolledWindow')


class BWBox(gtk.Box):
class BWBox(Gtk.Box):
"""
"""
def bw_pack_start_expand_fill(self, widget, padding=0):
Expand Down Expand Up @@ -97,40 +100,44 @@ def bw_pack_end_noexpand_nofill(self, widget, padding=0):
self.pack_end(widget, False, False, padding)


class BWHBox(gtk.HBox, BWBox):
class BWHBox(BWBox):
"""
"""
def __init__(self, homogeneous=False, spacing=12):
"""
"""
gtk.HBox.__init__(self, homogeneous, spacing)
Gtk.Box.__init__(self, orientation=Gtk.Orientation.HORIZONTAL,
homogeneous=homogeneous, spacing=spacing)


class BWVBox(gtk.VBox, BWBox):
class BWVBox(BWBox):
"""
"""
def __init__(self, homogeneous=False, spacing=12):
"""
"""
gtk.VBox.__init__(self, homogeneous, spacing)
Gtk.Box.__init__(self, orientation=Gtk.Orientation.VERTICAL,
homogeneous=homogeneous, spacing=spacing)


class BWStatusbar(gtk.Statusbar, BWBox):
class BWStatusbar(Gtk.Statusbar, BWBox):
"""
"""
def __init__(self, homogeneous=False, spacing=12):
"""
"""
gtk.HBox.__init__(self, homogeneous, spacing)
Gtk.Box.__init__(self, orientation=Gtk.Orientation.HORIZONTAL,
homogeneous=homogeneous, spacing=spacing)


class BWTable(gtk.Table, BWBox):
class BWTable(Gtk.Table, BWBox):
"""
"""
def __init__(self, rows=1, columns=1, homogeneous=False):
"""
"""
gtk.Table.__init__(self, rows, columns, homogeneous)
Gtk.Table.__init__(self, n_rows=rows, n_columns=columns,
homogeneous=homogeneous)
self.bw_set_spacing(12)

self.__rows = rows
Expand All @@ -154,8 +161,8 @@ def bw_resize(self, rows, columns):

def bw_attach_next(self,
child,
xoptions=gtk.EXPAND | gtk.FILL,
yoptions=gtk.EXPAND | gtk.FILL,
xoptions=Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL,
yoptions=Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL,
xpadding=0,
ypadding=0):
"""
Expand Down Expand Up @@ -185,13 +192,13 @@ def bw_attach_next(self,
self.__last_point = (row, column)


class BWScrolledWindow(gtk.ScrolledWindow):
class BWScrolledWindow(Gtk.ScrolledWindow):
"""
"""
def __init__(self):
"""
"""
gtk.ScrolledWindow.__init__(self)
self.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
self.set_shadow_type(gtk.SHADOW_NONE)
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)
21 changes: 12 additions & 9 deletions zenmap/radialnet/bestwidgets/buttons.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,34 +57,37 @@
# * *
# ***************************************************************************/

import gtk
import gi

gi.require_version("Gtk", "3.0")
from gi.repository import Gtk

class BWStockButton(gtk.Button):

class BWStockButton(Gtk.Button):
"""
"""
def __init__(self, stock, text=None, size=gtk.ICON_SIZE_BUTTON):
def __init__(self, stock, text=None, size=Gtk.IconSize.BUTTON):
"""
"""
gtk.Button.__init__(self, text)
Gtk.Button.__init__(self, label=text)

self.__size = size

self.__image = gtk.Image()
self.__image = Gtk.Image()
self.__image.set_from_stock(stock, self.__size)
self.set_image(self.__image)


class BWToggleStockButton(gtk.ToggleButton):
class BWToggleStockButton(Gtk.ToggleButton):
"""
"""
def __init__(self, stock, text=None, size=gtk.ICON_SIZE_BUTTON):
def __init__(self, stock, text=None, size=Gtk.IconSize.BUTTON):
"""
"""
gtk.ToggleButton.__init__(self, text)
Gtk.ToggleButton.__init__(self, label=text)

self.__size = size

self.__image = gtk.Image()
self.__image = Gtk.Image()
self.__image.set_from_stock(stock, self.__size)
self.set_image(self.__image)
26 changes: 14 additions & 12 deletions zenmap/radialnet/bestwidgets/comboboxes.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,21 @@
# * *
# ***************************************************************************/

import gtk
import gobject
import gi

gi.require_version("Gtk", "3.0")
from gi.repository import Gtk, GObject

class BWChangeableComboBoxEntry(gtk.ComboBoxEntry):

class BWChangeableComboBoxEntry(Gtk.ComboBoxText):
"""
"""
def __init__(self):
"""
"""
self.__liststore = gtk.ListStore(gobject.TYPE_STRING)
self.__liststore = Gtk.ListStore.new([str])

gtk.ComboBoxEntry.__init__(self, self.__liststore, 0)
Gtk.ComboBoxText.__init__(self, model=self.__liststore, has_entry=True)

self.connect("changed", self.__changed)
self.get_child().connect("changed", self.__entry_changed)
Expand Down Expand Up @@ -114,22 +116,22 @@ def button_clicked(widget, combo):
"""
combo.append_text('New')

window = gtk.Window()
window.connect("destroy", lambda w: gtk.main_quit())
window = Gtk.Window()
window.connect("destroy", lambda w: Gtk.main_quit())

box = gtk.HBox()
box = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, 0)

combo = BWChangeableComboBoxEntry()
combo.append_text('New')
combo.set_active(0)

button = gtk.Button('More')
button = Gtk.Button.new_with_label('More')
button.connect("clicked", button_clicked, combo)

box.pack_start(button, False, False)
box.pack_start(combo, True, True)
box.pack_start(button, False, False, 0)
box.pack_start(combo, True, True, 0)

window.add(box)
window.show_all()

gtk.main()
Gtk.main()
11 changes: 7 additions & 4 deletions zenmap/radialnet/bestwidgets/expanders.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,22 +57,25 @@
# * *
# ***************************************************************************/

import gtk
import gi

gi.require_version("Gtk", "3.0")
from gi.repository import Gtk
from radialnet.bestwidgets.labels import BWSectionLabel


class BWExpander(gtk.Expander):
class BWExpander(Gtk.Expander):
"""
"""
def __init__(self, label=''):
"""
"""
gtk.Expander.__init__(self)
Gtk.Expander.__init__(self)

self.__label = BWSectionLabel(label)
self.set_label_widget(self.__label)

self.__alignment = gtk.Alignment(0, 0, 1, 1)
self.__alignment = Gtk.Alignment.new(0, 0, 1, 1)
self.__alignment.set_padding(12, 0, 24, 0)

self.add(self.__alignment)
Expand Down
13 changes: 8 additions & 5 deletions zenmap/radialnet/bestwidgets/frames.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,21 +57,24 @@
# * *
# ***************************************************************************/

import gtk
import gi

gi.require_version("Gtk", "3.0")
from gi.repository import Gtk, Gdk


class BWFrame(gtk.Frame):
class BWFrame(Gtk.Frame):
"""
"""
def __init__(self, label=''):
"""
"""
gtk.Frame.__init__(self)
Gtk.Frame.__init__(self)

self.set_border_width(3)
self.set_shadow_type(gtk.SHADOW_NONE)
self.set_shadow_type(Gtk.ShadowType.NONE)

self.__alignment = gtk.Alignment(0, 0, 1, 1)
self.__alignment = Gtk.Alignment.new(0, 0, 1, 1)
self.__alignment.set_padding(12, 0, 24, 0)

self.add(self.__alignment)
Expand Down
17 changes: 10 additions & 7 deletions zenmap/radialnet/bestwidgets/labels.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,33 +57,36 @@
# * *
# ***************************************************************************/

import gtk
import gi

gi.require_version("Gtk", "3.0")
from gi.repository import Gtk


class BWLabel(gtk.Label):
class BWLabel(Gtk.Label):
"""
"""
def __init__(self, text=''):
"""
"""
gtk.Label.__init__(self)
Gtk.Label.__init__(self)

self.set_text(text)
self.set_justify(gtk.JUSTIFY_LEFT)
self.set_justify(Gtk.Justification.LEFT)
self.set_alignment(0, 0.50)
self.set_line_wrap(True)


class BWSectionLabel(gtk.Label):
class BWSectionLabel(Gtk.Label):
"""
"""
def __init__(self, text=''):
"""
"""
gtk.Label.__init__(self)
Gtk.Label.__init__(self)

self.set_markup('<b>' + text + '</b>')
self.set_justify(gtk.JUSTIFY_LEFT)
self.set_justify(Gtk.Justification.LEFT)
self.set_alignment(0, 0.50)
self.set_line_wrap(True)

Expand Down
Loading