summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorMohammed Sadiq <sadiq@sadiqpk.org>2018-05-08 21:24:29 +0530
committerMohammed Sadiq <sadiq@sadiqpk.org>2018-05-09 15:28:15 +0530
commit65b423eb05ba2e31c57a7f9d029f5312719366d1 (patch)
treed27ad4cb4ec3ebf1c5079a8a0c5cb7bd5ee196aa /examples
parent88ddda6d603dc065d229361934252ae1d7515eeb (diff)
downloadgtk+-65b423eb05ba2e31c57a7f9d029f5312719366d1.tar.gz
examples: Simplify counting buffer lines
We do have a gtk_text_buffer_get_line_count() function to get the line count.
Diffstat (limited to 'examples')
-rw-r--r--examples/application10/exampleappwin.c11
-rw-r--r--examples/application9/exampleappwin.c11
2 files changed, 2 insertions, 20 deletions
diff --git a/examples/application10/exampleappwin.c b/examples/application10/exampleappwin.c
index a9311ec5a2..7b0dc46575 100644
--- a/examples/application10/exampleappwin.c
+++ b/examples/application10/exampleappwin.c
@@ -134,16 +134,7 @@ update_lines (ExampleAppWindow *win)
view = gtk_bin_get_child (GTK_BIN (tab));
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
- count = 0;
-
- gtk_text_buffer_get_start_iter (buffer, &iter);
- while (!gtk_text_iter_is_end (&iter))
- {
- count++;
- if (!gtk_text_iter_forward_line (&iter))
- break;
- }
-
+ count = gtk_text_buffer_get_line_count (buffer);
lines = g_strdup_printf ("%d", count);
gtk_label_set_text (GTK_LABEL (win->lines), lines);
g_free (lines);
diff --git a/examples/application9/exampleappwin.c b/examples/application9/exampleappwin.c
index 50ad92a4ac..6d6ae980e9 100644
--- a/examples/application9/exampleappwin.c
+++ b/examples/application9/exampleappwin.c
@@ -134,16 +134,7 @@ update_lines (ExampleAppWindow *win)
view = gtk_bin_get_child (GTK_BIN (tab));
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
- count = 0;
-
- gtk_text_buffer_get_start_iter (buffer, &iter);
- while (!gtk_text_iter_is_end (&iter))
- {
- count++;
- if (!gtk_text_iter_forward_line (&iter))
- break;
- }
-
+ count = gtk_text_buffer_get_line_count (buffer);
lines = g_strdup_printf ("%d", count);
gtk_label_set_text (GTK_LABEL (win->lines), lines);
g_free (lines);