Skip to content

Commit e8a2c23

Browse files
authored
library: Add Calendar Entry (#239)
1 parent 344f702 commit e8a2c23

3 files changed

Lines changed: 57 additions & 0 deletions

File tree

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using Gtk 4.0;
2+
using Adw 1;
3+
4+
Adw.StatusPage {
5+
title: "Calendar";
6+
description: "Display a Gregorian calendar, one month at a time";
7+
8+
Box {
9+
orientation: vertical;
10+
halign: center;
11+
12+
Calendar calendar {
13+
show-day-names: true;
14+
show-week-numbers: false;
15+
show-heading: true;
16+
margin-bottom: 18;
17+
day: 1;
18+
}
19+
20+
LinkButton {
21+
label: "API Reference";
22+
uri: "https://docs.gtk.org/gtk4/class.Calendar.html";
23+
}
24+
}
25+
}

src/Library/demos/Calendar/main.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
const calendar = workbench.builder.get_object("calendar");
2+
3+
// calendar.get_date() returns a GLib.DateTime object
4+
// https://docs.gtk.org/glib/struct.DateTime.html
5+
6+
calendar.connect("notify::day", () => {
7+
console.log(calendar.get_date().format("%e"));
8+
});
9+
10+
calendar.connect("notify::month", () => {
11+
console.log(calendar.get_date().format("%B"));
12+
});
13+
14+
calendar.connect("notify::year", () => {
15+
console.log(calendar.get_date().format("%Y"));
16+
});
17+
18+
calendar.connect("day-selected", () => {
19+
console.log(calendar.get_date().format_iso8601());
20+
});
21+
22+
calendar.mark_day(15);
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"name": "Calendar",
3+
"category": "user_interface",
4+
"description": "Display a Gregorian calendar, one month at a time",
5+
"panels": [
6+
"ui",
7+
"preview"
8+
],
9+
"autorun": true
10+
}

0 commit comments

Comments
 (0)