[gtk+] gtk-demo: Improve text scroll example



commit eed5efec24cb24bfa385070bf985679c530e5948
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon Jul 21 06:40:12 2014 -0400

    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 files changed, 10 insertions(+), 8 deletions(-)
---
diff --git a/demos/gtk-demo/textscroll.c b/demos/gtk-demo/textscroll.c
index 3eaa1f9..90ae13b 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


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]