refactor(src/window/notification): adjust notification markup handling and UI width constraints
- Escape markup text for summary and body to prevent injection - Simplify Label creation for body with conditional null check - Increase max_chars_width for summary and body lines - Remove wrap and wrap_mode settings
This commit is contained in:
1 file changed
+26
-17
@@ -118,22 +118,33 @@ class ExpandableNotificationGroup(Box):
|
|||||||
children=[
|
children=[
|
||||||
Label(
|
Label(
|
||||||
name="notification-summary",
|
name="notification-summary",
|
||||||
markup=f"<b>{self.app_name}</b>",
|
markup=escape_markup_text(
|
||||||
|
latest_notification._notification.summary.replace(
|
||||||
|
"\n", " "
|
||||||
|
)
|
||||||
|
),
|
||||||
h_align="start",
|
h_align="start",
|
||||||
|
max_chars_width=25,
|
||||||
ellipsization="end",
|
ellipsization="end",
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
Label(
|
(
|
||||||
name="notification-body",
|
Label(
|
||||||
markup=escape_markup_text(
|
markup=escape_markup_text(
|
||||||
latest_notification._notification.summary.replace(
|
latest_notification._notification.body.replace(
|
||||||
"\n", " "
|
"\n", " "
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
max_chars_width=25,
|
max_chars_width=25,
|
||||||
h_align="start",
|
h_align="start",
|
||||||
ellipsization="end",
|
ellipsization="end",
|
||||||
|
)
|
||||||
|
if latest_notification._notification.body
|
||||||
|
else Label(
|
||||||
|
markup="",
|
||||||
|
h_align="start",
|
||||||
|
)
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -543,9 +554,8 @@ class NotificationCenterWidget(NotificationWidget):
|
|||||||
notification.summary.replace("\n", " ")
|
notification.summary.replace("\n", " ")
|
||||||
),
|
),
|
||||||
h_align="start",
|
h_align="start",
|
||||||
wrap=True,
|
max_chars_width=40,
|
||||||
wrap_mode="word-char",
|
ellipsization="end",
|
||||||
max_chars_width=30,
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -555,9 +565,8 @@ class NotificationCenterWidget(NotificationWidget):
|
|||||||
notification.body.replace("\n", " ")
|
notification.body.replace("\n", " ")
|
||||||
),
|
),
|
||||||
h_align="start",
|
h_align="start",
|
||||||
wrap=True,
|
max_chars_width=45,
|
||||||
wrap_mode="word-char",
|
ellipsization="end",
|
||||||
max_chars_width=35,
|
|
||||||
)
|
)
|
||||||
if notification.body
|
if notification.body
|
||||||
else Label(
|
else Label(
|
||||||
|
|||||||
Reference in new issue
Block a user