From eed5efec24cb24bfa385070bf985679c530e5948 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Mon, 21 Jul 2014 06:40:12 -0400 Subject: [PATCH] gtk-demo: Improve text scroll example Add numbers, so the lines can be differentiated, even if they don't move on screen. --- demos/gtk-demo/textscroll.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/demos/gtk-demo/textscroll.c b/demos/gtk-demo/textscroll.c index 3eaa1f99d0..90ae13b5ee 100644 --- a/demos/gtk-demo/textscroll.c +++ b/demos/gtk-demo/textscroll.c @@ -16,6 +16,7 @@ scroll_to_end (GtkTextView *textview) GtkTextIter iter; GtkTextMark *mark; char *spaces; + char *text; static int count; buffer = gtk_text_view_get_buffer (textview); @@ -32,11 +33,11 @@ scroll_to_end (GtkTextView *textview) spaces = g_strnfill (count++, ' '); gtk_text_buffer_insert (buffer, &iter, "\n", -1); gtk_text_buffer_insert (buffer, &iter, spaces, -1); - gtk_text_buffer_insert (buffer, &iter, - "Scroll to end scroll to end scroll " - "to end scroll to end ", - -1); + text = g_strdup_printf ("Scroll to end scroll to end scroll " + "to end scroll to end %d", count); + gtk_text_buffer_insert (buffer, &iter, text, -1); g_free (spaces); + g_free (text); /* Now scroll the end mark onscreen. */ @@ -60,6 +61,7 @@ scroll_to_bottom (GtkTextView *textview) GtkTextIter iter; GtkTextMark *mark; char *spaces; + char *text; static int count; buffer = gtk_text_view_get_buffer (textview); @@ -73,11 +75,11 @@ scroll_to_bottom (GtkTextView *textview) spaces = g_strnfill (count++, ' '); gtk_text_buffer_insert (buffer, &iter, "\n", -1); gtk_text_buffer_insert (buffer, &iter, spaces, -1); - gtk_text_buffer_insert (buffer, &iter, - "Scroll to bottom scroll to bottom scroll " - "to bottom scroll to bottom", - -1); + text = g_strdup_printf ("Scroll to bottom scroll to bottom scroll " + "to bottom scroll to bottom %d", count); + gtk_text_buffer_insert (buffer, &iter, text, -1); g_free (spaces); + g_free (text); /* Move the iterator to the beginning of line, so we don't scroll * in horizontal direction