Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add rust demo Flow Box #575

Merged
merged 1 commit into from
Sep 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions src/Library/demos/Flow Box/code.rs
Original file line number Diff line number Diff line change
@@ -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::<adw::Bin>()
.unwrap()
.child()
.unwrap()
.downcast::<gtk::Label>()
.unwrap()
.label();
let emoji = emoji.chars().next().unwrap();
println!("Unicode:{:X}", emoji as u32);
});
}

pub fn add_emoji(flowbox: &gtk::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);
}
1 change: 1 addition & 0 deletions src/about.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down