summaryrefslogtreecommitdiffstats
path: root/perl-install/standalone/logdrake
diff options
context:
space:
mode:
authorThierry Vignaud <tvignaud@mandriva.org>2004-03-11 10:52:18 +0000
committerThierry Vignaud <tvignaud@mandriva.org>2004-03-11 10:52:18 +0000
commit81fe326638c5477d96afc8c32e73456f3655140c (patch)
treea5204df1e180b5ecd6368fe91b96bd8abec8f117 /perl-install/standalone/logdrake
parent11fbfb07ee9bb95d69f94e684051a413ff7a7cb3 (diff)
downloaddrakx-81fe326638c5477d96afc8c32e73456f3655140c.tar
drakx-81fe326638c5477d96afc8c32e73456f3655140c.tar.gz
drakx-81fe326638c5477d96afc8c32e73456f3655140c.tar.bz2
drakx-81fe326638c5477d96afc8c32e73456f3655140c.tar.xz
drakx-81fe326638c5477d96afc8c32e73456f3655140c.zip
(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)
Diffstat (limited to 'perl-install/standalone/logdrake')
-rwxr-xr-xperl-install/standalone/logdrake29
1 files changed, 29 insertions, 0 deletions
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);
+}
##########################################################################################