Replies: 2 comments
-
|
I merged your pull request, it looks good. Although I kept tag_box and moved your implementation into tag_container: /// Creates a new GTK4 `Box` with a specified CSS class name.
/// Can be used for images.
pub fn tag_box(class_name: &str) -> Tag {
let tag = Box::new(Orientation::Vertical, 0);
tag.set_widget_name(class_name);
Tag::Box(tag)
}
/// Creates a new GTK4 `Box` with a specified CSS class name, orientation and spacing.
/// Used for grouping widgets together.
pub fn tag_container(
class_name: &str,
orientation: Orientation,
spacing: i32,
widgets: Vec<Tag>,
) -> Tag {
let tag = Box::new(orientation, spacing);
tag.set_widget_name(class_name);
let widgets: Vec<Widget> = widgets
.into_iter()
.map(|tag| match tag {
Tag::Label(label) => label.clone().upcast::<Widget>(),
Tag::Box(box_) => box_.clone().upcast::<Widget>(),
Tag::Button(button) => button.clone().upcast::<Widget>(),
})
.collect();
for widget in widgets {
tag.append(&widget);
}
Tag::Box(tag)
}I need tag_box so I can display images. I also got rid of the string Orientation and replaced it with default GTK4 Orientation: Original: pub fn tag_box(class_name: &str, orientation: &str, spacing: i32, widgets: Vec<Tag>) -> Tag {
let orientation = match orientation {
"v" => Orientation::Vertical,
"h" => Orientation::Horizontal,
"vertical" => Orientation::Vertical,
"horizontal" => Orientation::Horizontal,
_ => Orientation::Vertical,
};
...
}New: pub fn tag_container(
class_name: &str,
orientation: Orientation, // Doing it this way will get rid of redundant logic
spacing: i32,
widgets: Vec<Tag>,
) -> Tag ...Also, note that I have moved the orientations out of the root directory, example: chunks::Verticalwill now be under: chunks_rs::Orientation::Vertical |
Beta Was this translation helpful? Give feedback.
-
|
I thought providing string literals would be more friendly. Directly parsing the args will do too. But I thought modified |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
hey @drkrssll , spending some time made me realize I had misinterpret the structure, now I understand the use of
Tag, so even though I don't know gtk much, I will give it a try to make/modify thetag_boxlabel so that:-orientation,spacingand aVec<Tag>into it..appendto append the tags.Some of the logic was already there in taskbar, I want to have your opinion on it, what do you think of it?
This can then be used to make out
GtkAppfunctions where we can parse tags to a box tag and then that box tag will be given toChunk::new.Beta Was this translation helpful? Give feedback.
All reactions