linked scrolled text inaccuraccies
- From: zentara <zentara zentara net>
- To: gtk-perl-list gnome org
- Subject: linked scrolled text inaccuraccies
- Date: Sun, 22 Jan 2006 17:37:17 -0500
Hi again,
Thanks muppet,for your good example. It works, but in the intervening
time I tried to hack a linked scrollbar, and it didn't work as described
below.
I will mention that if I use
set_default_size
instead of
set_size_request
the window expands with the widget's size. I guess I
have to think about it more.
I'm sorry to pester you with
these textview questions, but I'm finding some
weird inconsistencies. I hope someone can explain
this.
I link the 2 textviews below, with a vertical adjustment.
At the line:
my $scroll_l = Gtk2::ScrolledWindow->new(undef,$vadj);
when I link the $vadj scroll, the scrolled window WILL NOT
goto the end mark at line 500, it ends up at around line 482.
If I make it
my $scroll_l = Gtk2::ScrolledWindow->new(undef,undef);
It will go to the end mark, but of course they won't be linked.
Further examination shows that if I drag the window, so that it is the
full size of my monitor, the scrolled window does show the end line.
What's wrong? I would like to know since linking vadjustments is something
I might want to do. Or is this just something to avoid?
P.S. I modified your example to insert 500 lines, and it does not scroll to the
end mark either. Does it work for you? Is this a window manager problem?
#####################################################################
#!/usr/bin/perl
use warnings;
use strict;
use Glib qw(FALSE TRUE);
use Gtk2 -init;
#----- 1 way works-------------------------------------------
Gtk2::Rc->parse_string(<<__);
style "bg_text_blue" {
base[NORMAL] = "#0000FF"
GtkTextView::cursor-color = "white"
}
style "bg_text_black" {
base[NORMAL] = "#000000"
base[INSENSITIVE] = "#000000"
GtkTextView::cursor-color = "white"
}
widget "*my_normal*" style "bg_text_blue"
widget "*my_line*" style "bg_text_black"
__
##------------------------------------------------------
# create a window with linked scrolled text views.
my $window = Gtk2::Window->new;
$window->signal_connect (destroy => sub {Gtk2->main_quit;return FALSE});
$window->set_size_request(500,300);
my $hbox = Gtk2::HBox->new();
$hbox->set( "border_width" => 0 );
$window->add($hbox);
###-- column numbers textview ------------
my $scroll = Gtk2::ScrolledWindow->new;
my $vadj = $scroll->get_vadjustment;
###################################################
##################################################
## problem lines here (undef,undef) works, but when
## I link them, scroll to end comes up short by 18 lines
my $scroll_l = Gtk2::ScrolledWindow->new(undef,$vadj);
#my $scroll_l = Gtk2::ScrolledWindow->new(undef,undef);
######################################################
#####################################################
######################################################
$scroll_l->set_policy ('never', 'never');
my $textview_l = Gtk2::TextView->new;
$textview_l->set_name("my_line1");
$textview_l->set_cursor_visible(0);
$textview_l->set_editable(0);
$textview_l->set_sensitive(0);
my $buffer_l = $textview_l->get_buffer;
create_tags($buffer_l);
$scroll_l->add($textview_l);
$hbox->pack_start($scroll_l,0, 0, 1 ); # expand?, fill?, padding;
#####---main text view-----------------------
my $textview = Gtk2::TextView->new;
$textview->set_name("my_normal1");
$textview->set_wrap_mode('none');
$scroll->add($textview);
$hbox->pack_start($scroll,1, 1, 1 ); # expand?, fill?, padding;
my $buffer = $textview->get_buffer;
create_tags($buffer);
#insert some lines
insert_w_lines();
$window->show_all;
Gtk2->main;
##########################################################3
sub insert_w_lines{
my @lines = (1..500);
my $lcount = 0;
foreach my $line (@lines){
$lcount++;
my $lineI = sprintf "%03d\n", $lcount;
$buffer_l->insert_with_tags_by_name ($buffer_l->get_end_iter, $lineI, 'col');
$buffer->insert_with_tags_by_name($buffer->get_end_iter, " $line\n",'blue');
}
my $end_mark = $buffer->create_mark( 'end', $buffer->get_end_iter, FALSE );
$textview->scroll_to_mark( $end_mark, 0.0, FALSE, 0.0, 1.0 );
return FALSE;
}
################################################################3
sub create_tags{
my $buffer = shift;
$buffer->create_tag('blue',
foreground => 'lightblue',
);
$buffer->create_tag('col',
foreground => 'green',
);
}
#############################################################################
--
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]