From bf39d4cda92b993104e9d6447a32c94c75427f11 Mon Sep 17 00:00:00 2001 From: Owen Taylor Date: Tue, 16 Feb 1999 04:52:21 +0000 Subject: [PATCH] Use a ScrolledWindow test how Text widgets work within ScrolledWindow. Mon Feb 15 23:55:27 1999 Owen Taylor * gtk/testgtk.c (create_text): Use a ScrolledWindow test how Text widgets work within ScrolledWindow. (POLICY_AUTOMATIC drew very badly, so it uses POLICY_ALWAYS for the vscrollbar) * gtk/gtktext.c (gtk_text_unrealize): Free the cache in the unrealize handler. Some code in gtktext.c assumes that if text->line_start_cache is non-NULL, the widget is realized. We'll recompute it again anyways if we later re-realize. --- ChangeLog | 13 +++++++++++++ ChangeLog.pre-2-0 | 13 +++++++++++++ ChangeLog.pre-2-10 | 13 +++++++++++++ ChangeLog.pre-2-2 | 13 +++++++++++++ ChangeLog.pre-2-4 | 13 +++++++++++++ ChangeLog.pre-2-6 | 13 +++++++++++++ ChangeLog.pre-2-8 | 13 +++++++++++++ gtk/gtktext.c | 3 ++- gtk/testgtk.c | 28 ++++++++-------------------- tests/testgtk.c | 28 ++++++++-------------------- 10 files changed, 109 insertions(+), 41 deletions(-) diff --git a/ChangeLog b/ChangeLog index 85b03e3514..a8583bf960 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +Mon Feb 15 23:55:27 1999 Owen Taylor + + * gtk/testgtk.c (create_text): Use a ScrolledWindow + test how Text widgets work within ScrolledWindow. + (POLICY_AUTOMATIC drew very badly, so it uses + POLICY_ALWAYS for the vscrollbar) + + * gtk/gtktext.c (gtk_text_unrealize): Free the cache + in the unrealize handler. Some code in gtktext.c + assumes that if text->line_start_cache is non-NULL, + the widget is realized. We'll recompute it again + anyways if we later re-realize. + Fri Feb 12 15:47:20 1999 Owen Taylor * gtk/gtkcalender.c gtk/gtkentry.c gtk/gtkhandlebox.c diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index 85b03e3514..a8583bf960 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,16 @@ +Mon Feb 15 23:55:27 1999 Owen Taylor + + * gtk/testgtk.c (create_text): Use a ScrolledWindow + test how Text widgets work within ScrolledWindow. + (POLICY_AUTOMATIC drew very badly, so it uses + POLICY_ALWAYS for the vscrollbar) + + * gtk/gtktext.c (gtk_text_unrealize): Free the cache + in the unrealize handler. Some code in gtktext.c + assumes that if text->line_start_cache is non-NULL, + the widget is realized. We'll recompute it again + anyways if we later re-realize. + Fri Feb 12 15:47:20 1999 Owen Taylor * gtk/gtkcalender.c gtk/gtkentry.c gtk/gtkhandlebox.c diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 85b03e3514..a8583bf960 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,16 @@ +Mon Feb 15 23:55:27 1999 Owen Taylor + + * gtk/testgtk.c (create_text): Use a ScrolledWindow + test how Text widgets work within ScrolledWindow. + (POLICY_AUTOMATIC drew very badly, so it uses + POLICY_ALWAYS for the vscrollbar) + + * gtk/gtktext.c (gtk_text_unrealize): Free the cache + in the unrealize handler. Some code in gtktext.c + assumes that if text->line_start_cache is non-NULL, + the widget is realized. We'll recompute it again + anyways if we later re-realize. + Fri Feb 12 15:47:20 1999 Owen Taylor * gtk/gtkcalender.c gtk/gtkentry.c gtk/gtkhandlebox.c diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index 85b03e3514..a8583bf960 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,16 @@ +Mon Feb 15 23:55:27 1999 Owen Taylor + + * gtk/testgtk.c (create_text): Use a ScrolledWindow + test how Text widgets work within ScrolledWindow. + (POLICY_AUTOMATIC drew very badly, so it uses + POLICY_ALWAYS for the vscrollbar) + + * gtk/gtktext.c (gtk_text_unrealize): Free the cache + in the unrealize handler. Some code in gtktext.c + assumes that if text->line_start_cache is non-NULL, + the widget is realized. We'll recompute it again + anyways if we later re-realize. + Fri Feb 12 15:47:20 1999 Owen Taylor * gtk/gtkcalender.c gtk/gtkentry.c gtk/gtkhandlebox.c diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 85b03e3514..a8583bf960 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,16 @@ +Mon Feb 15 23:55:27 1999 Owen Taylor + + * gtk/testgtk.c (create_text): Use a ScrolledWindow + test how Text widgets work within ScrolledWindow. + (POLICY_AUTOMATIC drew very badly, so it uses + POLICY_ALWAYS for the vscrollbar) + + * gtk/gtktext.c (gtk_text_unrealize): Free the cache + in the unrealize handler. Some code in gtktext.c + assumes that if text->line_start_cache is non-NULL, + the widget is realized. We'll recompute it again + anyways if we later re-realize. + Fri Feb 12 15:47:20 1999 Owen Taylor * gtk/gtkcalender.c gtk/gtkentry.c gtk/gtkhandlebox.c diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 85b03e3514..a8583bf960 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,16 @@ +Mon Feb 15 23:55:27 1999 Owen Taylor + + * gtk/testgtk.c (create_text): Use a ScrolledWindow + test how Text widgets work within ScrolledWindow. + (POLICY_AUTOMATIC drew very badly, so it uses + POLICY_ALWAYS for the vscrollbar) + + * gtk/gtktext.c (gtk_text_unrealize): Free the cache + in the unrealize handler. Some code in gtktext.c + assumes that if text->line_start_cache is non-NULL, + the widget is realized. We'll recompute it again + anyways if we later re-realize. + Fri Feb 12 15:47:20 1999 Owen Taylor * gtk/gtkcalender.c gtk/gtkentry.c gtk/gtkhandlebox.c diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 85b03e3514..a8583bf960 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,16 @@ +Mon Feb 15 23:55:27 1999 Owen Taylor + + * gtk/testgtk.c (create_text): Use a ScrolledWindow + test how Text widgets work within ScrolledWindow. + (POLICY_AUTOMATIC drew very badly, so it uses + POLICY_ALWAYS for the vscrollbar) + + * gtk/gtktext.c (gtk_text_unrealize): Free the cache + in the unrealize handler. Some code in gtktext.c + assumes that if text->line_start_cache is non-NULL, + the widget is realized. We'll recompute it again + anyways if we later re-realize. + Fri Feb 12 15:47:20 1999 Owen Taylor * gtk/gtkcalender.c gtk/gtkentry.c gtk/gtkhandlebox.c diff --git a/gtk/gtktext.c b/gtk/gtktext.c index c304326c35..6e02d0b792 100644 --- a/gtk/gtktext.c +++ b/gtk/gtktext.c @@ -1225,7 +1225,6 @@ gtk_text_finalize (GtkObject *object) g_free (text->text.wc); else g_free (text->text.ch); - free_cache (text); tmp_list = text->text_properties; while (tmp_list) @@ -1470,6 +1469,8 @@ gtk_text_unrealize (GtkWidget *widget) unrealize_properties (text); + free_cache (text); + if (GTK_WIDGET_CLASS (parent_class)->unrealize) (* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget); } diff --git a/gtk/testgtk.c b/gtk/testgtk.c index 980ac75c76..14e7942705 100644 --- a/gtk/testgtk.c +++ b/gtk/testgtk.c @@ -5528,9 +5528,7 @@ create_text (void) GtkWidget *button; GtkWidget *check; GtkWidget *separator; - GtkWidget *table; - GtkWidget *hscrollbar; - GtkWidget *vscrollbar; + GtkWidget *scrolled_window; GtkWidget *text; GdkFont *font; @@ -5562,29 +5560,19 @@ create_text (void) gtk_widget_show (box2); - table = gtk_table_new (2, 2, FALSE); - gtk_table_set_row_spacing (GTK_TABLE (table), 0, 2); - gtk_table_set_col_spacing (GTK_TABLE (table), 0, 2); - gtk_box_pack_start (GTK_BOX (box2), table, TRUE, TRUE, 0); - gtk_widget_show (table); + scrolled_window = gtk_scrolled_window_new (NULL, NULL); + gtk_box_pack_start (GTK_BOX (box2), scrolled_window, TRUE, TRUE, 0); + gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), + GTK_POLICY_NEVER, + GTK_POLICY_ALWAYS); + gtk_widget_show (scrolled_window); text = gtk_text_new (NULL, NULL); gtk_text_set_editable (GTK_TEXT (text), TRUE); - gtk_table_attach (GTK_TABLE (table), text, 0, 1, 0, 1, - GTK_EXPAND | GTK_SHRINK | GTK_FILL, - GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0); + gtk_container_add (GTK_CONTAINER (scrolled_window), text); gtk_widget_grab_focus (text); gtk_widget_show (text); - hscrollbar = gtk_hscrollbar_new (GTK_TEXT (text)->hadj); - gtk_table_attach (GTK_TABLE (table), hscrollbar, 0, 1, 1, 2, - GTK_EXPAND | GTK_FILL | GTK_SHRINK, GTK_FILL, 0, 0); - gtk_widget_show (hscrollbar); - - vscrollbar = gtk_vscrollbar_new (GTK_TEXT (text)->vadj); - gtk_table_attach (GTK_TABLE (table), vscrollbar, 1, 2, 0, 1, - GTK_FILL, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0); - gtk_widget_show (vscrollbar); gtk_text_freeze (GTK_TEXT (text)); diff --git a/tests/testgtk.c b/tests/testgtk.c index 980ac75c76..14e7942705 100644 --- a/tests/testgtk.c +++ b/tests/testgtk.c @@ -5528,9 +5528,7 @@ create_text (void) GtkWidget *button; GtkWidget *check; GtkWidget *separator; - GtkWidget *table; - GtkWidget *hscrollbar; - GtkWidget *vscrollbar; + GtkWidget *scrolled_window; GtkWidget *text; GdkFont *font; @@ -5562,29 +5560,19 @@ create_text (void) gtk_widget_show (box2); - table = gtk_table_new (2, 2, FALSE); - gtk_table_set_row_spacing (GTK_TABLE (table), 0, 2); - gtk_table_set_col_spacing (GTK_TABLE (table), 0, 2); - gtk_box_pack_start (GTK_BOX (box2), table, TRUE, TRUE, 0); - gtk_widget_show (table); + scrolled_window = gtk_scrolled_window_new (NULL, NULL); + gtk_box_pack_start (GTK_BOX (box2), scrolled_window, TRUE, TRUE, 0); + gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), + GTK_POLICY_NEVER, + GTK_POLICY_ALWAYS); + gtk_widget_show (scrolled_window); text = gtk_text_new (NULL, NULL); gtk_text_set_editable (GTK_TEXT (text), TRUE); - gtk_table_attach (GTK_TABLE (table), text, 0, 1, 0, 1, - GTK_EXPAND | GTK_SHRINK | GTK_FILL, - GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0); + gtk_container_add (GTK_CONTAINER (scrolled_window), text); gtk_widget_grab_focus (text); gtk_widget_show (text); - hscrollbar = gtk_hscrollbar_new (GTK_TEXT (text)->hadj); - gtk_table_attach (GTK_TABLE (table), hscrollbar, 0, 1, 1, 2, - GTK_EXPAND | GTK_FILL | GTK_SHRINK, GTK_FILL, 0, 0); - gtk_widget_show (hscrollbar); - - vscrollbar = gtk_vscrollbar_new (GTK_TEXT (text)->vadj); - gtk_table_attach (GTK_TABLE (table), vscrollbar, 1, 2, 0, 1, - GTK_FILL, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0); - gtk_widget_show (vscrollbar); gtk_text_freeze (GTK_TEXT (text));