#include "gdk.h"
#include "gtkmain.h"
+#include "gtkdebug.h"
#include "gtkselection.h"
#include "gtktextbufferrichtext.h"
#include "gtkintl.h"
#include "win32/gdkwin32.h"
#endif
-#include "gtkalias.h"
-
#undef DEBUG_SELECTION
/* Maximum size of a sent chunk, in bytes. Also the default size of
MULTIPLE,
TARGETS,
TIMESTAMP,
+ SAVE_TARGETS,
LAST_ATOM
};
/**
* gtk_selection_owner_set_for_display:
- * @display: the #Gdkdisplay where the selection is set
- * @widget: new selection owner (a #GdkWidget), or %NULL.
+ * @display: the #Gdkdisplay where the selection is set
+ * @widget: (allow-none): new selection owner (a #GdkWidget), or %NULL.
* @selection: an interned atom representing the selection to claim.
* @time_: timestamp with which to claim the selection
*
g_return_val_if_fail (GDK_IS_DISPLAY (display), FALSE);
g_return_val_if_fail (selection != GDK_NONE, FALSE);
- g_return_val_if_fail (widget == NULL || GTK_WIDGET_REALIZED (widget), FALSE);
+ g_return_val_if_fail (widget == NULL || gtk_widget_get_realized (widget), FALSE);
g_return_val_if_fail (widget == NULL || gtk_widget_get_display (widget) == display, FALSE);
if (widget == NULL)
window = NULL;
else
- window = widget->window;
+ window = gtk_widget_get_window (widget);
tmp_list = current_selections;
while (tmp_list)
if (old_owner && old_owner != widget)
{
GdkEvent *event = gdk_event_new (GDK_SELECTION_CLEAR);
-
- event->selection.window = g_object_ref (old_owner->window);
+
+ event->selection.window = g_object_ref (gtk_widget_get_window (old_owner));
event->selection.selection = selection;
event->selection.time = time;
/**
* gtk_selection_owner_set:
- * @widget: a #GtkWidget, or %NULL.
+ * @widget: (allow-none): a #GtkWidget, or %NULL.
* @selection: an interned atom representing the selection to claim
* @time_: timestamp with which to claim the selection
*
{
GdkDisplay *display;
- g_return_val_if_fail (widget == NULL || GTK_WIDGET_REALIZED (widget), FALSE);
+ g_return_val_if_fail (widget == NULL || gtk_widget_get_realized (widget), FALSE);
g_return_val_if_fail (selection != GDK_NONE, FALSE);
if (widget)
list = gtk_selection_target_list_get (widget, selection);
gtk_target_list_add (list, target, 0, info);
#ifdef GDK_WINDOWING_WIN32
- gdk_win32_selection_add_targets (widget->window, selection, 1, &target);
+ gdk_win32_selection_add_targets (gtk_widget_get_window (widget), selection, 1, &target);
#endif
}
for (i = 0; i < ntargets; ++i)
atoms[i] = gdk_atom_intern (targets[i].target, FALSE);
- gdk_win32_selection_add_targets (widget->window, selection, ntargets, atoms);
+ gdk_win32_selection_add_targets (gtk_widget_get_window (widget), selection, ntargets, atoms);
g_free (atoms);
}
#endif
if (initialize)
gtk_selection_init ();
- if (!GTK_WIDGET_REALIZED (widget))
+ if (!gtk_widget_get_realized (widget))
gtk_widget_realize (widget);
/* Check to see if there are already any retrievals in progress for
/* Otherwise, we need to go through X */
current_retrievals = g_list_append (current_retrievals, info);
- gdk_selection_convert (widget->window, selection, target, time_);
+ gdk_selection_convert (gtk_widget_get_window (widget), selection, target, time_);
gdk_threads_add_timeout (1000,
(GSourceFunc) gtk_selection_retrieval_timeout, info);
*
* Retrieves the display of the selection.
*
- * Returns: the display of the selection.
+ * Returns: (transfer none): the display of the selection.
*
* Since: 2.14
**/
*
* Gets the contents of the selection data as a #GdkPixbuf.
*
- * Return value: if the selection data contained a recognized
+ * Return value: (transfer full): if the selection data contained a recognized
* image type and it could be converted to a #GdkPixbuf, a
* newly allocated pixbuf is returned, otherwise %NULL.
* If the result is non-%NULL it must be freed with g_object_unref().
/**
* gtk_selection_data_set_uris:
* @selection_data: a #GtkSelectionData
- * @uris: a %NULL-terminated array of strings hilding URIs
+ * @uris: a %NULL-terminated array of strings holding URIs
*
* Sets the contents of the selection from a list of URIs.
* The string is converted to the form determined by
* @selection_data: a #GtkSelectionData
*
* Gets the contents of the selection data as array of URIs.
- *
- * Return value: if the selection data contains a list of
+ *
+ * Return value: (array zero-terminated=1) (element-type utf8) (transfer full): if
+ * the selection data contains a list of
* URIs, a newly allocated %NULL-terminated string array
- * containing the URIs, otherwise %NULL. If the result is
+ * containing the URIs, otherwise %NULL. If the result is
* non-%NULL it must be freed with g_strfreev().
*
* Since: 2.6
gtk_selection_atoms[MULTIPLE] = gdk_atom_intern_static_string ("MULTIPLE");
gtk_selection_atoms[TIMESTAMP] = gdk_atom_intern_static_string ("TIMESTAMP");
gtk_selection_atoms[TARGETS] = gdk_atom_intern_static_string ("TARGETS");
+ gtk_selection_atoms[SAVE_TARGETS] = gdk_atom_intern_static_string ("SAVE_TARGETS");
initialize = FALSE;
}
/**
- * gtk_selection_clear:
+ * _gtk_selection_clear:
* @widget: a #GtkWidget
* @event: the event
*
- * The default handler for the GtkWidget::selection_clear_event
+ * The default handler for the #GtkWidget::selection-clear-event
* signal.
*
* Return value: %TRUE if the event was handled, otherwise false
- *
- * Since: 2.2
- *
- * Deprecated: 2.4: Instead of calling this function, chain up from
- * your selection_clear_event handler. Calling this function
- * from any other context is illegal.
**/
gboolean
-gtk_selection_clear (GtkWidget *widget,
+_gtk_selection_clear (GtkWidget *widget,
GdkEventSelection *event)
{
/* Note that we filter clear events in gdkselection-x11.c, so
event->time);
g_free (mult_atoms);
g_slice_free (GtkIncrInfo, info);
- gdk_error_trap_pop ();
+ gdk_error_trap_pop_ignored ();
return TRUE;
}
- gdk_error_trap_pop ();
+ gdk_error_trap_pop_ignored ();
/* This is annoying; the ICCCM doesn't specify the property type
* used for the property contents, so the autoconversion for
#endif
gtk_selection_invoke_handler (widget, &data, event->time);
-
if (data.length < 0)
{
info->conversions[i].property = GDK_NONE;
g_message ("PropertyDelete, property %ld", event->atom);
#endif
- selection_max_size = GTK_SELECTION_MAX_SIZE (gdk_drawable_get_display (window));
+ selection_max_size = GTK_SELECTION_MAX_SIZE (gdk_window_get_display (window));
/* Now find the appropriate ongoing INCR */
tmp_list = current_incrs;
*************************************************************/
gboolean
-_gtk_selection_notify (GtkWidget *widget,
+_gtk_selection_notify (GtkWidget *widget,
GdkEventSelection *event)
{
GList *tmp_list;
GtkRetrievalInfo *info = NULL;
+ GdkWindow *window;
guchar *buffer = NULL;
gint length;
GdkAtom type;
gint format;
-
+
#ifdef DEBUG_SELECTION
g_message ("Initial receipt of selection %ld, target %ld (property = %ld)",
event->selection, event->target, event->property);
#endif
-
+
+ window = gtk_widget_get_window (widget);
+
tmp_list = current_retrievals;
while (tmp_list)
{
return FALSE;
if (event->property != GDK_NONE)
- length = gdk_selection_property_get (widget->window, &buffer,
+ length = gdk_selection_property_get (window, &buffer,
&type, &format);
else
length = 0; /* silence gcc */
info->notify_time = event->time;
info->idle_time = 0;
info->offset = 0; /* Mark as OK to proceed */
- gdk_window_set_events (widget->window,
- gdk_window_get_events (widget->window)
+ gdk_window_set_events (window,
+ gdk_window_get_events (window)
| GDK_PROPERTY_CHANGE_MASK);
}
else
type, format,
buffer, length, event->time);
}
-
- gdk_property_delete (widget->window, event->property);
-
+
+ gdk_property_delete (window, event->property);
+
g_free (buffer);
return TRUE;
{
GList *tmp_list;
GtkRetrievalInfo *info = NULL;
+ GdkWindow *window;
guchar *new_buffer;
int length;
GdkAtom type;
return FALSE;
info->idle_time = 0;
-
- length = gdk_selection_property_get (widget->window, &new_buffer,
+
+ window = gtk_widget_get_window (widget);
+ length = gdk_selection_property_get (window, &new_buffer,
&type, &format);
- gdk_property_delete (widget->window, event->atom);
-
+ gdk_property_delete (window, event->atom);
+
/* We could do a lot better efficiency-wise by paying attention to
what length was sent in the initial INCR transaction, instead of
doing memory allocation at every step. But its only guaranteed to
g_return_if_fail (widget != NULL);
target_list = gtk_selection_target_list_get (widget, data->selection);
- if (target_list &&
+ if (data->target != gtk_selection_atoms[SAVE_TARGETS] &&
+ target_list &&
gtk_target_list_find (target_list, data->target, &info))
{
g_signal_emit_by_name (widget,
tmp_list = tmp_list->next;
}
}
+ else if (data->target == gtk_selection_atoms[SAVE_TARGETS])
+ {
+ gtk_selection_data_set (data,
+ gdk_atom_intern_static_string ("NULL"),
+ 32, NULL, 0);
+ }
else
{
data->length = -1;
g_slice_free (GtkSelectionData, data);
}
-GType
-gtk_selection_data_get_type (void)
-{
- static GType our_type = 0;
-
- if (our_type == 0)
- our_type = g_boxed_type_register_static (I_("GtkSelectionData"),
- (GBoxedCopyFunc) gtk_selection_data_copy,
- (GBoxedFreeFunc) gtk_selection_data_free);
+G_DEFINE_BOXED_TYPE (GtkSelectionData, gtk_selection_data,
+ gtk_selection_data_copy,
+ gtk_selection_data_free)
- return our_type;
-}
-
-GType
-gtk_target_list_get_type (void)
-{
- static GType our_type = 0;
-
- if (our_type == 0)
- our_type = g_boxed_type_register_static (I_("GtkTargetList"),
- (GBoxedCopyFunc) gtk_target_list_ref,
- (GBoxedFreeFunc) gtk_target_list_unref);
-
- return our_type;
-}
+G_DEFINE_BOXED_TYPE (GtkTargetList, gtk_target_list,
+ gtk_target_list_ref,
+ gtk_target_list_unref)
static int
gtk_selection_bytes_per_item (gint format)
}
return 0;
}
-
-#define __GTK_SELECTION_C__
-#include "gtkaliasdef.c"