pub struct WebView(/* private fields */);
Implementations§
Source§impl WebView
impl WebView
pub fn new() -> WebView
Sourcepub fn with_context<P: IsA<WebContext>>(context: &P) -> WebView
pub fn with_context<P: IsA<WebContext>>(context: &P) -> WebView
Examples found in repository?
examples/main.rs (line 45)
34fn main() {
35 gtk::init().unwrap();
36
37 let window = Window::new(WindowType::Toplevel);
38 let context = WebContext::default().unwrap();
39 #[cfg(feature = "v2_4")]
40 context.set_web_extensions_initialization_user_data(&"webkit".to_variant());
41 context.set_web_extensions_directory("../webkit2gtk-webextension-rs/example/target/debug/");
42 #[cfg(feature = "v2_6")]
43 let webview = WebView::new_with_context_and_user_content_manager(&context, &UserContentManager::new());
44 #[cfg(not(feature = "v2_6"))]
45 let webview = WebView::with_context(&context);
46 webview.load_uri("https://crates.io/");
47 window.add(&webview);
48
49 let settings = WebViewExt::settings(&webview).unwrap();
50 settings.set_enable_developer_extras(true);
51
52 /*let inspector = webview.get_inspector().unwrap();
53 inspector.show();*/
54
55 window.show_all();
56
57 webview.run_javascript("alert('Hello');", None::<&gio::Cancellable>, |_result| {
58 });
59 webview.run_javascript("42", None::<&gio::Cancellable>, |result| {
60 match result {
61 Ok(result) => {
62 let context = result.global_context().unwrap();
63 let value = result.value().unwrap();
64 println!("is_boolean: {}", value.is_boolean(&context));
65 println!("is_number: {}", value.is_number(&context));
66 println!("{:?}", value.to_number(&context));
67 println!("{:?}", value.to_boolean(&context));
68 },
69 Err(error) => println!("{}", error),
70 }
71 });
72
73 window.connect_delete_event(|_, _| {
74 gtk::main_quit();
75 Inhibit(false)
76 });
77
78 gtk::main();
79}
Sourcepub fn builder() -> WebViewBuilder
pub fn builder() -> WebViewBuilder
Creates a new builder-pattern struct instance to construct WebView
objects.
This method returns an instance of WebViewBuilder
which can be used to create WebView
objects.
Trait Implementations§
Source§impl Ord for WebView
impl Ord for WebView
Source§impl ParentClassIs for WebView
impl ParentClassIs for WebView
type Parent = WebViewBase
Source§impl<T: ObjectType> PartialEq<T> for WebView
impl<T: ObjectType> PartialEq<T> for WebView
Source§impl<T: ObjectType> PartialOrd<T> for WebView
impl<T: ObjectType> PartialOrd<T> for WebView
Source§impl StaticType for WebView
impl StaticType for WebView
Source§fn static_type() -> Type
fn static_type() -> Type
Returns the type identifier of
Self
.impl Eq for WebView
impl IsA<Container> for WebView
impl IsA<WebViewBase> for WebView
impl IsA<Widget> for WebView
Auto Trait Implementations§
impl Freeze for WebView
impl RefUnwindSafe for WebView
impl !Send for WebView
impl !Sync for WebView
impl Unpin for WebView
impl UnwindSafe for WebView
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Cast for Twhere
T: ObjectType,
impl<T> Cast for Twhere
T: ObjectType,
Source§fn upcast<T>(self) -> Twhere
T: ObjectType,
Self: IsA<T>,
fn upcast<T>(self) -> Twhere
T: ObjectType,
Self: IsA<T>,
Upcasts an object to a superclass or interface
T
. Read moreSource§fn upcast_ref<T>(&self) -> &Twhere
T: ObjectType,
Self: IsA<T>,
fn upcast_ref<T>(&self) -> &Twhere
T: ObjectType,
Self: IsA<T>,
Upcasts an object to a reference of its superclass or interface
T
. Read moreSource§fn downcast<T>(self) -> Result<T, Self>where
T: ObjectType,
Self: CanDowncast<T>,
fn downcast<T>(self) -> Result<T, Self>where
T: ObjectType,
Self: CanDowncast<T>,
Tries to downcast to a subclass or interface implementor
T
. Read moreSource§fn downcast_ref<T>(&self) -> Option<&T>where
T: ObjectType,
Self: CanDowncast<T>,
fn downcast_ref<T>(&self) -> Option<&T>where
T: ObjectType,
Self: CanDowncast<T>,
Tries to downcast to a reference of its subclass or interface implementor
T
. Read moreSource§fn dynamic_cast<T>(self) -> Result<T, Self>where
T: ObjectType,
fn dynamic_cast<T>(self) -> Result<T, Self>where
T: ObjectType,
Tries to cast to an object of type
T
. This handles upcasting, downcasting
and casting between interface and interface implementors. All checks are performed at
runtime, while downcast
and upcast
will do many checks at compile-time already. Read moreSource§fn dynamic_cast_ref<T>(&self) -> Option<&T>where
T: ObjectType,
fn dynamic_cast_ref<T>(&self) -> Option<&T>where
T: ObjectType,
Tries to cast to reference to an object of type
T
. This handles upcasting, downcasting
and casting between interface and interface implementors. All checks are performed at
runtime, while downcast
and upcast
will do many checks at compile-time already. Read moreSource§unsafe fn unsafe_cast<T>(self) -> Twhere
T: ObjectType,
unsafe fn unsafe_cast<T>(self) -> Twhere
T: ObjectType,
Casts to
T
unconditionally. Read moreSource§unsafe fn unsafe_cast_ref<T>(&self) -> &Twhere
T: ObjectType,
unsafe fn unsafe_cast_ref<T>(&self) -> &Twhere
T: ObjectType,
Casts to
&T
unconditionally. Read moreSource§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<O> ContainerExt for O
impl<O> ContainerExt for O
fn add<P>(&self, widget: &P)
fn check_resize(&self)
fn child_notify<P>(&self, child: &P, child_property: &str)
fn child_notify_by_pspec<P>(&self, child: &P, pspec: &ParamSpec)
fn child_type(&self) -> Type
fn forall<P>(&self, callback: P)
fn foreach<P>(&self, callback: P)
fn border_width(&self) -> u32
fn children(&self) -> Vec<Widget>
fn focus_child(&self) -> Option<Widget>
fn focus_hadjustment(&self) -> Option<Adjustment>
fn focus_vadjustment(&self) -> Option<Adjustment>
fn path_for_child<P>(&self, child: &P) -> Option<WidgetPath>
fn propagate_draw<P>(&self, child: &P, cr: &Context)
fn remove<P>(&self, widget: &P)
fn set_border_width(&self, border_width: u32)
fn set_focus_chain(&self, focusable_widgets: &[Widget])
fn set_focus_child<P>(&self, child: Option<&P>)
fn set_focus_hadjustment<P>(&self, adjustment: &P)where
P: IsA<Adjustment>,
fn set_focus_vadjustment<P>(&self, adjustment: &P)where
P: IsA<Adjustment>,
fn unset_focus_chain(&self)
fn set_child<P>(&self, child: Option<&P>)
fn resize_mode(&self) -> ResizeMode
fn set_resize_mode(&self, resize_mode: ResizeMode)
fn connect_add<F>(&self, f: F) -> SignalHandlerId
fn connect_check_resize<F>(&self, f: F) -> SignalHandlerId
fn connect_remove<F>(&self, f: F) -> SignalHandlerId
fn connect_set_focus_child<F>(&self, f: F) -> SignalHandlerId
fn connect_border_width_notify<F>(&self, f: F) -> SignalHandlerId
fn connect_child_notify<F>(&self, f: F) -> SignalHandlerId
fn connect_resize_mode_notify<F>(&self, f: F) -> SignalHandlerId
Source§impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
Source§impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GPtrArray> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GPtrArray> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
Source§impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GSList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GSList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
Source§impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
Source§impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GPtrArray> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GPtrArray> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
Source§impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GSList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GSList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
Source§impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
Source§impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GPtrArray> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GPtrArray> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
Source§impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GSList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GSList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
Source§impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
Source§impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GPtrArray> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GPtrArray> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
Source§impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GSList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GSList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
Source§impl<T> ObjectExt for Twhere
T: ObjectType,
impl<T> ObjectExt for Twhere
T: ObjectType,
Source§fn is<U>(&self) -> boolwhere
U: StaticType,
fn is<U>(&self) -> boolwhere
U: StaticType,
Returns
true
if the object is an instance of (can be cast to) T
.fn type_(&self) -> Type
fn object_class(&self) -> &Class<Object>
fn class(&self) -> &Class<T>where
T: IsClass,
fn class_of<U>(&self) -> Option<&Class<U>>where
U: IsClass,
fn interface<U>(&self) -> Option<InterfaceRef<'_, U>>where
U: IsInterface,
fn set_property<'a, N, V>( &self, property_name: N, value: V, ) -> Result<(), BoolError>
fn set_property_from_value<'a, N>( &self, property_name: N, value: &Value, ) -> Result<(), BoolError>
fn set_properties( &self, property_values: &[(&str, &dyn ToValue)], ) -> Result<(), BoolError>
fn set_properties_from_value( &self, property_values: &[(&str, Value)], ) -> Result<(), BoolError>
fn property<'a, N>(&self, property_name: N) -> Result<Value, BoolError>
fn has_property<'a, N>(&self, property_name: N, type_: Option<Type>) -> bool
fn property_type<'a, N>(&self, property_name: N) -> Option<Type>
fn find_property<'a, N>(&self, property_name: N) -> Option<ParamSpec>
fn list_properties(&self) -> Vec<ParamSpec>
fn freeze_notify(&self) -> PropertyNotificationFreezeGuard
Source§unsafe fn qdata<QD>(&self, key: Quark) -> Option<NonNull<QD>>where
QD: 'static,
unsafe fn qdata<QD>(&self, key: Quark) -> Option<NonNull<QD>>where
QD: 'static,
Safety Read more
Source§unsafe fn data<QD>(&self, key: &str) -> Option<NonNull<QD>>where
QD: 'static,
unsafe fn data<QD>(&self, key: &str) -> Option<NonNull<QD>>where
QD: 'static,
Safety Read more
fn block_signal(&self, handler_id: &SignalHandlerId)
fn unblock_signal(&self, handler_id: &SignalHandlerId)
fn stop_signal_emission(&self, signal_name: &str)
fn connect<'a, N, F>( &self, signal_name: N, after: bool, callback: F, ) -> Result<SignalHandlerId, BoolError>
Source§fn connect_id<F>(
&self,
signal_id: SignalId,
details: Option<Quark>,
after: bool,
callback: F,
) -> Result<SignalHandlerId, BoolError>
fn connect_id<F>( &self, signal_id: SignalId, details: Option<Quark>, after: bool, callback: F, ) -> Result<SignalHandlerId, BoolError>
Same as
connect
but takes a SignalId
instead of a signal name.fn connect_local<'a, N, F>( &self, signal_name: N, after: bool, callback: F, ) -> Result<SignalHandlerId, BoolError>
Source§fn connect_local_id<F>(
&self,
signal_id: SignalId,
details: Option<Quark>,
after: bool,
callback: F,
) -> Result<SignalHandlerId, BoolError>
fn connect_local_id<F>( &self, signal_id: SignalId, details: Option<Quark>, after: bool, callback: F, ) -> Result<SignalHandlerId, BoolError>
Same as
connect_local
but takes a SignalId
instead of a signal name.unsafe fn connect_unsafe<'a, N, F>( &self, signal_name: N, after: bool, callback: F, ) -> Result<SignalHandlerId, BoolError>
Source§unsafe fn connect_unsafe_id<F>(
&self,
signal_id: SignalId,
details: Option<Quark>,
after: bool,
callback: F,
) -> Result<SignalHandlerId, BoolError>
unsafe fn connect_unsafe_id<F>( &self, signal_id: SignalId, details: Option<Quark>, after: bool, callback: F, ) -> Result<SignalHandlerId, BoolError>
Same as
connect_unsafe
but takes a SignalId
instead of a signal name.Source§fn emit(
&self,
signal_id: SignalId,
args: &[&dyn ToValue],
) -> Result<Option<Value>, BoolError>
fn emit( &self, signal_id: SignalId, args: &[&dyn ToValue], ) -> Result<Option<Value>, BoolError>
Emit signal by signal id.
Source§fn emit_with_values(
&self,
signal_id: SignalId,
args: &[Value],
) -> Result<Option<Value>, BoolError>
fn emit_with_values( &self, signal_id: SignalId, args: &[Value], ) -> Result<Option<Value>, BoolError>
Same as
emit
but takes Value
for the arguments.Source§fn emit_by_name<'a, N>(
&self,
signal_name: N,
args: &[&dyn ToValue],
) -> Result<Option<Value>, BoolError>
fn emit_by_name<'a, N>( &self, signal_name: N, args: &[&dyn ToValue], ) -> Result<Option<Value>, BoolError>
Emit signal by its name.
Source§fn emit_by_name_with_values<'a, N>(
&self,
signal_name: N,
args: &[Value],
) -> Result<Option<Value>, BoolError>
fn emit_by_name_with_values<'a, N>( &self, signal_name: N, args: &[Value], ) -> Result<Option<Value>, BoolError>
Same as
emit_by_name
but takes Value
for the arguments.Source§fn emit_with_details(
&self,
signal_id: SignalId,
details: Quark,
args: &[&dyn ToValue],
) -> Result<Option<Value>, BoolError>
fn emit_with_details( &self, signal_id: SignalId, details: Quark, args: &[&dyn ToValue], ) -> Result<Option<Value>, BoolError>
Emit signal with details by signal id.
Source§fn emit_with_details_and_values(
&self,
signal_id: SignalId,
details: Quark,
args: &[Value],
) -> Result<Option<Value>, BoolError>
fn emit_with_details_and_values( &self, signal_id: SignalId, details: Quark, args: &[Value], ) -> Result<Option<Value>, BoolError>
Same as
emit_with_details
but takes Value
for the arguments.