Remove App::on_open_files
, as it's a subset of on_open_urls
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
parent
d725876e64
commit
a210b05d00
4 changed files with 0 additions and 48 deletions
|
@ -274,20 +274,6 @@ impl App {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn on_open_files<F>(&mut self, mut callback: F) -> &mut Self
|
|
||||||
where
|
|
||||||
F: 'static + FnMut(Vec<PathBuf>, &mut MutableAppContext),
|
|
||||||
{
|
|
||||||
let cx = self.0.clone();
|
|
||||||
self.0
|
|
||||||
.borrow_mut()
|
|
||||||
.foreground_platform
|
|
||||||
.on_open_files(Box::new(move |paths| {
|
|
||||||
callback(paths, &mut *cx.borrow_mut())
|
|
||||||
}));
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn on_open_urls<F>(&mut self, mut callback: F) -> &mut Self
|
pub fn on_open_urls<F>(&mut self, mut callback: F) -> &mut Self
|
||||||
where
|
where
|
||||||
F: 'static + FnMut(Vec<String>, &mut MutableAppContext),
|
F: 'static + FnMut(Vec<String>, &mut MutableAppContext),
|
||||||
|
|
|
@ -62,7 +62,6 @@ pub(crate) trait ForegroundPlatform {
|
||||||
fn on_resign_active(&self, callback: Box<dyn FnMut()>);
|
fn on_resign_active(&self, callback: Box<dyn FnMut()>);
|
||||||
fn on_quit(&self, callback: Box<dyn FnMut()>);
|
fn on_quit(&self, callback: Box<dyn FnMut()>);
|
||||||
fn on_event(&self, callback: Box<dyn FnMut(Event) -> bool>);
|
fn on_event(&self, callback: Box<dyn FnMut(Event) -> bool>);
|
||||||
fn on_open_files(&self, callback: Box<dyn FnMut(Vec<PathBuf>)>);
|
|
||||||
fn on_open_urls(&self, callback: Box<dyn FnMut(Vec<String>)>);
|
fn on_open_urls(&self, callback: Box<dyn FnMut(Vec<String>)>);
|
||||||
fn run(&self, on_finish_launching: Box<dyn FnOnce() -> ()>);
|
fn run(&self, on_finish_launching: Box<dyn FnOnce() -> ()>);
|
||||||
|
|
||||||
|
|
|
@ -85,10 +85,6 @@ unsafe fn build_classes() {
|
||||||
sel!(handleGPUIMenuItem:),
|
sel!(handleGPUIMenuItem:),
|
||||||
handle_menu_item as extern "C" fn(&mut Object, Sel, id),
|
handle_menu_item as extern "C" fn(&mut Object, Sel, id),
|
||||||
);
|
);
|
||||||
decl.add_method(
|
|
||||||
sel!(application:openFiles:),
|
|
||||||
open_files as extern "C" fn(&mut Object, Sel, id, id),
|
|
||||||
);
|
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(application:openURLs:),
|
sel!(application:openURLs:),
|
||||||
open_urls as extern "C" fn(&mut Object, Sel, id, id),
|
open_urls as extern "C" fn(&mut Object, Sel, id, id),
|
||||||
|
@ -107,7 +103,6 @@ pub struct MacForegroundPlatformState {
|
||||||
quit: Option<Box<dyn FnMut()>>,
|
quit: Option<Box<dyn FnMut()>>,
|
||||||
event: Option<Box<dyn FnMut(crate::Event) -> bool>>,
|
event: Option<Box<dyn FnMut(crate::Event) -> bool>>,
|
||||||
menu_command: Option<Box<dyn FnMut(&dyn Action)>>,
|
menu_command: Option<Box<dyn FnMut(&dyn Action)>>,
|
||||||
open_files: Option<Box<dyn FnMut(Vec<PathBuf>)>>,
|
|
||||||
open_urls: Option<Box<dyn FnMut(Vec<String>)>>,
|
open_urls: Option<Box<dyn FnMut(Vec<String>)>>,
|
||||||
finish_launching: Option<Box<dyn FnOnce() -> ()>>,
|
finish_launching: Option<Box<dyn FnOnce() -> ()>>,
|
||||||
menu_actions: Vec<Box<dyn Action>>,
|
menu_actions: Vec<Box<dyn Action>>,
|
||||||
|
@ -210,10 +205,6 @@ impl platform::ForegroundPlatform for MacForegroundPlatform {
|
||||||
self.0.borrow_mut().event = Some(callback);
|
self.0.borrow_mut().event = Some(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn on_open_files(&self, callback: Box<dyn FnMut(Vec<PathBuf>)>) {
|
|
||||||
self.0.borrow_mut().open_files = Some(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn on_open_urls(&self, callback: Box<dyn FnMut(Vec<String>)>) {
|
fn on_open_urls(&self, callback: Box<dyn FnMut(Vec<String>)>) {
|
||||||
self.0.borrow_mut().open_urls = Some(callback);
|
self.0.borrow_mut().open_urls = Some(callback);
|
||||||
}
|
}
|
||||||
|
@ -673,28 +664,6 @@ extern "C" fn will_terminate(this: &mut Object, _: Sel, _: id) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" fn open_files(this: &mut Object, _: Sel, _: id, paths: id) {
|
|
||||||
let paths = unsafe {
|
|
||||||
(0..paths.count())
|
|
||||||
.into_iter()
|
|
||||||
.filter_map(|i| {
|
|
||||||
let path = paths.objectAtIndex(i);
|
|
||||||
match CStr::from_ptr(path.UTF8String() as *mut c_char).to_str() {
|
|
||||||
Ok(string) => Some(PathBuf::from(string)),
|
|
||||||
Err(err) => {
|
|
||||||
log::error!("error converting path to string: {}", err);
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.collect::<Vec<_>>()
|
|
||||||
};
|
|
||||||
let platform = unsafe { get_foreground_platform(this) };
|
|
||||||
if let Some(callback) = platform.0.borrow_mut().open_files.as_mut() {
|
|
||||||
callback(paths);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" fn open_urls(this: &mut Object, _: Sel, _: id, urls: id) {
|
extern "C" fn open_urls(this: &mut Object, _: Sel, _: id, urls: id) {
|
||||||
let urls = unsafe {
|
let urls = unsafe {
|
||||||
(0..urls.count())
|
(0..urls.count())
|
||||||
|
|
|
@ -66,8 +66,6 @@ impl super::ForegroundPlatform for ForegroundPlatform {
|
||||||
|
|
||||||
fn on_event(&self, _: Box<dyn FnMut(crate::Event) -> bool>) {}
|
fn on_event(&self, _: Box<dyn FnMut(crate::Event) -> bool>) {}
|
||||||
|
|
||||||
fn on_open_files(&self, _: Box<dyn FnMut(Vec<std::path::PathBuf>)>) {}
|
|
||||||
|
|
||||||
fn on_open_urls(&self, _: Box<dyn FnMut(Vec<String>)>) {}
|
fn on_open_urls(&self, _: Box<dyn FnMut(Vec<String>)>) {}
|
||||||
|
|
||||||
fn run(&self, _on_finish_launching: Box<dyn FnOnce() -> ()>) {
|
fn run(&self, _on_finish_launching: Box<dyn FnOnce() -> ()>) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue