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:
Carlos Garnacho
2018-11-23 11:48:53 +01:00
parent 17d00d49d4
commit 02c99524bf
18 changed files with 122 additions and 19 deletions

View File

@ -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

View File

@ -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',

View File

@ -0,0 +1,39 @@
/*
* 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 "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);
#endif /* META_SELECTION_SOURCE_MEMORY_H */

View File

@ -0,0 +1,85 @@
/*
* 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>
#include <meta/common.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 ())
META_EXPORT
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);
};
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 */

70
src/meta/meta-selection.h Normal file
View File

@ -0,0 +1,70 @@
/*
* 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 <meta/common.h>
#include <meta/display.h>
#include <meta/meta-selection-source.h>
#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,
gssize size,
GOutputStream *output,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
META_EXPORT
gboolean meta_selection_transfer_finish (MetaSelection *selection,
GAsyncResult *result,
GError **error);
#endif /* META_SELECTION_H */

View File

@ -43,5 +43,6 @@ typedef struct _MetaDnd MetaDnd;
typedef struct _MetaSettings MetaSettings;
typedef struct _MetaWorkspaceManager MetaWorkspaceManager;
typedef struct _MetaSelection MetaSelection;
#endif