#[repr(transparent)]pub struct Clipboard { /* private fields */ }
Expand description
The Clipboard
object represents data shared between applications or
inside an application.
To get a Clipboard
object, use DisplayExt::clipboard()
or
DisplayExt::primary_clipboard()
. You can find out about the data
that is currently available in a clipboard using
formats()
.
To make text or image data available in a clipboard, use
set_text()
or set_texture()
.
For other data, you can use set_content()
, which
takes a ContentProvider
object.
To read textual or image data from a clipboard, use
read_text_async()
or
read_texture_async()
. For other data, use
read_async()
, which provides a GInputStream
object.
Implementations§
source§impl Clipboard
impl Clipboard
sourcepub fn content(&self) -> Option<ContentProvider>
pub fn content(&self) -> Option<ContentProvider>
Returns the ContentProvider
currently set on @self.
If the @self is empty or its contents are not owned by the
current process, None
will be returned.
Returns
The content of a clipboard if the clipboard does not maintain any content
sourcepub fn formats(&self) -> ContentFormats
pub fn formats(&self) -> ContentFormats
Gets the formats that the clipboard can provide its current contents in.
Returns
The formats of the clipboard
sourcepub fn read_text_async<P: FnOnce(Result<Option<GString>, Error>) + 'static>(
&self,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P
)
pub fn read_text_async<P: FnOnce(Result<Option<GString>, Error>) + 'static>(
&self,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P
)
Asynchronously request the @self contents converted to a string.
When the operation is finished @callback will be called. You must then
call Gdk::Clipboard::read_text_finish()
to get the result.
This is a simple wrapper around read_value_async()
.
Use that function or read_async()
directly if you
need more control over the operation.
cancellable
optional GCancellable
object
callback
callback to call when the request is satisfied
pub fn read_text_future(
&self
) -> Pin<Box_<dyn Future<Output = Result<Option<GString>, Error>> + 'static>>
sourcepub fn read_texture_async<P: FnOnce(Result<Option<Texture>, Error>) + 'static>(
&self,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P
)
pub fn read_texture_async<P: FnOnce(Result<Option<Texture>, Error>) + 'static>(
&self,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P
)
Asynchronously request the @self contents converted to a gdk_pixbuf::Pixbuf
.
When the operation is finished @callback will be called. You must then
call Gdk::Clipboard::read_texture_finish()
to get the result.
This is a simple wrapper around read_value_async()
.
Use that function or read_async()
directly if you
need more control over the operation.
cancellable
optional GCancellable
object, None
to ignore.
callback
callback to call when the request is satisfied
pub fn read_texture_future(
&self
) -> Pin<Box_<dyn Future<Output = Result<Option<Texture>, Error>> + 'static>>
sourcepub fn read_value_async<P: FnOnce(Result<Value, Error>) + 'static>(
&self,
type_: Type,
io_priority: Priority,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P
)
pub fn read_value_async<P: FnOnce(Result<Value, Error>) + 'static>(
&self,
type_: Type,
io_priority: Priority,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P
)
Asynchronously request the @self contents converted to the given @type_.
When the operation is finished @callback will be called. You must then call
Gdk::Clipboard::read_value_finish()
to get the resulting GValue
.
For local clipboard contents that are available in the given GType
,
the value will be copied directly. Otherwise, GDK will try to use
content_deserialize_async()
to convert the clipboard’s data.
type_
a GType
to read
io_priority
the I/O priority of the request
cancellable
optional GCancellable
object
callback
callback to call when the request is satisfied
pub fn read_value_future(
&self,
type_: Type,
io_priority: Priority
) -> Pin<Box_<dyn Future<Output = Result<Value, Error>> + 'static>>
sourcepub fn set_content(
&self,
provider: Option<&impl IsA<ContentProvider>>
) -> Result<(), BoolError>
pub fn set_content(
&self,
provider: Option<&impl IsA<ContentProvider>>
) -> Result<(), BoolError>
Sets a new content provider on @self.
The clipboard will claim the Display
’s resources and advertise
these new contents to other applications.
In the rare case of a failure, this function will return false
. The
clipboard will then continue reporting its old contents and ignore
@provider.
If the contents are read by either an external application or the @self’s read functions, @self will select the best format to transfer the contents and then request that format from @provider.
provider
the new contents of @self
or None
to clear the clipboard
Returns
true
if setting the clipboard succeeded
sourcepub fn set_texture(&self, texture: &impl IsA<Texture>)
pub fn set_texture(&self, texture: &impl IsA<Texture>)
sourcepub fn store_async<P: FnOnce(Result<(), Error>) + 'static>(
&self,
io_priority: Priority,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P
)
pub fn store_async<P: FnOnce(Result<(), Error>) + 'static>(
&self,
io_priority: Priority,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P
)
Asynchronously instructs the @self to store its contents remotely.
If the clipboard is not local, this function does nothing but report success.
The @callback must call Gdk::Clipboard::store_finish()
.
The purpose of this call is to preserve clipboard contents beyond the lifetime of an application, so this function is typically called on exit. Depending on the platform, the functionality may not be available unless a “clipboard manager” is running.
This function is called automatically when a Gtk::Application
is
shut down, so you likely don’t need to call it.
io_priority
the I/O priority of the request
cancellable
optional GCancellable
object
callback
callback to call when the request is satisfied
pub fn store_future(
&self,
io_priority: Priority
) -> Pin<Box_<dyn Future<Output = Result<(), Error>> + 'static>>
sourcepub fn connect_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId
pub fn connect_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId
Emitted when the clipboard changes ownership.
pub fn connect_content_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId
pub fn connect_formats_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId
pub fn connect_local_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId
source§impl Clipboard
impl Clipboard
sourcepub fn read_async<Q: FnOnce(Result<(InputStream, GString), Error>) + 'static>(
&self,
mime_types: &[&str],
io_priority: Priority,
cancellable: Option<&impl IsA<Cancellable>>,
callback: Q
)
pub fn read_async<Q: FnOnce(Result<(InputStream, GString), Error>) + 'static>(
&self,
mime_types: &[&str],
io_priority: Priority,
cancellable: Option<&impl IsA<Cancellable>>,
callback: Q
)
Asynchronously requests an input stream to read the @self’s contents from.
When the operation is finished @callback will be called. You must then
call Gdk::Clipboard::read_finish()
to get the result of the operation.
The clipboard will choose the most suitable mime type from the given list to fulfill the request, preferring the ones listed first.
mime_types
a None
-terminated array of mime types to choose from
io_priority
the I/O priority of the request
cancellable
optional GCancellable
object
callback
callback to call when the request is satisfied
pub fn read_future(
&self,
mime_types: &[&str],
io_priority: Priority
) -> Pin<Box<dyn Future<Output = Result<(InputStream, GString), Error>> + 'static>>
Trait Implementations§
source§impl Ord for Clipboard
impl Ord for Clipboard
source§impl<OT: ObjectType> PartialEq<OT> for Clipboard
impl<OT: ObjectType> PartialEq<OT> for Clipboard
source§impl<OT: ObjectType> PartialOrd<OT> for Clipboard
impl<OT: ObjectType> PartialOrd<OT> for Clipboard
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl StaticType for Clipboard
impl StaticType for Clipboard
source§fn static_type() -> Type
fn static_type() -> Type
Self
.impl Eq for Clipboard
Auto Trait Implementations§
impl RefUnwindSafe for Clipboard
impl !Send for Clipboard
impl !Sync for Clipboard
impl Unpin for Clipboard
impl UnwindSafe for Clipboard
Blanket Implementations§
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>,
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>,
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>,
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>,
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,
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,
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,
T
unconditionally. Read moresource§unsafe fn unsafe_cast_ref<T>(&self) -> &Twhere
T: ObjectType,
unsafe fn unsafe_cast_ref<T>(&self) -> &Twhere
T: ObjectType,
&T
unconditionally. Read moresource§impl<U> IsSubclassableExt for Uwhere
U: IsClass + ParentClassIs,
impl<U> IsSubclassableExt for Uwhere
U: IsClass + ParentClassIs,
fn parent_class_init<T>(class: &mut Class<U>)where
T: ObjectSubclass,
<U as ParentClassIs>::Parent: IsSubclassable<T>,
fn parent_instance_init<T>(instance: &mut InitializingObject<T>)where
T: ObjectSubclass,
<U as ParentClassIs>::Parent: IsSubclassable<T>,
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,
true
if the object is an instance of (can be cast to) T
.source§fn object_class(&self) -> &Class<Object>
fn object_class(&self) -> &Class<Object>
ObjectClass
of the object. Read moresource§fn class_of<U>(&self) -> Option<&Class<U>>where
U: IsClass,
fn class_of<U>(&self) -> Option<&Class<U>>where
U: IsClass,
T
. Read moresource§fn interface<U>(&self) -> Option<InterfaceRef<'_, U>>where
U: IsInterface,
fn interface<U>(&self) -> Option<InterfaceRef<'_, U>>where
U: IsInterface,
T
of the object. Read moresource§fn set_property<V>(&self, property_name: &str, value: V)where
V: ToValue,
fn set_property<V>(&self, property_name: &str, value: V)where
V: ToValue,
source§fn set_property_from_value(&self, property_name: &str, value: &Value)
fn set_property_from_value(&self, property_name: &str, value: &Value)
source§fn set_properties(&self, property_values: &[(&str, &dyn ToValue)])
fn set_properties(&self, property_values: &[(&str, &dyn ToValue)])
source§fn set_properties_from_value(&self, property_values: &[(&str, Value)])
fn set_properties_from_value(&self, property_values: &[(&str, Value)])
source§fn property<V>(&self, property_name: &str) -> Vwhere
V: 'static + for<'b> FromValue<'b>,
fn property<V>(&self, property_name: &str) -> Vwhere
V: 'static + for<'b> FromValue<'b>,
property_name
of the object and cast it to the type V. Read moresource§fn property_value(&self, property_name: &str) -> Value
fn property_value(&self, property_name: &str) -> Value
property_name
of the object. Read moresource§fn property_type(&self, property_name: &str) -> Option<Type>
fn property_type(&self, property_name: &str) -> Option<Type>
property_name
of this object. Read moresource§fn find_property(&self, property_name: &str) -> Option<ParamSpec>
fn find_property(&self, property_name: &str) -> Option<ParamSpec>
ParamSpec
of the property property_name
of this object.source§fn list_properties(&self) -> PtrSlice<ParamSpec>
fn list_properties(&self) -> PtrSlice<ParamSpec>
ParamSpec
of the properties of this object.source§fn freeze_notify(&self) -> PropertyNotificationFreezeGuard
fn freeze_notify(&self) -> PropertyNotificationFreezeGuard
source§unsafe fn set_qdata<QD>(&self, key: Quark, value: QD)where
QD: 'static,
unsafe fn set_qdata<QD>(&self, key: Quark, value: QD)where
QD: 'static,
key
. Read moresource§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,
key
. Read moresource§unsafe fn steal_qdata<QD>(&self, key: Quark) -> Option<QD>where
QD: 'static,
unsafe fn steal_qdata<QD>(&self, key: Quark) -> Option<QD>where
QD: 'static,
key
. Read moresource§unsafe fn set_data<QD>(&self, key: &str, value: QD)where
QD: 'static,
unsafe fn set_data<QD>(&self, key: &str, value: QD)where
QD: 'static,
key
. Read moresource§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,
key
. Read moresource§unsafe fn steal_data<QD>(&self, key: &str) -> Option<QD>where
QD: 'static,
unsafe fn steal_data<QD>(&self, key: &str) -> Option<QD>where
QD: 'static,
key
. Read moresource§fn block_signal(&self, handler_id: &SignalHandlerId)
fn block_signal(&self, handler_id: &SignalHandlerId)
source§fn unblock_signal(&self, handler_id: &SignalHandlerId)
fn unblock_signal(&self, handler_id: &SignalHandlerId)
source§fn stop_signal_emission(&self, signal_id: SignalId, detail: Option<Quark>)
fn stop_signal_emission(&self, signal_id: SignalId, detail: Option<Quark>)
source§fn stop_signal_emission_by_name(&self, signal_name: &str)
fn stop_signal_emission_by_name(&self, signal_name: &str)
source§fn connect<F>(
&self,
signal_name: &str,
after: bool,
callback: F
) -> SignalHandlerIdwhere
F: 'static + Fn(&[Value]) -> Option<Value> + Send + Sync,
fn connect<F>(
&self,
signal_name: &str,
after: bool,
callback: F
) -> SignalHandlerIdwhere
F: 'static + Fn(&[Value]) -> Option<Value> + Send + Sync,
signal_name
on this object. Read moresource§fn connect_id<F>(
&self,
signal_id: SignalId,
details: Option<Quark>,
after: bool,
callback: F
) -> SignalHandlerIdwhere
F: 'static + Fn(&[Value]) -> Option<Value> + Send + Sync,
fn connect_id<F>(
&self,
signal_id: SignalId,
details: Option<Quark>,
after: bool,
callback: F
) -> SignalHandlerIdwhere
F: 'static + Fn(&[Value]) -> Option<Value> + Send + Sync,
signal_id
on this object. Read moresource§fn connect_local<F>(
&self,
signal_name: &str,
after: bool,
callback: F
) -> SignalHandlerIdwhere
F: 'static + Fn(&[Value]) -> Option<Value>,
fn connect_local<F>(
&self,
signal_name: &str,
after: bool,
callback: F
) -> SignalHandlerIdwhere
F: 'static + Fn(&[Value]) -> Option<Value>,
signal_name
on this object. Read moresource§fn connect_local_id<F>(
&self,
signal_id: SignalId,
details: Option<Quark>,
after: bool,
callback: F
) -> SignalHandlerIdwhere
F: 'static + Fn(&[Value]) -> Option<Value>,
fn connect_local_id<F>(
&self,
signal_id: SignalId,
details: Option<Quark>,
after: bool,
callback: F
) -> SignalHandlerIdwhere
F: 'static + Fn(&[Value]) -> Option<Value>,
signal_id
on this object. Read moresource§unsafe fn connect_unsafe<F>(
&self,
signal_name: &str,
after: bool,
callback: F
) -> SignalHandlerIdwhere
F: Fn(&[Value]) -> Option<Value>,
unsafe fn connect_unsafe<F>(
&self,
signal_name: &str,
after: bool,
callback: F
) -> SignalHandlerIdwhere
F: Fn(&[Value]) -> Option<Value>,
signal_name
on this object. Read moresource§unsafe fn connect_unsafe_id<F>(
&self,
signal_id: SignalId,
details: Option<Quark>,
after: bool,
callback: F
) -> SignalHandlerIdwhere
F: Fn(&[Value]) -> Option<Value>,
unsafe fn connect_unsafe_id<F>(
&self,
signal_id: SignalId,
details: Option<Quark>,
after: bool,
callback: F
) -> SignalHandlerIdwhere
F: Fn(&[Value]) -> Option<Value>,
signal_id
on this object. Read moresource§fn connect_closure(
&self,
signal_name: &str,
after: bool,
closure: RustClosure
) -> SignalHandlerId
fn connect_closure(
&self,
signal_name: &str,
after: bool,
closure: RustClosure
) -> SignalHandlerId
signal_name
on this object. Read moresource§fn connect_closure_id(
&self,
signal_id: SignalId,
details: Option<Quark>,
after: bool,
closure: RustClosure
) -> SignalHandlerId
fn connect_closure_id(
&self,
signal_id: SignalId,
details: Option<Quark>,
after: bool,
closure: RustClosure
) -> SignalHandlerId
signal_id
on this object. Read moresource§fn watch_closure(&self, closure: &impl AsRef<Closure>)
fn watch_closure(&self, closure: &impl AsRef<Closure>)
closure
to the lifetime of the object. When
the object’s reference count drops to zero, the closure will be
invalidated. An invalidated closure will ignore any calls to
invoke_with_values
, or
invoke
when using Rust closures.source§fn emit<R>(&self, signal_id: SignalId, args: &[&dyn ToValue]) -> Rwhere
R: TryFromClosureReturnValue,
fn emit<R>(&self, signal_id: SignalId, args: &[&dyn ToValue]) -> Rwhere
R: TryFromClosureReturnValue,
source§fn emit_with_values(&self, signal_id: SignalId, args: &[Value]) -> Option<Value>
fn emit_with_values(&self, signal_id: SignalId, args: &[Value]) -> Option<Value>
Self::emit
but takes Value
for the arguments.source§fn emit_by_name<R>(&self, signal_name: &str, args: &[&dyn ToValue]) -> Rwhere
R: TryFromClosureReturnValue,
fn emit_by_name<R>(&self, signal_name: &str, args: &[&dyn ToValue]) -> Rwhere
R: TryFromClosureReturnValue,
source§fn emit_by_name_with_values(
&self,
signal_name: &str,
args: &[Value]
) -> Option<Value>
fn emit_by_name_with_values(
&self,
signal_name: &str,
args: &[Value]
) -> Option<Value>
source§fn emit_by_name_with_details<R>(
&self,
signal_name: &str,
details: Quark,
args: &[&dyn ToValue]
) -> Rwhere
R: TryFromClosureReturnValue,
fn emit_by_name_with_details<R>(
&self,
signal_name: &str,
details: Quark,
args: &[&dyn ToValue]
) -> Rwhere
R: TryFromClosureReturnValue,
source§fn emit_by_name_with_details_and_values(
&self,
signal_name: &str,
details: Quark,
args: &[Value]
) -> Option<Value>
fn emit_by_name_with_details_and_values(
&self,
signal_name: &str,
details: Quark,
args: &[Value]
) -> Option<Value>
source§fn emit_with_details<R>(
&self,
signal_id: SignalId,
details: Quark,
args: &[&dyn ToValue]
) -> Rwhere
R: TryFromClosureReturnValue,
fn emit_with_details<R>(
&self,
signal_id: SignalId,
details: Quark,
args: &[&dyn ToValue]
) -> Rwhere
R: TryFromClosureReturnValue,
source§fn emit_with_details_and_values(
&self,
signal_id: SignalId,
details: Quark,
args: &[Value]
) -> Option<Value>
fn emit_with_details_and_values(
&self,
signal_id: SignalId,
details: Quark,
args: &[Value]
) -> Option<Value>
source§fn disconnect(&self, handler_id: SignalHandlerId)
fn disconnect(&self, handler_id: SignalHandlerId)
source§fn connect_notify<F>(&self, name: Option<&str>, f: F) -> SignalHandlerIdwhere
F: 'static + Fn(&T, &ParamSpec) + Send + Sync,
fn connect_notify<F>(&self, name: Option<&str>, f: F) -> SignalHandlerIdwhere
F: 'static + Fn(&T, &ParamSpec) + Send + Sync,
notify
signal of the object. Read moresource§fn connect_notify_local<F>(&self, name: Option<&str>, f: F) -> SignalHandlerIdwhere
F: 'static + Fn(&T, &ParamSpec),
fn connect_notify_local<F>(&self, name: Option<&str>, f: F) -> SignalHandlerIdwhere
F: 'static + Fn(&T, &ParamSpec),
notify
signal of the object. Read moresource§unsafe fn connect_notify_unsafe<F>(
&self,
name: Option<&str>,
f: F
) -> SignalHandlerIdwhere
F: Fn(&T, &ParamSpec),
unsafe fn connect_notify_unsafe<F>(
&self,
name: Option<&str>,
f: F
) -> SignalHandlerIdwhere
F: Fn(&T, &ParamSpec),
notify
signal of the object. Read more