mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-25 05:01:09 +00:00
examples: Simplify counting buffer lines
We do have a gtk_text_buffer_get_line_count() function to get the line count.
This commit is contained in:
parent
88ddda6d60
commit
65b423eb05
@ -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);
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user