fix(linux): menu must be the container's first child (#89)

* fix(linux): menu must be the container's first child

* check if gtk box instead

* Revert "check if gtk box instead"

* update change file
This commit is contained in:
Lucas Fernandes Nogueira 2023-08-03 11:54:08 -07:00 committed by GitHub
parent bb92b5667e
commit 7ca4b11564
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 0 deletions

View file

@ -0,0 +1,5 @@
---
"muda": minor
---
**Breaking Change:** On Linux, `Menu::inti_for_gtk_window` has been changed to require the second paramter to extend `gtk::Box`. This ensures that the menu bar is added at the beginning of the box instead of at the bottom.

View file

@ -147,6 +147,7 @@ impl Menu {
W: gtk::prelude::IsA<gtk::Window>, W: gtk::prelude::IsA<gtk::Window>,
W: gtk::prelude::IsA<gtk::Container>, W: gtk::prelude::IsA<gtk::Container>,
C: gtk::prelude::IsA<gtk::Container>, C: gtk::prelude::IsA<gtk::Container>,
C: gtk::prelude::IsA<gtk::Box>,
{ {
self.0.borrow_mut().init_for_gtk_window(window, container) self.0.borrow_mut().init_for_gtk_window(window, container)
} }

View file

@ -217,6 +217,7 @@ impl Menu {
W: IsA<gtk::Window>, W: IsA<gtk::Window>,
W: IsA<gtk::Container>, W: IsA<gtk::Container>,
C: IsA<gtk::Container>, C: IsA<gtk::Container>,
C: IsA<gtk::Box>,
{ {
let id = window.as_ptr() as u32; let id = window.as_ptr() as u32;
@ -245,6 +246,7 @@ impl Menu {
// add the menubar to the specified widget, otherwise to the window // add the menubar to the specified widget, otherwise to the window
if let Some(container) = container { if let Some(container) = container {
container.add(menu_bar); container.add(menu_bar);
container.reorder_child(menu_bar, 0);
} else { } else {
window.add(menu_bar); window.add(menu_bar);
} }