[mutter] remote-desktop: Add dummy remote selection source



commit a220506bf7bbd76a444bef1a0440060562d5be71
Author: Jonas Ã…dahl <jadahl gmail com>
Date:   Wed Nov 4 10:23:52 2020 +0100

    remote-desktop: Add dummy remote selection source
    
    It doesn't yet fetch data from the remote desktop session, but hooks up
    correctly.
    
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1552>

 src/core/meta-selection-source-remote.c | 121 ++++++++++++++++++++++++++++++++
 src/core/meta-selection-source-remote.h |  36 ++++++++++
 src/meson.build                         |   2 +
 3 files changed, 159 insertions(+)
---
diff --git a/src/core/meta-selection-source-remote.c b/src/core/meta-selection-source-remote.c
new file mode 100644
index 0000000000..828c8c8c85
--- /dev/null
+++ b/src/core/meta-selection-source-remote.c
@@ -0,0 +1,121 @@
+/*
+ * Copyright (C) 2020 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.
+ *
+ */
+
+#include "config.h"
+
+#include "core/meta-selection-source-remote.h"
+
+#include "backends/meta-remote-desktop-session.h"
+
+struct _MetaSelectionSourceRemote
+{
+  MetaSelectionSource parent;
+
+  MetaRemoteDesktopSession *session;
+  GList *mime_types;
+};
+
+G_DEFINE_TYPE (MetaSelectionSourceRemote,
+               meta_selection_source_remote,
+               META_TYPE_SELECTION_SOURCE)
+
+MetaSelectionSourceRemote *
+meta_selection_source_remote_new (MetaRemoteDesktopSession *session,
+                                  GList                    *mime_types)
+{
+  MetaSelectionSourceRemote *source_remote;
+
+  source_remote = g_object_new (META_TYPE_SELECTION_SOURCE_REMOTE, NULL);
+  source_remote->session = session;
+  source_remote->mime_types = mime_types;
+
+  return source_remote;
+}
+
+static void
+meta_selection_source_remote_read_async (MetaSelectionSource *source,
+                                         const char          *mimetype,
+                                         GCancellable        *cancellable,
+                                         GAsyncReadyCallback  callback,
+                                         gpointer             user_data)
+{
+  GTask *task;
+  GInputStream *stream;
+
+  task = g_task_new (source, cancellable, callback, user_data);
+  g_task_set_source_tag (task, meta_selection_source_remote_read_async);
+
+  stream = g_memory_input_stream_new_from_data ("place holder text", -1, NULL);
+  g_task_return_pointer (task, stream, g_object_unref);
+
+  g_object_unref (task);
+}
+
+static GInputStream *
+meta_selection_source_remote_read_finish (MetaSelectionSource  *source,
+                                          GAsyncResult         *result,
+                                          GError              **error)
+{
+  g_return_val_if_fail (g_task_is_valid (result, source), FALSE);
+  g_return_val_if_fail (g_task_get_source_tag (G_TASK (result)) ==
+                        meta_selection_source_remote_read_async, FALSE);
+
+  return g_task_propagate_pointer (G_TASK (result), error);
+}
+
+static GList *
+meta_selection_source_remote_get_mimetypes (MetaSelectionSource *source)
+{
+  MetaSelectionSourceRemote *source_remote =
+    META_SELECTION_SOURCE_REMOTE (source);
+
+  return g_list_copy_deep (source_remote->mime_types,
+                           (GCopyFunc) g_strdup,
+                           NULL);
+}
+
+static void
+meta_selection_source_remote_finalize (GObject *object)
+{
+  MetaSelectionSourceRemote *source_remote =
+    META_SELECTION_SOURCE_REMOTE (object);
+
+  g_list_free_full (source_remote->mime_types, g_free);
+
+  G_OBJECT_CLASS (meta_selection_source_remote_parent_class)->finalize (object);
+}
+
+static void
+meta_selection_source_remote_init (MetaSelectionSourceRemote *source_remote)
+{
+}
+
+static void
+meta_selection_source_remote_class_init (MetaSelectionSourceRemoteClass *klass)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+  MetaSelectionSourceClass *source_class = META_SELECTION_SOURCE_CLASS (klass);
+
+  object_class->finalize = meta_selection_source_remote_finalize;
+
+  source_class->read_async = meta_selection_source_remote_read_async;
+  source_class->read_finish = meta_selection_source_remote_read_finish;
+  source_class->get_mimetypes = meta_selection_source_remote_get_mimetypes;
+}
diff --git a/src/core/meta-selection-source-remote.h b/src/core/meta-selection-source-remote.h
new file mode 100644
index 0000000000..28a1127587
--- /dev/null
+++ b/src/core/meta-selection-source-remote.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2020 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.
+ *
+ */
+
+#ifndef META_SELECTION_SOURCE_REMOTE_H
+#define META_SELECTION_SOURCE_REMOTE_H
+
+#include "backends/meta-remote-desktop.h"
+#include "meta/meta-selection-source.h"
+
+#define META_TYPE_SELECTION_SOURCE_REMOTE (meta_selection_source_remote_get_type ())
+G_DECLARE_FINAL_TYPE (MetaSelectionSourceRemote,
+                      meta_selection_source_remote,
+                      META, SELECTION_SOURCE_REMOTE,
+                      MetaSelectionSource)
+
+MetaSelectionSourceRemote * meta_selection_source_remote_new (MetaRemoteDesktopSession *session,
+                                                              GList                    *mime_types);
+
+#endif /* META_SELECTION_SOURCE_REMOTE_H */
diff --git a/src/meson.build b/src/meson.build
index 3683907ff3..9fe5e8ebf5 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -487,6 +487,8 @@ if have_remote_desktop
     'backends/meta-screen-cast-stream.h',
     'backends/meta-screen-cast-stream-src.c',
     'backends/meta-screen-cast-stream-src.h',
+    'core/meta-selection-source-remote.c',
+    'core/meta-selection-source-remote.h',
   ]
 endif
 


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