update adjustments after validating destination yrange; fixes #53918 (This

2001-09-07  Havoc Pennington  <hp@redhat.com>

	* gtk/gtktextview.c (gtk_text_view_flush_scroll): update
	adjustments after validating destination yrange; fixes #53918
	(This may cause other issues, but I hope it won't)

2001-09-05  Havoc Pennington  <hp@redhat.com>

	* gtk/gtktextbtree.c (_gtk_text_btree_delete): when merging end
	line into start line, update the character counts in parent nodes;
	caused a bug when end and start line had different parent nodes.

2001-08-30  Havoc Pennington  <hp@redhat.com>

	* gtk/gtktexttag.c (_gtk_text_attributes_fill_from_tags): add
	assertion that tag is in a table
This commit is contained in:
Havoc Pennington 2001-09-07 21:39:18 +00:00 committed by Havoc Pennington
parent d8e3d58d42
commit f1427cd9bb
15 changed files with 249 additions and 62 deletions

View File

@ -1,3 +1,20 @@
2001-09-07 Havoc Pennington <hp@redhat.com>
* gtk/gtktextview.c (gtk_text_view_flush_scroll): update
adjustments after validating destination yrange; fixes #53918
(This may cause other issues, but I hope it won't)
2001-09-05 Havoc Pennington <hp@redhat.com>
* gtk/gtktextbtree.c (_gtk_text_btree_delete): when merging end
line into start line, update the character counts in parent nodes;
caused a bug when end and start line had different parent nodes.
2001-08-30 Havoc Pennington <hp@redhat.com>
* gtk/gtktexttag.c (_gtk_text_attributes_fill_from_tags): add
assertion that tag is in a table
Fri Sep 7 12:48:56 2001 Matthias Clasen <matthiasc@poet.de> Fri Sep 7 12:48:56 2001 Matthias Clasen <matthiasc@poet.de>
* gdk/x11/gdkkeys-x11.c (get_direction): Don't call * gdk/x11/gdkkeys-x11.c (get_direction): Don't call
@ -466,7 +483,7 @@ Tue Aug 21 12:43:29 2001 Owen Taylor <otaylor@redhat.com>
* configure.in (all_loaders): Add tga loader, * configure.in (all_loaders): Add tga loader,
patch by Nicola Girardi. (#56067) patch by Nicola Girardi. (#56067)
Tue Aug 21 02:57:13 2001 Jonathan Blandford <jrb@redhat.com>> Tue Aug 21 02:57:13 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreeview.c (gtk_tree_view_button_press): Fix up selection * gtk/gtktreeview.c (gtk_tree_view_button_press): Fix up selection
a little. More needs to be done tomorrow. a little. More needs to be done tomorrow.

View File

@ -1,3 +1,20 @@
2001-09-07 Havoc Pennington <hp@redhat.com>
* gtk/gtktextview.c (gtk_text_view_flush_scroll): update
adjustments after validating destination yrange; fixes #53918
(This may cause other issues, but I hope it won't)
2001-09-05 Havoc Pennington <hp@redhat.com>
* gtk/gtktextbtree.c (_gtk_text_btree_delete): when merging end
line into start line, update the character counts in parent nodes;
caused a bug when end and start line had different parent nodes.
2001-08-30 Havoc Pennington <hp@redhat.com>
* gtk/gtktexttag.c (_gtk_text_attributes_fill_from_tags): add
assertion that tag is in a table
Fri Sep 7 12:48:56 2001 Matthias Clasen <matthiasc@poet.de> Fri Sep 7 12:48:56 2001 Matthias Clasen <matthiasc@poet.de>
* gdk/x11/gdkkeys-x11.c (get_direction): Don't call * gdk/x11/gdkkeys-x11.c (get_direction): Don't call
@ -466,7 +483,7 @@ Tue Aug 21 12:43:29 2001 Owen Taylor <otaylor@redhat.com>
* configure.in (all_loaders): Add tga loader, * configure.in (all_loaders): Add tga loader,
patch by Nicola Girardi. (#56067) patch by Nicola Girardi. (#56067)
Tue Aug 21 02:57:13 2001 Jonathan Blandford <jrb@redhat.com>> Tue Aug 21 02:57:13 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreeview.c (gtk_tree_view_button_press): Fix up selection * gtk/gtktreeview.c (gtk_tree_view_button_press): Fix up selection
a little. More needs to be done tomorrow. a little. More needs to be done tomorrow.

View File

@ -1,3 +1,20 @@
2001-09-07 Havoc Pennington <hp@redhat.com>
* gtk/gtktextview.c (gtk_text_view_flush_scroll): update
adjustments after validating destination yrange; fixes #53918
(This may cause other issues, but I hope it won't)
2001-09-05 Havoc Pennington <hp@redhat.com>
* gtk/gtktextbtree.c (_gtk_text_btree_delete): when merging end
line into start line, update the character counts in parent nodes;
caused a bug when end and start line had different parent nodes.
2001-08-30 Havoc Pennington <hp@redhat.com>
* gtk/gtktexttag.c (_gtk_text_attributes_fill_from_tags): add
assertion that tag is in a table
Fri Sep 7 12:48:56 2001 Matthias Clasen <matthiasc@poet.de> Fri Sep 7 12:48:56 2001 Matthias Clasen <matthiasc@poet.de>
* gdk/x11/gdkkeys-x11.c (get_direction): Don't call * gdk/x11/gdkkeys-x11.c (get_direction): Don't call
@ -466,7 +483,7 @@ Tue Aug 21 12:43:29 2001 Owen Taylor <otaylor@redhat.com>
* configure.in (all_loaders): Add tga loader, * configure.in (all_loaders): Add tga loader,
patch by Nicola Girardi. (#56067) patch by Nicola Girardi. (#56067)
Tue Aug 21 02:57:13 2001 Jonathan Blandford <jrb@redhat.com>> Tue Aug 21 02:57:13 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreeview.c (gtk_tree_view_button_press): Fix up selection * gtk/gtktreeview.c (gtk_tree_view_button_press): Fix up selection
a little. More needs to be done tomorrow. a little. More needs to be done tomorrow.

View File

@ -1,3 +1,20 @@
2001-09-07 Havoc Pennington <hp@redhat.com>
* gtk/gtktextview.c (gtk_text_view_flush_scroll): update
adjustments after validating destination yrange; fixes #53918
(This may cause other issues, but I hope it won't)
2001-09-05 Havoc Pennington <hp@redhat.com>
* gtk/gtktextbtree.c (_gtk_text_btree_delete): when merging end
line into start line, update the character counts in parent nodes;
caused a bug when end and start line had different parent nodes.
2001-08-30 Havoc Pennington <hp@redhat.com>
* gtk/gtktexttag.c (_gtk_text_attributes_fill_from_tags): add
assertion that tag is in a table
Fri Sep 7 12:48:56 2001 Matthias Clasen <matthiasc@poet.de> Fri Sep 7 12:48:56 2001 Matthias Clasen <matthiasc@poet.de>
* gdk/x11/gdkkeys-x11.c (get_direction): Don't call * gdk/x11/gdkkeys-x11.c (get_direction): Don't call
@ -466,7 +483,7 @@ Tue Aug 21 12:43:29 2001 Owen Taylor <otaylor@redhat.com>
* configure.in (all_loaders): Add tga loader, * configure.in (all_loaders): Add tga loader,
patch by Nicola Girardi. (#56067) patch by Nicola Girardi. (#56067)
Tue Aug 21 02:57:13 2001 Jonathan Blandford <jrb@redhat.com>> Tue Aug 21 02:57:13 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreeview.c (gtk_tree_view_button_press): Fix up selection * gtk/gtktreeview.c (gtk_tree_view_button_press): Fix up selection
a little. More needs to be done tomorrow. a little. More needs to be done tomorrow.

View File

@ -1,3 +1,20 @@
2001-09-07 Havoc Pennington <hp@redhat.com>
* gtk/gtktextview.c (gtk_text_view_flush_scroll): update
adjustments after validating destination yrange; fixes #53918
(This may cause other issues, but I hope it won't)
2001-09-05 Havoc Pennington <hp@redhat.com>
* gtk/gtktextbtree.c (_gtk_text_btree_delete): when merging end
line into start line, update the character counts in parent nodes;
caused a bug when end and start line had different parent nodes.
2001-08-30 Havoc Pennington <hp@redhat.com>
* gtk/gtktexttag.c (_gtk_text_attributes_fill_from_tags): add
assertion that tag is in a table
Fri Sep 7 12:48:56 2001 Matthias Clasen <matthiasc@poet.de> Fri Sep 7 12:48:56 2001 Matthias Clasen <matthiasc@poet.de>
* gdk/x11/gdkkeys-x11.c (get_direction): Don't call * gdk/x11/gdkkeys-x11.c (get_direction): Don't call
@ -466,7 +483,7 @@ Tue Aug 21 12:43:29 2001 Owen Taylor <otaylor@redhat.com>
* configure.in (all_loaders): Add tga loader, * configure.in (all_loaders): Add tga loader,
patch by Nicola Girardi. (#56067) patch by Nicola Girardi. (#56067)
Tue Aug 21 02:57:13 2001 Jonathan Blandford <jrb@redhat.com>> Tue Aug 21 02:57:13 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreeview.c (gtk_tree_view_button_press): Fix up selection * gtk/gtktreeview.c (gtk_tree_view_button_press): Fix up selection
a little. More needs to be done tomorrow. a little. More needs to be done tomorrow.

View File

@ -1,3 +1,20 @@
2001-09-07 Havoc Pennington <hp@redhat.com>
* gtk/gtktextview.c (gtk_text_view_flush_scroll): update
adjustments after validating destination yrange; fixes #53918
(This may cause other issues, but I hope it won't)
2001-09-05 Havoc Pennington <hp@redhat.com>
* gtk/gtktextbtree.c (_gtk_text_btree_delete): when merging end
line into start line, update the character counts in parent nodes;
caused a bug when end and start line had different parent nodes.
2001-08-30 Havoc Pennington <hp@redhat.com>
* gtk/gtktexttag.c (_gtk_text_attributes_fill_from_tags): add
assertion that tag is in a table
Fri Sep 7 12:48:56 2001 Matthias Clasen <matthiasc@poet.de> Fri Sep 7 12:48:56 2001 Matthias Clasen <matthiasc@poet.de>
* gdk/x11/gdkkeys-x11.c (get_direction): Don't call * gdk/x11/gdkkeys-x11.c (get_direction): Don't call
@ -466,7 +483,7 @@ Tue Aug 21 12:43:29 2001 Owen Taylor <otaylor@redhat.com>
* configure.in (all_loaders): Add tga loader, * configure.in (all_loaders): Add tga loader,
patch by Nicola Girardi. (#56067) patch by Nicola Girardi. (#56067)
Tue Aug 21 02:57:13 2001 Jonathan Blandford <jrb@redhat.com>> Tue Aug 21 02:57:13 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreeview.c (gtk_tree_view_button_press): Fix up selection * gtk/gtktreeview.c (gtk_tree_view_button_press): Fix up selection
a little. More needs to be done tomorrow. a little. More needs to be done tomorrow.

View File

@ -1,3 +1,20 @@
2001-09-07 Havoc Pennington <hp@redhat.com>
* gtk/gtktextview.c (gtk_text_view_flush_scroll): update
adjustments after validating destination yrange; fixes #53918
(This may cause other issues, but I hope it won't)
2001-09-05 Havoc Pennington <hp@redhat.com>
* gtk/gtktextbtree.c (_gtk_text_btree_delete): when merging end
line into start line, update the character counts in parent nodes;
caused a bug when end and start line had different parent nodes.
2001-08-30 Havoc Pennington <hp@redhat.com>
* gtk/gtktexttag.c (_gtk_text_attributes_fill_from_tags): add
assertion that tag is in a table
Fri Sep 7 12:48:56 2001 Matthias Clasen <matthiasc@poet.de> Fri Sep 7 12:48:56 2001 Matthias Clasen <matthiasc@poet.de>
* gdk/x11/gdkkeys-x11.c (get_direction): Don't call * gdk/x11/gdkkeys-x11.c (get_direction): Don't call
@ -466,7 +483,7 @@ Tue Aug 21 12:43:29 2001 Owen Taylor <otaylor@redhat.com>
* configure.in (all_loaders): Add tga loader, * configure.in (all_loaders): Add tga loader,
patch by Nicola Girardi. (#56067) patch by Nicola Girardi. (#56067)
Tue Aug 21 02:57:13 2001 Jonathan Blandford <jrb@redhat.com>> Tue Aug 21 02:57:13 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreeview.c (gtk_tree_view_button_press): Fix up selection * gtk/gtktreeview.c (gtk_tree_view_button_press): Fix up selection
a little. More needs to be done tomorrow. a little. More needs to be done tomorrow.

View File

@ -1646,13 +1646,6 @@ arrow.
@show_toggle_indicator: unused @show_toggle_indicator: unused
@show_submenu_indicator: whether to show the arrow or not @show_submenu_indicator: whether to show the arrow or not
<!-- ##### MACRO gtk_notebook_set_page ##### -->
<para>
</para>
@notebook:
@page_num:
<!-- ##### FUNCTION gtk_object_arg_get ##### --> <!-- ##### FUNCTION gtk_object_arg_get ##### -->
<para> <para>
Private function to get an argument and argument info from an object. Private function to get an argument and argument info from an object.
@ -2370,14 +2363,6 @@ fundamental type.
@window: @window:
@Returns: @Returns:
<!-- ##### FUNCTION gtk_window_get_resizeable ##### -->
<para>
</para>
@window:
@Returns:
<!-- ##### FUNCTION gtk_window_set_decorations_hint ##### --> <!-- ##### FUNCTION gtk_window_set_decorations_hint ##### -->
<para> <para>
@ -2394,12 +2379,3 @@ fundamental type.
@window: @window:
@functions: @functions:
<!-- ##### FUNCTION gtk_window_set_resizeable ##### -->
<para>
</para>
@window:
@setting:
@resizeable:

View File

@ -96,9 +96,9 @@ Creates a new #GtkMenu.
Adds a new #GtkMenuItem to the end of the menu's item list. Adds a new #GtkMenuItem to the end of the menu's item list.
</para> </para>
<!-- # Unused Parameters # -->
@menu: a #GtkMenu. @menu: a #GtkMenu.
@child: The #GtkMenuItem to add. @child: The #GtkMenuItem to add.
<!-- # Unused Parameters # -->
@m: @m:
@c: @c:
@ -108,8 +108,8 @@ Adds a new #GtkMenuItem to the end of the menu's item list.
Adds a new #GtkMenuItem to the beginning of the menu's item list. Adds a new #GtkMenuItem to the beginning of the menu's item list.
</para> </para>
@menu_child:
<!-- # Unused Parameters # --> <!-- # Unused Parameters # -->
@menu_child:
@m: @m:
@c: @c:
@menu: a #GtkMenu. @menu: a #GtkMenu.
@ -122,10 +122,10 @@ Adds a new #GtkMenuItem to the menu's item list at the position
indicated by @position. indicated by @position.
</para> </para>
<!-- # Unused Parameters # -->
@menu: a #GtkMenu. @menu: a #GtkMenu.
@child: The #GtkMenuItem to add. @child: The #GtkMenuItem to add.
@pos: @pos:
<!-- # Unused Parameters # -->
@position: The position in the item list where @child is added. @position: The position in the item list where @child is added.
Positions are numbered from 0 to n-1. Positions are numbered from 0 to n-1.

View File

@ -132,6 +132,15 @@ Deprecated compatibility macro.
@Returns: @Returns:
<!-- ##### MACRO gtk_notebook_set_page ##### -->
<para>
</para>
<!-- # Unused Parameters # -->
@notebook:
@page_num:
<!-- ##### FUNCTION gtk_notebook_next_page ##### --> <!-- ##### FUNCTION gtk_notebook_next_page ##### -->
<para> <para>
</para> </para>

View File

@ -128,6 +128,26 @@ the child gets a larger allocation than it requests.
it's larger it's larger
<!-- ##### FUNCTION gtk_window_set_resizeable ##### -->
<para>
</para>
@window:
@setting:
<!-- # Unused Parameters # -->
@resizeable:
<!-- ##### FUNCTION gtk_window_get_resizeable ##### -->
<para>
</para>
@window:
@Returns:
<!-- ##### FUNCTION gtk_window_add_accel_group ##### --> <!-- ##### FUNCTION gtk_window_add_accel_group ##### -->
<para> <para>

View File

@ -102,7 +102,12 @@ struct _NodeData {
gint height; gint height;
gint width : 24; gint width : 24;
/* boolean indicating whether the height/width need to be recomputed */ /* boolean indicating whether the lines below this node are in need of validation.
* However, width/height should always represent the current total width and
* max height for lines below this node; the valid flag indicates whether the
* width/height on the lines needs recomputing, not whether the totals
* need recomputing.
*/
gint valid : 8; gint valid : 8;
}; };
@ -572,7 +577,10 @@ _gtk_text_btree_delete (GtkTextIter *start,
gtk_text_iter_order (start, end); gtk_text_iter_order (start, end);
tree = _gtk_text_iter_get_btree (start); tree = _gtk_text_iter_get_btree (start);
if (gtk_debug_flags & GTK_DEBUG_TEXT)
_gtk_text_btree_check (tree);
{ {
/* /*
* The code below is ugly, but it's needed to make sure there * The code below is ugly, but it's needed to make sure there
@ -611,7 +619,7 @@ _gtk_text_btree_delete (GtkTextIter *start,
} }
tags = _gtk_text_btree_get_tags (end, tags = _gtk_text_btree_get_tags (end,
&array_size); &array_size);
if (tags != NULL) if (tags != NULL)
{ {
@ -701,6 +709,9 @@ _gtk_text_btree_delete (GtkTextIter *start,
for (node = curnode; node != NULL; for (node = curnode; node != NULL;
node = node->parent) node = node->parent)
{ {
/* Don't update node->num_chars, because
* that was done when we deleted the segments.
*/
node->num_lines -= 1; node->num_lines -= 1;
} }
@ -791,21 +802,32 @@ _gtk_text_btree_delete (GtkTextIter *start,
{ {
BTreeView *view; BTreeView *view;
GtkTextBTreeNode *ancestor_node; GtkTextBTreeNode *ancestor_node;
GtkTextLine *prevline; GtkTextLine *prevline;
int chars_moved;
/* last_seg was appended to start_line up at the top of this function */
chars_moved = 0;
for (seg = last_seg; seg != NULL; for (seg = last_seg; seg != NULL;
seg = seg->next) seg = seg->next)
{ {
chars_moved += seg->char_count;
if (seg->type->lineChangeFunc != NULL) if (seg->type->lineChangeFunc != NULL)
{ {
(*seg->type->lineChangeFunc)(seg, end_line); (*seg->type->lineChangeFunc)(seg, end_line);
} }
} }
for (node = start_line->parent; node != NULL;
node = node->parent)
{
node->num_chars += chars_moved;
}
curnode = end_line->parent; curnode = end_line->parent;
for (node = curnode; node != NULL; for (node = curnode; node != NULL;
node = node->parent) node = node->parent)
{ {
node->num_chars -= chars_moved;
node->num_lines--; node->num_lines--;
} }
curnode->num_children--; curnode->num_children--;
@ -881,6 +903,9 @@ _gtk_text_btree_delete (GtkTextIter *start,
view = view->next; view = view->next;
} }
/* avoid dangling pointer */
deleted_lines = NULL;
gtk_text_btree_rebalance (tree, curnode); gtk_text_btree_rebalance (tree, curnode);
} }

View File

@ -1945,6 +1945,7 @@ _gtk_text_attributes_fill_from_tags (GtkTextAttributes *dest,
GtkTextTag *tag = tags[n]; GtkTextTag *tag = tags[n];
GtkTextAttributes *vals = tag->values; GtkTextAttributes *vals = tag->values;
g_assert (tag->table != NULL);
if (n > 0) if (n > 0)
g_assert (tags[n]->priority > tags[n-1]->priority); g_assert (tags[n]->priority > tags[n-1]->priority);

View File

@ -288,6 +288,7 @@ static void gtk_text_view_queue_scroll (GtkTextView *text_view,
gdouble yalign); gdouble yalign);
static gboolean gtk_text_view_flush_scroll (GtkTextView *text_view); static gboolean gtk_text_view_flush_scroll (GtkTextView *text_view);
static void gtk_text_view_update_adjustments (GtkTextView *text_view);
/* Container methods */ /* Container methods */
static void gtk_text_view_add (GtkContainer *container, static void gtk_text_view_add (GtkContainer *container,
@ -1233,6 +1234,8 @@ gtk_text_view_get_line_at_y (GtkTextView *text_view,
static gboolean static gboolean
set_adjustment_clamped (GtkAdjustment *adj, gdouble val) set_adjustment_clamped (GtkAdjustment *adj, gdouble val)
{ {
DV (g_print (" Setting adj to raw value %g\n", val));
/* We don't really want to clamp to upper; we want to clamp to /* We don't really want to clamp to upper; we want to clamp to
upper - page_size which is the highest value the scrollbar upper - page_size which is the highest value the scrollbar
will let us reach. */ will let us reach. */
@ -1244,6 +1247,7 @@ set_adjustment_clamped (GtkAdjustment *adj, gdouble val)
if (val != adj->value) if (val != adj->value)
{ {
DV (g_print (" Setting adj to clamped value %g\n", val));
gtk_adjustment_set_value (adj, val); gtk_adjustment_set_value (adj, val);
return TRUE; return TRUE;
} }
@ -1306,7 +1310,7 @@ gtk_text_view_scroll_to_iter (GtkTextView *text_view,
if (!GTK_WIDGET_MAPPED (widget)) if (!GTK_WIDGET_MAPPED (widget))
{ {
g_warning ("%s: calling this function before mapping the GtkTextView doesn't make sense, maybe try gtk_text_view_scroll_to_mark() instead", G_STRLOC); g_warning ("gtk_text_view_scroll_to_iter(): calling this function before showing the GtkTextView doesn't make sense, maybe try gtk_text_view_scroll_to_mark() instead");
return FALSE; return FALSE;
} }
@ -1314,6 +1318,8 @@ gtk_text_view_scroll_to_iter (GtkTextView *text_view,
iter, iter,
&rect); &rect);
DV (g_print (" target rect %d,%d %d x %d\n", rect.x, rect.y, rect.width, rect.height));
current_x_scroll = text_view->xoffset; current_x_scroll = text_view->xoffset;
current_y_scroll = text_view->yoffset; current_y_scroll = text_view->yoffset;
@ -1380,6 +1386,8 @@ gtk_text_view_scroll_to_iter (GtkTextView *text_view,
{ {
retval = set_adjustment_clamped (get_vadjustment (text_view), retval = set_adjustment_clamped (get_vadjustment (text_view),
current_y_scroll + scroll_inc); current_y_scroll + scroll_inc);
DV (g_print (" vert increment %d\n", scroll_inc));
} }
/* Horizontal scroll */ /* Horizontal scroll */
@ -1415,8 +1423,10 @@ gtk_text_view_scroll_to_iter (GtkTextView *text_view,
{ {
retval = set_adjustment_clamped (get_hadjustment (text_view), retval = set_adjustment_clamped (get_hadjustment (text_view),
current_x_scroll + scroll_inc); current_x_scroll + scroll_inc);
}
DV (g_print (" horiz increment %d\n", scroll_inc));
}
if (retval) if (retval)
DV(g_print (">Actually scrolled ("G_STRLOC")\n")); DV(g_print (">Actually scrolled ("G_STRLOC")\n"));
else else
@ -1473,9 +1483,8 @@ gtk_text_view_queue_scroll (GtkTextView *text_view,
static gboolean static gboolean
gtk_text_view_flush_scroll (GtkTextView *text_view) gtk_text_view_flush_scroll (GtkTextView *text_view)
{ {
GtkTextIter iter, start, end; GtkTextIter iter;
GtkTextPendingScroll *scroll; GtkTextPendingScroll *scroll;
gint y0, y1, height;
gboolean retval; gboolean retval;
DV(g_print(G_STRLOC"\n")); DV(g_print(G_STRLOC"\n"));
@ -1490,22 +1499,16 @@ gtk_text_view_flush_scroll (GtkTextView *text_view)
gtk_text_buffer_get_iter_at_mark (get_buffer (text_view), &iter, scroll->mark); gtk_text_buffer_get_iter_at_mark (get_buffer (text_view), &iter, scroll->mark);
start = iter; /* Validate arbitrary area around the scroll destination, so the adjustment
end = iter; * can meaningfully point into that area
/* Force-validate the region around the iterator, at least the lines
* on either side, so that we can meaningfully get the iter location
*/ */
gtk_text_iter_backward_line (&start);
gtk_text_iter_forward_line (&end);
gtk_text_layout_get_line_yrange (text_view->layout, &start, &y0, NULL);
gtk_text_layout_get_line_yrange (text_view->layout, &end, &y1, &height);
DV(g_print (">Validating scroll destination ("G_STRLOC")\n")); DV(g_print (">Validating scroll destination ("G_STRLOC")\n"));
gtk_text_layout_validate_yrange (text_view->layout, &start, y0, y1 + height); gtk_text_layout_validate_yrange (text_view->layout, &iter, -300, 300);
DV(g_print (">Done validating scroll destination ("G_STRLOC")\n")); DV(g_print (">Done validating scroll destination ("G_STRLOC")\n"));
/* Ensure we have updated width/height */
gtk_text_view_update_adjustments (text_view);
retval = gtk_text_view_scroll_to_iter (text_view, retval = gtk_text_view_scroll_to_iter (text_view,
&iter, &iter,
@ -1524,7 +1527,7 @@ gtk_text_view_set_adjustment_upper (GtkAdjustment *adj, gdouble upper)
{ {
if (upper != adj->upper) if (upper != adj->upper)
{ {
gdouble min = MAX (0., upper - adj->page_size); gdouble min = MAX (0.0, upper - adj->page_size);
gboolean value_changed = FALSE; gboolean value_changed = FALSE;
adj->upper = upper; adj->upper = upper;
@ -1540,7 +1543,7 @@ gtk_text_view_set_adjustment_upper (GtkAdjustment *adj, gdouble upper)
if (value_changed) if (value_changed)
{ {
DV(g_print(">Changed adj value because upper descreased ("G_STRLOC")\n")); DV(g_print(">Changed adj value because upper decreased ("G_STRLOC")\n"));
gtk_signal_emit_by_name (GTK_OBJECT (adj), "value_changed"); gtk_signal_emit_by_name (GTK_OBJECT (adj), "value_changed");
} }
} }
@ -3709,6 +3712,10 @@ cursor_blinks (GtkTextView *text_view)
GtkSettings *settings = gtk_widget_get_settings (GTK_WIDGET (text_view)); GtkSettings *settings = gtk_widget_get_settings (GTK_WIDGET (text_view));
gboolean blink; gboolean blink;
#ifdef DEBUG_VALIDATION_AND_SCROLLING
return FALSE;
#endif
g_object_get (G_OBJECT (settings), "gtk-cursor-blink", &blink, NULL); g_object_get (G_OBJECT (settings), "gtk-cursor-blink", &blink, NULL);
return blink; return blink;
} }
@ -3776,10 +3783,6 @@ gtk_text_view_stop_cursor_blink (GtkTextView *text_view)
static void static void
gtk_text_view_check_cursor_blink (GtkTextView *text_view) gtk_text_view_check_cursor_blink (GtkTextView *text_view)
{ {
#ifdef DEBUG_VALIDATION_AND_SCROLLING
return;
#endif
if (text_view->layout != NULL && if (text_view->layout != NULL &&
text_view->cursor_visible && text_view->cursor_visible &&
GTK_WIDGET_HAS_FOCUS (text_view)) GTK_WIDGET_HAS_FOCUS (text_view))
@ -4001,7 +4004,8 @@ gtk_text_view_scroll_pages (GtkTextView *text_view,
} }
gtk_text_layout_validate_yrange (text_view->layout, &anchor, y0, y1); gtk_text_layout_validate_yrange (text_view->layout, &anchor, y0, y1);
/* FIXME do we need to update the adjustment ranges here? */
gtk_text_view_get_virtual_cursor_pos (text_view, &cursor_x_pos, &cursor_y_pos); gtk_text_view_get_virtual_cursor_pos (text_view, &cursor_x_pos, &cursor_y_pos);
newval = adj->value; newval = adj->value;

View File

@ -191,6 +191,9 @@ msgbox_key_press_cb (GtkWidget *widget, GdkEventKey *event, gpointer data)
return FALSE; return FALSE;
} }
/* Don't copy this example, it's all crack-smoking - you can just use
* GtkMessageDialog now
*/
gint gint
msgbox_run (GtkWindow *parent, msgbox_run (GtkWindow *parent,
const char *message, const char *message,
@ -842,6 +845,35 @@ do_example (gpointer callback_data,
view_add_example_widgets (new_view); view_add_example_widgets (new_view);
} }
static void
do_insert_and_scroll (gpointer callback_data,
guint callback_action,
GtkWidget *widget)
{
View *view = view_from_widget (widget);
GtkTextBuffer *buffer;
GtkTextIter start, end;
GtkTextMark *mark;
buffer = view->buffer->buffer;
gtk_text_buffer_get_bounds (buffer, &start, &end);
mark = gtk_text_buffer_create_mark (buffer, NULL, &end, /* right grav */ FALSE);
gtk_text_iter_backward_char (&end);
gtk_text_buffer_insert (buffer, &end,
"Hello this is multiple lines of text\n"
"Line 1\n" "Line 2\n"
"Line 3\n" "Line 4\n"
"Line 5\n",
-1);
gtk_text_view_scroll_to_mark (GTK_TEXT_VIEW (view->text_view), mark,
0, TRUE, 0.0, 1.0);
gtk_text_buffer_delete_mark (buffer, mark);
}
static void static void
do_wrap_changed (gpointer callback_data, do_wrap_changed (gpointer callback_data,
guint callback_action, guint callback_action,
@ -1268,6 +1300,7 @@ static GtkItemFactoryEntry menu_items[] =
{ "/Attributes/Properties", NULL, do_properties, 0, NULL }, { "/Attributes/Properties", NULL, do_properties, 0, NULL },
{ "/_Test", NULL, 0, 0, "<Branch>" }, { "/_Test", NULL, 0, 0, "<Branch>" },
{ "/Test/_Example", NULL, do_example, 0, NULL }, { "/Test/_Example", NULL, do_example, 0, NULL },
{ "/Test/_Insert and scroll", NULL, do_insert_and_scroll, 0, NULL },
}; };
static gboolean static gboolean