From 81fe326638c5477d96afc8c32e73456f3655140c Mon Sep 17 00:00:00 2001 From: Thierry Vignaud Date: Thu, 11 Mar 2004 10:52:18 +0000 Subject: (text_append) introduce it, forked from gtktext_insert() unlike the later, it create named tags, thus reducing tagtable size from 30000+ tags to 10-20, thus speedup logdrake in quite a big way. it should probably replace gtktext_insert in mdk10.1 since all gtktext_insert users really have quite a few tags (eg: 1 for harddrake2 and rpmdrake) --- perl-install/standalone/logdrake | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'perl-install') diff --git a/perl-install/standalone/logdrake b/perl-install/standalone/logdrake index 67eef87d2..57ef90f86 100755 --- a/perl-install/standalone/logdrake +++ b/perl-install/standalone/logdrake @@ -286,6 +286,35 @@ sub parse_file { } } +sub text_append { + my ($textview, $t, %opts) = @_; + my $buffer = $textview->get_buffer; + my %gtk_tags; + if (ref($t) eq 'ARRAY') { + foreach my $token (@$t) { + my $iter1 = $buffer->get_end_iter; + if ($token->[0] =~ /^Gtk2::Gdk::Pixbuf/) { + $buffer->insert_pixbuf($iter1, $token->[0]); + next; + } + if ($token->[1]) { + my $tag = $token->[1]; + $gtk_tags{$tag} ||= $buffer->create_tag($tag, %{$tags{$token->[1]}}); + $buffer->insert_with_tags($iter1, $token->[0], $gtk_tags{$tag}); + } else { + $buffer->insert($iter1, $token->[0]); + } + } + } else { + $buffer->set_text($t); + } + #- the following line is needed to move the cursor to the beginning, so that if the + #- textview has a scrollbar, it won't scroll to the bottom when focusing (#3633) + $buffer->place_cursor($buffer->get_start_iter); + $textview->set_wrap_mode($opts{wrap_mode} || 'word'); + $textview->set_editable($opts{editable} || 0); + $textview->set_cursor_visible($opts{visible} || 0); +} ########################################################################################## -- cgit v1.2.1