summaryrefslogtreecommitdiff
path: root/gtk/gtkclipboard.c
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@redhat.com>2001-10-22 20:47:01 +0000
committerOwen Taylor <otaylor@src.gnome.org>2001-10-22 20:47:01 +0000
commit92d2dc0ba639efbc360a3de34d4a2ae722afa098 (patch)
tree07727da269ec0f3ecac5f8e6973354999342fdcc /gtk/gtkclipboard.c
parent8fe966936c5b855b27aca8e9b2d07839d14662a4 (diff)
downloadgtk+-92d2dc0ba639efbc360a3de34d4a2ae722afa098.tar.gz
Fixing popup menus to have "Paste" sensitized correctly. Original patches
Mon Oct 22 16:25:12 2001 Owen Taylor <otaylor@redhat.com> Fixing popup menus to have "Paste" sensitized correctly. Original patches from Damian Ivereigh, much mangled. * gtk/gtkselection.c: Add functions gtk_selection_data_get_targets(), gtk_selection_data_targets_include_text(). (#60854) * gtk/gtkclipboard.c: Add a simple do-it-all non-async "check if the clipboard has text" function gtk_clipboard_wait_is_text_available. (#60854) * gtk/gtkentry.c: Only enable the paste item if the clipboard contains text. (#60973) * gtk/gtktextview.c: Only enable the paste item if the clipboard contains text. (#60975)
Diffstat (limited to 'gtk/gtkclipboard.c')
-rw-r--r--gtk/gtkclipboard.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/gtk/gtkclipboard.c b/gtk/gtkclipboard.c
index df2ef1d3d0..6556231733 100644
--- a/gtk/gtkclipboard.c
+++ b/gtk/gtkclipboard.c
@@ -820,3 +820,35 @@ gtk_clipboard_wait_for_text (GtkClipboard *clipboard)
return results.data;
}
+/**
+ * gtk_clipboard_wait_is_text_available:
+ * @clipboard: a #GtkClipboard
+ *
+ * Test to see if there is text available to be pasted
+ * This is done by requesting the TARGETS atom and checking
+ * if it contains any of the names: STRING, TEXT, COMPOUND_TEXT,
+ * UTF8_STRING. This function waits for the data to be received
+ * using the main loop, so events, timeouts, etc, may be dispatched
+ * during the wait.
+ *
+ * This function is a little faster than calling
+ * gtk_clipboard_wait_for_text() since it doesn't need to retrieve
+ * the actual text.
+ *
+ * Return value: %TRUE is there is text available, %FALSE otherwise.
+ **/
+gboolean
+gtk_clipboard_wait_is_text_available (GtkClipboard *clipboard)
+{
+ GtkSelectionData *data;
+ gboolean result = FALSE;
+
+ data = gtk_clipboard_wait_for_contents (clipboard, gdk_atom_intern ("TARGETS", FALSE));
+ if (data)
+ {
+ result = gtk_selection_data_targets_include_text (data);
+ gtk_selection_data_free (data);
+ }
+
+ return result;
+}