-/* GTK - The GTK+ Toolkit
+/* GTK - The GIMP Toolkit
* Copyright (C) 2000 Red Hat, Inc.
* Copyright (C) 2004 Nokia Corporation
*
#include "gtkmarshalers.h"
#include "gtktextbufferrichtext.h"
#include "gtkintl.h"
-#include "gtkalias.h"
#ifdef GDK_WINDOWING_X11
#include "x11/gdkx.h"
GdkAtom *cached_targets;
gint n_cached_targets;
- guint notify_signal_id;
+ gulong notify_signal_id;
gboolean storing_selection;
GMainLoop *store_loop;
guint store_timeout;
* Since: 2.6
*/
clipboard_signals[OWNER_CHANGE] =
- g_signal_new (I_("owner_change"),
+ g_signal_new (I_("owner-change"),
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GtkClipboardClass, owner_change),
g_signal_handler_disconnect (clipboard_widget, clipboard->notify_signal_id);
g_free (clipboard->storable_targets);
+ g_free (clipboard->cached_targets);
G_OBJECT_CLASS (gtk_clipboard_parent_class)->finalize (object);
}
* if your application called "Foo" has a special-purpose
* clipboard, you might call it "_FOO_SPECIAL_CLIPBOARD".
*
- * Return value: the appropriate clipboard object. If no
+ * Return value: (transfer none): the appropriate clipboard object. If no
* clipboard already exists, a new one will
* be created. Once a clipboard object has
* been created, it is persistent and, since
gtk_clipboard_get_for_display (GdkDisplay *display,
GdkAtom selection)
{
+ g_return_val_if_fail (display != NULL, NULL); /* See bgo#463773; this is needed because Flash Player sucks */
g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
g_return_val_if_fail (!display->closed, NULL);
/**
- * gtk_clipboard_get():
- * @selection: a #GdkAtom which identifies the clipboard
- * to use.
- *
+ * gtk_clipboard_get:
+ * @selection: a #GdkAtom which identifies the clipboard to use
+ *
* Returns the clipboard object for the given selection.
* See gtk_clipboard_get_for_display() for complete details.
- *
- * Return value: the appropriate clipboard object. If no
- * clipboard already exists, a new one will
- * be created. Once a clipboard object has
- * been created, it is persistent and, since
- * it is owned by GTK+, must not be freed or
- * unrefd.
- **/
+ *
+ * Return value: (transfer none): the appropriate clipboard object. If no clipboard
+ * already exists, a new one will be created. Once a clipboard
+ * object has been created, it is persistent and, since it is
+ * owned by GTK+, must not be freed or unreffed.
+ */
GtkClipboard *
gtk_clipboard_get (GdkAtom selection)
{
{
GtkWidget *widget = gtk_invisible_new_for_screen (gdk_display_get_default_screen (display));
- g_signal_connect (widget, "selection_received",
+ g_signal_connect (widget, "selection-received",
G_CALLBACK (selection_received), NULL);
if (provider)
/* We need this for gdk_x11_get_server_time() */
gtk_widget_add_events (widget, GDK_PROPERTY_CHANGE_MASK);
- g_signal_connect (widget, "selection_get",
+ g_signal_connect (widget, "selection-get",
G_CALLBACK (selection_get_cb), NULL);
- g_signal_connect (widget, "selection_clear_event",
+ g_signal_connect (widget, "selection-clear-event",
G_CALLBACK (selection_clear_event_cb), NULL);
}
if (timestamp == GDK_CURRENT_TIME)
{
#ifdef GDK_WINDOWING_X11
- timestamp = gdk_x11_get_server_time (clipboard_widget->window);
+ timestamp = gdk_x11_get_server_time (gtk_widget_get_window (clipboard_widget));
#elif defined GDK_WINDOWING_WIN32
timestamp = GetMessageTime ();
#endif
{
clipboard->have_selection = TRUE;
+ if (clipboard->n_cached_targets != -1)
+ {
+ g_free (clipboard->cached_targets);
+ clipboard->cached_targets = NULL;
+ clipboard->n_cached_targets = -1;
+ }
+
if (!(clipboard->have_owner && have_owner) ||
clipboard->user_data != user_data)
{
/**
* gtk_clipboard_set_with_data:
- * @clipboard: a #GtkClipboard
- * @targets: array containing information about the available forms for the
- * clipboard data
- * @n_targets: number of elements in @targets
- * @get_func: function to call to get the actual clipboard data
- * @clear_func: when the clipboard contents are set again, this function will
- * be called, and @get_func will not be subsequently called.
- * @user_data: user data to pass to @get_func and @clear_func.
- *
+ * @clipboard: a #GtkClipboard
+ * @targets: array containing information about the available forms for the
+ * clipboard data
+ * @n_targets: number of elements in @targets
+ * @get_func: (scope async): function to call to get the actual clipboard data
+ * @clear_func: (scope async): when the clipboard contents are set again,
+ * this function will be called, and @get_func will not be subsequently
+ * called.
+ * @user_data: user data to pass to @get_func and @clear_func.
+ *
* Virtually sets the contents of the specified clipboard by providing
* a list of supported formats for the clipboard data and a function
* to call to get the actual data when it is requested.
- *
- * Return value: %TRUE if setting the clipboard data succeeded. If setting
- * the clipboard data failed the provided callback functions
- * will be ignored.
+ *
+ * Return value: %TRUE if setting the clipboard data succeeded.
+ * If setting the clipboard data failed the provided callback
+ * functions will be ignored.
**/
gboolean
gtk_clipboard_set_with_data (GtkClipboard *clipboard,
/**
* gtk_clipboard_set_with_owner:
- * @clipboard: a #GtkClipboard
- * @targets: array containing information about the available forms for the
- * clipboard data
- * @n_targets: number of elements in @targets
- * @get_func: function to call to get the actual clipboard data
- * @clear_func: when the clipboard contents are set again, this function will
- * be called, and @get_func will not be subsequently called.
- * @owner: an object that "owns" the data. This object will be passed
- * to the callbacks when called.
- *
+ * @clipboard: a #GtkClipboard
+ * @targets: array containing information about the available forms for
+ * the clipboard data
+ * @n_targets: number of elements in @targets
+ * @get_func: (scope async): function to call to get the actual clipboard data
+ * @clear_func: (scope async): when the clipboard contents are set again,
+ * this function will be called, and @get_func will not be subsequently
+ * called
+ * @owner: an object that "owns" the data. This object will be passed
+ * to the callbacks when called
+ *
* Virtually sets the contents of the specified clipboard by providing
* a list of supported formats for the clipboard data and a function
* to call to get the actual data when it is requested.
*
* The difference between this function and gtk_clipboard_set_with_data()
* is that instead of an generic @user_data pointer, a #GObject is passed
- * in.
- *
- * Return value: %TRUE if setting the clipboard data succeeded. If setting
- * the clipboard data failed the provided callback functions
- * will be ignored.
+ * in.
+ *
+ * Return value: %TRUE if setting the clipboard data succeeded.
+ * If setting the clipboard data failed the provided callback
+ * functions will be ignored.
**/
gboolean
gtk_clipboard_set_with_owner (GtkClipboard *clipboard,
/**
* gtk_clipboard_get_owner:
* @clipboard: a #GtkClipboard
- *
- * If the clipboard contents callbacks were set with
- * gtk_clipboard_set_with_owner(), and the gtk_clipboard_set_with_data() or
- * gtk_clipboard_clear() has not subsequently called, returns the owner set
+ *
+ * If the clipboard contents callbacks were set with
+ * gtk_clipboard_set_with_owner(), and the gtk_clipboard_set_with_data() or
+ * gtk_clipboard_clear() has not subsequently called, returns the owner set
* by gtk_clipboard_set_with_owner().
- *
- * Return value: the owner of the clipboard, if any; otherwise %NULL.
+ *
+ * Return value: (transfer none): the owner of the clipboard, if any;
+ * otherwise %NULL.
**/
GObject *
gtk_clipboard_get_owner (GtkClipboard *clipboard)
/**
* gtk_clipboard_request_contents:
* @clipboard: a #GtkClipboard
- * @target: an atom representing the form into which the clipboard
- * owner should convert the selection.
- * @callback: A function to call when the results are received
- * (or the retrieval fails). If the retrieval fails
- * the length field of @selection_data will be
- * negative.
+ * @target: an atom representing the form into which the clipboard
+ * owner should convert the selection.
+ * @callback: (scope async): A function to call when the results are received
+ * (or the retrieval fails). If the retrieval fails the length field of
+ * @selection_data will be negative.
* @user_data: user data to pass to @callback
- *
+ *
* Requests the contents of clipboard as the given target.
* When the results of the result are later received the supplied callback
* will be called.
/**
* gtk_clipboard_request_text:
* @clipboard: a #GtkClipboard
- * @callback: a function to call when the text is received,
- * or the retrieval fails. (It will always be called
- * one way or the other.)
+ * @callback: (scope async): a function to call when the text is 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 text. When the text is
* later received, it will be converted to UTF-8 if necessary, and
- * @callback will be called.
+ * @callback will be called.
*
* The @text parameter to @callback will contain the resulting text if
* the request succeeded, or %NULL if it failed. This could happen for
/**
* gtk_clipboard_request_rich_text:
* @clipboard: a #GtkClipboard
- * @buffer: a #GtkTextBuffer
- * @callback: a function to call when the text is received,
- * or the retrieval fails. (It will always be called
- * one way or the other.)
+ * @buffer: a #GtkTextBuffer
+ * @callback: (scope async): a function to call when the text is 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 rich text. When the rich
/**
* gtk_clipboard_request_image:
* @clipboard: a #GtkClipboard
- * @callback: a function to call when the image is received,
- * or the retrieval fails. (It will always be called
- * one way or the other.)
+ * @callback: (scope async): a function to call when the image is 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 image. When the image is
* later received, it will be converted to a #GdkPixbuf, and
- * @callback will be called.
+ * @callback will be called.
*
- * The @pixbuf parameter to @callback will contain the resulting
- * #GdkPixbuf if the request succeeded, or %NULL if it failed. This
- * could happen for various reasons, in particular if the clipboard
- * was empty or if the contents of the clipboard could not be
+ * The @pixbuf parameter to @callback will contain the resulting
+ * #GdkPixbuf if the request succeeded, or %NULL if it failed. This
+ * could happen for various reasons, in particular if the clipboard
+ * was empty or if the contents of the clipboard could not be
* converted into an image.
*
* Since: 2.6
/**
* gtk_clipboard_request_uris:
* @clipboard: a #GtkClipboard
- * @callback: a function to call when the URIs are received,
- * or the retrieval fails. (It will always be called
- * one way or the other.)
+ * @callback: (scope async): a function to call when the URIs 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 URIs. When the URIs are
* later received @callback will be called.
*
/**
* 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.)
+ * @callback: (scope async): 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.
+ *
+ * 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.
/**
* gtk_clipboard_wait_for_image:
* @clipboard: a #GtkClipboard
- *
+ *
* Requests the contents of the clipboard as image and converts
* the result to a #GdkPixbuf. 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: a newly-allocated #GdkPixbuf object which must
- * be disposed with g_object_unref(), or %NULL if
- * retrieving the selection data failed. (This
- * could happen for various reasons, in particular
- * if the clipboard was empty or if the contents of
- * the clipboard could not be converted into an image.)
+ *
+ * Return value: (transfer full): a newly-allocated #GdkPixbuf
+ * object which must be disposed with g_object_unref(), or
+ * %NULL if retrieving the selection data failed. (This could
+ * happen for various reasons, in particular if the clipboard
+ * was empty or if the contents of the clipboard could not be
+ * converted into an image.)
*
* Since: 2.6
**/
* Requests the contents of the clipboard as URIs. 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: a newly-allocated %NULL-terminated array of strings which must
+ *
+ * Return value: (array zero-terminated=1) (element-type utf8) (transfer full): a newly-allocated
+ * %NULL-terminated array of strings which must
* be freed with g_strfreev(), or %NULL if
- * retrieving the selection data failed. (This
- * could happen for various reasons, in particular
- * if the clipboard was empty or if the contents of
+ * retrieving the selection data failed. (This
+ * could happen for various reasons, in particular
+ * if the clipboard was empty or if the contents of
* the clipboard could not be converted into URI form.)
*
* Since: 2.14
*
* Gets the #GdkDisplay associated with @clipboard
*
- * Return value: the #GdkDisplay associated with @clipboard
+ * Return value: (transfer none): the #GdkDisplay associated with @clipboard
*
* Since: 2.2
**/
{
if (clipboard->n_cached_targets != -1)
{
- clipboard->n_cached_targets = -1;
g_free (clipboard->cached_targets);
+ clipboard->cached_targets = NULL;
+ clipboard->n_cached_targets = -1;
}
}
GdkDisplay *display;
GtkClipboard *clipboard;
- display = gdk_drawable_get_display (event->window);
+ display = gdk_window_get_display (event->window);
clipboard = clipboard_peek (display, event->selection, TRUE);
if (clipboard)
/**
* gtk_clipboard_set_can_store:
* @clipboard: a #GtkClipboard
- * @targets: array containing information about which forms should be stored
- * or %NULL to indicate that all forms should be stored.
+ * @targets: (allow-none): array containing information about which forms
+ * should be stored or %NULL to indicate that all forms should
+ * be stored.
* @n_targets: number of elements in @targets
*
* Hints that the clipboard data should be stored somewhere when the
g_object_ref (clipboard);
clipboard_widget = get_clipboard_widget (clipboard->display);
- clipboard->notify_signal_id = g_signal_connect (clipboard_widget, "selection_notify_event",
- G_CALLBACK (gtk_clipboard_selection_notify), clipboard);
-
+ clipboard->notify_signal_id = g_signal_connect (clipboard_widget,
+ "selection-notify-event",
+ G_CALLBACK (gtk_clipboard_selection_notify),
+ clipboard);
+
gdk_display_store_clipboard (clipboard->display,
- clipboard_widget->window,
+ gtk_widget_get_window (clipboard_widget),
clipboard_get_timestamp (clipboard),
clipboard->storable_targets,
clipboard->n_storable_targets);
clipboard->storing_selection = TRUE;
clipboard->store_loop = g_main_loop_new (NULL, TRUE);
- clipboard->store_timeout = g_timeout_add (10000, (GSourceFunc) gtk_clipboard_store_timeout, clipboard);
+ clipboard->store_timeout = g_timeout_add_seconds (10, (GSourceFunc) gtk_clipboard_store_timeout, clipboard);
if (g_main_loop_is_running (clipboard->store_loop))
{
g_slist_free (displays);
}
-
-#define __GTK_CLIPBOARD_C__
-#include "gtkaliasdef.c"