From 30ae136e9f2248346f8c7c1afa979bf1face4395 Mon Sep 17 00:00:00 2001 From: Sabrina Meindlhumer Date: Fri, 8 Sep 2023 21:24:32 +0200 Subject: [PATCH 1/6] library: Add rust demo calendar --- src/Library/demos/Calendar/code.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/Library/demos/Calendar/code.rs diff --git a/src/Library/demos/Calendar/code.rs b/src/Library/demos/Calendar/code.rs new file mode 100644 index 000000000..9468072df --- /dev/null +++ b/src/Library/demos/Calendar/code.rs @@ -0,0 +1,26 @@ +use crate::workbench; +use glib::clone; +use gtk::glib; + +pub fn main() { + let calendar: gtk::Calendar = workbench::builder().object("calendar").unwrap(); + + calendar.connect_day_notify(clone!(@weak calendar => move |_| { + println!("{}", calendar.date().format("%e").unwrap()); + })); + + calendar.connect_month_notify(clone!(@weak calendar => move |_| { + println!("{}", calendar.date().format("%B").unwrap()); + })); + + calendar.connect_year_notify(clone!(@weak calendar => move |_| { + println!("{}", calendar.date().format("%Y").unwrap()); + })); + + calendar.connect_day_selected(clone!(@weak calendar => move |_| { + println!("{}", calendar.date().format_iso8601().unwrap()); + })); + + calendar.mark_day(15); +} + From dc99a801854c6f0c7b3d70b0fec1c4855a884e26 Mon Sep 17 00:00:00 2001 From: Sabrina Meindlhumer Date: Fri, 8 Sep 2023 21:46:22 +0200 Subject: [PATCH 2/6] library: address comments --- src/Library/demos/Calendar/code.rs | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/Library/demos/Calendar/code.rs b/src/Library/demos/Calendar/code.rs index 9468072df..4df06fdb5 100644 --- a/src/Library/demos/Calendar/code.rs +++ b/src/Library/demos/Calendar/code.rs @@ -1,25 +1,23 @@ use crate::workbench; -use glib::clone; -use gtk::glib; pub fn main() { let calendar: gtk::Calendar = workbench::builder().object("calendar").unwrap(); - calendar.connect_day_notify(clone!(@weak calendar => move |_| { + calendar.connect_day_notify(move |calendar| { println!("{}", calendar.date().format("%e").unwrap()); - })); + }); - calendar.connect_month_notify(clone!(@weak calendar => move |_| { + calendar.connect_month_notify(move |calendar| { println!("{}", calendar.date().format("%B").unwrap()); - })); + }); - calendar.connect_year_notify(clone!(@weak calendar => move |_| { + calendar.connect_year_notify(move |calendar| { println!("{}", calendar.date().format("%Y").unwrap()); - })); + }); - calendar.connect_day_selected(clone!(@weak calendar => move |_| { + calendar.connect_day_selected(move |calendar| { println!("{}", calendar.date().format_iso8601().unwrap()); - })); + }); calendar.mark_day(15); } From c7b671d8cf84f12a209ff450828c8f4a80d1e63e Mon Sep 17 00:00:00 2001 From: Sabrina Meindlhumer <58905866+M-Sabrina@users.noreply.github.com> Date: Fri, 8 Sep 2023 21:51:23 +0200 Subject: [PATCH 3/6] Update src/Library/demos/Calendar/code.rs Co-authored-by: Hofer-Julian <30049909+Hofer-Julian@users.noreply.github.com> --- src/Library/demos/Calendar/code.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Library/demos/Calendar/code.rs b/src/Library/demos/Calendar/code.rs index 4df06fdb5..fa5f6739d 100644 --- a/src/Library/demos/Calendar/code.rs +++ b/src/Library/demos/Calendar/code.rs @@ -7,7 +7,7 @@ pub fn main() { println!("{}", calendar.date().format("%e").unwrap()); }); - calendar.connect_month_notify(move |calendar| { + calendar.connect_month_notify(|calendar| { println!("{}", calendar.date().format("%B").unwrap()); }); From 8cf1235f2469ea4f2859fc209891350c9fb5b802 Mon Sep 17 00:00:00 2001 From: Sabrina Meindlhumer <58905866+M-Sabrina@users.noreply.github.com> Date: Fri, 8 Sep 2023 21:51:33 +0200 Subject: [PATCH 4/6] Update src/Library/demos/Calendar/code.rs Co-authored-by: Hofer-Julian <30049909+Hofer-Julian@users.noreply.github.com> --- src/Library/demos/Calendar/code.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Library/demos/Calendar/code.rs b/src/Library/demos/Calendar/code.rs index fa5f6739d..24f2d07bd 100644 --- a/src/Library/demos/Calendar/code.rs +++ b/src/Library/demos/Calendar/code.rs @@ -11,7 +11,7 @@ pub fn main() { println!("{}", calendar.date().format("%B").unwrap()); }); - calendar.connect_year_notify(move |calendar| { + calendar.connect_year_notify(|calendar| { println!("{}", calendar.date().format("%Y").unwrap()); }); From 77b5397218935dfa5c8047d26290f92361324464 Mon Sep 17 00:00:00 2001 From: Sabrina Meindlhumer <58905866+M-Sabrina@users.noreply.github.com> Date: Fri, 8 Sep 2023 21:51:40 +0200 Subject: [PATCH 5/6] Update src/Library/demos/Calendar/code.rs Co-authored-by: Hofer-Julian <30049909+Hofer-Julian@users.noreply.github.com> --- src/Library/demos/Calendar/code.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Library/demos/Calendar/code.rs b/src/Library/demos/Calendar/code.rs index 24f2d07bd..777a3917d 100644 --- a/src/Library/demos/Calendar/code.rs +++ b/src/Library/demos/Calendar/code.rs @@ -15,7 +15,7 @@ pub fn main() { println!("{}", calendar.date().format("%Y").unwrap()); }); - calendar.connect_day_selected(move |calendar| { + calendar.connect_day_selected(|calendar| { println!("{}", calendar.date().format_iso8601().unwrap()); }); From 1d76e052ca097e9442c11efb2c8e92d2b31d72b5 Mon Sep 17 00:00:00 2001 From: Sabrina Meindlhumer <58905866+M-Sabrina@users.noreply.github.com> Date: Fri, 8 Sep 2023 21:52:40 +0200 Subject: [PATCH 6/6] Update src/Library/demos/Calendar/code.rs Co-authored-by: Hofer-Julian <30049909+Hofer-Julian@users.noreply.github.com> --- src/Library/demos/Calendar/code.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Library/demos/Calendar/code.rs b/src/Library/demos/Calendar/code.rs index 777a3917d..f185b6cfa 100644 --- a/src/Library/demos/Calendar/code.rs +++ b/src/Library/demos/Calendar/code.rs @@ -3,7 +3,7 @@ use crate::workbench; pub fn main() { let calendar: gtk::Calendar = workbench::builder().object("calendar").unwrap(); - calendar.connect_day_notify(move |calendar| { + calendar.connect_day_notify(|calendar| { println!("{}", calendar.date().format("%e").unwrap()); });