From 6f6aa0636750420181e03451bd1338f7f5123abd Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Sun, 5 May 2013 18:04:03 -0700 Subject: [PATCH] psppire-data-sheet: Obtain data sheet targets via callback. Calling gtk_clipboard_wait_is_target_available() within on_owner_change() seems to cause Window|Split to act oddly (the right panes were empty), perhaps because gtk_clipboard_wait_is_target_available() has a nested main loop. Switching to gtk_clipboard_request_targets() fixes the problem. Reported by John Darrington. --- src/ui/gui/psppire-data-sheet.c | 39 +++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/src/ui/gui/psppire-data-sheet.c b/src/ui/gui/psppire-data-sheet.c index f2cdc5bd5e..201fa8cd79 100644 --- a/src/ui/gui/psppire-data-sheet.c +++ b/src/ui/gui/psppire-data-sheet.c @@ -2474,23 +2474,40 @@ psppire_data_sheet_clip_received_cb (GtkClipboard *clipboard, } static void -on_owner_change (GtkClipboard *clip, GdkEventOwnerChange *event, gpointer data) +psppire_data_sheet_targets_received_cb (GtkClipboard *clipboard, + GdkAtom *atoms, + gint n_atoms, + gpointer data) { - PsppireDataSheet *data_sheet = PSPPIRE_DATA_SHEET (data); - gboolean compatible_target = FALSE; - GtkAction *action; + GtkAction *action = GTK_ACTION (data); + gboolean compatible_target; gint i; + compatible_target = FALSE; for (i = 0; i < G_N_ELEMENTS (targets); i++) { - GdkAtom atom = gdk_atom_intern (targets[i].target, TRUE); - if (gtk_clipboard_wait_is_target_available (clip, atom)) - { - compatible_target = TRUE; - break; - } + GdkAtom target = gdk_atom_intern (targets[i].target, TRUE); + gint j; + + for (j = 0; j < n_atoms; j++) + if (target == atoms[j]) + { + compatible_target = TRUE; + break; + } } - action = get_action_assert (data_sheet->builder, "edit_paste"); gtk_action_set_sensitive (action, compatible_target); + g_object_unref (action); +} + +static void +on_owner_change (GtkClipboard *clip, GdkEventOwnerChange *event, gpointer data) +{ + PsppireDataSheet *data_sheet = PSPPIRE_DATA_SHEET (data); + GtkAction *action = get_action_assert (data_sheet->builder, "edit_paste"); + + g_object_ref (action); + gtk_clipboard_request_targets (clip, psppire_data_sheet_targets_received_cb, + action); } -- 2.30.2