From 554838e4f602d59f5be241d1da188934d51d49c3 Mon Sep 17 00:00:00 2001 From: Kristian Rietveld Date: Sat, 16 Feb 2002 23:13:37 +0000 Subject: [PATCH] This commit lands the 'dy patch'. Sun Feb 17 00:13:06 2002 Kristian Rietveld This commit lands the 'dy patch'. * gtk/gtktreeview.c (validate_rows_handler): update top_row or dy, (gtk_tree_view_top_row_to_dy): new function, (gtk_tree_view_row_changed): update top_row or dy, (gtk_tree_view_rows_reordered): update top_row --- ChangeLog | 9 +++++++ ChangeLog.pre-2-0 | 9 +++++++ ChangeLog.pre-2-10 | 9 +++++++ ChangeLog.pre-2-2 | 9 +++++++ ChangeLog.pre-2-4 | 9 +++++++ ChangeLog.pre-2-6 | 9 +++++++ ChangeLog.pre-2-8 | 9 +++++++ gtk/gtktreeview.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++ 8 files changed, 121 insertions(+) diff --git a/ChangeLog b/ChangeLog index 18a56bd53c..28d873989a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +Sun Feb 17 00:13:06 2002 Kristian Rietveld + + This commit lands the 'dy patch'. + + * gtk/gtktreeview.c (validate_rows_handler): update top_row or dy, + (gtk_tree_view_top_row_to_dy): new function, + (gtk_tree_view_row_changed): update top_row or dy, + (gtk_tree_view_rows_reordered): update top_row + 2002-02-16 Matthias Clasen * examples/extract.awk: rearrange rules to not emit the example diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index 18a56bd53c..28d873989a 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,12 @@ +Sun Feb 17 00:13:06 2002 Kristian Rietveld + + This commit lands the 'dy patch'. + + * gtk/gtktreeview.c (validate_rows_handler): update top_row or dy, + (gtk_tree_view_top_row_to_dy): new function, + (gtk_tree_view_row_changed): update top_row or dy, + (gtk_tree_view_rows_reordered): update top_row + 2002-02-16 Matthias Clasen * examples/extract.awk: rearrange rules to not emit the example diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 18a56bd53c..28d873989a 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,12 @@ +Sun Feb 17 00:13:06 2002 Kristian Rietveld + + This commit lands the 'dy patch'. + + * gtk/gtktreeview.c (validate_rows_handler): update top_row or dy, + (gtk_tree_view_top_row_to_dy): new function, + (gtk_tree_view_row_changed): update top_row or dy, + (gtk_tree_view_rows_reordered): update top_row + 2002-02-16 Matthias Clasen * examples/extract.awk: rearrange rules to not emit the example diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index 18a56bd53c..28d873989a 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,12 @@ +Sun Feb 17 00:13:06 2002 Kristian Rietveld + + This commit lands the 'dy patch'. + + * gtk/gtktreeview.c (validate_rows_handler): update top_row or dy, + (gtk_tree_view_top_row_to_dy): new function, + (gtk_tree_view_row_changed): update top_row or dy, + (gtk_tree_view_rows_reordered): update top_row + 2002-02-16 Matthias Clasen * examples/extract.awk: rearrange rules to not emit the example diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 18a56bd53c..28d873989a 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,12 @@ +Sun Feb 17 00:13:06 2002 Kristian Rietveld + + This commit lands the 'dy patch'. + + * gtk/gtktreeview.c (validate_rows_handler): update top_row or dy, + (gtk_tree_view_top_row_to_dy): new function, + (gtk_tree_view_row_changed): update top_row or dy, + (gtk_tree_view_rows_reordered): update top_row + 2002-02-16 Matthias Clasen * examples/extract.awk: rearrange rules to not emit the example diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 18a56bd53c..28d873989a 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,12 @@ +Sun Feb 17 00:13:06 2002 Kristian Rietveld + + This commit lands the 'dy patch'. + + * gtk/gtktreeview.c (validate_rows_handler): update top_row or dy, + (gtk_tree_view_top_row_to_dy): new function, + (gtk_tree_view_row_changed): update top_row or dy, + (gtk_tree_view_rows_reordered): update top_row + 2002-02-16 Matthias Clasen * examples/extract.awk: rearrange rules to not emit the example diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 18a56bd53c..28d873989a 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,12 @@ +Sun Feb 17 00:13:06 2002 Kristian Rietveld + + This commit lands the 'dy patch'. + + * gtk/gtktreeview.c (validate_rows_handler): update top_row or dy, + (gtk_tree_view_top_row_to_dy): new function, + (gtk_tree_view_row_changed): update top_row or dy, + (gtk_tree_view_rows_reordered): update top_row + 2002-02-16 Matthias Clasen * examples/extract.awk: rearrange rules to not emit the example diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c index cba2feb9f4..b77a9cd96a 100644 --- a/gtk/gtktreeview.c +++ b/gtk/gtktreeview.c @@ -264,6 +264,7 @@ static gboolean validate_rows_handler (GtkTreeView *tree_view); static gboolean presize_handler_callback (gpointer data); static void install_presize_handler (GtkTreeView *tree_view); static void gtk_tree_view_dy_to_top_row (GtkTreeView *tree_view); +static void gtk_tree_view_top_row_to_dy (GtkTreeView *tree_view); /* Internal functions */ @@ -3455,6 +3456,11 @@ validate_rows_handler (GtkTreeView *tree_view) while (i < GTK_TREE_VIEW_NUM_ROWS_PER_IDLE); done: + if (gtk_tree_row_reference_valid (tree_view->priv->top_row)) + gtk_tree_view_top_row_to_dy (tree_view); + else + gtk_tree_view_dy_to_top_row (tree_view); + if (path) gtk_tree_path_free (path); if (validated_area) gtk_widget_queue_resize (GTK_WIDGET (tree_view)); @@ -3534,6 +3540,51 @@ gtk_tree_view_dy_to_top_row (GtkTreeView *tree_view) gtk_tree_path_free (path); } +static void +gtk_tree_view_top_row_to_dy (GtkTreeView *tree_view) +{ + GtkTreePath *path; + GtkRBTree *tree; + GtkRBNode *node; + + if (tree_view->priv->top_row) + path = gtk_tree_row_reference_get_path (tree_view->priv->top_row); + else + path = NULL; + + if (!path) + tree = NULL; + else + _gtk_tree_view_find_node (tree_view, path, &tree, &node); + + if (path) + gtk_tree_path_free (path); + + if (tree == NULL) + { + /* keep dy and set new toprow */ + gtk_tree_row_reference_free (tree_view->priv->top_row); + tree_view->priv->top_row = NULL; + tree_view->priv->top_row_dy = 0; + gtk_tree_view_dy_to_top_row (tree_view); + return; + } + + if (MAX (BACKGROUND_HEIGHT (node), tree_view->priv->expander_size) + < tree_view->priv->top_row_dy) + { + /* new top row */ + gtk_tree_view_dy_to_top_row (tree_view); + return; + } + + tree_view->priv->dy = _gtk_rbtree_node_find_offset (tree, node); + tree_view->priv->dy += tree_view->priv->top_row_dy; + gtk_adjustment_set_value (tree_view->priv->vadjustment, + tree_view->priv->dy); + gtk_adjustment_changed (tree_view->priv->vadjustment); +} + void _gtk_tree_view_install_mark_rows_col_dirty (GtkTreeView *tree_view) { @@ -5222,6 +5273,11 @@ gtk_tree_view_row_deleted (GtkTreeModel *model, _gtk_rbtree_remove_node (tree, node); } + if (gtk_tree_row_reference_valid (tree_view->priv->top_row)) + gtk_tree_view_top_row_to_dy (tree_view); + else + gtk_tree_view_dy_to_top_row (tree_view); + gtk_widget_queue_resize (GTK_WIDGET (tree_view)); if (selection_changed) @@ -5272,6 +5328,8 @@ gtk_tree_view_rows_reordered (GtkTreeModel *model, _gtk_rbtree_reorder (tree, new_order, len); gtk_widget_queue_draw (GTK_WIDGET (tree_view)); + + gtk_tree_view_dy_to_top_row (tree_view); }