Skip to content

Commit ec87407

Browse files
committed
required plugin dialog: add types
1 parent 8deda22 commit ec87407

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

safeeyes/safeeyes.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,14 +346,13 @@ def show_settings(self):
346346
)
347347
settings_dialog.show()
348348

349-
def show_required_plugin_dialog(self, error: RequiredPluginException):
349+
def show_required_plugin_dialog(self, error: RequiredPluginException) -> None:
350350
self.required_plugin_dialog_active = True
351351

352352
logging.info("Show RequiredPlugin dialog")
353353
plugin_id = error.get_plugin_id()
354354

355355
dialog = RequiredPluginDialog(
356-
error.get_plugin_id(),
357356
error.get_plugin_name(),
358357
error.get_message(),
359358
self.quit,

safeeyes/ui/required_plugin_dialog.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
import os
2424
import gi
25+
import typing
2526

2627
gi.require_version("Gtk", "4.0")
2728
from gi.repository import Gtk
@@ -43,12 +44,17 @@ class RequiredPluginDialog(Gtk.ApplicationWindow):
4344

4445
__gtype_name__ = "RequiredPluginDialog"
4546

46-
lbl_header = Gtk.Template.Child()
47-
lbl_message = Gtk.Template.Child()
48-
btn_extra_link = Gtk.Template.Child()
47+
lbl_header: Gtk.Label = Gtk.Template.Child()
48+
lbl_message: Gtk.Label = Gtk.Template.Child()
49+
btn_extra_link: Gtk.LinkButton = Gtk.Template.Child()
4950

5051
def __init__(
51-
self, plugin_id, plugin_name, message, on_quit, on_disable_plugin, application
52+
self,
53+
plugin_name: str,
54+
message: typing.Union[str, PluginDependency],
55+
on_quit: typing.Callable[[], None],
56+
on_disable_plugin: typing.Callable[[], None],
57+
application: Gtk.Application,
5258
):
5359
super().__init__(application=application)
5460

@@ -61,27 +67,28 @@ def __init__(
6167

6268
if isinstance(message, PluginDependency):
6369
self.lbl_message.set_label(_(message.message))
64-
self.btn_extra_link.set_uri(message.link)
70+
if message.link is not None:
71+
self.btn_extra_link.set_uri(message.link)
6572
self.btn_extra_link.set_visible(True)
6673
else:
6774
self.lbl_message.set_label(_(message))
6875

69-
def show(self):
76+
def show(self) -> None:
7077
"""Show the dialog."""
7178
self.present()
7279

7380
@Gtk.Template.Callback()
74-
def on_window_delete(self, *args):
81+
def on_window_delete(self, *args) -> None:
7582
"""Window close event handler."""
7683
self.destroy()
7784
self.on_quit()
7885

7986
@Gtk.Template.Callback()
80-
def on_close_clicked(self, *args):
87+
def on_close_clicked(self, *args) -> None:
8188
self.destroy()
8289
self.on_quit()
8390

8491
@Gtk.Template.Callback()
85-
def on_disable_plugin_clicked(self, *args):
92+
def on_disable_plugin_clicked(self, *args) -> None:
8693
self.destroy()
8794
self.on_disable_plugin()

0 commit comments

Comments
 (0)