#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
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;
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
/* 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().
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
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_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);
-
- return our_type;
-}
-
-GType
-gtk_target_list_get_type (void)
-{
- static GType our_type = 0;
+G_DEFINE_BOXED_TYPE (GtkSelectionData, gtk_selection_data,
+ gtk_selection_data_copy,
+ gtk_selection_data_free)
- 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"