Skip to content

Commit 360cd6f

Browse files
committed
Modify notification history and container management logic
1 parent c805e9a commit 360cd6f

File tree

1 file changed

+2
-41
lines changed

1 file changed

+2
-41
lines changed

modules/notifications.py

Lines changed: 2 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -353,25 +353,6 @@ def on_container_destroy(container):
353353
# Agregamos el contenido principal al hist_box
354354
hist_box.add(content_box)
355355

356-
# Si hay acciones, creamos y agregamos los botones
357-
if notification_box.notification.actions:
358-
action_buttons = Box(
359-
name="notification-action-buttons",
360-
spacing=4,
361-
h_expand=True,
362-
children=[
363-
HistoryActionButton(
364-
action,
365-
i,
366-
len(notification_box.notification.actions),
367-
container,
368-
on_destroy=lambda: on_container_destroy(container)
369-
)
370-
for i, action in enumerate(notification_box.notification.actions)
371-
],
372-
)
373-
hist_box.add(action_buttons)
374-
375356
# Modificar el botón de cerrar para que use nuestro método personalizado
376357
content_box.get_children()[3].get_children()[0].connect( # Box con botón de cerrar
377358
"clicked",
@@ -524,6 +505,8 @@ def on_new_notification(self, fabric_notif, id):
524505
# Limitar a 5 notificaciones
525506
while len(self.notifications) >= 5:
526507
oldest_notification = self.notifications[0]
508+
# Enviar al historial en lugar de marcar como expirada
509+
self.notch.notification_history.add_notification(oldest_notification)
527510
self.stack.remove(oldest_notification)
528511
self.notifications.pop(0)
529512
if self.current_index > 0:
@@ -677,25 +660,3 @@ def close_all_notifications(self, *args):
677660
notifications_to_close = self.notifications.copy()
678661
for notification_box in notifications_to_close:
679662
notification_box.notification.close("dismissed-by-user")
680-
681-
class HistoryActionButton(Button):
682-
def __init__(self, action: NotificationAction, index: int, total: int, hist_box, on_destroy=None):
683-
super().__init__(
684-
name="action-button",
685-
h_expand=True,
686-
on_clicked=self.on_clicked,
687-
child=Label(name="button-label", label=action.label),
688-
)
689-
self.action = action
690-
self.hist_box = hist_box
691-
self.on_destroy = on_destroy if on_destroy else lambda: self.hist_box.destroy() # Valor por defecto
692-
style_class = (
693-
"start-action" if index == 0
694-
else "end-action" if index == total - 1
695-
else "middle-action"
696-
)
697-
self.add_style_class(style_class)
698-
699-
def on_clicked(self, *_):
700-
self.action.invoke()
701-
self.on_destroy()

0 commit comments

Comments
 (0)