|
24 | 24 | from gi.repository import Gio, GLib |
25 | 25 | import logging |
26 | 26 | from safeeyes import utility |
| 27 | +from safeeyes.context import Context |
27 | 28 | from safeeyes.translations import translate as _ |
28 | 29 | import threading |
29 | 30 | import typing |
|
32 | 33 | Safe Eyes tray icon plugin |
33 | 34 | """ |
34 | 35 |
|
35 | | -context = None |
36 | 36 | tray_icon = None |
37 | 37 | safeeyes_config = None |
38 | 38 |
|
@@ -440,16 +440,16 @@ class TrayIcon: |
440 | 440 | _animation_timeout_id: typing.Optional[int] = None |
441 | 441 | _animation_icon_enabled: bool = False |
442 | 442 |
|
443 | | - def __init__(self, context, plugin_config): |
| 443 | + def __init__(self, context: Context, plugin_config): |
444 | 444 | 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 |
453 | 453 | self.plugin_config = plugin_config |
454 | 454 | self.date_time = None |
455 | 455 | self.active = True |
@@ -830,14 +830,12 @@ def stop_animation(self) -> None: |
830 | 830 |
|
831 | 831 | def init(ctx, safeeyes_cfg, plugin_config): |
832 | 832 | """Initialize the tray icon.""" |
833 | | - global context |
834 | 833 | global tray_icon |
835 | 834 | global safeeyes_config |
836 | 835 | logging.debug("Initialize Tray Icon plugin") |
837 | | - context = ctx |
838 | 836 | safeeyes_config = safeeyes_cfg |
839 | 837 | if not tray_icon: |
840 | | - tray_icon = TrayIcon(context, plugin_config) |
| 838 | + tray_icon = TrayIcon(ctx, plugin_config) |
841 | 839 | else: |
842 | 840 | tray_icon.initialize(plugin_config) |
843 | 841 |
|
|
0 commit comments