Allow NUOL for @target_list to mean, use gtk_drag_dest_get_target_list

Wed Oct  3 10:42:54 2001  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtkdnd.c (gtk_drag_dest_find_target): Allow
	NUOL for @target_list to mean, use
	gtk_drag_dest_get_target_list (widget).

	* gtk/gtkdnd.c (gtk_drag_finish): Fix problem where
	drop could hang when calling gtk_drag_finish with
	success == FALSE and del == TRUE.

	* gtk/gtkdnd.c (gtk_drag_dest_drop): Fix problem where
	drops without a matching target found would propagate
	to the parent widget rather than being rejected.

	* gtk/gtktextview.c (gtk_text_view_drag_data_received):
	Use text_view->dnd_mark instead of mark name to be
	consistent with the rest of the code.

	* gtk/gtktextview.c (gtk_text_view_drag_motion): Make
	pendantically correct for a drop-only-in-some-places
	widget. (Check whether you can insert in drag_drop,
	not just in drag_motion ... matters in theory, and
	for Motif drag and drop in practice.)

	* gtk/gtkentry.c (gtk_entry_drag_drop): Patch from
	Damian Ivereigh to not allow drops on non-editable
	entries. (#61124)

	* gtk/gtkentry.c (gtk_entry_motion_notify): Don't allow
	text to be moved from a non-editable entry.
This commit is contained in:
Owen Taylor 2001-10-03 15:08:10 +00:00 committed by Owen Taylor
parent b8a10f46a9
commit a8d54496fb
10 changed files with 335 additions and 39 deletions

View File

@ -1,3 +1,34 @@
Wed Oct 3 10:42:54 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkdnd.c (gtk_drag_dest_find_target): Allow
NUOL for @target_list to mean, use
gtk_drag_dest_get_target_list (widget).
* gtk/gtkdnd.c (gtk_drag_finish): Fix problem where
drop could hang when calling gtk_drag_finish with
success == FALSE and del == TRUE.
* gtk/gtkdnd.c (gtk_drag_dest_drop): Fix problem where
drops without a matching target found would propagate
to the parent widget rather than being rejected.
* gtk/gtktextview.c (gtk_text_view_drag_data_received):
Use text_view->dnd_mark instead of mark name to be
consistent with the rest of the code.
* gtk/gtktextview.c (gtk_text_view_drag_motion): Make
pendantically correct for a drop-only-in-some-places
widget. (Check whether you can insert in drag_drop,
not just in drag_motion ... matters in theory, and
for Motif drag and drop in practice.)
* gtk/gtkentry.c (gtk_entry_drag_drop): Patch from
Damian Ivereigh to not allow drops on non-editable
entries. (#61124)
* gtk/gtkentry.c (gtk_entry_motion_notify): Don't allow
text to be moved from a non-editable entry.
2001-10-03 James Henstridge <james@daa.com.au>
* gtk/gtktreeviewcolumn.c (gtk_tree_view_column_set_fixed_width):

View File

@ -1,3 +1,34 @@
Wed Oct 3 10:42:54 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkdnd.c (gtk_drag_dest_find_target): Allow
NUOL for @target_list to mean, use
gtk_drag_dest_get_target_list (widget).
* gtk/gtkdnd.c (gtk_drag_finish): Fix problem where
drop could hang when calling gtk_drag_finish with
success == FALSE and del == TRUE.
* gtk/gtkdnd.c (gtk_drag_dest_drop): Fix problem where
drops without a matching target found would propagate
to the parent widget rather than being rejected.
* gtk/gtktextview.c (gtk_text_view_drag_data_received):
Use text_view->dnd_mark instead of mark name to be
consistent with the rest of the code.
* gtk/gtktextview.c (gtk_text_view_drag_motion): Make
pendantically correct for a drop-only-in-some-places
widget. (Check whether you can insert in drag_drop,
not just in drag_motion ... matters in theory, and
for Motif drag and drop in practice.)
* gtk/gtkentry.c (gtk_entry_drag_drop): Patch from
Damian Ivereigh to not allow drops on non-editable
entries. (#61124)
* gtk/gtkentry.c (gtk_entry_motion_notify): Don't allow
text to be moved from a non-editable entry.
2001-10-03 James Henstridge <james@daa.com.au>
* gtk/gtktreeviewcolumn.c (gtk_tree_view_column_set_fixed_width):

View File

@ -1,3 +1,34 @@
Wed Oct 3 10:42:54 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkdnd.c (gtk_drag_dest_find_target): Allow
NUOL for @target_list to mean, use
gtk_drag_dest_get_target_list (widget).
* gtk/gtkdnd.c (gtk_drag_finish): Fix problem where
drop could hang when calling gtk_drag_finish with
success == FALSE and del == TRUE.
* gtk/gtkdnd.c (gtk_drag_dest_drop): Fix problem where
drops without a matching target found would propagate
to the parent widget rather than being rejected.
* gtk/gtktextview.c (gtk_text_view_drag_data_received):
Use text_view->dnd_mark instead of mark name to be
consistent with the rest of the code.
* gtk/gtktextview.c (gtk_text_view_drag_motion): Make
pendantically correct for a drop-only-in-some-places
widget. (Check whether you can insert in drag_drop,
not just in drag_motion ... matters in theory, and
for Motif drag and drop in practice.)
* gtk/gtkentry.c (gtk_entry_drag_drop): Patch from
Damian Ivereigh to not allow drops on non-editable
entries. (#61124)
* gtk/gtkentry.c (gtk_entry_motion_notify): Don't allow
text to be moved from a non-editable entry.
2001-10-03 James Henstridge <james@daa.com.au>
* gtk/gtktreeviewcolumn.c (gtk_tree_view_column_set_fixed_width):

View File

@ -1,3 +1,34 @@
Wed Oct 3 10:42:54 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkdnd.c (gtk_drag_dest_find_target): Allow
NUOL for @target_list to mean, use
gtk_drag_dest_get_target_list (widget).
* gtk/gtkdnd.c (gtk_drag_finish): Fix problem where
drop could hang when calling gtk_drag_finish with
success == FALSE and del == TRUE.
* gtk/gtkdnd.c (gtk_drag_dest_drop): Fix problem where
drops without a matching target found would propagate
to the parent widget rather than being rejected.
* gtk/gtktextview.c (gtk_text_view_drag_data_received):
Use text_view->dnd_mark instead of mark name to be
consistent with the rest of the code.
* gtk/gtktextview.c (gtk_text_view_drag_motion): Make
pendantically correct for a drop-only-in-some-places
widget. (Check whether you can insert in drag_drop,
not just in drag_motion ... matters in theory, and
for Motif drag and drop in practice.)
* gtk/gtkentry.c (gtk_entry_drag_drop): Patch from
Damian Ivereigh to not allow drops on non-editable
entries. (#61124)
* gtk/gtkentry.c (gtk_entry_motion_notify): Don't allow
text to be moved from a non-editable entry.
2001-10-03 James Henstridge <james@daa.com.au>
* gtk/gtktreeviewcolumn.c (gtk_tree_view_column_set_fixed_width):

View File

@ -1,3 +1,34 @@
Wed Oct 3 10:42:54 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkdnd.c (gtk_drag_dest_find_target): Allow
NUOL for @target_list to mean, use
gtk_drag_dest_get_target_list (widget).
* gtk/gtkdnd.c (gtk_drag_finish): Fix problem where
drop could hang when calling gtk_drag_finish with
success == FALSE and del == TRUE.
* gtk/gtkdnd.c (gtk_drag_dest_drop): Fix problem where
drops without a matching target found would propagate
to the parent widget rather than being rejected.
* gtk/gtktextview.c (gtk_text_view_drag_data_received):
Use text_view->dnd_mark instead of mark name to be
consistent with the rest of the code.
* gtk/gtktextview.c (gtk_text_view_drag_motion): Make
pendantically correct for a drop-only-in-some-places
widget. (Check whether you can insert in drag_drop,
not just in drag_motion ... matters in theory, and
for Motif drag and drop in practice.)
* gtk/gtkentry.c (gtk_entry_drag_drop): Patch from
Damian Ivereigh to not allow drops on non-editable
entries. (#61124)
* gtk/gtkentry.c (gtk_entry_motion_notify): Don't allow
text to be moved from a non-editable entry.
2001-10-03 James Henstridge <james@daa.com.au>
* gtk/gtktreeviewcolumn.c (gtk_tree_view_column_set_fixed_width):

View File

@ -1,3 +1,34 @@
Wed Oct 3 10:42:54 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkdnd.c (gtk_drag_dest_find_target): Allow
NUOL for @target_list to mean, use
gtk_drag_dest_get_target_list (widget).
* gtk/gtkdnd.c (gtk_drag_finish): Fix problem where
drop could hang when calling gtk_drag_finish with
success == FALSE and del == TRUE.
* gtk/gtkdnd.c (gtk_drag_dest_drop): Fix problem where
drops without a matching target found would propagate
to the parent widget rather than being rejected.
* gtk/gtktextview.c (gtk_text_view_drag_data_received):
Use text_view->dnd_mark instead of mark name to be
consistent with the rest of the code.
* gtk/gtktextview.c (gtk_text_view_drag_motion): Make
pendantically correct for a drop-only-in-some-places
widget. (Check whether you can insert in drag_drop,
not just in drag_motion ... matters in theory, and
for Motif drag and drop in practice.)
* gtk/gtkentry.c (gtk_entry_drag_drop): Patch from
Damian Ivereigh to not allow drops on non-editable
entries. (#61124)
* gtk/gtkentry.c (gtk_entry_motion_notify): Don't allow
text to be moved from a non-editable entry.
2001-10-03 James Henstridge <james@daa.com.au>
* gtk/gtktreeviewcolumn.c (gtk_tree_view_column_set_fixed_width):

View File

@ -1,3 +1,34 @@
Wed Oct 3 10:42:54 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkdnd.c (gtk_drag_dest_find_target): Allow
NUOL for @target_list to mean, use
gtk_drag_dest_get_target_list (widget).
* gtk/gtkdnd.c (gtk_drag_finish): Fix problem where
drop could hang when calling gtk_drag_finish with
success == FALSE and del == TRUE.
* gtk/gtkdnd.c (gtk_drag_dest_drop): Fix problem where
drops without a matching target found would propagate
to the parent widget rather than being rejected.
* gtk/gtktextview.c (gtk_text_view_drag_data_received):
Use text_view->dnd_mark instead of mark name to be
consistent with the rest of the code.
* gtk/gtktextview.c (gtk_text_view_drag_motion): Make
pendantically correct for a drop-only-in-some-places
widget. (Check whether you can insert in drag_drop,
not just in drag_motion ... matters in theory, and
for Motif drag and drop in practice.)
* gtk/gtkentry.c (gtk_entry_drag_drop): Patch from
Damian Ivereigh to not allow drops on non-editable
entries. (#61124)
* gtk/gtkentry.c (gtk_entry_motion_notify): Don't allow
text to be moved from a non-editable entry.
2001-10-03 James Henstridge <james@daa.com.au>
* gtk/gtktreeviewcolumn.c (gtk_tree_view_column_set_fixed_width):

View File

@ -699,7 +699,7 @@ gtk_drag_finish (GdkDragContext *context,
time);
}
if (!del)
if (!(success && del))
gdk_drop_finish (context, success, time);
}
@ -1061,7 +1061,8 @@ _gtk_drag_dest_handle_event (GtkWidget *toplevel,
* gtk_drag_dest_find_target:
* @widget: drag destination widget
* @context: drag context
* @target_list: list of droppable targets
* @target_list: list of droppable targets, or %NULL to use
* gtk_drag_dest_get_target_list (@widget).
*
* Looks for a match between @context->targets and the
* @dest_target_list, returning the first matching target, otherwise
@ -1080,7 +1081,15 @@ gtk_drag_dest_find_target (GtkWidget *widget,
{
GList *tmp_target;
GList *tmp_source = NULL;
GtkWidget *source_widget = gtk_drag_get_source_widget (context);
GtkWidget *source_widget;
g_return_val_if_fail (GTK_IS_WIDGET (widget), GDK_NONE);
g_return_val_if_fail (GDK_IS_DRAG_CONTEXT (context), GDK_NONE);
source_widget = gtk_drag_get_source_widget (context);
if (target_list == NULL)
target_list = gtk_drag_dest_get_target_list (widget);
if (target_list == NULL)
return GDK_NONE;
@ -1569,7 +1578,7 @@ gtk_drag_dest_motion (GtkWidget *widget,
}
}
if (action && gtk_drag_dest_find_target (widget, context, site->target_list))
if (action && gtk_drag_dest_find_target (widget, context, NULL))
{
if (!site->have_drag)
{
@ -1676,12 +1685,15 @@ gtk_drag_dest_drop (GtkWidget *widget,
if (site->flags & GTK_DEST_DEFAULT_DROP)
{
GdkAtom target = gtk_drag_dest_find_target (widget, context, site->target_list);
GdkAtom target = gtk_drag_dest_find_target (widget, context, NULL);
if (target == GDK_NONE)
return FALSE;
gtk_drag_get_data (widget, context, target, time);
{
gtk_drag_finish (context, FALSE, FALSE, time);
return TRUE;
}
else
gtk_drag_get_data (widget, context, target, time);
}
gtk_signal_emit_by_name (GTK_OBJECT (widget), "drag_drop",

View File

@ -146,6 +146,11 @@ static void gtk_entry_direction_changed (GtkWidget *widget,
static void gtk_entry_state_changed (GtkWidget *widget,
GtkStateType previous_state);
static gboolean gtk_entry_drag_drop (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
guint time);
static gboolean gtk_entry_drag_motion (GtkWidget *widget,
GdkDragContext *context,
gint x,
@ -380,6 +385,7 @@ gtk_entry_class_init (GtkEntryClass *class)
widget_class->state_changed = gtk_entry_state_changed;
widget_class->mnemonic_activate = gtk_entry_mnemonic_activate;
widget_class->drag_drop = gtk_entry_drag_drop;
widget_class->drag_motion = gtk_entry_drag_motion;
widget_class->drag_leave = gtk_entry_drag_leave;
widget_class->drag_data_received = gtk_entry_drag_data_received;
@ -908,7 +914,7 @@ gtk_entry_init (GtkEntry *entry)
entry->has_frame = TRUE;
gtk_drag_dest_set (GTK_WIDGET (entry),
GTK_DEST_DEFAULT_DROP | GTK_DEST_DEFAULT_HIGHLIGHT,
GTK_DEST_DEFAULT_HIGHLIGHT,
target_table, G_N_ELEMENTS (target_table),
GDK_ACTION_COPY | GDK_ACTION_MOVE);
@ -1525,8 +1531,9 @@ gtk_entry_motion_notify (GtkWidget *widget,
{
GdkDragContext *context;
GtkTargetList *target_list = gtk_target_list_new (target_table, G_N_ELEMENTS (target_table));
guint actions = entry->editable ? GDK_ACTION_COPY | GDK_ACTION_MOVE : GDK_ACTION_COPY;
context = gtk_drag_begin (widget, target_list, GDK_ACTION_COPY | GDK_ACTION_MOVE,
context = gtk_drag_begin (widget, target_list, actions,
entry->button, (GdkEvent *)event);
@ -3822,6 +3829,29 @@ gtk_entry_drag_leave (GtkWidget *widget,
gtk_widget_queue_draw (widget);
}
static gboolean
gtk_entry_drag_drop (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
guint time)
{
GtkEntry *entry;
GdkAtom target = GDK_NONE;
entry = GTK_ENTRY (widget);
if (entry->editable)
target = gtk_drag_dest_find_target (widget, context, NULL);
if (target != GDK_NONE)
gtk_drag_get_data (widget, context, target, time);
else
gtk_drag_finish (context, FALSE, FALSE, time);
return TRUE;
}
static gboolean
gtk_entry_drag_motion (GtkWidget *widget,
GdkDragContext *context,
@ -3843,28 +3873,37 @@ gtk_entry_drag_motion (GtkWidget *widget,
old_position = entry->dnd_position;
new_position = gtk_entry_find_position (entry, x + entry->scroll_offset);
source_widget = gtk_drag_get_source_widget (context);
suggested_action = context->suggested_action;
if (!gtk_editable_get_selection_bounds (GTK_EDITABLE (entry), &sel1, &sel2) ||
new_position < sel1 || new_position > sel2)
if (entry->editable)
{
if (source_widget == widget)
{
/* Default to MOVE, unless the user has
* pressed ctrl or alt to affect available actions
*/
if ((context->actions & GDK_ACTION_MOVE) != 0)
suggested_action = GDK_ACTION_MOVE;
}
source_widget = gtk_drag_get_source_widget (context);
suggested_action = context->suggested_action;
entry->dnd_position = new_position;
if (!gtk_editable_get_selection_bounds (GTK_EDITABLE (entry), &sel1, &sel2) ||
new_position < sel1 || new_position > sel2)
{
if (source_widget == widget)
{
/* Default to MOVE, unless the user has
* pressed ctrl or alt to affect available actions
*/
if ((context->actions & GDK_ACTION_MOVE) != 0)
suggested_action = GDK_ACTION_MOVE;
}
entry->dnd_position = new_position;
}
else
{
if (source_widget == widget)
suggested_action = 0; /* Can't drop in selection where drag started */
entry->dnd_position = -1;
}
}
else
{
if (source_widget == widget)
suggested_action = 0; /* Can't drop in selection where drag started */
/* Entry not editable */
suggested_action = 0;
entry->dnd_position = -1;
}
@ -3894,7 +3933,7 @@ gtk_entry_drag_data_received (GtkWidget *widget,
str = gtk_selection_data_get_text (selection_data);
if (str)
if (str && entry->editable)
{
gint new_position;
gint sel1, sel2;
@ -3914,6 +3953,12 @@ gtk_entry_drag_data_received (GtkWidget *widget,
}
g_free (str);
gtk_drag_finish (context, TRUE, context->action == GDK_ACTION_MOVE, time);
}
else
{
/* Drag and drop didn't happen! */
gtk_drag_finish (context, FALSE, FALSE, time);
}
}
@ -3947,7 +3992,8 @@ gtk_entry_drag_data_delete (GtkWidget *widget,
GtkEditable *editable = GTK_EDITABLE (widget);
if (gtk_editable_get_selection_bounds (editable, &sel_start, &sel_end))
if (GTK_ENTRY (widget)->editable &&
gtk_editable_get_selection_bounds (editable, &sel_start, &sel_end))
gtk_editable_delete_text (editable, sel_start, sel_end);
}

View File

@ -955,7 +955,7 @@ gtk_text_view_init (GtkTextView *text_view)
text_view->editable = TRUE;
gtk_drag_dest_set (widget,
GTK_DEST_DEFAULT_DROP,
0,
target_table, G_N_ELEMENTS (target_table),
GDK_ACTION_COPY | GDK_ACTION_MOVE);
@ -4903,6 +4903,8 @@ gtk_text_view_drag_drop (GtkWidget *widget,
guint time)
{
GtkTextView *text_view;
GtkTextIter drop_point;
GdkAtom target = GDK_NONE;
text_view = GTK_TEXT_VIEW (widget);
@ -4913,6 +4915,18 @@ gtk_text_view_drag_drop (GtkWidget *widget,
gtk_text_mark_set_visible (text_view->dnd_mark, FALSE);
gtk_text_buffer_get_iter_at_mark (get_buffer (text_view),
&drop_point,
text_view->dnd_mark);
if (gtk_text_iter_can_insert (&drop_point, text_view->editable))
target = gtk_drag_dest_find_target (widget, context, NULL);
if (target != GDK_NONE)
gtk_drag_get_data (widget, context, target, time);
else
gtk_drag_finish (context, FALSE, FALSE, time);
return TRUE;
}
@ -4945,19 +4959,19 @@ gtk_text_view_drag_data_received (GtkWidget *widget,
{
GtkTextIter drop_point;
GtkTextView *text_view;
GtkTextMark *drag_target_mark;
gboolean success = FALSE;
text_view = GTK_TEXT_VIEW (widget);
drag_target_mark = gtk_text_buffer_get_mark (get_buffer (text_view),
"gtk_drag_target");
if (drag_target_mark == NULL)
return;
if (!text_view->dnd_mark)
goto done;
gtk_text_buffer_get_iter_at_mark (get_buffer (text_view),
&drop_point,
drag_target_mark);
text_view->dnd_mark);
if (!gtk_text_iter_can_insert (&drop_point, text_view->editable))
goto done;
if (selection_data->target == gdk_atom_intern ("GTK_TEXT_BUFFER_CONTENTS", FALSE))
{
@ -5003,6 +5017,13 @@ gtk_text_view_drag_data_received (GtkWidget *widget,
}
else
insert_text_data (text_view, &drop_point, selection_data);
success = TRUE;
done:
gtk_drag_finish (context, success,
success && context->action == GDK_ACTION_MOVE,
time);
}
static GtkAdjustment*