From 7ca4b115646a0ec1c19547267959625b6842b288 Mon Sep 17 00:00:00 2001 From: Lucas Fernandes Nogueira Date: Thu, 3 Aug 2023 11:54:08 -0700 Subject: [PATCH] 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 --- .changes/gtk-add-menu-position.md | 5 +++++ src/menu.rs | 1 + src/platform_impl/gtk/mod.rs | 2 ++ 3 files changed, 8 insertions(+) create mode 100644 .changes/gtk-add-menu-position.md diff --git a/.changes/gtk-add-menu-position.md b/.changes/gtk-add-menu-position.md new file mode 100644 index 0000000..3201749 --- /dev/null +++ b/.changes/gtk-add-menu-position.md @@ -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. diff --git a/src/menu.rs b/src/menu.rs index 8279be0..65d99c6 100644 --- a/src/menu.rs +++ b/src/menu.rs @@ -147,6 +147,7 @@ impl Menu { W: gtk::prelude::IsA, W: gtk::prelude::IsA, C: gtk::prelude::IsA, + C: gtk::prelude::IsA, { self.0.borrow_mut().init_for_gtk_window(window, container) } diff --git a/src/platform_impl/gtk/mod.rs b/src/platform_impl/gtk/mod.rs index 5fa92a3..00b0ce6 100644 --- a/src/platform_impl/gtk/mod.rs +++ b/src/platform_impl/gtk/mod.rs @@ -217,6 +217,7 @@ impl Menu { W: IsA, W: IsA, C: IsA, + C: IsA, { let id = window.as_ptr() as u32; @@ -245,6 +246,7 @@ impl Menu { // add the menubar to the specified widget, otherwise to the window if let Some(container) = container { container.add(menu_bar); + container.reorder_child(menu_bar, 0); } else { window.add(menu_bar); }