Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions lib/Widgets/Toast.vala
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/*-
* Copyright 2016-2022 elementary, Inc. (https://elementary.io)
* Copyright 2016-2025 elementary, Inc. (https://elementary.io)
* Copyright 2016-2017 Artem Anufrij <[email protected]>
* Copyright 2016-2017 Daniel Foré <[email protected]>
* SPDX-License-Identifier: LGPL-3.0-or-later
*/

Expand Down Expand Up @@ -61,6 +60,7 @@ public class Granite.Toast : Gtk.Widget {
notification_label.label = value;
}
_title = value;
update_property (Gtk.AccessibleProperty.LABEL, value, -1);
}
}

Expand All @@ -76,6 +76,7 @@ public class Granite.Toast : Gtk.Widget {
}

class construct {
set_accessible_role (ALERT);
set_css_name ("toast");
}

Expand All @@ -91,6 +92,7 @@ public class Granite.Toast : Gtk.Widget {
valign = Gtk.Align.CENTER
};
close_button.add_css_class (Granite.STYLE_CLASS_CIRCULAR);
close_button.update_property (Gtk.AccessibleProperty.LABEL, _("Close"), -1);

notification_label = new Gtk.Label (title) {
wrap = true,
Expand Down Expand Up @@ -184,6 +186,16 @@ public class Granite.Toast : Gtk.Widget {
revealer.reveal_child = true;
}

string announcement;
if (default_action_button.visible) {
announcement = _("A toast appeared: %s, has a button: %s").printf (title, default_action_button.label);
} else {
announcement = _("A toast appeared: %s").printf (title);
}

grab_focus ();
announce (announcement, MEDIUM);

// Remove any old timeout, including one started by
// leave_notify_event for the previous notification
stop_timeout ();
Expand Down
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ libgranite_deps = [
gio_os_dep,
dependency('glib-2.0', version: '>=' + glib_min_version),
dependency('gobject-2.0', version: '>=' + glib_min_version),
dependency('gtk4', version: '>=4.12'),
dependency('gtk4', version: '>=4.14'),
]

pkgconfig = import('pkgconfig')
Expand Down