diff --git a/src/content/mod.rs b/src/content/mod.rs index c70477e..9752f24 100644 --- a/src/content/mod.rs +++ b/src/content/mod.rs @@ -44,19 +44,60 @@ pub fn content( let null_checkbutton = gtk::CheckButton::builder() .build(); + let layout_grid = gtk::Grid::builder() + .vexpand(true) + .hexpand(true) + .build(); + + let previews_size_group = gtk::SizeGroup::new(gtk::SizeGroupMode::Both); + + let mut last_widget: (Option, i32) = (None, 0); + for layout in desktop_layouts { let layout_name = layout.name.clone(); let layout_id = layout.id; let layout_box = gtk::Box::builder() - .orientation(gtk::Orientation::Horizontal) + .orientation(gtk::Orientation::Vertical) .build(); let layout_preview = gtk::Image::builder() .resource(format!("/com/github/pikaos-linux/pikagnomelayouts/previews/{}.svg", &layout_name)) + .vexpand(true) + .hexpand(true) + .margin_start(5) + .margin_end(5) + .margin_top(5) .build(); - content_box.append(&layout_preview); + + let layout_checkbutton = gtk::CheckButton::builder() + .group(&null_checkbutton) + .halign(gtk::Align::Center) + .valign(gtk::Align::Start) + .label(t!(format!("{}_label", &layout_name))) + .tooltip_text(t!(format!("{}_tooltip_text", &layout_name))) + .build(); + + previews_size_group.add_widget(&layout_preview); + + layout_box.append(&layout_preview); + layout_box.append(&layout_checkbutton); + + if last_widget.0.is_none() { + layout_grid.attach(&layout_box, 0, 0, 1, 1); + } else if last_widget.1 == 3 { + layout_grid.attach_next_to(&layout_box, Some(&last_widget.0.unwrap()), gtk::PositionType::Bottom, 1, 1) + } else if last_widget.1 > 3 { + layout_grid.attach_next_to(&layout_box, Some(&last_widget.0.unwrap()), gtk::PositionType::Left, 1, 1) + } else { + layout_grid.attach_next_to(&layout_box, Some(&last_widget.0.unwrap()), gtk::PositionType::Right, 1, 1) + } + + last_widget.0 = Some(layout_box); + last_widget.1 += 1; } + content_box.append(&layout_grid); + content_stack.add_named( &content_box, Some("content_page"),