mirror of
https://github.com/nmap/nmap.git
synced 2025-12-07 21:21:31 +00:00
Merge #2088: Update Zenmap to Python 3 and PyGObject
Note: Ndiff build will be broken until subsequent changes are made. Deprecation warnings will need to be addressed in future changes. Closes #2088
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -58,8 +57,11 @@
|
||||
# * *
|
||||
# ***************************************************************************/
|
||||
|
||||
import gtk
|
||||
import gobject
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, GLib, GdkPixbuf
|
||||
|
||||
import re
|
||||
import os.path
|
||||
|
||||
@@ -93,7 +95,7 @@ if pixmap_path:
|
||||
def get_pixmap_file_names(icon_name, size):
|
||||
yield '%s_%s.png' % (icon_name, size)
|
||||
|
||||
iconfactory = gtk.IconFactory()
|
||||
iconfactory = Gtk.IconFactory()
|
||||
for icon_name in icon_names:
|
||||
for type, size in (('icon', '32'), ('logo', '75')):
|
||||
key = '%s_%s' % (icon_name, type)
|
||||
@@ -101,9 +103,9 @@ if pixmap_path:
|
||||
for file_name in get_pixmap_file_names(icon_name, size):
|
||||
file_path = os.path.join(pixmap_path, file_name)
|
||||
try:
|
||||
pixbuf = gtk.gdk.pixbuf_new_from_file(file_path)
|
||||
pixbuf = GdkPixbuf.Pixbuf.new_from_file(file_path)
|
||||
break
|
||||
except gobject.GError:
|
||||
except GLib.GError:
|
||||
# Try again.
|
||||
pass
|
||||
else:
|
||||
@@ -113,7 +115,7 @@ if pixmap_path:
|
||||
', '.join(get_pixmap_file_names(icon_name, size)),
|
||||
pixmap_path))
|
||||
continue
|
||||
iconset = gtk.IconSet(pixbuf)
|
||||
iconset = Gtk.IconSet(pixbuf=pixbuf)
|
||||
iconfactory.add(key, iconset)
|
||||
log.debug('Register %s icon name for file %s' % (key, file_path))
|
||||
iconfactory.add_default()
|
||||
|
||||
Reference in New Issue
Block a user