diff --git a/src/core/display-private.h b/src/core/display-private.h index 421dc8e6c..068c710af 100644 --- a/src/core/display-private.h +++ b/src/core/display-private.h @@ -38,12 +38,12 @@ #include "clutter/clutter.h" #include "core/keybindings-private.h" #include "core/meta-gesture-tracker-private.h" -#include "core/meta-selection.h" #include "core/stack-tracker.h" #include "core/startup-notification-private.h" #include "meta/barrier.h" #include "meta/boxes.h" #include "meta/common.h" +#include "meta/meta-selection.h" #include "meta/prefs.h" typedef struct _MetaBell MetaBell; @@ -446,6 +446,4 @@ MetaWindow *meta_display_get_window_from_id (MetaDisplay *display, uint64_t window_id); uint64_t meta_display_generate_window_id (MetaDisplay *display); -MetaSelection * meta_display_get_selection (MetaDisplay *display); - #endif diff --git a/src/core/display.c b/src/core/display.c index ce882826f..819c61d5c 100644 --- a/src/core/display.c +++ b/src/core/display.c @@ -3689,6 +3689,12 @@ meta_display_get_sound_player (MetaDisplay *display) return display->sound_player; } +/** + * meta_display_get_selection: + * @display: a #MetaDisplay + * + * Returns: (transfer none): The selection manager of the display + */ MetaSelection * meta_display_get_selection (MetaDisplay *display) { diff --git a/src/core/meta-clipboard-manager.c b/src/core/meta-clipboard-manager.c index 432d845f4..1c1b587fe 100644 --- a/src/core/meta-clipboard-manager.c +++ b/src/core/meta-clipboard-manager.c @@ -22,7 +22,7 @@ #include "config.h" #include "core/meta-clipboard-manager.h" -#include "core/meta-selection-source-memory.h" +#include "meta/meta-selection-source-memory.h" #define MAX_TEXT_SIZE (4 * 1024 * 1024) /* 4MB */ #define MAX_IMAGE_SIZE (200 * 1024 * 1024) /* 200MB */ diff --git a/src/core/meta-selection-source-memory.c b/src/core/meta-selection-source-memory.c index e37cd523f..04b7f39a3 100644 --- a/src/core/meta-selection-source-memory.c +++ b/src/core/meta-selection-source-memory.c @@ -21,7 +21,7 @@ #include "config.h" -#include "core/meta-selection-source-memory.h" +#include "meta/meta-selection-source-memory.h" struct _MetaSelectionSourceMemory { diff --git a/src/core/meta-selection-source.c b/src/core/meta-selection-source.c index 4c0fbceba..b076391ce 100644 --- a/src/core/meta-selection-source.c +++ b/src/core/meta-selection-source.c @@ -21,8 +21,8 @@ #include "config.h" -#include "core/meta-selection.h" -#include "core/meta-selection-source.h" +#include "meta/meta-selection.h" +#include "meta/meta-selection-source.h" typedef struct MetaSelectionSourcePrivate MetaSelectionSourcePrivate; @@ -107,6 +107,16 @@ meta_selection_source_read_async (MetaSelectionSource *source, user_data); } +/** + * meta_selection_source_read_finish: + * @source: The selection source + * @result: The async result + * @error: Location for returned error + * + * Finishes a read from the selection source. + * + * Returns: (transfer full): The resulting #GInputStream + */ GInputStream * meta_selection_source_read_finish (MetaSelectionSource *source, GAsyncResult *result, @@ -120,6 +130,14 @@ meta_selection_source_read_finish (MetaSelectionSource *source, error); } +/** + * meta_selection_source_get_mimetypes: + * @source: The selection source + * + * Returns the list of supported mimetypes. + * + * Returns: (element-type utf8) (transfer full): The supported mimetypes + */ GList * meta_selection_source_get_mimetypes (MetaSelectionSource *source) { @@ -128,6 +146,14 @@ meta_selection_source_get_mimetypes (MetaSelectionSource *source) return META_SELECTION_SOURCE_GET_CLASS (source)->get_mimetypes (source); } +/** + * meta_selection_source_is_active: + * @source: the selection source + * + * Returns #TRUE if the source is active on a selection. + * + * Returns: #TRUE if the source owns a selection. + **/ gboolean meta_selection_source_is_active (MetaSelectionSource *source) { diff --git a/src/core/meta-selection.c b/src/core/meta-selection.c index 4815a8951..504d322e7 100644 --- a/src/core/meta-selection.c +++ b/src/core/meta-selection.c @@ -21,7 +21,7 @@ #include "config.h" -#include "core/meta-selection.h" +#include "meta/meta-selection.h" typedef struct TransferRequest TransferRequest; @@ -76,6 +76,15 @@ meta_selection_new (MetaDisplay *display) NULL); } +/** + * meta_selection_set_owner: + * @selection: The selection manager + * @selection_type: Selection type + * @owner: New selection owner + * + * Sets @owner as the owner of the selection given by @selection_type, + * unsets any previous owner there was. + **/ void meta_selection_set_owner (MetaSelection *selection, MetaSelectionType selection_type, @@ -95,6 +104,15 @@ meta_selection_set_owner (MetaSelection *selection, g_signal_emit (selection, signals[OWNER_CHANGED], 0, selection_type, owner); } +/** + * meta_selection_unset_owner: + * @selection: The selection manager + * @selection_type: Selection type + * @owner: Owner to unset + * + * Unsets @owner as the owner the selection given by @selection_type. If + * @owner does not own the selection, nothing is done. + **/ void meta_selection_unset_owner (MetaSelection *selection, MetaSelectionType selection_type, @@ -112,6 +130,15 @@ meta_selection_unset_owner (MetaSelection *selection, } } +/** + * meta_selection_get_mimetypes: + * @selection: The selection manager + * @selection_type: Selection to query + * + * Returns the list of supported mimetypes for the given selection type. + * + * Returns: (element-type utf8) (transfer full): The supported mimetypes + */ GList * meta_selection_get_mimetypes (MetaSelection *selection, MetaSelectionType selection_type) @@ -253,6 +280,20 @@ source_read_cb (MetaSelectionSource *source, } } +/** + * meta_selection_transfer_async: + * @selection: The selection manager + * @selection_type: Selection type + * @mimetype: Mimetype to transfer + * @size: Maximum size to transfer, -1 for unlimited + * @output: Output stream to write contents to + * @cancellable: Cancellable + * @callback: User callback + * @user_data: User data + * + * Requests a transfer of @mimetype on the selection given by + * @selection_type. + **/ void meta_selection_transfer_async (MetaSelection *selection, MetaSelectionType selection_type, @@ -283,6 +324,16 @@ meta_selection_transfer_async (MetaSelection *selection, task); } +/** + * meta_selection_transfer_finish: + * @selection: The selection manager + * @result: The async result + * @error: Location for returned error, or %NULL + * + * Finishes the transfer of a queried mimetype. + * + * Returns: #TRUE if the transfer was successful. + **/ gboolean meta_selection_transfer_finish (MetaSelection *selection, GAsyncResult *result, diff --git a/src/meson.build b/src/meson.build index 787023dd3..1370eac0b 100644 --- a/src/meson.build +++ b/src/meson.build @@ -343,11 +343,8 @@ mutter_sources = [ 'core/meta-inhibit-shortcuts-dialog-default-private.h', 'core/meta-launch-context.c', 'core/meta-selection.c', - 'core/meta-selection.h', 'core/meta-selection-source.c', - 'core/meta-selection-source.h', 'core/meta-selection-source-memory.c', - 'core/meta-selection-source-memory.h', 'core/meta-sound-player.c', 'core/meta-workspace-manager.c', 'core/meta-workspace-manager-private.h', diff --git a/src/meta/display.h b/src/meta/display.h index 170392048..09c1f99ec 100644 --- a/src/meta/display.h +++ b/src/meta/display.h @@ -294,4 +294,7 @@ MetaStartupNotification * meta_display_get_startup_notification (MetaDisplay *di META_EXPORT MetaSoundPlayer * meta_display_get_sound_player (MetaDisplay *display); +META_EXPORT +MetaSelection * meta_display_get_selection (MetaDisplay *display); + #endif diff --git a/src/meta/meson.build b/src/meta/meson.build index 2bd50e4f7..14caec58d 100644 --- a/src/meta/meson.build +++ b/src/meta/meson.build @@ -22,6 +22,9 @@ mutter_public_headers = [ 'meta-monitor-manager.h', 'meta-plugin.h', 'meta-remote-access-controller.h', + 'meta-selection.h', + 'meta-selection-source.h', + 'meta-selection-source-memory.h', 'meta-settings.h', 'meta-shadow-factory.h', 'meta-shaped-texture.h', diff --git a/src/core/meta-selection-source-memory.h b/src/meta/meta-selection-source-memory.h similarity index 95% rename from src/core/meta-selection-source-memory.h rename to src/meta/meta-selection-source-memory.h index d0c3f6720..b72e12762 100644 --- a/src/core/meta-selection-source-memory.h +++ b/src/meta/meta-selection-source-memory.h @@ -22,14 +22,17 @@ #ifndef META_MEMORY_SELECTION_SOURCE_H #define META_MEMORY_SELECTION_SOURCE_H -#include "core/meta-selection-source.h" +#include "meta/meta-selection-source.h" #define META_TYPE_SELECTION_SOURCE_MEMORY (meta_selection_source_memory_get_type ()) + +META_EXPORT G_DECLARE_FINAL_TYPE (MetaSelectionSourceMemory, meta_selection_source_memory, META, SELECTION_SOURCE_MEMORY, MetaSelectionSource) +META_EXPORT MetaSelectionSource * meta_selection_source_memory_new (const char *mimetype, GBytes *content); diff --git a/src/core/meta-selection-source.h b/src/meta/meta-selection-source.h similarity index 97% rename from src/core/meta-selection-source.h rename to src/meta/meta-selection-source.h index 579ebc783..a341bede1 100644 --- a/src/core/meta-selection-source.h +++ b/src/meta/meta-selection-source.h @@ -24,6 +24,8 @@ #include +#include + typedef enum { META_SELECTION_PRIMARY, @@ -37,6 +39,7 @@ typedef struct _MetaSelectionSource MetaSelectionSource; #define META_TYPE_SELECTION_SOURCE (meta_selection_source_get_type ()) +META_EXPORT G_DECLARE_DERIVABLE_TYPE (MetaSelectionSource, meta_selection_source, META, SELECTION_SOURCE, @@ -61,18 +64,22 @@ struct _MetaSelectionSourceClass GError **error); }; +META_EXPORT void meta_selection_source_read_async (MetaSelectionSource *source, const gchar *mimetype, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); +META_EXPORT GInputStream * meta_selection_source_read_finish (MetaSelectionSource *source, GAsyncResult *result, GError **error); +META_EXPORT GList * meta_selection_source_get_mimetypes (MetaSelectionSource *source); +META_EXPORT gboolean meta_selection_source_is_active (MetaSelectionSource *source); #endif /* META_SELECTION_SOURCE_H */ diff --git a/src/core/meta-selection.h b/src/meta/meta-selection.h similarity index 93% rename from src/core/meta-selection.h rename to src/meta/meta-selection.h index 275ca544d..ef86dce1d 100644 --- a/src/core/meta-selection.h +++ b/src/meta/meta-selection.h @@ -24,29 +24,36 @@ #include -#include "core/meta-selection-source.h" -#include "meta/display.h" +#include +#include +#include #define META_TYPE_SELECTION (meta_selection_get_type ()) +META_EXPORT G_DECLARE_FINAL_TYPE (MetaSelection, meta_selection, META, SELECTION, GObject) +META_EXPORT MetaSelection * meta_selection_new (MetaDisplay *display); +META_EXPORT void meta_selection_set_owner (MetaSelection *selection, MetaSelectionType selection_type, MetaSelectionSource *owner); +META_EXPORT void meta_selection_unset_owner (MetaSelection *selection, MetaSelectionType selection_type, MetaSelectionSource *owner); +META_EXPORT GList * meta_selection_get_mimetypes (MetaSelection *selection, MetaSelectionType selection_type); +META_EXPORT void meta_selection_transfer_async (MetaSelection *selection, MetaSelectionType selection_type, const gchar *mimetype, @@ -55,6 +62,7 @@ void meta_selection_transfer_async (MetaSelection *selection, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); +META_EXPORT gboolean meta_selection_transfer_finish (MetaSelection *selection, GAsyncResult *result, GError **error); diff --git a/src/meta/types.h b/src/meta/types.h index f9ff90b9b..49fb56816 100644 --- a/src/meta/types.h +++ b/src/meta/types.h @@ -43,5 +43,6 @@ typedef struct _MetaDnd MetaDnd; typedef struct _MetaSettings MetaSettings; typedef struct _MetaWorkspaceManager MetaWorkspaceManager; +typedef struct _MetaSelection MetaSelection; #endif diff --git a/src/wayland/meta-selection-source-wayland-private.h b/src/wayland/meta-selection-source-wayland-private.h index 5976271cf..6affc77a8 100644 --- a/src/wayland/meta-selection-source-wayland-private.h +++ b/src/wayland/meta-selection-source-wayland-private.h @@ -24,7 +24,7 @@ #include -#include "core/meta-selection-source.h" +#include "meta/meta-selection-source.h" #define META_TYPE_SELECTION_SOURCE_WAYLAND (meta_selection_source_wayland_get_type ()) diff --git a/src/wayland/meta-wayland-data-device.h b/src/wayland/meta-wayland-data-device.h index 58b72ecf1..729baacd9 100644 --- a/src/wayland/meta-wayland-data-device.h +++ b/src/wayland/meta-wayland-data-device.h @@ -27,7 +27,7 @@ #include #include "clutter/clutter.h" -#include "core/meta-selection-source.h" +#include "meta/meta-selection-source.h" #include "wayland/meta-wayland-types.h" typedef struct _MetaWaylandDragGrab MetaWaylandDragGrab; diff --git a/src/x11/meta-selection-source-x11-private.h b/src/x11/meta-selection-source-x11-private.h index a03d64b95..bcd21a356 100644 --- a/src/x11/meta-selection-source-x11-private.h +++ b/src/x11/meta-selection-source-x11-private.h @@ -22,7 +22,7 @@ #ifndef META_SELECTION_SOURCE_X11_H #define META_SELECTION_SOURCE_X11_H -#include "core/meta-selection-source.h" +#include "meta/meta-selection-source.h" #include "x11/meta-x11-display-private.h" #define META_TYPE_SELECTION_SOURCE_X11 (meta_selection_source_x11_get_type ()) diff --git a/src/x11/meta-x11-display-private.h b/src/x11/meta-x11-display-private.h index cf6bd4082..9a8ab83b2 100644 --- a/src/x11/meta-x11-display-private.h +++ b/src/x11/meta-x11-display-private.h @@ -30,8 +30,8 @@ #include "backends/meta-monitor-manager-private.h" #include "core/display-private.h" -#include "core/meta-selection-source.h" #include "meta/common.h" +#include "meta/meta-selection-source.h" #include "meta/types.h" #include "meta/meta-x11-display.h" #include "meta-startup-notification-x11.h" diff --git a/src/x11/meta-x11-selection-private.h b/src/x11/meta-x11-selection-private.h index 9e42751bb..b551ef602 100644 --- a/src/x11/meta-x11-selection-private.h +++ b/src/x11/meta-x11-selection-private.h @@ -22,7 +22,7 @@ #ifndef META_X11_SELECTION_H #define META_X11_SELECTION_H -#include "core/meta-selection.h" +#include "meta/meta-selection.h" #include "x11/meta-x11-display-private.h" gboolean meta_x11_selection_handle_event (MetaX11Display *display,