File tree Expand file tree Collapse file tree
src/Library/demos/Calendar Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 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 ) ;
Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments