From db33c382b7abeb8fdcac5bd9d0cc83773e2d5703 Mon Sep 17 00:00:00 2001 From: Ryan McGrath Date: Wed, 11 Mar 2020 19:45:35 -0700 Subject: [PATCH] Fix up the NSToolbar wrapper to follow the new paradigm --- appkit/src/lib.rs | 2 +- appkit/src/pasteboard/pasteboard.rs | 2 +- appkit/src/toolbar/item.rs | 18 ++-- appkit/src/toolbar/mod.rs | 9 +- appkit/src/toolbar/toolbar.rs | 153 +++++++++++++++------------- appkit/src/toolbar/traits.rs | 17 ++++ appkit/src/view/view.rs | 1 - appkit/src/window/handle.rs | 20 +--- appkit/src/window/window.rs | 7 +- 9 files changed, 133 insertions(+), 96 deletions(-) create mode 100644 appkit/src/toolbar/traits.rs diff --git a/appkit/src/lib.rs b/appkit/src/lib.rs index d6f35b4..bb88de8 100644 --- a/appkit/src/lib.rs +++ b/appkit/src/lib.rs @@ -49,7 +49,7 @@ pub mod prelude { pub use crate::menu::{Menu, MenuItem}; pub use crate::notifications::{Notification, NotificationCenter, NotificationAuthOption}; - pub use crate::toolbar::{ToolbarDelegate}; + pub use crate::toolbar::{Toolbar, ToolbarController}; pub use crate::networking::URLRequest; diff --git a/appkit/src/pasteboard/pasteboard.rs b/appkit/src/pasteboard/pasteboard.rs index 7e5f315..0ae054b 100644 --- a/appkit/src/pasteboard/pasteboard.rs +++ b/appkit/src/pasteboard/pasteboard.rs @@ -12,7 +12,7 @@ use objc_id::Id; use url::Url; use crate::error::AppKitError; -use crate::pasteboard::types::{PasteboardName, PasteboardType}; +use crate::pasteboard::types::{PasteboardName}; use crate::utils::str_from; /// Represents an `NSPasteboard`, enabling you to handle copy/paste/drag and drop. diff --git a/appkit/src/toolbar/item.rs b/appkit/src/toolbar/item.rs index 305f1ca..4150a80 100644 --- a/appkit/src/toolbar/item.rs +++ b/appkit/src/toolbar/item.rs @@ -14,21 +14,23 @@ use crate::button::Button; /// A wrapper for `NSWindow`. Holds (retains) pointers for the Objective-C runtime /// where our `NSWindow` and associated delegate live. -pub struct ToolbarItem<'a> { - pub identifier: &'a str, +pub struct ToolbarItem { + pub identifier: String, pub inner: Id, pub button: Option