mirror of
https://github.com/nmap/nmap.git
synced 2026-08-04 14:49:29 +00:00
Resolve more deprecation warnings regarding Buttons and Images
This commit is contained in:
parent
51a3d3de22
commit
b45f865fb9
9 changed files with 52 additions and 81 deletions
|
|
@ -62,21 +62,19 @@ gi.require_version("Gtk", "3.0")
|
|||
from gi.repository import Gtk
|
||||
|
||||
|
||||
class BWStockButton(Gtk.Button):
|
||||
"""
|
||||
"""
|
||||
def __init__(self, stock, text=None):
|
||||
class _BWButton:
|
||||
def __init__(self, klass, stock, text=None):
|
||||
"""
|
||||
"""
|
||||
Gtk.Button.__init__(self, label=text)
|
||||
self.set_icon_name(stock)
|
||||
klass.__init__(self, label=text)
|
||||
img = Gtk.Image.new_from_icon_name(stock, Gtk.IconSize.BUTTON)
|
||||
self.set_image(img)
|
||||
|
||||
class BWStockButton(Gtk.Button, _BWButton):
|
||||
def __init__(self, *args, **kwargs):
|
||||
_BWButton.__init__(self, Gtk.Button, *args, **kwargs)
|
||||
|
||||
|
||||
class BWToggleStockButton(Gtk.ToggleButton):
|
||||
"""
|
||||
"""
|
||||
def __init__(self, stock, text=None):
|
||||
"""
|
||||
"""
|
||||
Gtk.ToggleButton.__init__(self, label=text)
|
||||
self.set_icon_name(stock)
|
||||
class BWToggleStockButton(Gtk.ToggleButton, _BWButton):
|
||||
def __init__(self, *args, **kwargs):
|
||||
_BWButton.__init__(self, Gtk.ToggleButton, *args, **kwargs)
|
||||
|
|
|
|||
|
|
@ -92,8 +92,7 @@ class ToolsMenu(Gtk.Menu):
|
|||
"""
|
||||
self.__hosts = Gtk.ImageMenuItem.new_with_label(_('Hosts viewer'))
|
||||
self.__hosts.connect("activate", self.__hosts_viewer_callback)
|
||||
self.__hosts_image = Gtk.Image()
|
||||
self.__hosts_image.set_from_stock("dialog-information-symbolic", Gtk.IconSize.MENU)
|
||||
self.__hosts_image = Gtk.Image.new_from_icon_name("dialog-information-symbolic", Gtk.IconSize.MENU)
|
||||
self.__hosts.set_image(self.__hosts_image)
|
||||
|
||||
self.append(self.__hosts)
|
||||
|
|
|
|||
|
|
@ -151,9 +151,8 @@ class ScanChooser(HIGVBox):
|
|||
self.hbox._pack_expand_fill(self.table)
|
||||
|
||||
def _attaching_widgets(self):
|
||||
self.table.attach_label(self.combo_scan, 0, 1, 0, 1, yoptions=0)
|
||||
self.table.attach_label(
|
||||
self.btn_open_scan, 1, 2, 0, 1, yoptions=0, xoptions=0)
|
||||
self.table.attach_label(self.combo_scan, 0, 1, 0, 1)
|
||||
self.table.attach_label(self.btn_open_scan, 1, 2, 0, 1)
|
||||
self.table.attach_entry(self.exp_scan, 0, 2, 1, 2)
|
||||
|
||||
def _set_scrolled(self):
|
||||
|
|
|
|||
|
|
@ -31,8 +31,7 @@ class FilterBar(HIGHBox):
|
|||
self.entry.show()
|
||||
|
||||
help_button = Gtk.Button()
|
||||
icon = Gtk.Image()
|
||||
icon.set_from_stock(Gtk.STOCK_INFO, Gtk.IconSize.BUTTON)
|
||||
icon = Gtk.Image.new_from_icon_name("dialog-information", Gtk.IconSize.BUTTON)
|
||||
help_button.add(icon)
|
||||
help_button.connect("clicked", self._help_button_clicked)
|
||||
self.pack_start(help_button, False, True, 0)
|
||||
|
|
|
|||
|
|
@ -826,9 +826,7 @@ This scan has not been run yet. Start the scan with the "Scan" button first.'))
|
|||
vbox.set_border_width(5)
|
||||
vbox.set_spacing(12)
|
||||
|
||||
image = Gtk.Image()
|
||||
image.set_from_stock(
|
||||
Gtk.STOCK_DIALOG_QUESTION, Gtk.IconSize.DIALOG)
|
||||
image = Gtk.Image.new_from_icon_name("dialog-question", Gtk.IconSize.DIALOG)
|
||||
|
||||
vbox.pack_start(alert, True, True, 0)
|
||||
vbox.pack_start(text, True, True, 0)
|
||||
|
|
@ -868,9 +866,7 @@ This scan has not been run yet. Start the scan with the "Scan" button first.'))
|
|||
vbox.set_border_width(5)
|
||||
vbox.set_spacing(12)
|
||||
|
||||
image = Gtk.Image()
|
||||
image.set_from_stock(
|
||||
Gtk.STOCK_DIALOG_WARNING, Gtk.IconSize.DIALOG)
|
||||
image = Gtk.Image.new_from_icon_name("dialog-warning", Gtk.IconSize.DIALOG)
|
||||
|
||||
vbox.pack_start(alert, True, True, 0)
|
||||
vbox.pack_start(text, True, True, 0)
|
||||
|
|
|
|||
|
|
@ -195,13 +195,13 @@ class ProfileEditor(HIGWindow):
|
|||
# Buttons
|
||||
self.buttons_hbox = HIGHBox()
|
||||
|
||||
self.cancel_button = HIGButton(stock=Gtk.STOCK_CANCEL)
|
||||
self.cancel_button = HIGButton(title=_("Cancel"))
|
||||
self.cancel_button.connect('clicked', self.exit)
|
||||
|
||||
self.delete_button = HIGButton(stock=Gtk.STOCK_DELETE)
|
||||
self.delete_button = HIGButton(stock="edit-delete")
|
||||
self.delete_button.connect('clicked', self.delete_profile)
|
||||
|
||||
self.save_button = HIGButton(_("Save Changes"), stock=Gtk.STOCK_SAVE)
|
||||
self.save_button = HIGButton(_("Save Changes"), stock="document-save")
|
||||
self.save_button.connect('clicked', self.save_profile)
|
||||
|
||||
###
|
||||
|
|
@ -363,9 +363,7 @@ class ProfileEditor(HIGWindow):
|
|||
vbox.set_border_width(5)
|
||||
vbox.set_spacing(12)
|
||||
|
||||
image = Gtk.Image()
|
||||
image.set_from_stock(
|
||||
Gtk.STOCK_DIALOG_WARNING, Gtk.IconSize.DIALOG)
|
||||
image = Gtk.Image.new_from_icon_name("dialog-warning", Gtk.IconSize.DIALOG)
|
||||
|
||||
vbox.pack_start(alert, True, True, 0)
|
||||
vbox.pack_start(text, True, True, 0)
|
||||
|
|
|
|||
|
|
@ -163,7 +163,7 @@ class ScriptInterface:
|
|||
NMAP_DELAY = 200
|
||||
|
||||
def __init__(self, root_tabs, ops, update_command, help_buf):
|
||||
self.hmainbox = HIGHBox(False, 0)
|
||||
self.hmainbox = HIGHBox(spacing=0)
|
||||
self.notscripttab = False # show profile editor it is a script tab
|
||||
self.nmap_process = None
|
||||
self.script_list_timeout_id = None
|
||||
|
|
@ -202,7 +202,7 @@ class ScriptInterface:
|
|||
self.script_list_widget = self.make_script_list_widget()
|
||||
self.script_list_widget.show_all()
|
||||
|
||||
vbox = HIGVBox(False, 5)
|
||||
vbox = HIGVBox(spacing=5)
|
||||
vbox.pack_start(self.make_description_widget(), True, True, 0)
|
||||
vbox.pack_start(self.make_arguments_widget(), True, True, 0)
|
||||
self.hmainbox.pack_end(vbox, True, True, 0)
|
||||
|
|
@ -478,7 +478,7 @@ clicking in the value field beside the argument name.""")
|
|||
self.file_scrolled_window.add(self.file_listview)
|
||||
vbox.pack_start(self.file_scrolled_window, False, True, 0)
|
||||
|
||||
hbox = HIGHBox(False, 2)
|
||||
hbox = HIGHBox(spacing=2)
|
||||
self.remove_file_button = HIGButton(stock=Gtk.STOCK_REMOVE)
|
||||
self.remove_file_button.connect(
|
||||
"clicked", self.remove_file_button_clicked_cb)
|
||||
|
|
|
|||
|
|
@ -70,51 +70,34 @@ 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)
|
||||
class HIGMixButton:
|
||||
def __init__(self, klass, title="", stock=None):
|
||||
klass.__init__(self, label=title)
|
||||
if stock:
|
||||
img = Gtk.Image.new_from_icon_name(stock, Gtk.IconSize.BUTTON)
|
||||
content = img
|
||||
if title:
|
||||
content = Gtk.Box.new(orientation=Gtk.Orientation.HORIZONTAL,
|
||||
spacing=4)
|
||||
lbl = Gtk.Label.new(title)
|
||||
|
||||
self.lbl = Gtk.Label.new(title)
|
||||
hbox1 = Gtk.Box.new(orientation=Gtk.Orientation.HORIZONTAL, spacing=2)
|
||||
hbox1.set_homogeneous(False)
|
||||
hbox1.pack_start(img, False, False, 0)
|
||||
hbox1.pack_start(lbl, False, False, 0)
|
||||
|
||||
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.hbox1.set_halign(Gtk.Align.CENTER)
|
||||
self.hbox1.set_valign(Gtk.Align.CENTER)
|
||||
self.hbox1.set_hexpand(False)
|
||||
self.hbox1.set_vexpand(False)
|
||||
self.pack_start(self.hbox1, True, True, 0)
|
||||
hbox1.set_halign(Gtk.Align.CENTER)
|
||||
hbox1.set_valign(Gtk.Align.CENTER)
|
||||
hbox1.set_hexpand(False)
|
||||
hbox1.set_vexpand(False)
|
||||
content.pack_start(hbox1, True, True, 0)
|
||||
self.child = content
|
||||
|
||||
|
||||
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 HIGButton(Gtk.Button, HIGMixButton):
|
||||
def __init__(self, *args, **kwargs):
|
||||
HIGMixButton.__init__(self, Gtk.Button, *args, **kwargs)
|
||||
|
||||
|
||||
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)
|
||||
class HIGToggleButton(Gtk.ToggleButton, HIGMixButton):
|
||||
def __init__(self, *args, **kwargs):
|
||||
HIGMixButton.__init__(self, Gtk.ToggleButton, *args, **kwargs)
|
||||
|
|
|
|||
|
|
@ -87,8 +87,7 @@ class HIGClosableTabLabel(HIGHBox):
|
|||
|
||||
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_image = Gtk.Image.new_from_icon_name("window-close", Gtk.IconSize.BUTTON)
|
||||
self.close_button = HIGButton()
|
||||
self.close_button.set_size_request(20, 20)
|
||||
self.close_button.set_relief(Gtk.ReliefStyle.NONE)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue