sync to tree changes
2001-01-19 Havoc Pennington <hp@redhat.com> * demos/gtk-demo/main.c (button_press_event_cb): sync to tree changes * gtk/gtkrbtree.c (_gtk_rbtree_node_find_offset): fix this function * gtk/gtktreeviewcolumn.c (gtk_tree_view_column_set_widget): implement * gtk/gtktreeview.c (gtk_tree_view_move_to): rename scroll_to_cell, matches TextView scroll functions better (gtk_tree_view_tree_to_widget_coords): new function (gtk_tree_view_widget_to_tree_coords): new function (gtk_tree_view_get_visible_rect): new function (gtk_tree_view_get_path_at_pos): accept negative coordinates (gtk_tree_view_draw_node_focus_rect): new function moved from draw_focus, also, use width of bin_window as width of the focus rect (gtk_tree_view_expand_row): fix bug where it didn't recognize already-expanded rows (gtk_tree_view_get_cell_rect): new function (gtk_tree_view_get_path_at_pos): return the click position relative to the passed-in cell (gtk_tree_view_set_expander_column): new function * configure.in: remove gtk-config-2.0 chmod * gtk/gtktextview.c (gtk_text_view_drag_motion): small cleanups, and properly handle drags with targets we don't understand (gtk_text_view_drag_end): don't stop scrolling, the source isn't scrolling anyway (gtk_text_view_drag_drop): stop scrolling here though, and set the mark invisible * gtk/gtkdnd.c (gtk_drag_dest_find_target): export as a public function (gtk_drag_dest_get_target_list): new function (gtk_drag_dest_set_target_list): new function * gtk/gtktreeview.c: Add a bunch of drag-and-drop implementation * gtk/gtktreeprivate.h (struct _GtkTreeViewPrivate): add fields related to drag-and-drop
This commit is contained in:
committed by
Havoc Pennington
parent
3da8e3c7dd
commit
e248e4e79e
@ -4235,19 +4235,13 @@ gtk_text_view_start_selection_dnd (GtkTextView *text_view,
|
||||
gtk_target_list_unref (target_list);
|
||||
|
||||
gtk_drag_set_icon_default (context);
|
||||
|
||||
/* We're inside the selection, so start without being able
|
||||
* to accept the drag.
|
||||
*/
|
||||
gdk_drag_status (context, 0, event->time);
|
||||
gtk_text_mark_set_visible (text_view->dnd_mark, FALSE);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_text_view_drag_begin (GtkWidget *widget,
|
||||
GdkDragContext *context)
|
||||
{
|
||||
|
||||
/* do nothing */
|
||||
}
|
||||
|
||||
static void
|
||||
@ -4257,14 +4251,6 @@ gtk_text_view_drag_end (GtkWidget *widget,
|
||||
GtkTextView *text_view;
|
||||
|
||||
text_view = GTK_TEXT_VIEW (widget);
|
||||
|
||||
gtk_text_mark_set_visible (text_view->dnd_mark, FALSE);
|
||||
|
||||
if (text_view->scroll_timeout != 0)
|
||||
{
|
||||
gtk_timeout_remove (text_view->scroll_timeout);
|
||||
text_view->scroll_timeout = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
@ -4353,6 +4339,7 @@ gtk_text_view_drag_motion (GtkWidget *widget,
|
||||
GtkTextIter end;
|
||||
GdkRectangle target_rect;
|
||||
gint bx, by;
|
||||
GdkDragAction suggested_action = 0;
|
||||
|
||||
text_view = GTK_TEXT_VIEW (widget);
|
||||
|
||||
@ -4362,7 +4349,7 @@ gtk_text_view_drag_motion (GtkWidget *widget,
|
||||
y < target_rect.y ||
|
||||
x > (target_rect.x + target_rect.width) ||
|
||||
y > (target_rect.y + target_rect.height))
|
||||
return FALSE; /* outside the text window */
|
||||
return FALSE; /* outside the text window, allow parent widgets to handle event */
|
||||
|
||||
gtk_text_view_window_to_buffer_coords (text_view,
|
||||
GTK_TEXT_WINDOW_WIDGET,
|
||||
@ -4372,21 +4359,23 @@ gtk_text_view_drag_motion (GtkWidget *widget,
|
||||
gtk_text_layout_get_iter_at_pixel (text_view->layout,
|
||||
&newplace,
|
||||
bx, by);
|
||||
|
||||
if (gtk_text_buffer_get_selection_bounds (get_buffer (text_view),
|
||||
|
||||
if (gtk_drag_dest_find_target (widget, context,
|
||||
gtk_drag_dest_get_target_list (widget)) == GDK_NONE)
|
||||
{
|
||||
/* can't accept any of the offered targets */
|
||||
}
|
||||
else if (gtk_text_buffer_get_selection_bounds (get_buffer (text_view),
|
||||
&start, &end) &&
|
||||
gtk_text_iter_in_range (&newplace, &start, &end))
|
||||
{
|
||||
/* We're inside the selection. */
|
||||
gdk_drag_status (context, 0, time);
|
||||
gtk_text_mark_set_visible (text_view->dnd_mark, FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (gtk_text_iter_editable (&newplace, text_view->editable))
|
||||
{
|
||||
GtkWidget *source_widget;
|
||||
GdkDragAction suggested_action;
|
||||
|
||||
suggested_action = context->suggested_action;
|
||||
|
||||
@ -4400,20 +4389,26 @@ gtk_text_view_drag_motion (GtkWidget *widget,
|
||||
if ((context->actions & GDK_ACTION_MOVE) != 0)
|
||||
suggested_action = GDK_ACTION_MOVE;
|
||||
}
|
||||
|
||||
gtk_text_mark_set_visible (text_view->dnd_mark,
|
||||
text_view->cursor_visible);
|
||||
|
||||
gdk_drag_status (context, suggested_action, time);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Can't drop here. */
|
||||
gdk_drag_status (context, 0, time);
|
||||
gtk_text_mark_set_visible (text_view->dnd_mark, FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
if (suggested_action != 0)
|
||||
{
|
||||
gtk_text_mark_set_visible (text_view->dnd_mark,
|
||||
text_view->cursor_visible);
|
||||
|
||||
gdk_drag_status (context, suggested_action, time);
|
||||
}
|
||||
else
|
||||
{
|
||||
gdk_drag_status (context, 0, time);
|
||||
gtk_text_mark_set_visible (text_view->dnd_mark, FALSE);
|
||||
}
|
||||
|
||||
gtk_text_buffer_move_mark (get_buffer (text_view),
|
||||
text_view->dnd_mark,
|
||||
&newplace);
|
||||
@ -4427,7 +4422,10 @@ gtk_text_view_drag_motion (GtkWidget *widget,
|
||||
|
||||
text_view->scroll_timeout =
|
||||
gtk_timeout_add (50, drag_scan_timeout, text_view);
|
||||
|
||||
|
||||
/* TRUE return means don't propagate the drag motion to parent
|
||||
* widgets that may also be drop sites.
|
||||
*/
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -4438,18 +4436,17 @@ gtk_text_view_drag_drop (GtkWidget *widget,
|
||||
gint y,
|
||||
guint time)
|
||||
{
|
||||
#if 0
|
||||
/* called automatically. */
|
||||
if (context->targets)
|
||||
{
|
||||
gtk_drag_get_data (widget, context,
|
||||
GPOINTER_TO_INT (context->targets->data),
|
||||
time);
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
return FALSE;
|
||||
#endif
|
||||
GtkTextView *text_view;
|
||||
|
||||
text_view = GTK_TEXT_VIEW (widget);
|
||||
|
||||
if (text_view->scroll_timeout != 0)
|
||||
gtk_timeout_remove (text_view->scroll_timeout);
|
||||
|
||||
text_view->scroll_timeout = 0;
|
||||
|
||||
gtk_text_mark_set_visible (text_view->dnd_mark, FALSE);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user