network: improve message, fix deactivate error
This commit is contained in:
parent
f530d36ae1
commit
9c13468e66
@ -121,8 +121,8 @@ class SdbusNm:
|
|||||||
if status.returncode != 0:
|
if status.returncode != 0:
|
||||||
raise RuntimeError("Failed to start NetworkManager service")
|
raise RuntimeError("Failed to start NetworkManager service")
|
||||||
except FileNotFoundError as e:
|
except FileNotFoundError as e:
|
||||||
logging.error("NetworkManager might not be installed")
|
logging.exception(f"{e}")
|
||||||
raise RuntimeError(f"{e}\n" "it might not be installed?\n") from e
|
raise RuntimeError(f"{e}") from e
|
||||||
|
|
||||||
def is_wifi_enabled(self):
|
def is_wifi_enabled(self):
|
||||||
return self.nm.wireless_enabled
|
return self.nm.wireless_enabled
|
||||||
|
@ -12,25 +12,32 @@ class Panel(ScreenPanel):
|
|||||||
|
|
||||||
def __init__(self, screen, title):
|
def __init__(self, screen, title):
|
||||||
super().__init__(screen, title)
|
super().__init__(screen, title)
|
||||||
self.show_add = False
|
|
||||||
self.update_timeout = None
|
|
||||||
self.network_list = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, hexpand=True, vexpand=True)
|
|
||||||
self.network_rows = {}
|
|
||||||
self.networks = {}
|
|
||||||
try:
|
try:
|
||||||
self.sdbus_nm = SdbusNm(self.popup_callback)
|
self.sdbus_nm = SdbusNm(self.popup_callback)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.exception("Failed to initialize")
|
logging.exception("Failed to initialize")
|
||||||
self.sdbus_nm = None
|
self.sdbus_nm = None
|
||||||
self.content.add(
|
self.error_box = Gtk.Box(
|
||||||
|
orientation=Gtk.Orientation.VERTICAL,
|
||||||
|
hexpand=True,
|
||||||
|
vexpand=True
|
||||||
|
)
|
||||||
|
self.error_box.add(
|
||||||
Gtk.Label(
|
Gtk.Label(
|
||||||
label=_("Failed to initialize sdbus") + f"\n{e}",
|
label=_("Failed to initialize") + f"\n{e}",
|
||||||
wrap=True,
|
wrap=True,
|
||||||
wrap_mode=Pango.WrapMode.WORD_CHAR,
|
wrap_mode=Pango.WrapMode.WORD_CHAR,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
self.error_box.set_valign(Gtk.Align.CENTER)
|
||||||
|
self.content.add(self.error_box)
|
||||||
self._screen.panels_reinit.append(self._screen._cur_panels[-1])
|
self._screen.panels_reinit.append(self._screen._cur_panels[-1])
|
||||||
return
|
return
|
||||||
|
self.show_add = False
|
||||||
|
self.update_timeout = None
|
||||||
|
self.network_list = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, hexpand=True, vexpand=True)
|
||||||
|
self.network_rows = {}
|
||||||
|
self.networks = {}
|
||||||
self.wifi_signal_icons = {
|
self.wifi_signal_icons = {
|
||||||
'excellent': self._gtk.PixbufFromIcon('wifi_excellent'),
|
'excellent': self._gtk.PixbufFromIcon('wifi_excellent'),
|
||||||
'good': self._gtk.PixbufFromIcon('wifi_good'),
|
'good': self._gtk.PixbufFromIcon('wifi_good'),
|
||||||
@ -354,6 +361,8 @@ class Panel(ScreenPanel):
|
|||||||
self.update_timeout = GLib.timeout_add_seconds(5, self.update_single_network_info)
|
self.update_timeout = GLib.timeout_add_seconds(5, self.update_single_network_info)
|
||||||
|
|
||||||
def deactivate(self):
|
def deactivate(self):
|
||||||
|
if self.sdbus_nm is None:
|
||||||
|
return
|
||||||
if self.update_timeout is not None:
|
if self.update_timeout is not None:
|
||||||
GLib.source_remove(self.update_timeout)
|
GLib.source_remove(self.update_timeout)
|
||||||
self.update_timeout = None
|
self.update_timeout = None
|
||||||
|
Loading…
x
Reference in New Issue
Block a user