Skip to content

Commit 14c5601

Browse files
committed
add types, remove unused global
1 parent 051670e commit 14c5601

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

safeeyes/plugins/trayicon/plugin.py

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
from gi.repository import Gio, GLib
2525
import logging
2626
from safeeyes import utility
27+
from safeeyes.context import Context
2728
from safeeyes.translations import translate as _
2829
import threading
2930
import typing
@@ -32,7 +33,6 @@
3233
Safe Eyes tray icon plugin
3334
"""
3435

35-
context = None
3636
tray_icon = None
3737
safeeyes_config = None
3838

@@ -440,16 +440,16 @@ class TrayIcon:
440440
_animation_timeout_id: typing.Optional[int] = None
441441
_animation_icon_enabled: bool = False
442442

443-
def __init__(self, context, plugin_config):
443+
def __init__(self, context: Context, plugin_config):
444444
self.context = context
445-
self.on_show_settings = context["api"]["show_settings"]
446-
self.on_show_about = context["api"]["show_about"]
447-
self.quit = context["api"]["quit"]
448-
self.enable_safeeyes = context["api"]["enable_safeeyes"]
449-
self.disable_safeeyes = context["api"]["disable_safeeyes"]
450-
self.take_break = context["api"]["take_break"]
451-
self.has_breaks = context["api"]["has_breaks"]
452-
self.get_break_time = context["api"]["get_break_time"]
445+
self.on_show_settings = context.api.show_settings
446+
self.on_show_about = context.api.show_about
447+
self.quit = context.api.quit
448+
self.enable_safeeyes = context.api.enable_safeeyes
449+
self.disable_safeeyes = context.api.disable_safeeyes
450+
self.take_break = context.api.take_break
451+
self.has_breaks = context.api.has_breaks
452+
self.get_break_time = context.api.get_break_time
453453
self.plugin_config = plugin_config
454454
self.date_time = None
455455
self.active = True
@@ -830,14 +830,12 @@ def stop_animation(self) -> None:
830830

831831
def init(ctx, safeeyes_cfg, plugin_config):
832832
"""Initialize the tray icon."""
833-
global context
834833
global tray_icon
835834
global safeeyes_config
836835
logging.debug("Initialize Tray Icon plugin")
837-
context = ctx
838836
safeeyes_config = safeeyes_cfg
839837
if not tray_icon:
840-
tray_icon = TrayIcon(context, plugin_config)
838+
tray_icon = TrayIcon(ctx, plugin_config)
841839
else:
842840
tray_icon.initialize(plugin_config)
843841

0 commit comments

Comments
 (0)