From 676c02e985b073f09c0dbb86890e6fd83849a73e Mon Sep 17 00:00:00 2001 From: Sabrina Meindlhumer <58905866+M-Sabrina@users.noreply.github.com> Date: Tue, 5 Sep 2023 22:48:28 +0200 Subject: [PATCH] Add rust demo Flow Box (#575) --- src/Library/demos/Flow Box/code.rs | 42 ++++++++++++++++++++++++++++++ src/about.js | 1 + 2 files changed, 43 insertions(+) create mode 100644 src/Library/demos/Flow Box/code.rs diff --git a/src/Library/demos/Flow Box/code.rs b/src/Library/demos/Flow Box/code.rs new file mode 100644 index 000000000..b0b5e5ae2 --- /dev/null +++ b/src/Library/demos/Flow Box/code.rs @@ -0,0 +1,42 @@ +use crate::workbench; +use adw::prelude::*; +use std::str; + +pub fn main() { + let flowbox: gtk::FlowBox = workbench::builder().object("flowbox").unwrap(); + for code in 128513..=128591 { + let tmp = char::from_u32(code).unwrap(); + add_emoji(&flowbox, &tmp.to_string()); + } + flowbox.connect_child_activated(|_, item| { + // FlowBoxChild -> AdwBin -> Label + let emoji = item + .child() + .unwrap() + .downcast::() + .unwrap() + .child() + .unwrap() + .downcast::() + .unwrap() + .label(); + let emoji = emoji.chars().next().unwrap(); + println!("Unicode:{:X}", emoji as u32); + }); +} + +pub fn add_emoji(flowbox: >k::FlowBox, unicode: &str) { + let label = gtk::Label::builder() + .vexpand(true) + .hexpand(true) + .label(unicode) + .css_classes(["emoji"]) + .build(); + let item = adw::Bin::builder() + .child(&label) + .width_request(100) + .height_request(100) + .css_classes(["card"]) + .build(); + flowbox.append(&item); +} diff --git a/src/about.js b/src/about.js index 673b227f8..3a9394332 100644 --- a/src/about.js +++ b/src/about.js @@ -78,6 +78,7 @@ ${getBlueprintVersion()} "Adeel Ahmed Qureshi https://github.com/itsAdee", "Muhammad Bilal https://github.com/mbilal234", "Onkar https://github.com/onkarrai06", + "Sabrina Meindlhumer https://github.com/m-sabrina", // Add yourself as // "John Doe", // or