mirror of
https://github.com/servo/servo.git
synced 2025-08-15 18:35:33 +01:00
Move tinyfiledialog out of script into embedder.
This commit is contained in:
parent
24c14ac94e
commit
675b36dde5
6 changed files with 81 additions and 45 deletions
|
@ -7,7 +7,9 @@ use crate::window_trait::{WindowPortsMethods, LINE_HEIGHT};
|
|||
use euclid::{Point2D, Vector2D};
|
||||
use keyboard_types::{Key, KeyboardEvent, Modifiers, ShortcutMatcher};
|
||||
use servo::compositing::windowing::{WebRenderDebugOption, WindowEvent};
|
||||
use servo::embedder_traits::{EmbedderMsg, FilterPattern, PromptDefinition, PromptOrigin, PromptResult};
|
||||
use servo::embedder_traits::{
|
||||
EmbedderMsg, FilterPattern, PermissionRequest, PromptDefinition, PromptOrigin, PromptResult,
|
||||
};
|
||||
use servo::msg::constellation_msg::TopLevelBrowsingContextId as BrowserId;
|
||||
use servo::msg::constellation_msg::TraversalDirection;
|
||||
use servo::net_traits::pub_domains::is_reg_domain;
|
||||
|
@ -491,6 +493,10 @@ where
|
|||
self.event_queue.push(WindowEvent::SendError(None, reason));
|
||||
};
|
||||
},
|
||||
EmbedderMsg::PromptPermission(message, dialog_title, sender) => {
|
||||
let permission_state = prompt_user(&message, &dialog_title);
|
||||
let _ = sender.send(permission_state);
|
||||
}
|
||||
EmbedderMsg::ShowIME(_kind) => {
|
||||
debug!("ShowIME received");
|
||||
},
|
||||
|
@ -513,6 +519,28 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
fn prompt_user(prompt: &str, dialog_title: &str) -> PermissionRequest {
|
||||
if opts::get().headless {
|
||||
return PermissionRequest::Denied;
|
||||
}
|
||||
match tinyfiledialogs::message_box_yes_no(
|
||||
dialog_title,
|
||||
prompt,
|
||||
MessageBoxIcon::Question,
|
||||
YesNo::No,
|
||||
) {
|
||||
YesNo::Yes => PermissionRequest::Granted,
|
||||
YesNo::No => PermissionRequest::Denied,
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "linux"))]
|
||||
fn prompt_user(_prompt: &str, _dialog_title: &str) -> PermissionRequest {
|
||||
// TODO popup only supported on linux
|
||||
PermissionRequest::Denied
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
fn platform_get_selected_devices(devices: Vec<String>) -> Option<String> {
|
||||
let picker_name = "Choose a device";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue