Skip to content
Snippets Groups Projects

WIP: (conditional) addition of SSD installation page, some code-reorganizations, fix of stack sidebar tabbing, exit directly without cleanup script

Open plom requested to merge plom_experiments into main
1 file
+ 24
0
Compare changes
  • Side-by-side
  • Inline
+ 24
0
@@ -1000,4 +1000,28 @@ fn build_ui(app: &Application) {
if got_nvme {
build_encrypt_page(&stack, &window);
}
let key_ctrl = gtk::EventControllerKey::new();
window.add_controller(key_ctrl.clone());
key_ctrl.connect_key_pressed(move |_a, key, _b, _c| {
if key == gdk::Key::Tab || key == gdk::Key::ISO_Left_Tab {
match GtkWindowExt::focus(&window) {
Some(w) if w.is::<gtk::ListBoxRow>() && w.parent().unwrap().parent().unwrap().parent().unwrap().parent().unwrap().is::<StackSidebar>() => {
    • minute @mntmn commented on commit 364f2d21
      Owner

      This parent().unwrap() cascade is really something! (This would panic on any ListBox that doesn't have that many parents, right?)

      Edited by minute
      • Author Maintainer

        From my GTK experiments, it accurately represents the depth any ListBoxRow should find itself in, so the unwrap() /should/ never panic. But I guess it's better to be safe than sorry, so I'll replace them with some more graceful handling.

        Edited by plom
      • Author Maintainer

        @mntmn New pattern: !11 (d5009180)

        Edited by plom
      • Please register or sign in to reply
Please register or sign in to reply
let old_focus_idx = w.clone().downcast::<gtk::ListBoxRow>().unwrap().index();
let new_focus_idx = old_focus_idx + match key {
gdk::Key::Tab => 1,
_ => -1
};
if new_focus_idx >= 0 && new_focus_idx < 8 {
let list_box = w.parent().unwrap().downcast::<gtk::ListBox>().unwrap();
let next_row = list_box.row_at_index(new_focus_idx.try_into().unwrap()).unwrap();
next_row.grab_focus();
return glib::Propagation::Stop
}
},
_ => ()
}
}
glib::Propagation::Proceed
});
}
Loading