gdk_flush ();
gdk_error_trap_pop ();
- gdk_window_add_filter (NULL, root_key_filter, GDK_WINDOW_XID (window));
+ gdk_window_add_filter (NULL, root_key_filter, (gpointer) GDK_WINDOW_XID (window));
}
-void
+static void
ungrab_dnd_keys (GtkWidget *widget,
guint32 time)
{
window = widget->window;
root = gdk_screen_get_root_window (gtk_widget_get_screen (widget));
- gdk_window_remove_filter (NULL, root_key_filter, GDK_WINDOW_XID (window));
+ gdk_window_remove_filter (NULL, root_key_filter, (gpointer) GDK_WINDOW_XID (window));
gdk_error_trap_push ();
{
gint x, y, width, height;
- if (GTK_WIDGET_DRAWABLE (widget))
+ if (gtk_widget_is_drawable (widget))
{
cairo_t *cr;
- if (GTK_WIDGET_NO_WINDOW (widget))
+ if (!gtk_widget_get_has_window (widget))
{
x = widget->allocation.x;
y = widget->allocation.y;
* and invokations of gtk_drag_finish() in #GtkWidget:drag-data-received.
* Especially the later is dramatic, when your own #GtkWidget:drag-motion
* handler calls gtk_drag_get_data() to inspect the dragged data.
+ *
+ * There's no way to set a default action here, you can use the
+ * #GtkWidget:drag-motion callback for that. Here's an example which selects
+ * the action to use depending on whether the control key is pressed or not:
+ * |[
+ * static void
+ * drag_motion (GtkWidget *widget,
+ * GdkDragContext *context,
+ * gint x,
+ * gint y,
+ * guint time)
+ * {
+ * GdkModifierType mask;
+ *
+ * gdk_window_get_pointer (gtk_widget_get_window (widget),
+ * NULL, NULL, &mask);
+ * if (mask & GDK_CONTROL_MASK)
+ * gdk_drag_status (context, GDK_ACTION_COPY, time);
+ * else
+ * gdk_drag_status (context, GDK_ACTION_MOVE, time);
+ * }
+ * ]|
*/
void
gtk_drag_dest_set (GtkWidget *widget,
void
gtk_drag_dest_unset (GtkWidget *widget)
{
+ GtkDragDestSite *old_site;
+
g_return_if_fail (GTK_IS_WIDGET (widget));
+ old_site = g_object_get_data (G_OBJECT (widget),
+ "gtk-drag-dest");
+ if (old_site)
+ {
+ g_signal_handlers_disconnect_by_func (widget,
+ gtk_drag_dest_realized,
+ old_site);
+ g_signal_handlers_disconnect_by_func (widget,
+ gtk_drag_dest_hierarchy_changed,
+ old_site);
+ }
+
g_object_set_data (G_OBJECT (widget), I_("gtk-drag-dest"), NULL);
}
/**
* gtk_drag_dest_set_target_list:
* @widget: a #GtkWidget that's a drag destination
- * @target_list: list of droppable targets, or %NULL for none
+ * @target_list: (allow-none): list of droppable targets, or %NULL for none
*
* Sets the target types that this widget can accept from drag-and-drop.
* The widget must first be made into a drag destination with
* gtk_drag_dest_find_target:
* @widget: drag destination widget
* @context: drag context
- * @target_list: list of droppable targets, or %NULL to use
+ * @target_list: (allow-none): list of droppable targets, or %NULL to use
* gtk_drag_dest_get_target_list (@widget).
*
* Looks for a match between @context->targets and the
gint x_offset = 0;
gint y_offset = 0;
- if (data->found || !GTK_WIDGET_MAPPED (widget) || !GTK_WIDGET_SENSITIVE (widget))
+ if (data->found || !GTK_WIDGET_MAPPED (widget) || !gtk_widget_get_sensitive (widget))
return;
/* Note that in the following code, we only count the
allocation_to_window_x = widget->allocation.x;
allocation_to_window_y = widget->allocation.y;
- if (!GTK_WIDGET_NO_WINDOW (widget))
+ if (gtk_widget_get_has_window (widget))
{
/* The allocation is relative to the parent window for
* window widgets, not to widget->window.
gtk_container_forall (GTK_CONTAINER (widget), prepend_and_ref_widget, &children);
for (tmp_list = children; tmp_list; tmp_list = tmp_list->next)
{
- if (!new_data.found && GTK_WIDGET_DRAWABLE (tmp_list->data))
+ if (!new_data.found && gtk_widget_is_drawable (tmp_list->data))
gtk_drag_find_widget (tmp_list->data, &new_data);
g_object_unref (tmp_list->data);
}
{
GtkWidget *toplevel = gtk_widget_get_toplevel (widget);
- if (GTK_WIDGET_TOPLEVEL (toplevel))
+ if (gtk_widget_is_toplevel (toplevel))
gdk_window_register_dnd (toplevel->window);
}
{
GtkWidget *toplevel = gtk_widget_get_toplevel (widget);
- if (GTK_WIDGET_TOPLEVEL (toplevel) && GTK_WIDGET_REALIZED (toplevel))
+ if (gtk_widget_is_toplevel (toplevel) && GTK_WIDGET_REALIZED (toplevel))
gdk_window_register_dnd (toplevel->window);
}
/**
* gtk_drag_source_set_target_list:
* @widget: a #GtkWidget that's a drag source
- * @target_list: list of draggable targets, or %NULL for none
+ * @target_list: (allow-none): list of draggable targets, or %NULL for none
*
* Changes the target types that this widget offers for drag-and-drop.
* The widget must first be made into a drag source with
* @widget: a #GtkWidget
* @colormap: the colormap of the icon
* @pixmap: the image data for the icon
- * @mask: the transparency mask for an image.
- *
+ * @mask: (allow-none): the transparency mask for an image.
+ *
* Sets the icon that will be used for drags from a particular widget
- * from a pixmap/mask. GTK+ retains references for the arguments, and
+ * from a pixmap/mask. GTK+ retains references for the arguments, and
* will release them when they are no longer needed.
* Use gtk_drag_source_set_icon_pixbuf() instead.
**/
info->cur_x - hot_x,
info->cur_y - hot_y);
- if (GTK_WIDGET_VISIBLE (icon_window))
+ if (gtk_widget_get_visible (icon_window))
gdk_window_raise (icon_window->window);
else
gtk_widget_show (icon_window);
* with a context for the source side of a drag)
* @colormap: the colormap of the icon
* @pixmap: the image data for the icon
- * @mask: the transparency mask for the icon or %NULL for none.
+ * @mask: (allow-none): the transparency mask for the icon or %NULL for none.
* @hot_x: the X offset within @pixmap of the hotspot.
* @hot_y: the Y offset within @pixmap of the hotspot.
*