[gtk+/gtk-2-24] Implement _gtk_clipboard_store_all()
- From: Christian Kellner <gicmo src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/gtk-2-24] Implement _gtk_clipboard_store_all()
- Date: Mon, 14 May 2012 19:43:43 +0000 (UTC)
commit eb831590cd9354bdcb9933ca9bfe531b12177473
Author: Kristian Rietveld <kris lanedo com>
Date: Sun Apr 22 12:14:23 2012 +0200
Implement _gtk_clipboard_store_all()
This pushes the clipboard contents to the OS X clipboard when the
application is quit. Without doing this, clipboard data set by a GTK+
application cannot be accessed after the clipboard has been quit.
Currently, we implement this the easy way because the clipboard
support is fully implemented in GTK+. In the future this might change.
gtk/gtkclipboard-quartz.c | 58 +++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 56 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkclipboard-quartz.c b/gtk/gtkclipboard-quartz.c
index b18165c..3e6da20 100644
--- a/gtk/gtkclipboard-quartz.c
+++ b/gtk/gtkclipboard-quartz.c
@@ -1004,13 +1004,67 @@ gtk_clipboard_set_can_store (GtkClipboard *clipboard,
void
gtk_clipboard_store (GtkClipboard *clipboard)
{
- /* FIXME: Implement */
+ int i;
+ int n_targets = 0;
+ GtkTargetEntry *targets;
+
+ g_return_if_fail (GTK_IS_CLIPBOARD (clipboard));
+
+ if (!clipboard->target_list)
+ return;
+
+ /* We simply store all targets into the OS X clipboard. We should be
+ * using the functions gdk_display_supports_clipboard_persistence() and
+ * gdk_display_store_clipboard(), but since for OS X the clipboard support
+ * was implemented in GTK+ and not through GdkSelections, we do it this
+ * way. Doing this properly could be worthwhile to implement in the future.
+ */
+
+ targets = gtk_target_table_new_from_list (clipboard->target_list,
+ &n_targets);
+ for (i = 0; i < n_targets; i++)
+ {
+ GtkSelectionData selection_data;
+
+ memset (&selection_data, 0, sizeof (GtkSelectionData));
+
+ selection_data.selection = clipboard->selection;
+ selection_data.target = gdk_atom_intern_static_string (targets[i].target);
+ selection_data.display = gdk_display_get_default ();
+ selection_data.length = -1;
+
+ clipboard->get_func (clipboard, &selection_data,
+ targets[i].info, clipboard->user_data);
+
+ if (selection_data.length >= 0)
+ _gtk_quartz_set_selection_data_for_pasteboard (clipboard->pasteboard,
+ &selection_data);
+
+ g_free (selection_data.data);
+ }
}
void
_gtk_clipboard_store_all (void)
{
- /* FIXME: Implement */
+ GtkClipboard *clipboard;
+ GSList *displays, *list;
+
+ displays = gdk_display_manager_list_displays (gdk_display_manager_get ());
+
+ list = displays;
+ while (list)
+ {
+ GdkDisplay *display = list->data;
+
+ clipboard = clipboard_peek (display, GDK_SELECTION_CLIPBOARD, TRUE);
+
+ if (clipboard)
+ gtk_clipboard_store (clipboard);
+
+ list = list->next;
+ }
+ g_slist_free (displays);
}
#define __GTK_CLIPBOARD_C__
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]