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:
Havoc Pennington 2001-01-19 22:39:19 +00:00 committed by Havoc Pennington
parent 3da8e3c7dd
commit e248e4e79e
20 changed files with 2232 additions and 322 deletions

View File

@ -1,4 +1,49 @@
2001-01-19 <alexl@redhat.com>
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
2001-01-19 Alexander Larsson <alexl@redhat.com>
* gdk/linux-fb/gdkprivate-fb.h:
Define EMULATE_GDKFONT.
@ -67,7 +112,7 @@ Mon Jan 8 11:58:05 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkobject.h: Remove trailing , from enum
2001-01-17 <alexl@redhat.com>
2001-01-17 Alexander Larsson <alexl@redhat.com>
* gdk/linux-fb/gdkdrawable-fb2.c (gdk_shadow_fb_draw_arc):
Doh! Mixed up x and y.

View File

@ -1,4 +1,49 @@
2001-01-19 <alexl@redhat.com>
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
2001-01-19 Alexander Larsson <alexl@redhat.com>
* gdk/linux-fb/gdkprivate-fb.h:
Define EMULATE_GDKFONT.
@ -67,7 +112,7 @@ Mon Jan 8 11:58:05 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkobject.h: Remove trailing , from enum
2001-01-17 <alexl@redhat.com>
2001-01-17 Alexander Larsson <alexl@redhat.com>
* gdk/linux-fb/gdkdrawable-fb2.c (gdk_shadow_fb_draw_arc):
Doh! Mixed up x and y.

View File

@ -1,4 +1,49 @@
2001-01-19 <alexl@redhat.com>
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
2001-01-19 Alexander Larsson <alexl@redhat.com>
* gdk/linux-fb/gdkprivate-fb.h:
Define EMULATE_GDKFONT.
@ -67,7 +112,7 @@ Mon Jan 8 11:58:05 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkobject.h: Remove trailing , from enum
2001-01-17 <alexl@redhat.com>
2001-01-17 Alexander Larsson <alexl@redhat.com>
* gdk/linux-fb/gdkdrawable-fb2.c (gdk_shadow_fb_draw_arc):
Doh! Mixed up x and y.

View File

@ -1,4 +1,49 @@
2001-01-19 <alexl@redhat.com>
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
2001-01-19 Alexander Larsson <alexl@redhat.com>
* gdk/linux-fb/gdkprivate-fb.h:
Define EMULATE_GDKFONT.
@ -67,7 +112,7 @@ Mon Jan 8 11:58:05 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkobject.h: Remove trailing , from enum
2001-01-17 <alexl@redhat.com>
2001-01-17 Alexander Larsson <alexl@redhat.com>
* gdk/linux-fb/gdkdrawable-fb2.c (gdk_shadow_fb_draw_arc):
Doh! Mixed up x and y.

View File

@ -1,4 +1,49 @@
2001-01-19 <alexl@redhat.com>
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
2001-01-19 Alexander Larsson <alexl@redhat.com>
* gdk/linux-fb/gdkprivate-fb.h:
Define EMULATE_GDKFONT.
@ -67,7 +112,7 @@ Mon Jan 8 11:58:05 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkobject.h: Remove trailing , from enum
2001-01-17 <alexl@redhat.com>
2001-01-17 Alexander Larsson <alexl@redhat.com>
* gdk/linux-fb/gdkdrawable-fb2.c (gdk_shadow_fb_draw_arc):
Doh! Mixed up x and y.

View File

@ -1,4 +1,49 @@
2001-01-19 <alexl@redhat.com>
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
2001-01-19 Alexander Larsson <alexl@redhat.com>
* gdk/linux-fb/gdkprivate-fb.h:
Define EMULATE_GDKFONT.
@ -67,7 +112,7 @@ Mon Jan 8 11:58:05 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkobject.h: Remove trailing , from enum
2001-01-17 <alexl@redhat.com>
2001-01-17 Alexander Larsson <alexl@redhat.com>
* gdk/linux-fb/gdkdrawable-fb2.c (gdk_shadow_fb_draw_arc):
Doh! Mixed up x and y.

View File

@ -1,4 +1,49 @@
2001-01-19 <alexl@redhat.com>
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
2001-01-19 Alexander Larsson <alexl@redhat.com>
* gdk/linux-fb/gdkprivate-fb.h:
Define EMULATE_GDKFONT.
@ -67,7 +112,7 @@ Mon Jan 8 11:58:05 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkobject.h: Remove trailing , from enum
2001-01-17 <alexl@redhat.com>
2001-01-17 Alexander Larsson <alexl@redhat.com>
* gdk/linux-fb/gdkdrawable-fb2.c (gdk_shadow_fb_draw_arc):
Doh! Mixed up x and y.

View File

@ -1187,4 +1187,4 @@ modules/input/Makefile
contrib/Makefile
contrib/gdk-pixbuf-xlib/Makefile
contrib/gdk-pixbuf-xlib/gdk-pixbuf-xlib-2.0.pc
], [chmod +x gtk-config-2.0])
])

View File

@ -245,6 +245,8 @@ button_press_event_cb (GtkTreeView *tree_view,
event->x,
event->y,
&path,
NULL,
NULL,
NULL);
if (path)

View File

@ -187,9 +187,6 @@ static gboolean gtk_drag_highlight_expose (GtkWidget *widget,
GdkEventExpose *event,
gpointer data);
static GdkAtom gtk_drag_dest_find_target (GtkWidget *widget,
GtkDragDestSite *site,
GdkDragContext *context);
static void gtk_drag_selection_received (GtkWidget *widget,
GtkSelectionData *selection_data,
guint32 time,
@ -943,6 +940,58 @@ gtk_drag_dest_unset (GtkWidget *widget)
gtk_object_set_data (GTK_OBJECT (widget), "gtk-drag-dest", NULL);
}
/**
* gtk_drag_dest_get_target_list:
* @widget: a #GtkWidget
*
* Returns the list of targets this widget can accept from
* drag-and-drop.
*
* Return value: the #GtkTargetList, or %NULL if none
**/
GtkTargetList*
gtk_drag_dest_get_target_list (GtkWidget *widget)
{
GtkDragDestSite *site;
site = gtk_object_get_data (GTK_OBJECT (widget), "gtk-drag-dest");
return site ? site->target_list : 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
*
* 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_set().
**/
void
gtk_drag_dest_set_target_list (GtkWidget *widget,
GtkTargetList *target_list)
{
GtkDragDestSite *site;
site = gtk_object_get_data (GTK_OBJECT (widget), "gtk-drag-dest");
if (site == NULL)
{
g_warning ("can't set a target list on a widget until you've called gtk_drag_dest_set() to make the widget into a drag destination");
return;
}
if (target_list)
gtk_target_list_ref (site->target_list);
if (site->target_list)
gtk_target_list_unref (site->target_list);
site->target_list = target_list;
}
/*************************************************************
* gtk_drag_dest_handle_event:
* Called from widget event handling code on Drag events
@ -1042,25 +1091,35 @@ gtk_drag_dest_handle_event (GtkWidget *toplevel,
}
}
/*************************************************************
/**
* gtk_drag_dest_find_target:
* Decide on a target for the drag.
* arguments:
* site:
* context:
* results:
*************************************************************/
static GdkAtom
gtk_drag_dest_find_target (GtkWidget *widget,
GtkDragDestSite *site,
GdkDragContext *context)
* @widget: drag destination widget
* @context: drag context
* @dest_target_list: list of droppable targets
*
* Looks for a match between @context->targets and the
* @dest_target_list, returning the first matching target, otherwise
* returning %GDK_NONE. @dest_target_list should usually be the return
* value from gtk_drag_dest_get_target_list(), but some widgets may
* have different valid targets for different parts of the widget; in
* that case, they will have to implement a drag_motion handler that
* passes the correct target list to this function.
*
* Return value: first target that the source offers and the dest can accept, or %GDK_NONE
**/
GdkAtom
gtk_drag_dest_find_target (GtkWidget *widget,
GdkDragContext *context,
GtkTargetList *dest_target_list)
{
GList *tmp_target;
GList *tmp_source = NULL;
GtkWidget *source_widget = gtk_drag_get_source_widget (context);
tmp_target = site->target_list->list;
if (dest_target_list == NULL)
return GDK_NONE;
tmp_target = dest_target_list->list;
while (tmp_target)
{
GtkTargetPair *pair = tmp_target->data;
@ -1532,7 +1591,7 @@ gtk_drag_dest_motion (GtkWidget *widget,
}
}
if (action && gtk_drag_dest_find_target (widget, site, context))
if (action && gtk_drag_dest_find_target (widget, context, site->target_list))
{
if (!site->have_drag)
{
@ -1639,7 +1698,7 @@ gtk_drag_dest_drop (GtkWidget *widget,
if (site->flags & GTK_DEST_DEFAULT_DROP)
{
GdkAtom target = gtk_drag_dest_find_target (widget, site, context);
GdkAtom target = gtk_drag_dest_find_target (widget, context, site->target_list);
if (target == GDK_NONE)
return FALSE;
@ -2453,6 +2512,7 @@ gtk_drag_source_event_cb (GtkWidget *widget,
i, event);
info = gtk_drag_get_source_info (context, FALSE);
if (!info->icon_window)
{
if (site->pixmap)

View File

@ -77,12 +77,15 @@ void gtk_drag_dest_set_proxy (GtkWidget *widget,
GdkDragProtocol protocol,
gboolean use_coordinates);
/* There probably should be functions for setting the targets
* as a GtkTargetList
*/
void gtk_drag_dest_unset (GtkWidget *widget);
GdkAtom gtk_drag_dest_find_target (GtkWidget *widget,
GdkDragContext *context,
GtkTargetList *target_list);
GtkTargetList* gtk_drag_dest_get_target_list (GtkWidget *widget);
void gtk_drag_dest_set_target_list (GtkWidget *widget,
GtkTargetList *target_list);
/* Source side */
void gtk_drag_source_set (GtkWidget *widget,

View File

@ -647,14 +647,19 @@ _gtk_rbtree_node_find_offset (GtkRBTree *tree,
{
last = node;
node = node->parent;
/* Add left branch, plus children, iff we came from the right */
if (node->right == last)
retval += node->left->offset + GTK_RBNODE_GET_HEIGHT (node);
retval += node->offset - node->right->offset;
if (node == tree->nil)
{
node = tree->parent_node;
tree = tree->parent_tree;
/* Add the parent node, plus the left branch. */
if (node)
retval += node->left->offset;
retval += node->left->offset + GTK_RBNODE_GET_HEIGHT (node);
}
}
return retval;

View File

@ -57,14 +57,17 @@ struct _GtkRBNode
GtkRBNode *left;
GtkRBNode *right;
GtkRBNode *parent;
gint count; /* aggregate number of children we have */
gint offset; /* aggregate of the heights of all our children */
GtkRBTree *children;
};
struct _GtkRBNodeView
{
GtkRBNode parent;
/* count is the number of nodes beneath us, plus 1 for ourselves.
* i.e. node->left->count + node->right->count + 1
*/
gint count;
/* this is the total of sizes of
* node->left, node->right, our own height, and the height
* of all trees in ->children, iff children exists because
* the thing is expanded.
*/
gint offset;
GtkRBTree *children;
};

View File

@ -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;
}

View File

@ -69,6 +69,8 @@ struct _GtkTreeViewPrivate
GdkWindow *bin_window;
GdkWindow *header_window;
gint expander_column;
/* Selection stuff */
GtkTreePath *anchor;
GtkTreePath *cursor;
@ -82,7 +84,6 @@ struct _GtkTreeViewPrivate
/* Prelight information */
GtkRBNode *prelight_node;
GtkRBTree *prelight_tree;
gint prelight_offset;
/* Selection information */
GtkTreeSelection *selection;
@ -91,6 +92,18 @@ struct _GtkTreeViewPrivate
gint n_columns;
GList *columns;
gint header_height;
/* Scroll timeout (e.g. during dnd) */
guint scroll_timeout;
/* Row drag-and-drop */
GtkTreePath *drag_dest_row;
GtkTreeViewDropPosition drag_dest_pos;
guint open_dest_timeout;
gint pressed_button;
gint press_start_x;
gint press_start_y;
};
#ifdef __GNUC__

File diff suppressed because it is too large Load Diff

View File

@ -22,11 +22,24 @@
#include <gtk/gtkcontainer.h>
#include <gtk/gtktreemodel.h>
#include <gtk/gtktreeviewcolumn.h>
#include <gtk/gtkdnd.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
typedef enum
{
/* drop before/after this row */
GTK_TREE_VIEW_DROP_BEFORE,
GTK_TREE_VIEW_DROP_AFTER,
/* drop as a child of this row (with fallback to before or after
* if into is not possible)
*/
GTK_TREE_VIEW_DROP_INTO_OR_BEFORE,
GTK_TREE_VIEW_DROP_INTO_OR_AFTER
} GtkTreeViewDropPosition;
#define GTK_TYPE_TREE_VIEW (gtk_tree_view_get_type ())
#define GTK_TREE_VIEW(obj) (GTK_CHECK_CAST ((obj), GTK_TYPE_TREE_VIEW, GtkTreeView))
#define GTK_TREE_VIEW_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_TREE_VIEW, GtkTreeViewClass))
@ -89,8 +102,17 @@ gint gtk_tree_view_insert_column (GtkTreeView *tr
GtkTreeViewColumn *gtk_tree_view_get_column (GtkTreeView *tree_view,
gint n);
void gtk_tree_view_set_expander_column (GtkTreeView *tree_view,
gint col);
gint gtk_tree_view_get_expander_column (GtkTreeView *tree_view);
/* Actions */
void gtk_tree_view_move_to (GtkTreeView *tree_view,
void gtk_tree_view_scroll_to_point (GtkTreeView *tree_view,
gint tree_x,
gint tree_y);
void gtk_tree_view_scroll_to_cell (GtkTreeView *tree_view,
GtkTreePath *path,
GtkTreeViewColumn *column,
gfloat row_align,
@ -100,7 +122,14 @@ gboolean gtk_tree_view_get_path_at_pos (GtkTreeView *tr
gint x,
gint y,
GtkTreePath **path,
GtkTreeViewColumn **column);
GtkTreeViewColumn **column,
gint *cell_x,
gint *cell_y);
void gtk_tree_view_get_cell_rect (GtkTreeView *tree_view,
GtkTreePath *path,
GtkTreeViewColumn *column,
GdkRectangle *rect);
void gtk_tree_view_expand_all (GtkTreeView *tree_view);
void gtk_tree_view_collapse_all (GtkTreeView *tree_view);
gboolean gtk_tree_view_expand_row (GtkTreeView *tree_view,
@ -109,6 +138,77 @@ gboolean gtk_tree_view_expand_row (GtkTreeView *tr
gboolean gtk_tree_view_collapse_row (GtkTreeView *tree_view,
GtkTreePath *path);
void gtk_tree_view_get_visible_rect (GtkTreeView *tree_view,
GdkRectangle *visible_rect);
void gtk_tree_view_widget_to_tree_coords (GtkTreeView *tree_view,
gint wx,
gint wy,
gint *tx,
gint *ty);
void gtk_tree_view_tree_to_widget_coords (GtkTreeView *tree_view,
gint tx,
gint ty,
gint *wx,
gint *wy);
/* Drag-and-Drop support */
typedef gboolean (* GtkTreeViewDraggableFunc) (GtkTreeView *tree_view,
GdkDragContext *context,
GtkTreePath *path,
gpointer user_data);
/* this func can change "pos" if it likes, in addition to returning
* true/false for whether a drop is possible
*/
typedef gboolean (* GtkTreeViewDroppableFunc) (GtkTreeView *tree_view,
GdkDragContext *context,
GtkTreePath *path,
GtkTreeViewDropPosition *pos,
gpointer user_data);
void gtk_tree_view_set_rows_drag_source (GtkTreeView *tree_view,
GdkModifierType start_button_mask,
const GtkTargetEntry *targets,
gint n_targets,
GdkDragAction actions,
GtkTreeViewDraggableFunc row_draggable_func,
gpointer user_data);
void gtk_tree_view_set_rows_drag_dest (GtkTreeView *tree_view,
const GtkTargetEntry *targets,
gint n_targets,
GdkDragAction actions,
GtkTreeViewDroppableFunc location_droppable_func,
gpointer user_data);
void gtk_tree_view_unset_rows_drag_source (GtkTreeView *tree_view);
void gtk_tree_view_unset_rows_drag_dest (GtkTreeView *tree_view);
/* These are useful to implement your own custom stuff. */
void gtk_tree_view_set_drag_dest_row (GtkTreeView *tree_view,
GtkTreePath *path,
GtkTreeViewDropPosition pos);
gboolean gtk_tree_view_get_dest_row_at_pos (GtkTreeView *tree_view,
gint drag_x,
gint drag_y,
GtkTreePath **path,
GtkTreeViewDropPosition *pos);
GdkPixmap* gtk_tree_view_create_row_drag_icon (GtkTreeView *tree_view,
GtkTreePath *path);
/* The selection data would normally have target type GTK_TREE_VIEW_ROW in this
* case. If the target is wrong these functions return FALSE.
*/
gboolean gtk_selection_data_set_tree_row (GtkSelectionData *selection_data,
GtkTreeView *tree_view,
GtkTreePath *path);
gboolean gtk_selection_data_get_tree_row (GtkSelectionData *selection_data,
GtkTreeView **tree_view,
GtkTreePath **path);
#ifdef __cplusplus
}

View File

@ -914,6 +914,48 @@ gtk_tree_view_column_clicked (GtkTreeViewColumn *tree_column)
gtk_signal_emit (GTK_OBJECT (tree_column), tree_column_signals[CLICKED]);
}
static void
update_button_contents (GtkTreeViewColumn *tree_column)
{
if (tree_column->button)
{
GtkWidget *current_child = GTK_BIN (GTK_BIN (tree_column->button)->child)->child;
if (tree_column->child)
{
if (current_child != tree_column->child)
{
gtk_container_remove (GTK_CONTAINER (tree_column->button),
current_child);
gtk_container_add (GTK_CONTAINER (tree_column->button),
tree_column->child);
}
}
else
{
if (current_child == NULL)
{
current_child = gtk_label_new (NULL);
gtk_widget_show (current_child);
gtk_container_add (GTK_CONTAINER (tree_column->button),
current_child);
}
g_return_if_fail (GTK_IS_LABEL (current_child));
if (tree_column->title)
gtk_label_set_text (GTK_LABEL (current_child),
tree_column->title);
else
gtk_label_set_text (GTK_LABEL (current_child),
"");
}
}
}
/**
* gtk_tree_view_column_set_title:
* @tree_column: A #GtkTreeViewColumn.
@ -924,7 +966,7 @@ gtk_tree_view_column_clicked (GtkTreeViewColumn *tree_column)
**/
void
gtk_tree_view_column_set_title (GtkTreeViewColumn *tree_column,
gchar *title)
gchar *title)
{
g_return_if_fail (tree_column != NULL);
g_return_if_fail (GTK_IS_TREE_VIEW_COLUMN (tree_column));
@ -935,20 +977,7 @@ gtk_tree_view_column_set_title (GtkTreeViewColumn *tree_column,
else
tree_column->title = NULL;
/* Hmmm. This is a little ugly... */
if (tree_column->button)
{
if (GTK_BIN (tree_column->button)->child &&
GTK_IS_ALIGNMENT (GTK_BIN (tree_column->button)->child))
{
if (GTK_BIN (GTK_BIN (tree_column->button)->child)->child &&
GTK_IS_LABEL (GTK_BIN (GTK_BIN (tree_column->button)->child)->child))
{
gtk_label_set_text (GTK_LABEL (GTK_BIN (GTK_BIN (tree_column->button)->child)->child),
tree_column->title);
}
}
}
update_button_contents (tree_column);
g_object_notify (G_OBJECT (tree_column), "title");
}
@ -1047,45 +1076,21 @@ void
gtk_tree_view_column_set_widget (GtkTreeViewColumn *tree_column,
GtkWidget *widget)
{
/* FIXME: Implement this function. */
#if 0
gint new_button = 0;
GtkWidget *old_widget;
g_return_if_fail (GTK_IS_TREE_VIEW_COLUMN (tree_column));
g_return_if_fail (widget == NULL || GTK_IS_WIDGET (widget));
g_return_if_fail (tree_view != NULL);
g_return_if_fail (GTK_IS_TREE_VIEW (tree_view));
if (column < 0 || column >= tree_view->priv->columns)
return;
/* if the column button doesn't currently exist,
* it has to be created first */
if (!column->button)
{
column_button_create (tree_view, column);
new_button = 1;
}
column_title_new (clist, column, NULL);
/* remove and destroy the old widget */
old_widget = GTK_BIN (clist->column[column].button)->child;
if (old_widget)
gtk_container_remove (GTK_CONTAINER (clist->column[column].button),
old_widget);
/* add and show the widget */
if (widget)
{
gtk_container_add (GTK_CONTAINER (clist->column[column].button), widget);
gtk_widget_show (widget);
gtk_object_ref (GTK_OBJECT (widget));
gtk_object_sink (GTK_OBJECT (widget));
}
/* if this button didn't previously exist, then the
* column button positions have to be re-computed */
if (GTK_WIDGET_VISIBLE (clist) && new_button)
size_allocate_title_buttons (clist);
#endif
if (tree_column->child)
gtk_object_unref (GTK_OBJECT (tree_column->child));
tree_column->child = widget;
update_button_contents (tree_column);
g_object_notify (G_OBJECT (tree_column), "widget");
}
@ -1106,10 +1111,7 @@ gtk_tree_view_column_get_widget (GtkTreeViewColumn *tree_column)
g_return_val_if_fail (tree_column != NULL, NULL);
g_return_val_if_fail (GTK_IS_TREE_VIEW_COLUMN (tree_column), NULL);
if (tree_column->button)
return GTK_BUTTON (tree_column->button)->child;
return NULL;
return tree_column->child;
}
/**
@ -1134,8 +1136,6 @@ gtk_tree_view_column_set_justification (GtkTreeViewColumn *tree_column,
tree_column->justification = justification;
/* change the alignment of the button title if it's not a
* custom widget */
alignment = GTK_BIN (tree_column->button)->child;
if (GTK_IS_ALIGNMENT (alignment))
@ -1165,3 +1165,4 @@ gtk_tree_view_column_set_justification (GtkTreeViewColumn *tree_column,
g_object_notify (G_OBJECT (tree_column), "justification");
}

View File

@ -55,6 +55,7 @@ struct _GtkTreeViewColumn
GtkWidget *tree_view;
GtkWidget *button;
GtkWidget *child;
GdkWindow *window;
GtkJustification justification;

View File

@ -248,7 +248,9 @@ set_columns_type (GtkTreeView *tree_view, ColumnsType type)
{
GtkTreeViewColumn *col;
GtkCellRenderer *rend;
GdkPixbuf *pixbuf;
GtkWidget *image;
current_column_type = type;
col = gtk_tree_view_get_column (tree_view, 0);
@ -307,6 +309,16 @@ set_columns_type (GtkTreeView *tree_view, ColumnsType type)
setup_column (col);
gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), col);
pixbuf = gdk_pixbuf_new_from_xpm_data (book_closed_xpm);
image = gtk_image_new_from_pixbuf (pixbuf);
gtk_widget_show (image);
gtk_tree_view_column_set_widget (col, image);
g_object_unref (G_OBJECT (pixbuf));
g_object_unref (G_OBJECT (rend));
g_object_unref (G_OBJECT (col));
@ -333,6 +345,8 @@ set_columns_type (GtkTreeView *tree_view, ColumnsType type)
g_object_unref (G_OBJECT (rend));
g_object_unref (G_OBJECT (col));
gtk_tree_view_set_expander_column (tree_view, 1);
/* FALL THRU */
@ -527,6 +541,17 @@ columns_selected (GtkOptionMenu *om, gpointer data)
}
}
enum
{
TARGET_GTK_TREE_VIEW_ROW
};
static GtkTargetEntry row_targets[] = {
{ "GTK_TREE_VIEW_ROW", GTK_TARGET_SAME_APP,
TARGET_GTK_TREE_VIEW_ROW }
};
int
main (int argc,
char **argv)
@ -574,6 +599,19 @@ main (int argc,
gtk_container_add (GTK_CONTAINER (window), table);
tv = gtk_tree_view_new_with_model (models[0]);
gtk_tree_view_set_rows_drag_source (GTK_TREE_VIEW (tv),
GDK_BUTTON1_MASK,
row_targets,
G_N_ELEMENTS (row_targets),
GDK_ACTION_MOVE | GDK_ACTION_COPY,
NULL, NULL);
gtk_tree_view_set_rows_drag_dest (GTK_TREE_VIEW (tv),
row_targets,
G_N_ELEMENTS (row_targets),
GDK_ACTION_MOVE | GDK_ACTION_COPY,
NULL, NULL);
/* Model menu */