1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// from webkit-gir-files
// DO NOT EDIT
use crate::{ffi, ApplicationInfo, WebView};
use glib::{
prelude::*,
signal::{connect_raw, SignalHandlerId},
translate::*,
};
use std::boxed::Box as Box_;
glib::wrapper! {
/// Automation Session.
///
/// WebKitAutomationSession represents an automation session of a WebKitWebContext.
/// When a new session is requested, a WebKitAutomationSession is created and the signal
/// WebKitWebContext::automation-started is emitted with the WebKitAutomationSession as
/// argument. Then, the automation client can request the session to create a new
/// #WebKitWebView to interact with it. When this happens the signal #WebKitAutomationSession::create-web-view
/// is emitted.
///
/// ## Properties
///
///
/// #### `id`
/// The session unique identifier.
///
/// Readable | Writeable | Construct Only
///
/// ## Signals
///
///
/// #### `create-web-view`
/// This signal is emitted when the automation client requests a new
/// browsing context to interact with it. The callback handler should
/// return a #WebKitWebView created with #WebKitWebView:is-controlled-by-automation
/// construct property enabled and #WebKitWebView:automation-presentation-type construct
/// property set if needed.
///
/// If the signal is emitted with "tab" detail, the returned #WebKitWebView should be
/// a new web view added to a new tab of the current browsing context window.
/// If the signal is emitted with "window" detail, the returned #WebKitWebView should be
/// a new web view added to a new window.
/// When creating a new web view and there's an active browsing context, the new window
/// or tab shouldn't be focused.
///
/// Detailed
#[doc(alias = "WebKitAutomationSession")]
pub struct AutomationSession(Object<ffi::WebKitAutomationSession, ffi::WebKitAutomationSessionClass>);
match fn {
type_ => || ffi::webkit_automation_session_get_type(),
}
}
impl AutomationSession {
/// Get the the previously set #WebKitAutomationSession.
///
/// Get the #WebKitAutomationSession previously set with webkit_automation_session_set_application_info().
///
/// # Returns
///
/// the #WebKitAutomationSession of @self, or [`None`] if no one has been set.
#[doc(alias = "webkit_automation_session_get_application_info")]
#[doc(alias = "get_application_info")]
pub fn application_info(&self) -> Option<ApplicationInfo> {
unsafe {
from_glib_none(ffi::webkit_automation_session_get_application_info(
self.to_glib_none().0,
))
}
}
/// Get the unique identifier of a #WebKitAutomationSession
///
/// # Returns
///
/// the unique identifier of @self
#[doc(alias = "webkit_automation_session_get_id")]
#[doc(alias = "get_id")]
pub fn id(&self) -> Option<glib::GString> {
unsafe { from_glib_none(ffi::webkit_automation_session_get_id(self.to_glib_none().0)) }
}
/// Set the application information to @self.
///
/// This information will be used by the driver service
/// to match the requested capabilities with the actual application information. If this information
/// is not provided to the session when a new automation session is requested, the creation might fail
/// if the client requested a specific browser name or version. This will not have any effect when called
/// after the automation session has been fully created, so this must be called in the callback of
/// #WebKitWebContext::automation-started signal.
/// ## `info`
/// a #WebKitApplicationInfo
#[doc(alias = "webkit_automation_session_set_application_info")]
pub fn set_application_info(&self, info: &ApplicationInfo) {
unsafe {
ffi::webkit_automation_session_set_application_info(
self.to_glib_none().0,
info.to_glib_none().0,
);
}
}
/// This signal is emitted when the automation client requests a new
/// browsing context to interact with it. The callback handler should
/// return a #WebKitWebView created with #WebKitWebView:is-controlled-by-automation
/// construct property enabled and #WebKitWebView:automation-presentation-type construct
/// property set if needed.
///
/// If the signal is emitted with "tab" detail, the returned #WebKitWebView should be
/// a new web view added to a new tab of the current browsing context window.
/// If the signal is emitted with "window" detail, the returned #WebKitWebView should be
/// a new web view added to a new window.
/// When creating a new web view and there's an active browsing context, the new window
/// or tab shouldn't be focused.
///
/// # Returns
///
/// a #WebKitWebView widget.
#[doc(alias = "create-web-view")]
pub fn connect_create_web_view<F: Fn(&Self) -> WebView + 'static>(
&self,
detail: Option<&str>,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn create_web_view_trampoline<
F: Fn(&AutomationSession) -> WebView + 'static,
>(
this: *mut ffi::WebKitAutomationSession,
f: glib::ffi::gpointer,
) -> *mut ffi::WebKitWebView {
let f: &F = &*(f as *const F);
f(&from_glib_borrow(this)) /*Not checked*/
.to_glib_none()
.0
}
unsafe {
let f: Box_<F> = Box_::new(f);
let detailed_signal_name = detail.map(|name| format!("create-web-view::{name}\0"));
let signal_name: &[u8] = detailed_signal_name
.as_ref()
.map_or(&b"create-web-view\0"[..], |n| n.as_bytes());
connect_raw(
self.as_ptr() as *mut _,
signal_name.as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
create_web_view_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
}