mirror of
https://github.com/brl/mutter.git
synced 2025-06-13 16:59:30 +00:00
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. https://gitlab.gnome.org/GNOME/mutter/merge_requests/320
This commit is contained in:
@ -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
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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 */
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "core/meta-selection-source-memory.h"
|
||||
#include "meta/meta-selection-source-memory.h"
|
||||
|
||||
struct _MetaSelectionSourceMemory
|
||||
{
|
||||
|
@ -1,36 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2018 Red Hat
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
* 02111-1307, USA.
|
||||
*
|
||||
* Author: Carlos Garnacho <carlosg@gnome.org>
|
||||
*/
|
||||
|
||||
#ifndef META_MEMORY_SELECTION_SOURCE_H
|
||||
#define META_MEMORY_SELECTION_SOURCE_H
|
||||
|
||||
#include "core/meta-selection-source.h"
|
||||
|
||||
#define META_TYPE_SELECTION_SOURCE_MEMORY (meta_selection_source_memory_get_type ())
|
||||
G_DECLARE_FINAL_TYPE (MetaSelectionSourceMemory,
|
||||
meta_selection_source_memory,
|
||||
META, SELECTION_SOURCE_MEMORY,
|
||||
MetaSelectionSource)
|
||||
|
||||
MetaSelectionSource * meta_selection_source_memory_new (const char *mimetype,
|
||||
GBytes *content);
|
||||
|
||||
#endif /* META_SELECTION_SOURCE_MEMORY_H */
|
@ -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)
|
||||
{
|
||||
|
@ -1,78 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2018 Red Hat
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
* 02111-1307, USA.
|
||||
*
|
||||
* Author: Carlos Garnacho <carlosg@gnome.org>
|
||||
*/
|
||||
|
||||
#ifndef META_SELECTION_SOURCE_H
|
||||
#define META_SELECTION_SOURCE_H
|
||||
|
||||
#include <gio/gio.h>
|
||||
|
||||
typedef enum
|
||||
{
|
||||
META_SELECTION_PRIMARY,
|
||||
META_SELECTION_CLIPBOARD,
|
||||
META_SELECTION_DND,
|
||||
META_N_SELECTION_TYPES,
|
||||
} MetaSelectionType;
|
||||
|
||||
typedef struct _MetaSelectionSourceClass MetaSelectionSourceClass;
|
||||
typedef struct _MetaSelectionSource MetaSelectionSource;
|
||||
|
||||
#define META_TYPE_SELECTION_SOURCE (meta_selection_source_get_type ())
|
||||
|
||||
G_DECLARE_DERIVABLE_TYPE (MetaSelectionSource,
|
||||
meta_selection_source,
|
||||
META, SELECTION_SOURCE,
|
||||
GObject)
|
||||
|
||||
struct _MetaSelectionSourceClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
|
||||
void (* activated) (MetaSelectionSource *source);
|
||||
void (* deactivated) (MetaSelectionSource *source);
|
||||
|
||||
GList * (* get_mimetypes) (MetaSelectionSource *source);
|
||||
|
||||
void (* read_async) (MetaSelectionSource *source,
|
||||
const gchar *mimetype,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
GInputStream * (* read_finish) (MetaSelectionSource *source,
|
||||
GAsyncResult *result,
|
||||
GError **error);
|
||||
};
|
||||
|
||||
void meta_selection_source_read_async (MetaSelectionSource *source,
|
||||
const gchar *mimetype,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
|
||||
GInputStream * meta_selection_source_read_finish (MetaSelectionSource *source,
|
||||
GAsyncResult *result,
|
||||
GError **error);
|
||||
|
||||
GList * meta_selection_source_get_mimetypes (MetaSelectionSource *source);
|
||||
|
||||
gboolean meta_selection_source_is_active (MetaSelectionSource *source);
|
||||
|
||||
#endif /* META_SELECTION_SOURCE_H */
|
@ -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,
|
||||
|
@ -1,62 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2018 Red Hat
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
* 02111-1307, USA.
|
||||
*
|
||||
* Author: Carlos Garnacho <carlosg@gnome.org>
|
||||
*/
|
||||
|
||||
#ifndef META_SELECTION_H
|
||||
#define META_SELECTION_H
|
||||
|
||||
#include <gio/gio.h>
|
||||
|
||||
#include "core/meta-selection-source.h"
|
||||
#include "meta/display.h"
|
||||
|
||||
#define META_TYPE_SELECTION (meta_selection_get_type ())
|
||||
|
||||
G_DECLARE_FINAL_TYPE (MetaSelection,
|
||||
meta_selection,
|
||||
META, SELECTION,
|
||||
GObject)
|
||||
|
||||
MetaSelection *
|
||||
meta_selection_new (MetaDisplay *display);
|
||||
|
||||
void meta_selection_set_owner (MetaSelection *selection,
|
||||
MetaSelectionType selection_type,
|
||||
MetaSelectionSource *owner);
|
||||
void meta_selection_unset_owner (MetaSelection *selection,
|
||||
MetaSelectionType selection_type,
|
||||
MetaSelectionSource *owner);
|
||||
|
||||
GList * meta_selection_get_mimetypes (MetaSelection *selection,
|
||||
MetaSelectionType selection_type);
|
||||
|
||||
void meta_selection_transfer_async (MetaSelection *selection,
|
||||
MetaSelectionType selection_type,
|
||||
const gchar *mimetype,
|
||||
gssize size,
|
||||
GOutputStream *output,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
gboolean meta_selection_transfer_finish (MetaSelection *selection,
|
||||
GAsyncResult *result,
|
||||
GError **error);
|
||||
|
||||
#endif /* META_SELECTION_H */
|
Reference in New Issue
Block a user