Add an option to disable tray notifications

This commit is contained in:
DevilXD committed 2023-02-19 13:16:27 +01:00
1 parent bfd3893921
commit 4100ae5661
3 files changed
+21

No files matched your search

+16
View File
@@ -1042,6 +1042,9 @@ class TrayIcon:
def notify(
self, message: str, title: str | None = None, duration: float = 10
) -> asyncio.Task[None] | None:
# do nothing if the user disabled notifications
if not self._manager._twitch.settings.tray_notifications:
return None
if self.icon is not None:
icon = self.icon
@@ -1386,6 +1389,7 @@ class _SettingsVars(TypedDict):
proxy: StringVar
autostart: IntVar
priority_only: IntVar
tray_notifications: IntVar
class SettingsPanel:
@@ -1400,6 +1404,7 @@ class SettingsPanel:
"tray": IntVar(master, self._settings.autostart_tray),
"autostart": IntVar(master, self._settings.autostart),
"priority_only": IntVar(master, self._settings.priority_only),
"tray_notifications": IntVar(master, self._settings.tray_notifications),
}
master.rowconfigure(0, weight=1)
master.columnconfigure(0, weight=1)
@@ -1442,6 +1447,14 @@ class SettingsPanel:
ttk.Checkbutton(
checkboxes_frame, variable=self._vars["tray"], command=self.update_autostart
).grid(column=1, row=irow, sticky="w")
ttk.Label(
checkboxes_frame, text=_("gui", "settings", "general", "tray_notifications")
).grid(column=0, row=(irow := irow + 1), sticky="e")
ttk.Checkbutton(
checkboxes_frame,
variable=self._vars["tray_notifications"],
command=self.update_notifications,
).grid(column=1, row=irow, sticky="w")
ttk.Label(
checkboxes_frame, text=_("gui", "settings", "general", "priority_only")
).grid(column=0, row=(irow := irow + 1), sticky="e")
@@ -1548,6 +1561,9 @@ class SettingsPanel:
self._priority_list.selection_clear(0, "end")
self._exclude_list.selection_clear(0, "end")
def update_notifications(self) -> None:
self._settings.tray_notifications = bool(self._vars["tray_notifications"])
def update_autostart(self) -> None:
enabled = bool(self._vars["autostart"].get())
tray = bool(self._vars["tray"].get())
+3
View File
@@ -19,6 +19,7 @@ class SettingsFile(TypedDict):
priority: list[str]
priority_only: bool
autostart_tray: bool
tray_notifications: bool
default_settings: SettingsFile = {
@@ -29,6 +30,7 @@ default_settings: SettingsFile = {
"priority_only": True,
"autostart_tray": False,
"language": DEFAULT_LANG,
"tray_notifications": True,
}
@@ -49,6 +51,7 @@ class Settings:
priority: list[str]
priority_only: bool
autostart_tray: bool
tray_notifications: bool
PASSTHROUGH = ("_settings", "_args", "_altered")
+2
View File
@@ -164,6 +164,7 @@ class GUISettingsGeneral(TypedDict):
name: str
autostart: str
tray: str
tray_notifications: str
priority_only: str
proxy: str
@@ -358,6 +359,7 @@ default_translation: Translation = {
"name": "General",
"autostart": "Autostart: ",
"tray": "Autostart into tray: ",
"tray_notifications": "Tray notifications: ",
"priority_only": "Priority Only: ",
"proxy": "Proxy (requires restart):",
},