[mutter/wip/carlosg/clipboard-manager: 16/16] Make MetaSelection, MetaSelectionSource and MetaMemorySelectionSource public



commit 846dd304ddbcc0b57b450c168e3f10089bca508d
Author: Carlos Garnacho <carlosg gnome org>
Date:   Fri Nov 23 11:48:53 2018 +0100

    Make MetaSelection, MetaSelectionSource and MetaMemorySelectionSource public
    
    This exposes the base so that we can reimplement StClipboard on top. Some
    gtk-docs have been added for documentation and introspection purposes.

 src/core/display-private.h                         |  2 +-
 src/core/display.c                                 |  6 +++
 src/core/meta-clipboard-manager.c                  |  2 +-
 src/core/meta-memory-selection-source.c            |  2 +-
 src/core/meta-selection-source.c                   | 33 +++++++++++++-
 src/core/meta-selection.c                          | 53 +++++++++++++++++++++-
 src/meson.build                                    |  3 --
 src/meta/display.h                                 |  2 +
 src/meta/meson.build                               |  3 ++
 src/{core => meta}/meta-memory-selection-source.h  |  2 +-
 src/{core => meta}/meta-selection-source.h         |  0
 src/{core => meta}/meta-selection.h                |  2 +-
 src/meta/types.h                                   |  1 +
 src/wayland/meta-wayland-data-device.h             |  2 +-
 .../meta-wayland-selection-source-private.h        |  2 +-
 src/x11/meta-x11-display-private.h                 |  2 +-
 src/x11/meta-x11-selection-private.h               |  2 +-
 src/x11/meta-x11-selection-source-private.h        |  2 +-
 18 files changed, 105 insertions(+), 16 deletions(-)
---
diff --git a/src/core/display-private.h b/src/core/display-private.h
index f730d6642..cab84c038 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;
diff --git a/src/core/display.c b/src/core/display.c
index 266614cb3..5160682fb 100644
--- a/src/core/display.c
+++ b/src/core/display.c
@@ -3652,6 +3652,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 ca00fc82c..58a1c56fe 100644
--- a/src/core/meta-clipboard-manager.c
+++ b/src/core/meta-clipboard-manager.c
@@ -21,7 +21,7 @@
 #include "config.h"
 
 #include "core/meta-clipboard-manager.h"
-#include "core/meta-memory-selection-source.h"
+#include "meta/meta-memory-selection-source.h"
 
 #define MAX_TEXT_SIZE (4 * 1024 * 1024) /* 4MB */
 #define MAX_IMAGE_SIZE (200 * 1024 * 1024) /* 200MB */
diff --git a/src/core/meta-memory-selection-source.c b/src/core/meta-memory-selection-source.c
index b7355af8f..f162910d5 100644
--- a/src/core/meta-memory-selection-source.c
+++ b/src/core/meta-memory-selection-source.c
@@ -20,7 +20,7 @@
  */
 #include "config.h"
 
-#include "core/meta-memory-selection-source.h"
+#include "meta/meta-memory-selection-source.h"
 
 struct _MetaMemorySelectionSource
 {
diff --git a/src/core/meta-selection-source.c b/src/core/meta-selection-source.c
index afe061990..e8da81f2b 100644
--- a/src/core/meta-selection-source.c
+++ b/src/core/meta-selection-source.c
@@ -20,8 +20,8 @@
  */
 #include "config.h"
 
-#include "meta-selection.h"
-#include "meta-selection-source.h"
+#include "meta/meta-selection.h"
+#include "meta/meta-selection-source.h"
 
 typedef struct MetaSelectionSourcePrivate MetaSelectionSourcePrivate;
 
@@ -106,6 +106,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,
@@ -116,12 +126,31 @@ 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)
 {
   return META_SELECTION_SOURCE_GET_CLASS (source)->get_mimetypes (source);
 }
 
+/**
+ * meta_selection_source_get_selection:
+ * @source: the selection source
+ * @selection: (out): return location for the current selection type
+ *
+ * If the source is currently the owner of a selection, returns #TRUE
+ * and fills in @selection with the currently owned selection. Otherwise
+ * returns #FALSE.
+ *
+ * Returns: #TRUE if the source owns a selection.
+ **/
 gboolean
 meta_selection_source_get_selection (MetaSelectionSource *source,
                                      MetaSelectionType   *selection)
diff --git a/src/core/meta-selection.c b/src/core/meta-selection.c
index 04782caac..e68a50615 100644
--- a/src/core/meta-selection.c
+++ b/src/core/meta-selection.c
@@ -20,7 +20,7 @@
  */
 #include "config.h"
 
-#include "meta-selection.h"
+#include "meta/meta-selection.h"
 
 typedef struct TransferRequest TransferRequest;
 
@@ -85,6 +85,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,
@@ -104,6 +113,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,
@@ -121,6 +139,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)
@@ -262,6 +289,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,
@@ -292,6 +333,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 92f5402cd..df42ec473 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -337,11 +337,8 @@ mutter_sources = [
   'core/meta-inhibit-shortcuts-dialog-default.c',
   'core/meta-inhibit-shortcuts-dialog-default-private.h',
   'core/meta-memory-selection-source.c',
-  'core/meta-memory-selection-source.h',
   'core/meta-selection.c',
-  'core/meta-selection.h',
   'core/meta-selection-source.c',
-  'core/meta-selection-source.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 918817809..669834f19 100644
--- a/src/meta/display.h
+++ b/src/meta/display.h
@@ -233,4 +233,6 @@ MetaStartupNotification * meta_display_get_startup_notification (MetaDisplay *di
 
 MetaSoundPlayer * meta_display_get_sound_player (MetaDisplay *display);
 
+MetaSelection * meta_display_get_selection (MetaDisplay *display);
+
 #endif
diff --git a/src/meta/meson.build b/src/meta/meson.build
index a5a6ad2be..e9398d7d7 100644
--- a/src/meta/meson.build
+++ b/src/meta/meson.build
@@ -18,9 +18,12 @@ mutter_public_headers = [
   'meta-dnd.h',
   'meta-idle-monitor.h',
   'meta-inhibit-shortcuts-dialog.h',
+  'meta-memory-selection-source.h',
   'meta-monitor-manager.h',
   'meta-plugin.h',
   'meta-remote-access-controller.h',
+  'meta-selection.h',
+  'meta-selection-source.h',
   'meta-settings.h',
   'meta-shadow-factory.h',
   'meta-shaped-texture.h',
diff --git a/src/core/meta-memory-selection-source.h b/src/meta/meta-memory-selection-source.h
similarity index 97%
rename from src/core/meta-memory-selection-source.h
rename to src/meta/meta-memory-selection-source.h
index a20bbd361..ef86ea0ca 100644
--- a/src/core/meta-memory-selection-source.h
+++ b/src/meta/meta-memory-selection-source.h
@@ -22,7 +22,7 @@
 #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_MEMORY_SELECTION_SOURCE (meta_memory_selection_source_get_type ())
 G_DECLARE_FINAL_TYPE (MetaMemorySelectionSource,
diff --git a/src/core/meta-selection-source.h b/src/meta/meta-selection-source.h
similarity index 100%
rename from src/core/meta-selection-source.h
rename to src/meta/meta-selection-source.h
diff --git a/src/core/meta-selection.h b/src/meta/meta-selection.h
similarity index 98%
rename from src/core/meta-selection.h
rename to src/meta/meta-selection.h
index c0d1f50e3..e0f5f6102 100644
--- a/src/core/meta-selection.h
+++ b/src/meta/meta-selection.h
@@ -23,8 +23,8 @@
 
 #include <gio/gio.h>
 
-#include "core/meta-selection-source.h"
 #include "meta/display.h"
+#include "meta/meta-selection-source.h"
 
 #define META_TYPE_SELECTION (meta_selection_get_type ())
 
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-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 <wayland-server.h>
 
 #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/wayland/meta-wayland-selection-source-private.h 
b/src/wayland/meta-wayland-selection-source-private.h
index 5af26c397..9f9b9f9a6 100644
--- a/src/wayland/meta-wayland-selection-source-private.h
+++ b/src/wayland/meta-wayland-selection-source-private.h
@@ -24,7 +24,7 @@
 
 #include <wayland-server.h>
 
-#include "core/meta-selection-source.h"
+#include "meta/meta-selection-source.h"
 
 #define META_TYPE_WAYLAND_SELECTION_SOURCE (meta_wayland_selection_source_get_type ())
 
diff --git a/src/x11/meta-x11-display-private.h b/src/x11/meta-x11-display-private.h
index b61c41561..708e23e69 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,
diff --git a/src/x11/meta-x11-selection-source-private.h b/src/x11/meta-x11-selection-source-private.h
index 95348a674..ea518be62 100644
--- a/src/x11/meta-x11-selection-source-private.h
+++ b/src/x11/meta-x11-selection-source-private.h
@@ -22,7 +22,7 @@
 #ifndef META_X11_SELECTION_SOURCE_H
 #define META_X11_SELECTION_SOURCE_H
 
-#include "core/meta-selection-source.h"
+#include "meta/meta-selection-source.h"
 #include "x11/meta-x11-display-private.h"
 
 #define META_TYPE_X11_SELECTION_SOURCE (meta_x11_selection_source_get_type ())


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]