+Wed Mar 6 23:20:51 2002 Jonathan Blandford <jrb@redhat.com>
+and Kristian Rietveld <kris@gtk.org>
+
+ Finishing touch for 2.0.0 release, fixes #70782, #72729, the
+ 'stealth' bug and other last-minute minor issues.
+
+ * gtk/gtktreeview.c (gtk_tree_view_bin_expose): set dnd dest line
+ drawing right. We can't draw the line at the position of the next
+ row, because that one still has to be drawn. So draw everthing at
+ a -1 offset.
+ (validate_visible_area): add check for invalid descendants and
+ NULL scroll_to_path path, get scrolling right. Also, fix the
+ area_above value. Pretty amazing I got it wrong.
+ (get_logical_dest_row): add gtk-tree-model-drop-append magic, so
+ dragging a row to the end of the model works right.
+ (gtk_tree_view_get_dest_row_at_pos): minor floating point fix
+ (gtk_tree_view_start_editing): add call to validate_row
+ (gtk_tree_view_tree_to_widget_coords): Never subtract
+ HEADER_HEIGHT from y values anymore!!!
+ (gtk_tree_view_widget_coords_to_tree): ditto.
+ (gtk_tree_view_scroll_to_point): allow -1 as values for the
+ scroll_to coords
+ (gtk_tree_view_move_cursor_page_up_down): Don't need scroll_to_y
+ as clamp_node_visible will make it work.
+
+ * gtk/gtktreestore.c (gtk_tree_store_drag_data_received): also check
+ path depth, as we can't get iters from empty paths
+
+ * gtk/gtkliststore.c (gtk_list_store_drag_data_received): handle
+ gtk-tree-model-drop-append
+
+ * gtk/gtktreednd.c (gtk_tree_set_row_drag_data): free path_str
+
+ * tests/testtreeflow.c (main): select path where we are scrolling to
+
2002-03-06 Darin Adler <darin@bentspoon.com>
* gtk/gtktreemodelsort.c: (gtk_tree_model_sort_insert_value):
+Wed Mar 6 23:20:51 2002 Jonathan Blandford <jrb@redhat.com>
+and Kristian Rietveld <kris@gtk.org>
+
+ Finishing touch for 2.0.0 release, fixes #70782, #72729, the
+ 'stealth' bug and other last-minute minor issues.
+
+ * gtk/gtktreeview.c (gtk_tree_view_bin_expose): set dnd dest line
+ drawing right. We can't draw the line at the position of the next
+ row, because that one still has to be drawn. So draw everthing at
+ a -1 offset.
+ (validate_visible_area): add check for invalid descendants and
+ NULL scroll_to_path path, get scrolling right. Also, fix the
+ area_above value. Pretty amazing I got it wrong.
+ (get_logical_dest_row): add gtk-tree-model-drop-append magic, so
+ dragging a row to the end of the model works right.
+ (gtk_tree_view_get_dest_row_at_pos): minor floating point fix
+ (gtk_tree_view_start_editing): add call to validate_row
+ (gtk_tree_view_tree_to_widget_coords): Never subtract
+ HEADER_HEIGHT from y values anymore!!!
+ (gtk_tree_view_widget_coords_to_tree): ditto.
+ (gtk_tree_view_scroll_to_point): allow -1 as values for the
+ scroll_to coords
+ (gtk_tree_view_move_cursor_page_up_down): Don't need scroll_to_y
+ as clamp_node_visible will make it work.
+
+ * gtk/gtktreestore.c (gtk_tree_store_drag_data_received): also check
+ path depth, as we can't get iters from empty paths
+
+ * gtk/gtkliststore.c (gtk_list_store_drag_data_received): handle
+ gtk-tree-model-drop-append
+
+ * gtk/gtktreednd.c (gtk_tree_set_row_drag_data): free path_str
+
+ * tests/testtreeflow.c (main): select path where we are scrolling to
+
2002-03-06 Darin Adler <darin@bentspoon.com>
* gtk/gtktreemodelsort.c: (gtk_tree_model_sort_insert_value):
+Wed Mar 6 23:20:51 2002 Jonathan Blandford <jrb@redhat.com>
+and Kristian Rietveld <kris@gtk.org>
+
+ Finishing touch for 2.0.0 release, fixes #70782, #72729, the
+ 'stealth' bug and other last-minute minor issues.
+
+ * gtk/gtktreeview.c (gtk_tree_view_bin_expose): set dnd dest line
+ drawing right. We can't draw the line at the position of the next
+ row, because that one still has to be drawn. So draw everthing at
+ a -1 offset.
+ (validate_visible_area): add check for invalid descendants and
+ NULL scroll_to_path path, get scrolling right. Also, fix the
+ area_above value. Pretty amazing I got it wrong.
+ (get_logical_dest_row): add gtk-tree-model-drop-append magic, so
+ dragging a row to the end of the model works right.
+ (gtk_tree_view_get_dest_row_at_pos): minor floating point fix
+ (gtk_tree_view_start_editing): add call to validate_row
+ (gtk_tree_view_tree_to_widget_coords): Never subtract
+ HEADER_HEIGHT from y values anymore!!!
+ (gtk_tree_view_widget_coords_to_tree): ditto.
+ (gtk_tree_view_scroll_to_point): allow -1 as values for the
+ scroll_to coords
+ (gtk_tree_view_move_cursor_page_up_down): Don't need scroll_to_y
+ as clamp_node_visible will make it work.
+
+ * gtk/gtktreestore.c (gtk_tree_store_drag_data_received): also check
+ path depth, as we can't get iters from empty paths
+
+ * gtk/gtkliststore.c (gtk_list_store_drag_data_received): handle
+ gtk-tree-model-drop-append
+
+ * gtk/gtktreednd.c (gtk_tree_set_row_drag_data): free path_str
+
+ * tests/testtreeflow.c (main): select path where we are scrolling to
+
2002-03-06 Darin Adler <darin@bentspoon.com>
* gtk/gtktreemodelsort.c: (gtk_tree_model_sort_insert_value):
+Wed Mar 6 23:20:51 2002 Jonathan Blandford <jrb@redhat.com>
+and Kristian Rietveld <kris@gtk.org>
+
+ Finishing touch for 2.0.0 release, fixes #70782, #72729, the
+ 'stealth' bug and other last-minute minor issues.
+
+ * gtk/gtktreeview.c (gtk_tree_view_bin_expose): set dnd dest line
+ drawing right. We can't draw the line at the position of the next
+ row, because that one still has to be drawn. So draw everthing at
+ a -1 offset.
+ (validate_visible_area): add check for invalid descendants and
+ NULL scroll_to_path path, get scrolling right. Also, fix the
+ area_above value. Pretty amazing I got it wrong.
+ (get_logical_dest_row): add gtk-tree-model-drop-append magic, so
+ dragging a row to the end of the model works right.
+ (gtk_tree_view_get_dest_row_at_pos): minor floating point fix
+ (gtk_tree_view_start_editing): add call to validate_row
+ (gtk_tree_view_tree_to_widget_coords): Never subtract
+ HEADER_HEIGHT from y values anymore!!!
+ (gtk_tree_view_widget_coords_to_tree): ditto.
+ (gtk_tree_view_scroll_to_point): allow -1 as values for the
+ scroll_to coords
+ (gtk_tree_view_move_cursor_page_up_down): Don't need scroll_to_y
+ as clamp_node_visible will make it work.
+
+ * gtk/gtktreestore.c (gtk_tree_store_drag_data_received): also check
+ path depth, as we can't get iters from empty paths
+
+ * gtk/gtkliststore.c (gtk_list_store_drag_data_received): handle
+ gtk-tree-model-drop-append
+
+ * gtk/gtktreednd.c (gtk_tree_set_row_drag_data): free path_str
+
+ * tests/testtreeflow.c (main): select path where we are scrolling to
+
2002-03-06 Darin Adler <darin@bentspoon.com>
* gtk/gtktreemodelsort.c: (gtk_tree_model_sort_insert_value):
+Wed Mar 6 23:20:51 2002 Jonathan Blandford <jrb@redhat.com>
+and Kristian Rietveld <kris@gtk.org>
+
+ Finishing touch for 2.0.0 release, fixes #70782, #72729, the
+ 'stealth' bug and other last-minute minor issues.
+
+ * gtk/gtktreeview.c (gtk_tree_view_bin_expose): set dnd dest line
+ drawing right. We can't draw the line at the position of the next
+ row, because that one still has to be drawn. So draw everthing at
+ a -1 offset.
+ (validate_visible_area): add check for invalid descendants and
+ NULL scroll_to_path path, get scrolling right. Also, fix the
+ area_above value. Pretty amazing I got it wrong.
+ (get_logical_dest_row): add gtk-tree-model-drop-append magic, so
+ dragging a row to the end of the model works right.
+ (gtk_tree_view_get_dest_row_at_pos): minor floating point fix
+ (gtk_tree_view_start_editing): add call to validate_row
+ (gtk_tree_view_tree_to_widget_coords): Never subtract
+ HEADER_HEIGHT from y values anymore!!!
+ (gtk_tree_view_widget_coords_to_tree): ditto.
+ (gtk_tree_view_scroll_to_point): allow -1 as values for the
+ scroll_to coords
+ (gtk_tree_view_move_cursor_page_up_down): Don't need scroll_to_y
+ as clamp_node_visible will make it work.
+
+ * gtk/gtktreestore.c (gtk_tree_store_drag_data_received): also check
+ path depth, as we can't get iters from empty paths
+
+ * gtk/gtkliststore.c (gtk_list_store_drag_data_received): handle
+ gtk-tree-model-drop-append
+
+ * gtk/gtktreednd.c (gtk_tree_set_row_drag_data): free path_str
+
+ * tests/testtreeflow.c (main): select path where we are scrolling to
+
2002-03-06 Darin Adler <darin@bentspoon.com>
* gtk/gtktreemodelsort.c: (gtk_tree_model_sort_insert_value):
+Wed Mar 6 23:20:51 2002 Jonathan Blandford <jrb@redhat.com>
+and Kristian Rietveld <kris@gtk.org>
+
+ Finishing touch for 2.0.0 release, fixes #70782, #72729, the
+ 'stealth' bug and other last-minute minor issues.
+
+ * gtk/gtktreeview.c (gtk_tree_view_bin_expose): set dnd dest line
+ drawing right. We can't draw the line at the position of the next
+ row, because that one still has to be drawn. So draw everthing at
+ a -1 offset.
+ (validate_visible_area): add check for invalid descendants and
+ NULL scroll_to_path path, get scrolling right. Also, fix the
+ area_above value. Pretty amazing I got it wrong.
+ (get_logical_dest_row): add gtk-tree-model-drop-append magic, so
+ dragging a row to the end of the model works right.
+ (gtk_tree_view_get_dest_row_at_pos): minor floating point fix
+ (gtk_tree_view_start_editing): add call to validate_row
+ (gtk_tree_view_tree_to_widget_coords): Never subtract
+ HEADER_HEIGHT from y values anymore!!!
+ (gtk_tree_view_widget_coords_to_tree): ditto.
+ (gtk_tree_view_scroll_to_point): allow -1 as values for the
+ scroll_to coords
+ (gtk_tree_view_move_cursor_page_up_down): Don't need scroll_to_y
+ as clamp_node_visible will make it work.
+
+ * gtk/gtktreestore.c (gtk_tree_store_drag_data_received): also check
+ path depth, as we can't get iters from empty paths
+
+ * gtk/gtkliststore.c (gtk_list_store_drag_data_received): handle
+ gtk-tree-model-drop-append
+
+ * gtk/gtktreednd.c (gtk_tree_set_row_drag_data): free path_str
+
+ * tests/testtreeflow.c (main): select path where we are scrolling to
+
2002-03-06 Darin Adler <darin@bentspoon.com>
* gtk/gtktreemodelsort.c: (gtk_tree_model_sort_insert_value):
+Wed Mar 6 23:20:51 2002 Jonathan Blandford <jrb@redhat.com>
+and Kristian Rietveld <kris@gtk.org>
+
+ Finishing touch for 2.0.0 release, fixes #70782, #72729, the
+ 'stealth' bug and other last-minute minor issues.
+
+ * gtk/gtktreeview.c (gtk_tree_view_bin_expose): set dnd dest line
+ drawing right. We can't draw the line at the position of the next
+ row, because that one still has to be drawn. So draw everthing at
+ a -1 offset.
+ (validate_visible_area): add check for invalid descendants and
+ NULL scroll_to_path path, get scrolling right. Also, fix the
+ area_above value. Pretty amazing I got it wrong.
+ (get_logical_dest_row): add gtk-tree-model-drop-append magic, so
+ dragging a row to the end of the model works right.
+ (gtk_tree_view_get_dest_row_at_pos): minor floating point fix
+ (gtk_tree_view_start_editing): add call to validate_row
+ (gtk_tree_view_tree_to_widget_coords): Never subtract
+ HEADER_HEIGHT from y values anymore!!!
+ (gtk_tree_view_widget_coords_to_tree): ditto.
+ (gtk_tree_view_scroll_to_point): allow -1 as values for the
+ scroll_to coords
+ (gtk_tree_view_move_cursor_page_up_down): Don't need scroll_to_y
+ as clamp_node_visible will make it work.
+
+ * gtk/gtktreestore.c (gtk_tree_store_drag_data_received): also check
+ path depth, as we can't get iters from empty paths
+
+ * gtk/gtkliststore.c (gtk_list_store_drag_data_received): handle
+ gtk-tree-model-drop-append
+
+ * gtk/gtktreednd.c (gtk_tree_set_row_drag_data): free path_str
+
+ * tests/testtreeflow.c (main): select path where we are scrolling to
+
2002-03-06 Darin Adler <darin@bentspoon.com>
* gtk/gtktreemodelsort.c: (gtk_tree_model_sort_insert_value):
+Thu Mar 7 02:58:16 2002 Jonathan Blandford <jrb@redhat.com>
+
+ * gtk/tmpl/gtkliststore.sgml: start implementing
+
+ * gtk/question_index.sgml: "I can set with the tree, but not
+ get???!?!"
+
Wed Mar 6 18:11:05 2002 Owen Taylor <otaylor@redhat.com>
* gtk/resources.sgml: Mention the need to subscribe
</answer>
</qandaentry>
+<qandaentry>
+<question><para>
+I can set data easily on my <link
+ linkend="GtkTreeStore">GtkTreeStore</link>/<link
+ linkend="GtkListStore">GtkListStore</link> models using <link
+linkend="gtk-tree-model-get">gtk_list_store_set()</link> and <link
+linkend="gtk-tree-model-get">gtk_tree_store_set()</link>, but can't read
+ it back?
+</para></question>
+
+<answer>
+<para>
+Both the <link
+ linkend="GtkTreeStore">GtkTreeStore</link> and the <link
+ linkend="GtkListStore">GtkListStore</link> implement the
+ <link linkend="GtkTreeModel">GtkTreeModel</link>
+ interface. Consequentially, the can use any function
+ this interface implements. The easiest way to read a
+ set of data back is to use
+ <link
+linkend="gtk-tree-model-get">gtk_tree_model_get()</link>.
+</para>
+</answer>
+</qandaentry>
+
</qandadiv>
<!-- ##### SECTION Long_Description ##### -->
<para>
-
+The #GtkListStore object is a list model for use with a #GtkTreeView
+widget. It implements the #GtkTreeModel interface, and consequentialy,
+can use all of the methods available there. It also implements the
+#GtkTreeSortable interface so you can sort the list using the view.
+Finally, it also implements the tree <link linkend="gtktreednd">drag and
+drop</link> interfaces.
</para>
<!-- ##### SECTION See_Also ##### -->
prev))
{
GtkTreeIter tmp_iter = dest_iter;
- gtk_list_store_insert_after (GTK_LIST_STORE (tree_model),
- &dest_iter,
- &tmp_iter);
+
+ if (GPOINTER_TO_INT (g_object_get_data (G_OBJECT (tree_model), "gtk-tree-model-drop-append")))
+ gtk_list_store_append (GTK_LIST_STORE (tree_model), &dest_iter);
+ else
+ gtk_list_store_insert_after (GTK_LIST_STORE (tree_model),
+ &dest_iter, &tmp_iter);
+
retval = TRUE;
}
}
+ g_object_set_data (G_OBJECT (tree_model), "gtk-tree-model-drop-append",
+ NULL);
+
gtk_tree_path_free (prev);
/* If we succeeded in creating dest_iter, copy data from src
trd = g_malloc (struct_size);
strcpy (trd->path, path_str);
+
+ g_free (path_str);
trd->model = tree_model;
/* Get the parent, NULL if parent is the root */
dest_parent_p = NULL;
parent = gtk_tree_path_copy (dest);
- if (gtk_tree_path_up (parent))
+ if (gtk_tree_path_up (parent) &&
+ gtk_tree_path_get_depth (parent) > 0)
{
gtk_tree_model_get_iter (tree_model,
&dest_parent,
#define GTK_TREE_VIEW_SEARCH_DIALOG_KEY "gtk-tree-view-search-dialog"
#define GTK_TREE_VIEW_PRIORITY_VALIDATE (GDK_PRIORITY_REDRAW + 5)
-#define GTK_TREE_VIEW_NUM_ROWS_PER_IDLE 50
+#define GTK_TREE_VIEW_NUM_ROWS_PER_IDLE 500
#define SCROLL_EDGE_SIZE 15
#define EXPANDER_EXTRA_PADDING 4
switch (tree_view->priv->drag_dest_pos)
{
case GTK_TREE_VIEW_DROP_BEFORE:
- highlight_y = background_area.y - vertical_separator/2;
+ highlight_y = background_area.y - 1;
+ if (highlight_y < 0)
+ highlight_y = 0;
break;
case GTK_TREE_VIEW_DROP_AFTER:
- highlight_y = background_area.y + background_area.height + vertical_separator/2;
+ highlight_y = background_area.y + background_area.height - 1;
break;
case GTK_TREE_VIEW_DROP_INTO_OR_BEFORE:
if (tree_view->priv->tree == NULL)
return;
+ if (! GTK_RBNODE_FLAG_SET (tree_view->priv->tree->root, GTK_RBNODE_DESCENDANTS_INVALID) &&
+ tree_view->priv->scroll_to_path == NULL)
+ return;
+
total_height = GTK_WIDGET (tree_view)->allocation.height - TREE_VIEW_HEADER_HEIGHT (tree_view);
/* First, we check to see if we need to scroll anywhere
gint height = MAX (GTK_RBNODE_GET_HEIGHT (node), tree_view->priv->expander_size);
area_above = (total_height - height) *
tree_view->priv->scroll_to_row_align;
- area_below = total_height - height - area_above;
+ area_below = total_height - area_above - height;
area_above = MAX (area_above, 0);
area_below = MAX (area_below, 0);
}
else
{
+ /* FIXME: */
g_warning ("non use_align not implemented yet");
gtk_tree_path_free (path);
path = NULL;
}
gtk_tree_path_free (path);
- /* If we ran out of tree, and have extra area_below left, we need to remove it from the area_above */
+ /* If we ran out of tree, and have extra area_below left, we need to remove it
+ * from the area_above */
if (area_below > 0)
area_above += area_below;
_gtk_tree_view_find_node (tree_view, above_path, &tree, &node);
- _gtk_rbtree_prev_full (tree, node, &tree, &node);
- if (! gtk_tree_path_prev (above_path) && node != NULL)
- {
- gtk_tree_path_free (above_path);
- above_path = _gtk_tree_view_find_path (tree_view, tree, node);
- }
- while (node != NULL && area_above > 0)
+ /* We walk backwards */
+ do
{
- /* We walk ever so slowly backwards... */
+ _gtk_rbtree_prev_full (tree, node, &tree, &node);
+ if (! gtk_tree_path_prev (above_path) && node != NULL)
+ {
+ gtk_tree_path_free (above_path);
+ above_path = _gtk_tree_view_find_path (tree_view, tree, node);
+ }
gtk_tree_model_get_iter (tree_view->priv->model, &iter, above_path);
+ if (node == NULL)
+ break;
+
if (GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_INVALID) ||
GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_COLUMN_INVALID))
{
size_changed = TRUE;
}
area_above -= MAX (GTK_RBNODE_GET_HEIGHT (node), tree_view->priv->expander_size);
-
- _gtk_rbtree_prev_full (tree, node, &tree, &node);
- if (! gtk_tree_path_prev (above_path) && node)
- {
- gtk_tree_path_free (above_path);
- above_path = _gtk_tree_view_find_path (tree_view, tree, node);
- }
modify_dy = TRUE;
}
+ while (area_above > 0);
/* if we walk backwards at all, then we need to reset our dy. */
- if (modify_dy && node != NULL)
+ if (modify_dy)
{
- gtk_tree_row_reference_free (tree_view->priv->top_row);
- tree_view->priv->top_row =
- gtk_tree_row_reference_new_proxy (G_OBJECT (tree_view), tree_view->priv->model, above_path);
- tree_view->priv->top_row_dy = - area_above;
+ if (node != NULL)
+ {
+ tree_view->priv->dy = _gtk_rbtree_node_find_offset (tree, node) - area_above;
+ }
+ else
+ {
+ tree_view->priv->dy = 0;
+ }
+ gtk_adjustment_set_value (tree_view->priv->vadjustment, tree_view->priv->dy);
need_redraw = TRUE;
}
- else
- {
- /* hrm. */
- }
if (tree_view->priv->scroll_to_path)
{
}
else
{
+ GtkTreeIter iter;
+ GtkTreeModel *model = gtk_tree_view_get_model (tree_view);
+
g_assert (pos == GTK_TREE_VIEW_DROP_AFTER);
- gtk_tree_path_next (path);
+
+ gtk_tree_model_get_iter (model, &iter, path);
+
+ if (!gtk_tree_model_iter_next (model, &iter))
+ g_object_set_data (G_OBJECT (model), "gtk-tree-model-drop-append",
+ GINT_TO_POINTER (1));
+ else
+ {
+ g_object_set_data (G_OBJECT (model), "gtk-tree-model-drop-append",
+ NULL);
+ gtk_tree_path_next (path);
+ }
}
return path;
GtkRBTree *tree,
GtkRBNode *node)
{
- gint offset;
- gint real_height;
+ GdkRectangle cell_rect;
+ GdkRectangle vis_rect;
+ gint dest_y;
/* We process updates because we want to clear old selected items when we scroll.
* if this is removed, we get a "selection streak" at the bottom. */
if (GTK_WIDGET_REALIZED (tree_view))
gdk_window_process_updates (tree_view->priv->bin_window, TRUE);
+ cell_rect.y = TREE_WINDOW_Y_TO_RBTREE_Y (tree_view, BACKGROUND_FIRST_PIXEL (tree_view, tree, node));
+ cell_rect.height = BACKGROUND_HEIGHT (node);
+ gtk_tree_view_get_visible_rect (tree_view, &vis_rect);
- real_height = MAX (GTK_RBNODE_GET_HEIGHT (node), tree_view->priv->expander_size);
-
- offset = _gtk_rbtree_node_find_offset (tree, node);
+ dest_y = vis_rect.y;
- /* we reverse the order, b/c in the unusual case of the
- * node's height being taller then the visible area, we'd rather
- * have the node flush to the top
- */
- if (offset + real_height >
- tree_view->priv->vadjustment->value + tree_view->priv->vadjustment->page_size)
- gtk_adjustment_set_value (GTK_ADJUSTMENT (tree_view->priv->vadjustment),
- offset + real_height -
- tree_view->priv->vadjustment->page_size);
- if (offset < tree_view->priv->vadjustment->value)
- gtk_adjustment_set_value (GTK_ADJUSTMENT (tree_view->priv->vadjustment),
- offset);
+ if (cell_rect.y + cell_rect.height > vis_rect.y + vis_rect.height)
+ dest_y = cell_rect.y + cell_rect.height - vis_rect.height;
+ if (cell_rect.y < vis_rect.y)
+ dest_y = cell_rect.y;
+ gtk_tree_view_scroll_to_point (tree_view, -1, dest_y);
}
static void
cursor_path = _gtk_tree_view_find_path (tree_view, cursor_tree, cursor_node);
g_return_if_fail (cursor_path != NULL);
gtk_tree_view_real_set_cursor (tree_view, cursor_path, TRUE);
- gtk_tree_view_scroll_to_point (tree_view, -1, y);
gtk_tree_view_clamp_node_visible (tree_view, cursor_tree, cursor_node);
gtk_tree_path_free (cursor_path);
}
gdk_window_get_position (tree_view->priv->bin_window, &x, &y);
if (headers_visible)
{
- gdk_window_move_resize (tree_view->priv->bin_window, x + TREE_VIEW_HEADER_HEIGHT (tree_view), y, tree_view->priv->width, GTK_WIDGET (tree_view)->allocation.height - + TREE_VIEW_HEADER_HEIGHT (tree_view));
+ gdk_window_move_resize (tree_view->priv->bin_window, x, y + TREE_VIEW_HEADER_HEIGHT (tree_view), tree_view->priv->width, GTK_WIDGET (tree_view)->allocation.height - + TREE_VIEW_HEADER_HEIGHT (tree_view));
if (GTK_WIDGET_MAPPED (tree_view))
gtk_tree_view_map_buttons (tree_view);
/**
* gtk_tree_view_scroll_to_point:
* @tree_view: a #GtkTreeView
- * @tree_x: X coordinate of new top-left pixel of visible area
- * @tree_y: Y coordinate of new top-left pixel of visible area
+ * @tree_x: X coordinate of new top-left pixel of visible area, or -1
+ * @tree_y: Y coordinate of new top-left pixel of visible area, or -1
*
* Scrolls the tree view such that the top-left corner of the visible
* area is @tree_x, @tree_y, where @tree_x and @tree_y are specified
* in tree window coordinates. The @tree_view must be realized before
* this function is called. If it isn't, you probably want to be
* using gtk_tree_view_scroll_to_cell().
+ *
+ * If either @tree_x or @tree_y are -1, then that direction isn't scrolled.
**/
void
gtk_tree_view_scroll_to_point (GtkTreeView *tree_view,
hadj = tree_view->priv->hadjustment;
vadj = tree_view->priv->vadjustment;
- gtk_adjustment_set_value (hadj, CLAMP (tree_x, hadj->lower, hadj->upper - hadj->page_size));
- gtk_adjustment_set_value (vadj, CLAMP (tree_y, vadj->lower, vadj->upper - vadj->page_size));
+ if (tree_x != -1)
+ gtk_adjustment_set_value (hadj, CLAMP (tree_x, hadj->lower, hadj->upper - hadj->page_size));
+ if (tree_y != -1)
+ gtk_adjustment_set_value (vadj, CLAMP (tree_y, vadj->lower, vadj->upper - vadj->page_size));
}
/**
* tree does the minimum amount of work to scroll the cell onto the screen.
* This means that the cell will be scrolled to the edge closest to it's current
* position. If the cell is currently visible on the screen, nothing is done.
+ *
+ * This function only works if the model is set, and @path is a valid row on the
+ * model. If the model changes before the @tree_view is realized, the centered
+ * path will be modified to reflect this change.
**/
void
gtk_tree_view_scroll_to_cell (GtkTreeView *tree_view,
gfloat col_align)
{
g_return_if_fail (GTK_IS_TREE_VIEW (tree_view));
+ g_return_if_fail (tree_view->priv->model != NULL);
+ g_return_if_fail (tree_view->priv->tree != NULL);
g_return_if_fail (row_align >= 0.0 && row_align <= 1.0);
g_return_if_fail (col_align >= 0.0 && col_align <= 1.0);
g_return_if_fail (path != NULL || column != NULL);
+#if 0
+ g_print ("gtk_tree_view_scroll_to_cell:\npath: %s\ncolumn: %s\nuse_align: %d\nrow_align: %f\ncol_align: %f\n",
+ gtk_tree_path_to_string (path), column?"non-null":"null", use_align, row_align, col_align);
+#endif
row_align = CLAMP (row_align, 0.0, 1.0);
col_align = CLAMP (col_align, 0.0, 1.0);
- if (tree_view->priv->scroll_to_path)
- gtk_tree_row_reference_free (tree_view->priv->scroll_to_path);
-
- tree_view->priv->scroll_to_path = NULL;
- tree_view->priv->scroll_to_column = NULL;
- if (path)
- tree_view->priv->scroll_to_path = gtk_tree_row_reference_new_proxy (G_OBJECT (tree_view), tree_view->priv->model, path);
- if (column)
- tree_view->priv->scroll_to_column = column;
- tree_view->priv->scroll_to_use_align = use_align;
- tree_view->priv->scroll_to_row_align = row_align;
- tree_view->priv->scroll_to_col_align = col_align;
+ /* Note: Despite the benefits that come from having one code path for the
+ * scrolling code, we short-circuit validate_visible_area's immplementation as
+ * it is much slower than just going to the point.
+ */
+ if (! GTK_WIDGET_REALIZED (tree_view) ||
+ GTK_RBNODE_FLAG_SET (tree_view->priv->tree->root, GTK_RBNODE_DESCENDANTS_INVALID))
+ {
+ if (tree_view->priv->scroll_to_path)
+ gtk_tree_row_reference_free (tree_view->priv->scroll_to_path);
- install_presize_handler (tree_view);
-}
-#if 0
- gtk_tree_view_get_cell_area (tree_view, path, column, &cell_rect);
- gtk_tree_view_get_visible_rect (tree_view, &vis_rect);
+ tree_view->priv->scroll_to_path = NULL;
+ tree_view->priv->scroll_to_column = NULL;
- dest_x = vis_rect.x;
- dest_y = vis_rect.y;
+ if (path)
+ tree_view->priv->scroll_to_path = gtk_tree_row_reference_new_proxy (G_OBJECT (tree_view), tree_view->priv->model, path);
+ if (column)
+ tree_view->priv->scroll_to_column = column;
+ tree_view->priv->scroll_to_use_align = use_align;
+ tree_view->priv->scroll_to_row_align = row_align;
+ tree_view->priv->scroll_to_col_align = col_align;
- if (column)
- {
- if (use_align)
- {
- dest_x = cell_rect.x + cell_rect.width * row_align - vis_rect.width * row_align;
- }
- else
- {
- if (cell_rect.x < vis_rect.x)
- dest_x = cell_rect.x - vis_rect.width * within_margin;
- else if (cell_rect.x + cell_rect.width > vis_rect.x + vis_rect.width)
- dest_x = cell_rect.x + cell_rect.width - vis_rect.width * (1 - within_margin);
- }
+ install_presize_handler (tree_view);
}
-
- if (path)
+ else
{
- if (use_align)
+ GdkRectangle cell_rect;
+ GdkRectangle vis_rect;
+ gint dest_x, dest_y;
+
+ gtk_tree_view_get_cell_area (tree_view, path, column, &cell_rect);
+ gtk_tree_view_widget_to_tree_coords (tree_view, cell_rect.x, cell_rect.y, &(cell_rect.x), &(cell_rect.y));
+ gtk_tree_view_get_visible_rect (tree_view, &vis_rect);
+
+ dest_x = vis_rect.x;
+ dest_y = vis_rect.y;
+
+ if (column)
{
- dest_y = cell_rect.y + cell_rect.height * col_align - vis_rect.height * col_align;
+ if (use_align)
+ {
+ dest_x = cell_rect.x - ((vis_rect.width - cell_rect.width) * col_align);
+ }
+ else
+ {
+ if (cell_rect.x < vis_rect.x)
+ dest_x = cell_rect.x;
+ if (cell_rect.x + cell_rect.width > vis_rect.x + vis_rect.width)
+ dest_x = cell_rect.x + cell_rect.width - vis_rect.width;
+ }
}
- else
+
+ if (path)
{
- if (cell_rect.y < vis_rect.y)
- dest_y = cell_rect.y - vis_rect.height * within_margin;
- else if (cell_rect.y + cell_rect.height > vis_rect.y + vis_rect.height)
- dest_y = cell_rect.y + cell_rect.height - vis_rect.height * (1 - within_margin);
+ if (use_align)
+ {
+ dest_y = cell_rect.y - ((vis_rect.height - cell_rect.height) * row_align);
+ dest_y = MAX (dest_y, 0);
+ }
+ else
+ {
+ if (cell_rect.y < vis_rect.y)
+ dest_y = cell_rect.y;
+ if (cell_rect.y + cell_rect.height > vis_rect.y + vis_rect.height)
+ dest_y = cell_rect.y + cell_rect.height - vis_rect.height;
+ }
}
- }
-
- gtk_tree_view_scroll_to_point (tree_view, dest_x, dest_y);
-#endif
+ gtk_tree_view_scroll_to_point (tree_view, dest_x, dest_y);
+ }
+}
/**
* gtk_tree_view_row_activated:
if (tx)
*tx = wx + tree_view->priv->hadjustment->value;
if (ty)
- *ty = wy + tree_view->priv->dy - TREE_VIEW_HEADER_HEIGHT (tree_view);
+ *ty = wy + tree_view->priv->dy;
}
/**
if (wx)
*wx = tx - tree_view->priv->hadjustment->value;
if (wy)
- *wy = ty - tree_view->priv->dy + TREE_VIEW_HEADER_HEIGHT (tree_view);
+ *wy = ty - tree_view->priv->dy;
}
static void
{
*pos = GTK_TREE_VIEW_DROP_INTO_OR_BEFORE;
}
- else if (offset_into_row < third * 2)
+ else if (offset_into_row < third * 2.0)
{
*pos = GTK_TREE_VIEW_DROP_INTO_OR_AFTER;
}
path_string = gtk_tree_path_to_string (cursor_path);
gtk_tree_model_get_iter (tree_view->priv->model, &iter, cursor_path);
+
+ validate_row (tree_view, cursor_tree, cursor_node, &iter, cursor_path);
+
gtk_tree_view_column_cell_set_cell_data (tree_view->priv->focus_column,
tree_view->priv->model,
&iter,
tree_view = gtk_tree_view_new_with_model (model);
gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (tree_view), path, NULL, TRUE, 0.5, 0.0);
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view));
+ gtk_tree_selection_select_path (selection, path);
gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (tree_view), TRUE);
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (tree_view), FALSE);
gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree_view),