[gtk+] quartz: merge the clipboard storing code from gtk-2-24
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] quartz: merge the clipboard storing code from gtk-2-24
- Date: Thu, 17 Jan 2013 12:16:49 +0000 (UTC)
commit c1e0317824f4d743538f53d4d640f3265e324752
Author: Michael Natterer <mitch lanedo com>
Date: Thu Jan 17 13:16:02 2013 +0100
quartz: merge the clipboard storing code from gtk-2-24
gtk/gtkclipboard-quartz.c | 67 +++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 65 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkclipboard-quartz.c b/gtk/gtkclipboard-quartz.c
index bccc41a..482f6aa 100644
--- a/gtk/gtkclipboard-quartz.c
+++ b/gtk/gtkclipboard-quartz.c
@@ -1039,11 +1039,74 @@ 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 || !clipboard->get_func)
+ 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;
+
+ /* in each loop iteration, check if the content is still
+ * there, because calling get_func() can do anything to
+ * the clipboard
+ */
+ if (!clipboard->target_list || !clipboard->get_func)
+ break;
+
+ 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);
+ }
+
+ if (targets)
+ gtk_target_table_free (targets, n_targets);
}
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;
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]