Skip to content

Commit

Permalink
fix: Fixed single notification close action
Browse files Browse the repository at this point in the history
  • Loading branch information
tomlin7 committed Jun 18, 2024
1 parent dcea8b8 commit 516e0d0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
12 changes: 6 additions & 6 deletions src/biscuit/common/notifications/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,20 +184,20 @@ def clear(self, *_) -> None:
i.delete()
self.count = 0

def delete(self, notification: Notification) -> None:
def delete_notification(self, notification: Notification) -> None:
"""Delete a notification
Args:
notification (Notification): notification to delete"""

self.notifications.remove(notification)
self.count -= 1
notification.destroy()
if not self.count:
self.hide()
else:
self.show()
self.count -= 1

self.update_idletasks()
self._follow_root()

if not self.count:
self.hide()

self.base.statusbar.update_notifications()
16 changes: 13 additions & 3 deletions src/biscuit/common/notifications/notification.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
from __future__ import annotations

import tkinter as tk
import typing

from ..ui import Frame, Icon, IconButton, Label

if typing.TYPE_CHECKING:
from .manager import Notifications


class Notification(Frame):
"""Notification class
Holds the notification icon, text and close button"""

def __init__(self, master, icon: str, text: str, fg: str, *args, **kwargs) -> None:
def __init__(
self, master: Notifications, icon: str, text: str, fg: str, *args, **kwargs
) -> None:
"""Create a notification
Args:
Expand All @@ -17,6 +26,7 @@ def __init__(self, master, icon: str, text: str, fg: str, *args, **kwargs) -> No
fg (str): Foreground color"""

super().__init__(master, *args, **kwargs)
self.master: Notifications = master
self.config(**self.base.theme.notifications)

self.icon = Icon(self, icon, padx=5, **self.base.theme.utils.iconbutton)
Expand All @@ -29,7 +39,7 @@ def __init__(self, master, icon: str, text: str, fg: str, *args, **kwargs) -> No
anchor=tk.W,
padx=10,
pady=10,
**self.base.theme.utils.iconbutton
**self.base.theme.utils.iconbutton,
)
self.label.pack(side=tk.LEFT, expand=1, fill=tk.BOTH)

Expand All @@ -39,4 +49,4 @@ def __init__(self, master, icon: str, text: str, fg: str, *args, **kwargs) -> No
def delete(self):
"""Delete the notification"""

self.master.delete(self)
self.master.delete_notification(self)

0 comments on commit 516e0d0

Please sign in to comment.