diff --git a/Cargo.toml b/Cargo.toml index 0df5db45..fe7a339f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -47,6 +47,10 @@ features = [ gtk = { version = "0.18", optional = true } libxdo = { version = "0.6.0", optional = true } +[target.'cfg(target_os = "freebsd")'.dependencies] +gtk = { version = "0.18", optional = true } +libxdo = { version = "0.6.0", optional = true } + [target.'cfg(target_os = "macos")'.dependencies] objc2 = "0.6.0" objc2-core-foundation = { version = "0.3.0", default-features = false, features = [ diff --git a/src/error.rs b/src/error.rs index ffc17796..01def221 100644 --- a/src/error.rs +++ b/src/error.rs @@ -15,13 +15,13 @@ pub enum Error { #[cfg(windows)] #[error("This menu has not been initialized for this hwnd`")] NotInitialized, - #[cfg(all(target_os = "linux", feature = "gtk"))] + #[cfg(all(any(target_os = "linux", target_os = "freebsd"), feature = "gtk"))] #[error("This menu has not been initialized for this gtk window`")] NotInitialized, #[cfg(windows)] #[error("This menu has already been initialized for this hwnd`")] AlreadyInitialized, - #[cfg(all(target_os = "linux", feature = "gtk"))] + #[cfg(all(any(target_os = "linux", target_os = "freebsd"), feature = "gtk"))] #[error("This menu has already been initialized for this gtk window`")] AlreadyInitialized, #[error(transparent)] diff --git a/src/items/mod.rs b/src/items/mod.rs index 39c9b157..7da896b9 100644 --- a/src/items/mod.rs +++ b/src/items/mod.rs @@ -19,7 +19,7 @@ mod test { use crate::{CheckMenuItem, IconMenuItem, MenuId, MenuItem, PredefinedMenuItem, Submenu}; #[test] - #[cfg_attr(all(miri, not(target_os = "linux")), ignore)] + #[cfg_attr(all(miri, not(any(target_os = "linux", target_os = "freebsd"))), ignore)] fn it_returns_same_id() { let id = MenuId::new("1"); assert_eq!(id, MenuItem::with_id(id.clone(), "", true, None).id()); @@ -35,7 +35,7 @@ mod test { } #[test] - #[cfg_attr(all(miri, not(target_os = "linux")), ignore)] + #[cfg_attr(all(miri, not(any(target_os = "linux", target_os = "freebsd"))), ignore)] fn test_convert_from_id_and_into_id() { let id = "TEST ID"; let expected = MenuId(id.to_string()); diff --git a/src/items/submenu.rs b/src/items/submenu.rs index a93b841c..4f84360f 100644 --- a/src/items/submenu.rs +++ b/src/items/submenu.rs @@ -248,7 +248,7 @@ impl ContextMenu for Submenu { self.inner.borrow().detach_menu_subclass_from_hwnd(hwnd) } - #[cfg(all(target_os = "linux", feature = "gtk"))] + #[cfg(all(any(target_os = "linux", target_os = "freebsd"), feature = "gtk"))] fn show_context_menu_for_gtk_window( &self, w: >k::Window, @@ -259,7 +259,7 @@ impl ContextMenu for Submenu { .show_context_menu_for_gtk_window(w, position) } - #[cfg(all(target_os = "linux", feature = "gtk"))] + #[cfg(all(any(target_os = "linux", target_os = "freebsd"), feature = "gtk"))] fn gtk_context_menu(&self) -> gtk::Menu { self.inner.borrow_mut().gtk_context_menu() } diff --git a/src/lib.rs b/src/lib.rs index 40347ab3..f53e4216 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -77,14 +77,14 @@ //! ```no_run //! # let menu = muda::Menu::new(); //! # let window_hwnd = 0; -//! # #[cfg(target_os = "linux")] +//! # #[cfg(any(target_os = "linux", target_os = "freebsd"))] //! # let gtk_window = gtk::Window::builder().build(); -//! # #[cfg(target_os = "linux")] +//! # #[cfg(any(target_os = "linux", target_os = "freebsd"))] //! # let vertical_gtk_box = gtk::Box::new(gtk::Orientation::Vertical, 0); //! // --snip-- //! #[cfg(target_os = "windows")] //! unsafe { menu.init_for_hwnd(window_hwnd) }; -//! #[cfg(target_os = "linux")] +//! #[cfg(any(target_os = "linux", target_os = "freebsd"))] //! menu.init_for_gtk_window(>k_window, Some(&vertical_gtk_box)); //! #[cfg(target_os = "macos")] //! menu.init_for_nsapp(); @@ -98,7 +98,7 @@ //! use muda::ContextMenu; //! # let menu = muda::Menu::new(); //! # let window_hwnd = 0; -//! # #[cfg(target_os = "linux")] +//! # #[cfg(any(target_os = "linux", target_os = "freebsd"))] //! # let gtk_window = gtk::Window::builder().build(); //! # #[cfg(target_os = "macos")] //! # let nsview = std::ptr::null(); @@ -106,7 +106,7 @@ //! let position = muda::dpi::PhysicalPosition { x: 100., y: 120. }; //! #[cfg(target_os = "windows")] //! unsafe { menu.show_context_menu_for_hwnd(window_hwnd, Some(position.into())) }; -//! #[cfg(target_os = "linux")] +//! #[cfg(any(target_os = "linux", target_os = "freebsd"))] //! menu.show_context_menu_for_gtk_window(>k_window, Some(position.into())); //! #[cfg(target_os = "macos")] //! unsafe { menu.show_context_menu_for_nsview(nsview, Some(position.into())) }; @@ -375,7 +375,7 @@ pub trait ContextMenu { /// Returns `true` if menu tracking ended because an item was selected or clicked outside the menu to dismiss it. /// /// Returns `false` if menu tracking was cancelled for any reason. - #[cfg(all(target_os = "linux", feature = "gtk"))] + #[cfg(all(any(target_os = "linux", target_os = "freebsd"), feature = "gtk"))] fn show_context_menu_for_gtk_window( &self, w: >k::Window, @@ -385,7 +385,7 @@ pub trait ContextMenu { /// Get the underlying gtk menu reserved for context menus. /// /// The returned [`gtk::Menu`] is valid as long as the `ContextMenu` is. - #[cfg(all(target_os = "linux", feature = "gtk"))] + #[cfg(all(any(target_os = "linux", target_os = "freebsd"), feature = "gtk"))] fn gtk_context_menu(&self) -> gtk::Menu; /// Shows this menu as a context menu for the specified `NSView`. diff --git a/src/menu.rs b/src/menu.rs index b1245dac..b1795ee5 100644 --- a/src/menu.rs +++ b/src/menu.rs @@ -182,7 +182,7 @@ impl Menu { /// ## Panics: /// /// Panics if the gtk event loop hasn't been initialized on the thread. - #[cfg(all(target_os = "linux", feature = "gtk"))] + #[cfg(all(any(target_os = "linux", target_os = "freebsd"), feature = "gtk"))] pub fn init_for_gtk_window(&self, window: &W, container: Option<&C>) -> crate::Result<()> where W: gtk::prelude::IsA, @@ -270,7 +270,7 @@ impl Menu { } /// Removes this menu from a [`gtk::Window`] - #[cfg(all(target_os = "linux", feature = "gtk"))] + #[cfg(all(any(target_os = "linux", target_os = "freebsd"), feature = "gtk"))] pub fn remove_for_gtk_window(&self, window: &W) -> crate::Result<()> where W: gtk::prelude::IsA, @@ -289,7 +289,7 @@ impl Menu { } /// Hides this menu from a [`gtk::Window`] - #[cfg(all(target_os = "linux", feature = "gtk"))] + #[cfg(all(any(target_os = "linux", target_os = "freebsd"), feature = "gtk"))] pub fn hide_for_gtk_window(&self, window: &W) -> crate::Result<()> where W: gtk::prelude::IsA, @@ -308,7 +308,7 @@ impl Menu { } /// Shows this menu on a [`gtk::Window`] - #[cfg(all(target_os = "linux", feature = "gtk"))] + #[cfg(all(any(target_os = "linux", target_os = "freebsd"), feature = "gtk"))] pub fn show_for_gtk_window(&self, window: &W) -> crate::Result<()> where W: gtk::prelude::IsA, @@ -327,7 +327,7 @@ impl Menu { } /// Returns whether this menu visible on a [`gtk::Window`] - #[cfg(all(target_os = "linux", feature = "gtk"))] + #[cfg(all(any(target_os = "linux", target_os = "freebsd"), feature = "gtk"))] pub fn is_visible_on_gtk_window(&self, window: &W) -> bool where W: gtk::prelude::IsA, @@ -335,7 +335,7 @@ impl Menu { self.inner.borrow().is_visible_on_gtk_window(window) } - #[cfg(all(target_os = "linux", feature = "gtk"))] + #[cfg(all(any(target_os = "linux", target_os = "freebsd"), feature = "gtk"))] /// Returns the [`gtk::MenuBar`] that is associated with this window if it exists. /// This is useful to get information about the menubar for example its height. pub fn gtk_menubar_for_gtk_window(self, window: &W) -> Option @@ -391,7 +391,7 @@ impl ContextMenu for Menu { self.inner.borrow().detach_menu_subclass_from_hwnd(hwnd) } - #[cfg(all(target_os = "linux", feature = "gtk"))] + #[cfg(all(any(target_os = "linux", target_os = "freebsd"), feature = "gtk"))] fn show_context_menu_for_gtk_window( &self, window: >k::Window, @@ -402,7 +402,7 @@ impl ContextMenu for Menu { .show_context_menu_for_gtk_window(window, position) } - #[cfg(all(target_os = "linux", feature = "gtk"))] + #[cfg(all(any(target_os = "linux", target_os = "freebsd"), feature = "gtk"))] fn gtk_context_menu(&self) -> gtk::Menu { self.inner.borrow_mut().gtk_context_menu() } diff --git a/src/platform_impl/mod.rs b/src/platform_impl/mod.rs index d3908f28..9f7041c5 100644 --- a/src/platform_impl/mod.rs +++ b/src/platform_impl/mod.rs @@ -5,7 +5,7 @@ #[cfg(target_os = "windows")] #[path = "windows/mod.rs"] mod platform; -#[cfg(all(target_os = "linux", feature = "gtk"))] +#[cfg(any(target_os = "linux", target_os = "freebsd"))] #[path = "gtk/mod.rs"] mod platform; #[cfg(target_os = "macos")] diff --git a/zellij.core b/zellij.core new file mode 100644 index 00000000..f185150b Binary files /dev/null and b/zellij.core differ