From f9debe2f690e165944810058569503a6b207f903 Mon Sep 17 00:00:00 2001 From: Havoc Pennington Date: Mon, 25 Feb 2002 04:55:56 +0000 Subject: [PATCH] add dx/dy to child allocation, don't subtract them. Also, copy code from 2002-02-24 Havoc Pennington * gtk/gtktextview.c (gtk_text_view_value_changed): add dx/dy to child allocation, don't subtract them. Also, copy code from CList to recursively adjust the child allocation, instead of just adjusting immediate children. #69115 --- ChangeLog | 7 ++++ ChangeLog.pre-2-0 | 7 ++++ ChangeLog.pre-2-10 | 7 ++++ ChangeLog.pre-2-2 | 7 ++++ ChangeLog.pre-2-4 | 7 ++++ ChangeLog.pre-2-6 | 7 ++++ ChangeLog.pre-2-8 | 7 ++++ gtk/gtktextview.c | 83 ++++++++++++++++++++++++++++++++++++++++------ 8 files changed, 121 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9ab9b6c5f..0b7f35b4a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2002-02-24 Havoc Pennington + + * gtk/gtktextview.c (gtk_text_view_value_changed): add dx/dy to + child allocation, don't subtract them. Also, copy code from CList + to recursively adjust the child allocation, instead of just + adjusting immediate children. #69115 + 2002-02-24 Havoc Pennington * gtk/gtkstyle.c (_gtk_draw_insertion_cursor): change to pass in diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index 9ab9b6c5f..0b7f35b4a 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,10 @@ +2002-02-24 Havoc Pennington + + * gtk/gtktextview.c (gtk_text_view_value_changed): add dx/dy to + child allocation, don't subtract them. Also, copy code from CList + to recursively adjust the child allocation, instead of just + adjusting immediate children. #69115 + 2002-02-24 Havoc Pennington * gtk/gtkstyle.c (_gtk_draw_insertion_cursor): change to pass in diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 9ab9b6c5f..0b7f35b4a 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,10 @@ +2002-02-24 Havoc Pennington + + * gtk/gtktextview.c (gtk_text_view_value_changed): add dx/dy to + child allocation, don't subtract them. Also, copy code from CList + to recursively adjust the child allocation, instead of just + adjusting immediate children. #69115 + 2002-02-24 Havoc Pennington * gtk/gtkstyle.c (_gtk_draw_insertion_cursor): change to pass in diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index 9ab9b6c5f..0b7f35b4a 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,10 @@ +2002-02-24 Havoc Pennington + + * gtk/gtktextview.c (gtk_text_view_value_changed): add dx/dy to + child allocation, don't subtract them. Also, copy code from CList + to recursively adjust the child allocation, instead of just + adjusting immediate children. #69115 + 2002-02-24 Havoc Pennington * gtk/gtkstyle.c (_gtk_draw_insertion_cursor): change to pass in diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 9ab9b6c5f..0b7f35b4a 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,10 @@ +2002-02-24 Havoc Pennington + + * gtk/gtktextview.c (gtk_text_view_value_changed): add dx/dy to + child allocation, don't subtract them. Also, copy code from CList + to recursively adjust the child allocation, instead of just + adjusting immediate children. #69115 + 2002-02-24 Havoc Pennington * gtk/gtkstyle.c (_gtk_draw_insertion_cursor): change to pass in diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 9ab9b6c5f..0b7f35b4a 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,10 @@ +2002-02-24 Havoc Pennington + + * gtk/gtktextview.c (gtk_text_view_value_changed): add dx/dy to + child allocation, don't subtract them. Also, copy code from CList + to recursively adjust the child allocation, instead of just + adjusting immediate children. #69115 + 2002-02-24 Havoc Pennington * gtk/gtkstyle.c (_gtk_draw_insertion_cursor): change to pass in diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 9ab9b6c5f..0b7f35b4a 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,10 @@ +2002-02-24 Havoc Pennington + + * gtk/gtktextview.c (gtk_text_view_value_changed): add dx/dy to + child allocation, don't subtract them. Also, copy code from CList + to recursively adjust the child allocation, instead of just + adjusting immediate children. #69115 + 2002-02-24 Havoc Pennington * gtk/gtkstyle.c (_gtk_draw_insertion_cursor): change to pass in diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c index 1b5faf23b..fc50cd847 100644 --- a/gtk/gtktextview.c +++ b/gtk/gtktextview.c @@ -5782,6 +5782,77 @@ gtk_text_view_set_scroll_adjustments (GtkTextView *text_view, gtk_text_view_value_changed (NULL, text_view); } +/* FIXME this adjust_allocation is a big cut-and-paste from + * GtkCList, needs to be some "official" way to do this + * factored out. + */ +typedef struct +{ + GdkWindow *window; + int dx; + int dy; +} ScrollData; + +/* The window to which widget->window is relative */ +#define ALLOCATION_WINDOW(widget) \ + (GTK_WIDGET_NO_WINDOW (widget) ? \ + (widget)->window : \ + gdk_window_get_parent ((widget)->window)) + +static void +adjust_allocation_recurse (GtkWidget *widget, + gpointer data) +{ + ScrollData *scroll_data = data; + + /* Need to really size allocate instead of just poking + * into widget->allocation if the widget is not realized. + * FIXME someone figure out why this was. + */ + if (!GTK_WIDGET_REALIZED (widget)) + { + if (GTK_WIDGET_VISIBLE (widget)) + { + GdkRectangle tmp_rectangle = widget->allocation; + tmp_rectangle.x += scroll_data->dx; + tmp_rectangle.y += scroll_data->dy; + + gtk_widget_size_allocate (widget, &tmp_rectangle); + } + } + else + { + if (ALLOCATION_WINDOW (widget) == scroll_data->window) + { + widget->allocation.x += scroll_data->dx; + widget->allocation.y += scroll_data->dy; + + if (GTK_IS_CONTAINER (widget)) + gtk_container_forall (GTK_CONTAINER (widget), + adjust_allocation_recurse, + data); + } + } +} + +static void +adjust_allocation (GtkWidget *widget, + int dx, + int dy) +{ + ScrollData scroll_data; + + if (GTK_WIDGET_REALIZED (widget)) + scroll_data.window = ALLOCATION_WINDOW (widget); + else + scroll_data.window = NULL; + + scroll_data.dx = dx; + scroll_data.dy = dy; + + adjust_allocation_recurse (widget, &scroll_data); +} + static void gtk_text_view_value_changed (GtkAdjustment *adj, GtkTextView *text_view) @@ -5860,17 +5931,7 @@ gtk_text_view_value_changed (GtkAdjustment *adj, GtkTextViewChild *child = tmp_list->data; if (child->anchor) - { - child->widget->allocation.x -= dx; - child->widget->allocation.y -= dy; - -#if 0 - g_print ("allocation for %p tweaked to %d,%d\n", - child->widget, - child->widget->allocation.x, - child->widget->allocation.y); -#endif - } + adjust_allocation (child->widget, dx, dy); tmp_list = g_slist_next (tmp_list); }