Add an option to disable tray notifications
This commit is contained in:
1 parent
bfd3893921
commit
4100ae5661
3 files changed
+21
No files matched your search
@@ -1042,6 +1042,9 @@ class TrayIcon:
|
|||||||
def notify(
|
def notify(
|
||||||
self, message: str, title: str | None = None, duration: float = 10
|
self, message: str, title: str | None = None, duration: float = 10
|
||||||
) -> asyncio.Task[None] | None:
|
) -> 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:
|
if self.icon is not None:
|
||||||
icon = self.icon
|
icon = self.icon
|
||||||
|
|
||||||
@@ -1386,6 +1389,7 @@ class _SettingsVars(TypedDict):
|
|||||||
proxy: StringVar
|
proxy: StringVar
|
||||||
autostart: IntVar
|
autostart: IntVar
|
||||||
priority_only: IntVar
|
priority_only: IntVar
|
||||||
|
tray_notifications: IntVar
|
||||||
|
|
||||||
|
|
||||||
class SettingsPanel:
|
class SettingsPanel:
|
||||||
@@ -1400,6 +1404,7 @@ class SettingsPanel:
|
|||||||
"tray": IntVar(master, self._settings.autostart_tray),
|
"tray": IntVar(master, self._settings.autostart_tray),
|
||||||
"autostart": IntVar(master, self._settings.autostart),
|
"autostart": IntVar(master, self._settings.autostart),
|
||||||
"priority_only": IntVar(master, self._settings.priority_only),
|
"priority_only": IntVar(master, self._settings.priority_only),
|
||||||
|
"tray_notifications": IntVar(master, self._settings.tray_notifications),
|
||||||
}
|
}
|
||||||
master.rowconfigure(0, weight=1)
|
master.rowconfigure(0, weight=1)
|
||||||
master.columnconfigure(0, weight=1)
|
master.columnconfigure(0, weight=1)
|
||||||
@@ -1442,6 +1447,14 @@ class SettingsPanel:
|
|||||||
ttk.Checkbutton(
|
ttk.Checkbutton(
|
||||||
checkboxes_frame, variable=self._vars["tray"], command=self.update_autostart
|
checkboxes_frame, variable=self._vars["tray"], command=self.update_autostart
|
||||||
).grid(column=1, row=irow, sticky="w")
|
).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(
|
ttk.Label(
|
||||||
checkboxes_frame, text=_("gui", "settings", "general", "priority_only")
|
checkboxes_frame, text=_("gui", "settings", "general", "priority_only")
|
||||||
).grid(column=0, row=(irow := irow + 1), sticky="e")
|
).grid(column=0, row=(irow := irow + 1), sticky="e")
|
||||||
@@ -1548,6 +1561,9 @@ class SettingsPanel:
|
|||||||
self._priority_list.selection_clear(0, "end")
|
self._priority_list.selection_clear(0, "end")
|
||||||
self._exclude_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:
|
def update_autostart(self) -> None:
|
||||||
enabled = bool(self._vars["autostart"].get())
|
enabled = bool(self._vars["autostart"].get())
|
||||||
tray = bool(self._vars["tray"].get())
|
tray = bool(self._vars["tray"].get())
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ class SettingsFile(TypedDict):
|
|||||||
priority: list[str]
|
priority: list[str]
|
||||||
priority_only: bool
|
priority_only: bool
|
||||||
autostart_tray: bool
|
autostart_tray: bool
|
||||||
|
tray_notifications: bool
|
||||||
|
|
||||||
|
|
||||||
default_settings: SettingsFile = {
|
default_settings: SettingsFile = {
|
||||||
@@ -29,6 +30,7 @@ default_settings: SettingsFile = {
|
|||||||
"priority_only": True,
|
"priority_only": True,
|
||||||
"autostart_tray": False,
|
"autostart_tray": False,
|
||||||
"language": DEFAULT_LANG,
|
"language": DEFAULT_LANG,
|
||||||
|
"tray_notifications": True,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -49,6 +51,7 @@ class Settings:
|
|||||||
priority: list[str]
|
priority: list[str]
|
||||||
priority_only: bool
|
priority_only: bool
|
||||||
autostart_tray: bool
|
autostart_tray: bool
|
||||||
|
tray_notifications: bool
|
||||||
|
|
||||||
PASSTHROUGH = ("_settings", "_args", "_altered")
|
PASSTHROUGH = ("_settings", "_args", "_altered")
|
||||||
|
|
||||||
|
|||||||
@@ -164,6 +164,7 @@ class GUISettingsGeneral(TypedDict):
|
|||||||
name: str
|
name: str
|
||||||
autostart: str
|
autostart: str
|
||||||
tray: str
|
tray: str
|
||||||
|
tray_notifications: str
|
||||||
priority_only: str
|
priority_only: str
|
||||||
proxy: str
|
proxy: str
|
||||||
|
|
||||||
@@ -358,6 +359,7 @@ default_translation: Translation = {
|
|||||||
"name": "General",
|
"name": "General",
|
||||||
"autostart": "Autostart: ",
|
"autostart": "Autostart: ",
|
||||||
"tray": "Autostart into tray: ",
|
"tray": "Autostart into tray: ",
|
||||||
|
"tray_notifications": "Tray notifications: ",
|
||||||
"priority_only": "Priority Only: ",
|
"priority_only": "Priority Only: ",
|
||||||
"proxy": "Proxy (requires restart):",
|
"proxy": "Proxy (requires restart):",
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in new issue
Block a user