Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Comment on lines +50 to +52
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can reuse the linux deps above via the same any(target_os = "linux", target_os = "freebsd") you used in code

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood, will make changes and update it!


[target.'cfg(target_os = "macos")'.dependencies]
objc2 = "0.6.0"
objc2-core-foundation = { version = "0.3.0", default-features = false, features = [
Expand Down
4 changes: 2 additions & 2 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
4 changes: 2 additions & 2 deletions src/items/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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());
Expand Down
4 changes: 2 additions & 2 deletions src/items/submenu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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: &gtk::Window,
Expand All @@ -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()
}
Expand Down
14 changes: 7 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(&gtk_window, Some(&vertical_gtk_box));
//! #[cfg(target_os = "macos")]
//! menu.init_for_nsapp();
Expand All @@ -98,15 +98,15 @@
//! 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();
//! // --snip--
//! 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(&gtk_window, Some(position.into()));
//! #[cfg(target_os = "macos")]
//! unsafe { menu.show_context_menu_for_nsview(nsview, Some(position.into())) };
Expand Down Expand Up @@ -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: &gtk::Window,
Expand All @@ -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`.
Expand Down
16 changes: 8 additions & 8 deletions src/menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<W, C>(&self, window: &W, container: Option<&C>) -> crate::Result<()>
where
W: gtk::prelude::IsA<gtk::Window>,
Expand Down Expand Up @@ -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<W>(&self, window: &W) -> crate::Result<()>
where
W: gtk::prelude::IsA<gtk::Window>,
Expand All @@ -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<W>(&self, window: &W) -> crate::Result<()>
where
W: gtk::prelude::IsA<gtk::Window>,
Expand All @@ -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<W>(&self, window: &W) -> crate::Result<()>
where
W: gtk::prelude::IsA<gtk::Window>,
Expand All @@ -327,15 +327,15 @@ 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<W>(&self, window: &W) -> bool
where
W: gtk::prelude::IsA<gtk::Window>,
{
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<W>(self, window: &W) -> Option<gtk::MenuBar>
Expand Down Expand Up @@ -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: &gtk::Window,
Expand All @@ -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()
}
Expand Down
2 changes: 1 addition & 1 deletion src/platform_impl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down
Binary file added zellij.core
Binary file not shown.
Loading