From 0f62d5315c47ee94a37d061456184d6a7b8947a6 Mon Sep 17 00:00:00 2001 From: Vika Date: Wed, 19 Feb 2025 21:07:25 +0300 Subject: Use WrapLayout for the tag pill widget This is what I originally wanted to use, actually. --- Cargo.toml | 4 ++-- src/components/post_editor.rs | 24 ++++++++---------------- 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index d4723d1..411e4af 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ default = ["smart-summary"] relm4-icons-build = "0.10.0-beta.1" [dependencies] -adw = { version = "0.7.0", package = "libadwaita", features = ["v1_6"] } +adw = { version = "0.7.1", package = "libadwaita", features = ["v1_7"] } futures = "0.3.30" gettext-rs = { version = "=0.7.0", features = ["gettext-system"] } gio = { version = "0.20.1", features = ["v2_80"] } @@ -24,7 +24,7 @@ kittybox-util = { git = "https://git.vikanezrimaya.xyz/kittybox", version = "0.3 libsecret = { version = "0.7.0", features = ["v0_21_2"] } log = { version = "0.4.22", features = ["std"] } microformats = "0.9.1" -relm4 = { version = "0.9.0", features = ["gnome_46", "adw", "css", "macros", "libadwaita"] } +relm4 = { version = "0.9.1", features = ["gnome_46", "adw", "css", "macros", "libadwaita"] } relm4-icons = { version = "0.10.0-beta.1", features = ["icon-development-kit"] } serde = { version = "1.0.208", features = ["derive"] } serde_json = "1.0.125" diff --git a/src/components/post_editor.rs b/src/components/post_editor.rs index c42b06a..d9d85c0 100644 --- a/src/components/post_editor.rs +++ b/src/components/post_editor.rs @@ -211,19 +211,7 @@ impl Component for Post }, }, - #[name = "tag_viewport"] - gtk::ScrolledWindow { - set_height_request: 32, - set_valign: gtk::Align::Center, - - gtk::Viewport { - set_scroll_to_focus: true, - set_valign: gtk::Align::Center, - - #[wrap(Some)] - set_child = model.tags.widget(), - } - }, + model.tags.widget(), #[name = "content_label"] gtk::Label { @@ -354,8 +342,12 @@ impl Component for Post tags: FactoryVecDeque::builder() .launch({ let listbox = gtk::Box::default(); - listbox.set_orientation(gtk::Orientation::Horizontal); - listbox.set_spacing(5); + let layout = adw::WrapLayout::builder() + .child_spacing(5) + .line_spacing(5) + .build(); + + listbox.set_layout_manager(Some(layout)); listbox }) .forward( @@ -427,7 +419,7 @@ impl Component for Post Row::TwoColumn(&widgets.name_label, widgets.name_field.upcast_ref::()), Row::TwoColumn(&widgets.summary_label, widgets.summary_field.upcast_ref::()), Row::TwoColumn(&widgets.tag_label, widgets.tag_holder.upcast_ref::()), - Row::SecondColumn(widgets.tag_viewport.upcast_ref::()), + Row::SecondColumn(model.tags.widget().upcast_ref::()), Row::TwoColumn(&widgets.content_label, widgets.content_textarea_wrapper.upcast_ref::()), Row::Span(widgets.misc_prop_wrapper.upcast_ref::()), ].into_iter().enumerate() { -- cgit 1.4.1