Skip to content

Commit 7c98cb9

Browse files
authored
library: port Viewswitcher entry to Vala (#254)
1 parent 3b22679 commit 7c98cb9

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#! /usr/bin/env -S vala workbench.vala --pkg gtk4 --pkg libadwaita-1
2+
3+
public void main() {
4+
var notifications_page = workbench.builder.get_object("page3") as Adw.ViewStackPage;
5+
var notification_list = workbench.builder.get_object("notification_list") as Gtk.ListBox;
6+
7+
int notification_count = 5;
8+
9+
notifications_page.badge_number = notification_count;
10+
11+
for (int i = 0; i < notification_count; i++){
12+
var notification_row = new Adw.ActionRow(){
13+
title = "Notification",
14+
selectable = false,
15+
};
16+
17+
var button = new Gtk.Button(){
18+
halign = Gtk.Align.CENTER,
19+
valign = Gtk.Align.CENTER,
20+
margin_top = 10,
21+
margin_bottom = 10,
22+
icon_name = "check-plain-symbolic"
23+
};
24+
25+
button.clicked.connect( () => {
26+
notifications_page.badge_number = --notification_count;
27+
notification_list.remove(notification_row);
28+
29+
if (notifications_page.badge_number == 0)
30+
notifications_page.needs_attention = false;
31+
});
32+
33+
notification_row.add_suffix(button);
34+
35+
notification_list.append(notification_row);
36+
}
37+
}
38+

0 commit comments

Comments
 (0)