mirror of
https://github.com/nmap/nmap.git
synced 2025-12-07 13:11:28 +00:00
Zenmap dark mode. Fixes #2358
This commit is contained in:
@@ -1,5 +1,8 @@
|
|||||||
#Nmap Changelog ($Id$); -*-text-*-
|
#Nmap Changelog ($Id$); -*-text-*-
|
||||||
|
|
||||||
|
o [Zenmap][GH#2358] Added dark mode, accessed via Help->Toggle Dark Mode or
|
||||||
|
window::dark_mode in zenmap.conf. [Daniel Miller]
|
||||||
|
|
||||||
o Upgraded included libraries: Lua 5.4.7, libssh2 1.11.1, libpcap 1.10.5,
|
o Upgraded included libraries: Lua 5.4.7, libssh2 1.11.1, libpcap 1.10.5,
|
||||||
libpcre 10.45
|
libpcre 10.45
|
||||||
|
|
||||||
|
|||||||
@@ -84,6 +84,14 @@ except ImportError:
|
|||||||
def is_maemo():
|
def is_maemo():
|
||||||
return MAEMO
|
return MAEMO
|
||||||
|
|
||||||
|
def boolean_sanity(attr):
|
||||||
|
if attr is True or \
|
||||||
|
attr == "True" or \
|
||||||
|
attr == "true" or \
|
||||||
|
attr == "1":
|
||||||
|
return "True"
|
||||||
|
return "False"
|
||||||
|
|
||||||
|
|
||||||
class SearchConfig(UmitConfigParser, object):
|
class SearchConfig(UmitConfigParser, object):
|
||||||
section_name = "search"
|
section_name = "search"
|
||||||
@@ -109,14 +117,6 @@ class SearchConfig(UmitConfigParser, object):
|
|||||||
def _set_it(self, p_name, value):
|
def _set_it(self, p_name, value):
|
||||||
config_parser.set(self.section_name, p_name, value)
|
config_parser.set(self.section_name, p_name, value)
|
||||||
|
|
||||||
def boolean_sanity(self, attr):
|
|
||||||
if attr is True or \
|
|
||||||
attr == "True" or \
|
|
||||||
attr == "true" or \
|
|
||||||
attr == "1":
|
|
||||||
return "True"
|
|
||||||
return "False"
|
|
||||||
|
|
||||||
def get_directory(self):
|
def get_directory(self):
|
||||||
return self._get_it("directory", "")
|
return self._get_it("directory", "")
|
||||||
|
|
||||||
@@ -142,16 +142,16 @@ class SearchConfig(UmitConfigParser, object):
|
|||||||
self._set_it("save_time", save_time)
|
self._set_it("save_time", save_time)
|
||||||
|
|
||||||
def get_store_results(self):
|
def get_store_results(self):
|
||||||
return self.boolean_sanity(self._get_it("store_results", True))
|
return boolean_sanity(self._get_it("store_results", True))
|
||||||
|
|
||||||
def set_store_results(self, store_results):
|
def set_store_results(self, store_results):
|
||||||
self._set_it("store_results", self.boolean_sanity(store_results))
|
self._set_it("store_results", boolean_sanity(store_results))
|
||||||
|
|
||||||
def get_search_db(self):
|
def get_search_db(self):
|
||||||
return self.boolean_sanity(self._get_it("search_db", True))
|
return boolean_sanity(self._get_it("search_db", True))
|
||||||
|
|
||||||
def set_search_db(self, search_db):
|
def set_search_db(self, search_db):
|
||||||
self._set_it("search_db", self.boolean_sanity(search_db))
|
self._set_it("search_db", boolean_sanity(search_db))
|
||||||
|
|
||||||
def get_converted_save_time(self):
|
def get_converted_save_time(self):
|
||||||
try:
|
try:
|
||||||
@@ -251,6 +251,7 @@ class WindowConfig(UmitConfigParser, object):
|
|||||||
default_y = 0
|
default_y = 0
|
||||||
default_width = -1
|
default_width = -1
|
||||||
default_height = 650
|
default_height = 650
|
||||||
|
default_dark_mode = False
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
if not config_parser.has_section(self.section_name):
|
if not config_parser.has_section(self.section_name):
|
||||||
@@ -265,6 +266,7 @@ class WindowConfig(UmitConfigParser, object):
|
|||||||
self.y = self.default_y
|
self.y = self.default_y
|
||||||
self.width = self.default_width
|
self.width = self.default_width
|
||||||
self.height = self.default_height
|
self.height = self.default_height
|
||||||
|
self.dark_mode = self.default_dark_mode
|
||||||
|
|
||||||
def _get_it(self, p_name, default):
|
def _get_it(self, p_name, default):
|
||||||
return config_parser.get(self.section_name, p_name, fallback=default)
|
return config_parser.get(self.section_name, p_name, fallback=default)
|
||||||
@@ -340,10 +342,17 @@ class WindowConfig(UmitConfigParser, object):
|
|||||||
def set_height(self, height):
|
def set_height(self, height):
|
||||||
self._set_it("height", "%d" % height)
|
self._set_it("height", "%d" % height)
|
||||||
|
|
||||||
|
def get_dark_mode(self):
|
||||||
|
return boolean_sanity(self._get_it("dark_mode", self.default_dark_mode))
|
||||||
|
|
||||||
|
def set_dark_mode(self, mode):
|
||||||
|
self._set_it("dark_mode", boolean_sanity(mode))
|
||||||
|
|
||||||
x = property(get_x, set_x)
|
x = property(get_x, set_x)
|
||||||
y = property(get_y, set_y)
|
y = property(get_y, set_y)
|
||||||
width = property(get_width, set_width)
|
width = property(get_width, set_width)
|
||||||
height = property(get_height, set_height)
|
height = property(get_height, set_height)
|
||||||
|
dark_mode = property(get_dark_mode, set_dark_mode)
|
||||||
|
|
||||||
|
|
||||||
class CommandProfile (Profile, object):
|
class CommandProfile (Profile, object):
|
||||||
|
|||||||
@@ -132,6 +132,9 @@ class ScanWindow(UmitScanWindow):
|
|||||||
UmitScanWindow.__init__(self)
|
UmitScanWindow.__init__(self)
|
||||||
|
|
||||||
window = WindowConfig()
|
window = WindowConfig()
|
||||||
|
settings = Gtk.Settings.get_default()
|
||||||
|
settings.set_property("gtk-application-prefer-dark-theme",
|
||||||
|
window.dark_mode)
|
||||||
|
|
||||||
self.set_title(_(APP_DISPLAY_NAME))
|
self.set_title(_(APP_DISPLAY_NAME))
|
||||||
self.move(window.x, window.y)
|
self.move(window.x, window.y)
|
||||||
@@ -303,6 +306,13 @@ class ScanWindow(UmitScanWindow):
|
|||||||
None,
|
None,
|
||||||
_('Shows the application help'),
|
_('Shows the application help'),
|
||||||
self._help_cb),
|
self._help_cb),
|
||||||
|
|
||||||
|
('Toggle Dark Mode',
|
||||||
|
None,
|
||||||
|
_('Toggle Dark Mode'),
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
self._toggle_dark),
|
||||||
]
|
]
|
||||||
|
|
||||||
# See info on UIManager at:
|
# See info on UIManager at:
|
||||||
@@ -351,6 +361,7 @@ class ScanWindow(UmitScanWindow):
|
|||||||
<menuitem action='Show Help'/>
|
<menuitem action='Show Help'/>
|
||||||
<menuitem action='Report a bug'/>
|
<menuitem action='Report a bug'/>
|
||||||
<menuitem action='About'/>
|
<menuitem action='About'/>
|
||||||
|
<menuitem action='Toggle Dark Mode'/>
|
||||||
</menu>
|
</menu>
|
||||||
|
|
||||||
</menubar>
|
</menubar>
|
||||||
@@ -767,6 +778,14 @@ This scan has not been run yet. Start the scan with the "Scan" button first.'))
|
|||||||
def _help_cb(self, action):
|
def _help_cb(self, action):
|
||||||
self.show_help()
|
self.show_help()
|
||||||
|
|
||||||
|
def _toggle_dark(self, action):
|
||||||
|
window = WindowConfig()
|
||||||
|
window.dark_mode = not window.dark_mode
|
||||||
|
settings = Gtk.Settings.get_default()
|
||||||
|
settings.set_property("gtk-application-prefer-dark-theme",
|
||||||
|
window.dark_mode)
|
||||||
|
|
||||||
|
|
||||||
def _exit_cb(self, *args):
|
def _exit_cb(self, *args):
|
||||||
"""Closes the window, prompting for confirmation if necessary. If one
|
"""Closes the window, prompting for confirmation if necessary. If one
|
||||||
of the tabs couldn't be closed, the function returns True and doesn't
|
of the tabs couldn't be closed, the function returns True and doesn't
|
||||||
|
|||||||
Reference in New Issue
Block a user