+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):
+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):
+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):
+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):
+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):
+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):
+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):
time);
}
- if (!del)
+ if (!(success && del))
gdk_drop_finish (context, success, time);
}
* 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
{
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;
}
}
- 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)
{
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",
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,
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;
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);
{
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);
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,
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;
+
+ 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 = new_position;
+ 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;
}
-
+
gdk_drag_status (context, suggested_action, time);
if (entry->dnd_position != old_position)
str = gtk_selection_data_get_text (selection_data);
- if (str)
+ if (str && entry->editable)
{
gint new_position;
gint sel1, sel2;
}
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);
}
}
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);
}
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);
guint time)
{
GtkTextView *text_view;
+ GtkTextIter drop_point;
+ GdkAtom target = GDK_NONE;
text_view = GTK_TEXT_VIEW (widget);
text_view->scroll_timeout = 0;
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;
}
{
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))
{
}
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*