When I to create a help overlay programmatically auto-height is ignored. All shortcuts are listen in one column. I have this sample code:
use gtk::prelude::*;
use gtk::{ApplicationWindow, Button, ShortcutsWindow};
const GENERAL_SHORTCUTS: [(&str, &str); 3] = [
("Open Command Pallette", "<Primary><Shift>P"),
("Quit", "<Primary>Q"),
("Re-execute Last Script", "<Primary><Shift>B"),
];
const EDITOR_SHORTCUTS: [(&str, &str); 12] = [
("Undo", "<Primary>Z"),
("Redo", "<Primary><Shift>Z"),
("Move line up", "<Alt>Up"),
("Move line down", "<Alt>Down"),
("Move cursor backwards one word", "<Primary>Left"),
("Move cursor forward one word", "<Primary>Right"),
("Move cursor to beginning of previous line", "<Primary>Up"),
("Move cursor to end of next line", "<Primary>Down"),
("Move cursor to beginning of line", "<Primary>Page_Up"),
("Move cursor to end of line", "<Primary>Page_Down"),
("Move cursor to beginning of document", "<Primary>Home"),
("Move cursor to end of document", "<Primary>End"),
];
const APP_ID: &str = "org.gtk_rs.HelloWorld2";
fn main() {
let app = adw::Application::builder().application_id(APP_ID).build();
app.connect_activate(build_ui);
app.run();
}
fn build_ui(app: &adw::Application) {
let window = ApplicationWindow::builder()
.application(app)
.title("My GTK App")
.build();
window.present();
let shortcutswindow = gtk::builders::ShortcutsWindowBuilder::new().modal(true).build();
let general_group = gtk::builders::ShortcutsGroupBuilder::new().title("General").build();
for (title, accelerator) in GENERAL_SHORTCUTS.iter() {
general_group.append(
>k::builders::ShortcutsShortcutBuilder::new()
.title(title)
.accelerator(accelerator)
.visible(true)
.build(),
);
}
let editors_group = gtk::builders::ShortcutsGroupBuilder::new().title("Editor").build();
for (title, accelerator) in EDITOR_SHORTCUTS.iter() {
editors_group.append(
>k::builders::ShortcutsShortcutBuilder::new()
.title(title)
.accelerator(accelerator)
.visible(true)
.build(),
);
}
let section = gtk::builders::ShortcutsSectionBuilder::new().max_height(6).section_name("section1").title("section1").build();
section.append(&general_group);
section.append(&editors_group);
shortcutswindow.set_child(Some(§ion));
shortcutswindow.present();
}
How can I make ShortcutsSection distribute the shortcuts over multiple columns?