Commit 411d798e authored by Matthias Clasen's avatar Matthias Clasen Committed by Matthias Clasen

Improved DND support for GtkNotebook (#332991, Carlos Garnacho)

2006-03-22  Matthias Clasen  <mclasen@redhat.com>

	Improved DND support for GtkNotebook  (#332991, Carlos Garnacho)

	* gtk/gtk.symbols:
	* gtk/gtkdnd.h:
	* gtk/gtkdnd.c: Add a track_motion flag on GtkDragDest
	with getter and setter, for cases where the drag destination
	is interested in drag motion events independent of targets.

	* gtk/gtksettings.c (gtk_settings_class_init): Add a setting
	for the timeout used when expanding during DND.

	* gtk/gtknotebook.c: Use the track_motion flag to switch
	notebook tabs when hovering over tabs during DND.
parent 8a1478a5
2006-03-22 Matthias Clasen <mclasen@redhat.com>
Improved DND support for GtkNotebook (#332991, Carlos Garnacho)
* gtk/gtk.symbols:
* gtk/gtkdnd.h:
* gtk/gtkdnd.c: Add a track_motion flag on GtkDragDest
with getter and setter, for cases where the drag destination
is interested in drag motion events independent of targets.
* gtk/gtksettings.c (gtk_settings_class_init): Add a setting
for the timeout used when expanding during DND.
* gtk/gtknotebook.c: Use the track_motion flag to switch
notebook tabs when hovering over tabs during DND.
2006-03-22 Matthias Clasen <mclasen@redhat.com>
* gtk/gtktreeview.c (gtk_tree_view_bin_expose): Use fg_gc to
......
2006-03-22 Matthias Clasen <mclasen@redhat.com>
Improved DND support for GtkNotebook (#332991, Carlos Garnacho)
* gtk/gtk.symbols:
* gtk/gtkdnd.h:
* gtk/gtkdnd.c: Add a track_motion flag on GtkDragDest
with getter and setter, for cases where the drag destination
is interested in drag motion events independent of targets.
* gtk/gtksettings.c (gtk_settings_class_init): Add a setting
for the timeout used when expanding during DND.
* gtk/gtknotebook.c: Use the track_motion flag to switch
notebook tabs when hovering over tabs during DND.
2006-03-22 Matthias Clasen <mclasen@redhat.com>
* gtk/gtktreeview.c (gtk_tree_view_bin_expose): Use fg_gc to
......
......@@ -996,6 +996,8 @@ gtk_drag_dest_get_target_list
gtk_drag_dest_set
gtk_drag_dest_set_proxy
gtk_drag_dest_set_target_list
gtk_drag_dest_set_track_motion
gtk_drag_dest_get_track_motion
gtk_drag_dest_unset
gtk_drag_finish
gtk_drag_get_data
......
......@@ -131,6 +131,7 @@ struct _GtkDragDestSite
guint do_proxy : 1;
guint proxy_coords : 1;
guint have_drag : 1;
guint track_motion : 1;
};
struct _GtkDragDestInfo
......@@ -1026,6 +1027,8 @@ gtk_drag_dest_set_internal (GtkWidget *widget,
g_signal_handlers_disconnect_by_func (widget,
gtk_drag_dest_hierarchy_changed,
old_site);
site->track_motion = old_site->track_motion;
}
if (GTK_WIDGET_REALIZED (widget))
......@@ -1272,6 +1275,61 @@ gtk_drag_dest_add_uri_targets (GtkWidget *widget)
gtk_target_list_unref (target_list);
}
/**
* gtk_drag_dest_set_track_motion:
* @widget: a #GtkWidget that's a drag destination
* @track_motion: whether to accept all targets
*
* Tells the widget to emit ::drag-motion and ::drag-leave
* events regardless of the targets and the %GTK_DEST_DEFAULT_MOTION
* flag.
*
* This may be used when a widget wants to do generic
* actions regardless of the targets that the source offers.
*
* Since: 2.10
**/
void
gtk_drag_dest_set_track_motion (GtkWidget *widget,
gboolean track_motion)
{
GtkDragDestSite *site;
g_return_if_fail (GTK_IS_WIDGET (widget));
site = g_object_get_data (G_OBJECT (widget), "gtk-drag-dest");
g_return_if_fail (site != NULL);
site->track_motion = track_motion != FALSE;
}
/**
* gtk_drag_dest_get_track_motion:
* @widget: a #GtkWidget that's a drag destination
*
* Returns whether the widget has been configured to always
* emit ::drag-motion signals.
*
* Return Value: %TRUE if the widget always emits ::drag-motion events
*
* Since: 2.10
**/
gboolean
gtk_drag_dest_get_track_motion (GtkWidget *widget)
{
GtkDragDestSite *site;
g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
site = g_object_get_data (G_OBJECT (widget), "gtk-drag-dest");
if (site)
return site->track_motion;
return FALSE;
}
/*************************************************************
* _gtk_drag_dest_handle_event:
* Called from widget event handling code on Drag events
......@@ -1352,7 +1410,7 @@ _gtk_drag_dest_handle_event (GtkWidget *toplevel,
data.callback = (event->type == GDK_DRAG_MOTION) ?
gtk_drag_dest_motion : gtk_drag_dest_drop;
data.time = event->dnd.time;
gtk_drag_find_widget (toplevel, &data);
if (info->widget && !data.found)
......@@ -1856,9 +1914,9 @@ gtk_drag_dest_leave (GtkWidget *widget,
if ((site->flags & GTK_DEST_DEFAULT_HIGHLIGHT) && site->have_drag)
gtk_drag_unhighlight (widget);
if (!(site->flags & GTK_DEST_DEFAULT_MOTION) || site->have_drag)
g_signal_emit_by_name (widget, "drag_leave",
context, time);
if (!(site->flags & GTK_DEST_DEFAULT_MOTION) || site->have_drag ||
site->track_motion)
g_signal_emit_by_name (widget, "drag_leave", context, time);
site->have_drag = FALSE;
}
......@@ -1935,7 +1993,7 @@ gtk_drag_dest_motion (GtkWidget *widget,
{
gint i;
for (i=0; i<8; i++)
for (i = 0; i < 8; i++)
{
if ((site->actions & (1 << i)) &&
(context->actions & (1 << i)))
......@@ -1945,7 +2003,7 @@ gtk_drag_dest_motion (GtkWidget *widget,
}
}
}
if (action && gtk_drag_dest_find_target (widget, context, NULL))
{
if (!site->have_drag)
......@@ -1954,13 +2012,14 @@ gtk_drag_dest_motion (GtkWidget *widget,
if (site->flags & GTK_DEST_DEFAULT_HIGHLIGHT)
gtk_drag_highlight (widget);
}
gdk_drag_status (context, action, time);
}
else
{
gdk_drag_status (context, 0, time);
return TRUE;
if (!site->track_motion)
return TRUE;
}
}
......@@ -2055,13 +2114,13 @@ gtk_drag_dest_drop (GtkWidget *widget,
if (site->flags & GTK_DEST_DEFAULT_DROP)
{
GdkAtom target = gtk_drag_dest_find_target (widget, context, NULL);
if (target == GDK_NONE)
{
gtk_drag_finish (context, FALSE, FALSE, time);
return TRUE;
}
else
else
gtk_drag_get_data (widget, context, target, time);
}
......
/* -*- Mode: C; c-file-style: "gnu"; tab-width: 8 -*- */
/* GTK - The GIMP Toolkit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
......@@ -87,6 +88,10 @@ void gtk_drag_dest_add_text_targets (GtkWidget *widget);
void gtk_drag_dest_add_image_targets (GtkWidget *widget);
void gtk_drag_dest_add_uri_targets (GtkWidget *widget);
void gtk_drag_dest_set_track_motion (GtkWidget *widget,
gboolean track_motion);
gboolean gtk_drag_dest_get_track_motion (GtkWidget *widget);
/* Source side */
void gtk_drag_source_set (GtkWidget *widget,
......
This diff is collapsed.
......@@ -34,6 +34,7 @@
#define DEFAULT_TIMEOUT_INITIAL 200
#define DEFAULT_TIMEOUT_REPEAT 20
#define DEFAULT_TIMEOUT_EXPAND 500
typedef struct _GtkSettingsValuePrivate GtkSettingsValuePrivate;
......@@ -87,6 +88,7 @@ enum {
PROP_SHOW_UNICODE_MENU,
PROP_TIMEOUT_INITIAL,
PROP_TIMEOUT_REPEAT,
PROP_TIMEOUT_EXPAND,
PROP_COLOR_SCHEME,
PROP_ENABLE_ANIMATIONS,
PROP_TOUCHSCREEN_MODE,
......@@ -452,6 +454,16 @@ gtk_settings_class_init (GtkSettingsClass *class)
g_assert (result == PROP_TIMEOUT_REPEAT);
result = settings_install_property_parser (class,
g_param_spec_int ("gtk-timeout-expand",
P_("Expand timeout"),
P_("Expand value for timeouts, when a widget is expanding a new region"),
0, G_MAXINT, DEFAULT_TIMEOUT_EXPAND,
GTK_PARAM_READWRITE),
NULL);
g_assert (result == PROP_TIMEOUT_EXPAND);
/**
* GtkSettings:gtk-color-scheme:
*
......
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