[]Struct gtk::Clipboard

pub struct Clipboard(_, _);

The Clipboard object represents a clipboard of data shared between different processes or between different widgets in the same process. Each clipboard is identified by a name encoded as a gdk::Atom. (Conversion to and from strings can be done with gdk::Atom_::intern and gdk::Atom_::name.) The default clipboard corresponds to the “CLIPBOARD” atom; another commonly used clipboard is the “PRIMARY” clipboard, which, in X, traditionally contains the currently selected text.

To support having a number of different formats on the clipboard at the same time, the clipboard mechanism allows providing callbacks instead of the actual data. When you set the contents of the clipboard, you can either supply the data directly (via functions like ClipboardExt::set_text), or you can supply a callback to be called at a later time when the data is needed (via ClipboardExt::set_with_data or ClipboardExt::set_with_owner.) Providing a callback also avoids having to make copies of the data when it is not needed.

ClipboardExt::set_with_data and ClipboardExt::set_with_owner are quite similar; the choice between the two depends mostly on which is more convenient in a particular situation. The former is most useful when you want to have a blob of data with callbacks to convert it into the various data types that you advertise. When the clear_func you provided is called, you simply free the data blob. The latter is more useful when the contents of clipboard reflect the internal state of a gobject::Object (As an example, for the PRIMARY clipboard, when an entry widget provides the clipboard’s contents the contents are simply the text within the selected region.) If the contents change, the entry widget can call ClipboardExt::set_with_owner to update the timestamp for clipboard ownership, without having to worry about clear_func being called.

Requesting the data from the clipboard is essentially asynchronous. If the contents of the clipboard are provided within the same process, then a direct function call will be made to retrieve the data, but if they are provided by another process, then the data needs to be retrieved from the other process, which may take some time. To avoid blocking the user interface, the call to request the selection, ClipboardExt::request_contents takes a callback that will be called when the contents are received (or when the request fails.) If you don’t want to deal with providing a separate callback, you can also use ClipboardExt::wait_for_contents. What this does is run the GLib main loop recursively waiting for the contents. This can simplify the code flow, but you still have to be aware that other callbacks in your program can be called while this recursive mainloop is running.

Along with the functions to get the clipboard contents as an arbitrary data chunk, there are also functions to retrieve it as text, ClipboardExt::request_text and ClipboardExt::wait_for_text. These functions take care of determining which formats are advertised by the clipboard provider, asking for the clipboard in the best available format and converting the results into the UTF-8 encoding. (The standard form for representing strings in GTK+.)

Implements

ClipboardExt, glib::object::ObjectExt

Methods

impl Clipboard
[src]

Returns the clipboard object for the given selection. See Clipboard::get_for_display for complete details.

selection

a gdk::Atom which identifies the clipboard to use

Returns

the appropriate clipboard object. If no clipboard already exists, a new one will be created. Once a clipboard object has been created, it is persistent and, since it is owned by GTK+, must not be freed or unreffed.

Returns the default clipboard object for use with cut/copy/paste menu items and keyboard shortcuts.

Feature: v3_16

display

the gdk::Display for which the clipboard is to be retrieved.

Returns

the default clipboard object.

Returns the clipboard object for the given selection. Cut/copy/paste menu items and keyboard shortcuts should use the default clipboard, returned by passing GDK_SELECTION_CLIPBOARD for selection. (GDK_NONE is supported as a synonym for GDK_SELECTION_CLIPBOARD for backwards compatibility reasons.) The currently-selected object or text should be provided on the clipboard identified by GDK_SELECTION_PRIMARY. Cut/copy/paste menu items conceptually copy the contents of the GDK_SELECTION_PRIMARY clipboard to the default clipboard, i.e. they copy the selection to what the user sees as the clipboard.

(Passing GDK_NONE is the same as using gdk_atom_intern ("CLIPBOARD", FALSE).

See the FreeDesktop Clipboard Specification for a detailed discussion of the “CLIPBOARD” vs. “PRIMARY” selections under the X window system. On Win32 the GDK_SELECTION_PRIMARY clipboard is essentially ignored.)

It’s possible to have arbitrary named clipboards; if you do invent new clipboards, you should prefix the selection name with an underscore (because the ICCCM requires that nonstandard atoms are underscore-prefixed), and namespace it as well. For example, if your application called “Foo” has a special-purpose clipboard, you might call it “_FOO_SPECIAL_CLIPBOARD”.

display

the gdk::Display for which the clipboard is to be retrieved or created.

selection

a gdk::Atom which identifies the clipboard to use.

Returns

the appropriate clipboard object. If no clipboard already exists, a new one will be created. Once a clipboard object has been created, it is persistent and, since it is owned by GTK+, must not be freed or unrefd.

Trait Implementations

impl<T: IsA<Object>> PartialOrd<T> for Clipboard

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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl Ord for Clipboard

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

impl<T: IsA<Object>> PartialEq<T> for Clipboard

This method tests for !=.

impl Clone for Clipboard

Performs copy-assignment from source. Read more

impl Eq for Clipboard

impl Debug for Clipboard

impl Hash for Clipboard

Feeds a slice of this type into the given [Hasher]. Read more

impl IsA<Object> for Clipboard

impl StaticType for Clipboard

Auto Trait Implementations

impl !Send for Clipboard

impl !Sync for Clipboard

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

impl<T> From for T
[src]

impl<T, U> TryFrom for T where
    T: From<U>, 
[src]

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<'a, T> ToGlibContainerFromSlice for T where
    T: GlibPtrDefault + ToGlibPtr<'a, <T as GlibPtrDefault>::GlibType>, 
[src]

impl<'a, T> ToGlibContainerFromSlice for T where
    T: GlibPtrDefault + ToGlibPtr<'a, <T as GlibPtrDefault>::GlibType>, 
[src]

impl<'a, T> ToGlibContainerFromSlice for T where
    T: GlibPtrDefault + ToGlibPtr<'a, <T as GlibPtrDefault>::GlibType>, 
[src]

impl<T> Cast for T where
    T: IsA<Object>, 
[src]

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

Returns true if the object is an instance of (can be cast to) T.

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

impl<T> IsA for T where
    T: StaticType + Wrapper + Into<ObjectRef> + UnsafeFrom<ObjectRef> + ToGlibPtr<'a, *mut <T as Wrapper>::GlibType>, 
[src]

impl<Super, Sub> Downcast for Super where
    Sub: IsA<Super>,
    Super: IsA<Super>, 
[src]

impl<T> ObjectExt for T where
    T: IsA<Object> + SetValue
[src]

impl<T> ToValue for T where
    T: SetValue + ?Sized
[src]