Struct gdk4::Clipboard [−][src]
pub struct Clipboard(_);
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
Creates a new builder-pattern struct instance to construct Clipboard
objects.
This method returns an instance of ClipboardBuilder
which can be used to create Clipboard
objects.
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
Gets the formats that the clipboard can provide its current contents in.
Returns
The formats of the clipboard
pub fn set_content<P: IsA<ContentProvider>>(
&self,
provider: Option<&P>
) -> Result<(), BoolError>
pub fn set_content<P: IsA<ContentProvider>>(
&self,
provider: Option<&P>
) -> 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
Emitted when the clipboard changes ownership.
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_async_future(
&self,
mime_types: &[&str],
io_priority: Priority
) -> Pin<Box<dyn Future<Output = Result<(InputStream, GString), Error>> + 'static>>
Sets the clipboard to contain the value collected from the given varargs.
⚠️ The following code is in c ⚠️
gdk_clipboard_set (clipboard, GTK_TYPE_TEXT_BUFFER, buffer);
type_
type of value to set
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_async_future(
&self,
io_priority: Priority
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + 'static>>
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_async_future(
&self,
type_: Type,
io_priority: Priority
) -> Pin<Box<dyn Future<Output = Result<Value, Error>> + 'static>>
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_async_future(
&self
) -> Pin<Box<dyn Future<Output = Result<Option<GString>, Error>> + 'static>>
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
Trait Implementations
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
Returns the type identifier of Self
.
Auto Trait Implementations
impl RefUnwindSafe for Clipboard
impl UnwindSafe for Clipboard
Blanket Implementations
Mutably borrows from an owned value. Read more
Upcasts an object to a superclass or interface T
. Read more
Upcasts an object to a reference of its superclass or interface T
. Read more
Tries to downcast to a subclass or interface implementor T
. Read more
Tries to downcast to a reference of its subclass or interface implementor T
. Read more
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 more
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 more
Casts to T
unconditionally. Read more
Casts to &T
unconditionally. Read more
Returns true
if the object is an instance of (can be cast to) T
.
pub fn set_property<'a, N, V>(
&self,
property_name: N,
value: V
) -> Result<(), BoolError> where
N: Into<&'a str>,
V: ToValue,
pub fn set_property_from_value<'a, N>(
&self,
property_name: N,
value: &Value
) -> Result<(), BoolError> where
N: Into<&'a str>,
pub fn set_properties_from_value(
&self,
property_values: &[(&str, Value)]
) -> Result<(), BoolError>
pub fn has_property<'a, N>(&self, property_name: N, type_: Option<Type>) -> bool where
N: Into<&'a str>,
pub fn find_property<'a, N>(&self, property_name: N) -> Option<ParamSpec> where
N: Into<&'a str>,
Safety Read more
Safety Read more
Safety Read more
Safety Read more
pub fn connect<'a, N, F>(
&self,
signal_name: N,
after: bool,
callback: F
) -> Result<SignalHandlerId, BoolError> where
N: Into<&'a str>,
F: 'static + Fn(&[Value]) -> Option<Value> + Send + Sync,
Same as connect
but takes a SignalId
instead of a signal name.
pub fn connect_local<'a, N, F>(
&self,
signal_name: N,
after: bool,
callback: F
) -> Result<SignalHandlerId, BoolError> where
N: Into<&'a str>,
F: 'static + Fn(&[Value]) -> Option<Value>,
Same as connect_local
but takes a SignalId
instead of a signal name.
pub unsafe fn connect_unsafe<'a, N, F>(
&self,
signal_name: N,
after: bool,
callback: F
) -> Result<SignalHandlerId, BoolError> where
N: Into<&'a str>,
F: Fn(&[Value]) -> Option<Value>,
Same as connect_unsafe
but takes a SignalId
instead of a signal name.
Emit signal by signal id.
Same as emit
but takes Value
for the arguments.
Emit signal by its name.
Same as emit_by_name
but takes Value
for the arguments.
Emit signal with details by signal id.
Same as emit_with_details
but takes Value
for the arguments.
pub fn connect_notify<F>(&self, name: Option<&str>, f: F) -> SignalHandlerId where
F: 'static + Fn(&T, &ParamSpec) + Send + Sync,
pub fn connect_notify_local<F>(
&self,
name: Option<&str>,
f: F
) -> SignalHandlerId where
F: 'static + Fn(&T, &ParamSpec),
pub unsafe fn connect_notify_unsafe<F>(
&self,
name: Option<&str>,
f: F
) -> SignalHandlerId where
F: Fn(&T, &ParamSpec),
pub fn bind_property<'a, O, N, M>(
&'a self,
source_property: N,
target: &'a O,
target_property: M
) -> BindingBuilder<'a> where
O: ObjectType,
N: Into<&'a str>,
M: Into<&'a str>,
Returns a SendValue
clone of self
.