Commit 5a76c236 authored by Matthias Clasen's avatar Matthias Clasen Committed by Matthias Clasen

Add GtkClipboardTargetReceivedFunc, gtk_clipboard_request_targets() and

Wed Dec 24 01:12:53 2003  Matthias Clasen  <maclas@gmx.de>

	* gtk/gtkclipboard.[hc]: Add GtkClipboardTargetReceivedFunc,
	gtk_clipboard_request_targets() and
	gtk_clipboard_wait_for_targets().  (#101774, Dom Lachowicz)
parent f3c77419
Wed Dec 24 01:12:53 2003 Matthias Clasen <maclas@gmx.de>
* gtk/gtkclipboard.[hc]: Add GtkClipboardTargetReceivedFunc,
gtk_clipboard_request_targets() and
gtk_clipboard_wait_for_targets(). (#101774, Dom Lachowicz)
Mon Dec 22 00:40:39 2003 Matthias Clasen <maclas@gmx.de>
* gtk/gtkcalendar.c (gtk_calendar_paint_arrow): Use
......
Wed Dec 24 01:12:53 2003 Matthias Clasen <maclas@gmx.de>
* gtk/gtkclipboard.[hc]: Add GtkClipboardTargetReceivedFunc,
gtk_clipboard_request_targets() and
gtk_clipboard_wait_for_targets(). (#101774, Dom Lachowicz)
Mon Dec 22 00:40:39 2003 Matthias Clasen <maclas@gmx.de>
* gtk/gtkcalendar.c (gtk_calendar_paint_arrow): Use
......
Wed Dec 24 01:12:53 2003 Matthias Clasen <maclas@gmx.de>
* gtk/gtkclipboard.[hc]: Add GtkClipboardTargetReceivedFunc,
gtk_clipboard_request_targets() and
gtk_clipboard_wait_for_targets(). (#101774, Dom Lachowicz)
Mon Dec 22 00:40:39 2003 Matthias Clasen <maclas@gmx.de>
* gtk/gtkcalendar.c (gtk_calendar_paint_arrow): Use
......
Wed Dec 24 01:12:53 2003 Matthias Clasen <maclas@gmx.de>
* gtk/gtkclipboard.[hc]: Add GtkClipboardTargetReceivedFunc,
gtk_clipboard_request_targets() and
gtk_clipboard_wait_for_targets(). (#101774, Dom Lachowicz)
Mon Dec 22 00:40:39 2003 Matthias Clasen <maclas@gmx.de>
* gtk/gtkcalendar.c (gtk_calendar_paint_arrow): Use
......
Wed Dec 24 01:12:53 2003 Matthias Clasen <maclas@gmx.de>
* gtk/gtkclipboard.[hc]: Add GtkClipboardTargetReceivedFunc,
gtk_clipboard_request_targets() and
gtk_clipboard_wait_for_targets(). (#101774, Dom Lachowicz)
Mon Dec 22 00:40:39 2003 Matthias Clasen <maclas@gmx.de>
* gtk/gtkcalendar.c (gtk_calendar_paint_arrow): Use
......
Wed Dec 24 01:12:12 2003 Matthias Clasen <maclas@gmx.de>
* gtk/gtk-sections.txt: Add GtkClipboardTargetReceivedFunc,
gtk_clipboard_request_targets, gtk_clipboard_wait_for_targets.
Wed Dec 24 01:11:36 2003 Matthias Clasen <maclas@gmx.de>
* gtk/tmpl/gtkclipboard.sgml: Document GtkClipboardTargetReceivedFunc.
Sun Dec 21 01:58:33 2003 Matthias Clasen <maclas@gmx.de>
* gtk/gtk-sections.txt: Add gtk_menu_shell_cancel.
......
......@@ -4743,6 +4743,7 @@ gtk_selection_data_get_type
GtkClipboard
GtkClipboardReceivedFunc
GtkClipboardTextReceivedFunc
GtkClipboardTargetsReceivedFunc
GtkClipboardGetFunc
GtkClipboardClearFunc
gtk_clipboard_get
......@@ -4755,9 +4756,11 @@ gtk_clipboard_clear
gtk_clipboard_set_text
gtk_clipboard_request_contents
gtk_clipboard_request_text
gtk_clipboard_request_targets
gtk_clipboard_wait_for_contents
gtk_clipboard_wait_for_text
gtk_clipboard_wait_is_text_available
gtk_clipboard_wait_for_targets
<SUBSECTION Standard>
GTK_CLIPBOARD
GTK_TYPE_CLIPBOARD
......
......@@ -115,6 +115,20 @@ Storing data on clipboards
@data: the @user_data supplied to gtk_clipboard_request_text().
<!-- ##### USER_FUNCTION GtkClipboardTargetsReceivedFunc ##### -->
<para>
A function to be called when the results of gtk_clipboard_request_targets()
are received, or when the request fails.
</para>
@clipboard: the #GtkClipboard
@atoms: the supported targets, as array of #GdkAtom, or %NULL
if retrieving the data failed.
@n_atoms: the length of the @atoms array.
@data: the @user_data supplied to gtk_clipboard_request_targets().
@Since: 2.4
<!-- ##### USER_FUNCTION GtkClipboardGetFunc ##### -->
<para>
A function that will be called to provide the contents of the selection.
......@@ -253,6 +267,16 @@ will not be used again.
@user_data:
<!-- ##### FUNCTION gtk_clipboard_request_targets ##### -->
<para>
</para>
@clipboard:
@callback:
@user_data:
<!-- ##### FUNCTION gtk_clipboard_wait_for_contents ##### -->
<para>
......@@ -269,12 +293,7 @@ will not be used again.
</para>
@clipboard:
@Returns: <!--
Local variables:
mode: sgml
sgml-parent-document: ("../gtk-docs.sgml" "book" "refsect2" "")
End:
-->
@Returns:
<!-- ##### FUNCTION gtk_clipboard_wait_is_text_available ##### -->
......@@ -286,3 +305,20 @@ End:
@Returns:
<!-- ##### FUNCTION gtk_clipboard_wait_for_targets ##### -->
<para>
</para>
@clipboard:
@targets:
@n_targets:
@Returns:
<!--
Local variables:
mode: sgml
sgml-parent-document: ("../gtk-docs.sgml" "book" "refsect2" "")
End:
-->
......@@ -37,6 +37,7 @@ typedef struct _GtkClipboardClass GtkClipboardClass;
typedef struct _RequestContentsInfo RequestContentsInfo;
typedef struct _RequestTextInfo RequestTextInfo;
typedef struct _RequestTargetsInfo RequestTargetsInfo;
struct _GtkClipboard
{
......@@ -72,6 +73,12 @@ struct _RequestTextInfo
gpointer user_data;
};
struct _RequestTargetsInfo
{
GtkClipboardTargetsReceivedFunc callback;
gpointer user_data;
};
static void gtk_clipboard_class_init (GtkClipboardClass *class);
static void gtk_clipboard_finalize (GObject *object);
......@@ -833,6 +840,57 @@ gtk_clipboard_request_text (GtkClipboard *clipboard,
info);
}
static void
request_targets_received_func (GtkClipboard *clipboard,
GtkSelectionData *selection_data,
gpointer data)
{
RequestTargetsInfo *info = data;
GdkAtom *targets = NULL;
gint n_targets = 0;
gtk_selection_data_get_targets (selection_data, &targets, &n_targets);
info->callback (clipboard, targets, n_targets, info->user_data);
g_free (info);
g_free (targets);
}
/**
* gtk_clipboard_request_targets:
* @clipboard: a #GtkClipboard
* @callback: a function to call when the targets are received,
* or the retrieval fails. (It will always be called
* one way or the other.)
* @user_data: user data to pass to @callback.
*
* Requests the contents of the clipboard as list of supported targets.
* When the list is later received, @callback will be called.
*
* The @targets parameter to @callback will contain the resulting targets if
* the request succeeded, or %NULL if it failed.
*
* Since: 2.4
**/
void
gtk_clipboard_request_targets (GtkClipboard *clipboard,
GtkClipboardTargetsReceivedFunc callback,
gpointer user_data)
{
RequestTargetsInfo *info;
g_return_if_fail (clipboard != NULL);
g_return_if_fail (callback != NULL);
info = g_new (RequestTargetsInfo, 1);
info->callback = callback;
info->user_data = user_data;
gtk_clipboard_request_contents (clipboard, gdk_atom_intern ("TARGETS", FALSE),
request_targets_received_func,
info);
}
typedef struct
{
......@@ -1000,3 +1058,49 @@ gtk_clipboard_wait_is_text_available (GtkClipboard *clipboard)
return result;
}
/**
* gtk_clipboard_wait_for_targets
* @clipboard: a #GtkClipboard
* @targets: location to store an array of targets. The result
* stored here must be freed with g_free().
* @n_targets: location to store number of items in @targets.
*
* Returns a list of targets that are present on the clipboard, or %NULL
* if there aren't any targets available. The returned list must be
* freed with g_free().
* This function waits for the data to be received using the main
* loop, so events, timeouts, etc, may be dispatched during the wait.
*
* Return value: %TRUE if any targets are present on the clipboard,
* otherwise %FALSE.
*
* Since: 2.4
*/
gboolean
gtk_clipboard_wait_for_targets (GtkClipboard *clipboard,
GdkAtom **targets,
gint *n_targets)
{
GtkSelectionData *data;
gboolean result = FALSE;
g_return_val_if_fail (clipboard != NULL, FALSE);
/* TODO: see http://bugzilla.gnome.org/show_bug.cgi?id=101774 with regard to XFIXES */
if (n_targets)
*n_targets = 0;
targets = NULL;
data = gtk_clipboard_wait_for_contents (clipboard, gdk_atom_intern ("TARGETS", FALSE));
if (data)
{
result = gtk_selection_data_get_targets (data, targets, n_targets);
gtk_selection_data_free (data);
}
return result;
}
......@@ -38,6 +38,10 @@ typedef void (* GtkClipboardReceivedFunc) (GtkClipboard *clipboard,
typedef void (* GtkClipboardTextReceivedFunc) (GtkClipboard *clipboard,
const gchar *text,
gpointer data);
typedef void (* GtkClipboardTargetsReceivedFunc) (GtkClipboard *clipboard,
GdkAtom *atoms,
gint n_atoms,
gpointer data);
/* Should these functions have GtkClipboard *clipboard as the first argument?
* right now for ClearFunc, you may have trouble determining _which_ clipboard
......@@ -86,6 +90,9 @@ void gtk_clipboard_request_contents (GtkClipboard *clipboard,
void gtk_clipboard_request_text (GtkClipboard *clipboard,
GtkClipboardTextReceivedFunc callback,
gpointer user_data);
void gtk_clipboard_request_targets (GtkClipboard *clipboard,
GtkClipboardTargetsReceivedFunc callback,
gpointer user_data);
GtkSelectionData *gtk_clipboard_wait_for_contents (GtkClipboard *clipboard,
GdkAtom target);
......@@ -93,6 +100,10 @@ gchar * gtk_clipboard_wait_for_text (GtkClipboard *clipboard);
gboolean gtk_clipboard_wait_is_text_available (GtkClipboard *clipboard);
gboolean gtk_clipboard_wait_for_targets (GtkClipboard *clipboard,
GdkAtom **targets,
gint *n_targets);
#ifdef __cplusplus
}
#endif /* __cplusplus */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment