Re: Text insertion problem
- From: Paolo Molaro <lupus ximian com>
- To: gtk-perl-list gnome org
- Subject: Re: Text insertion problem
- Date: Fri, 23 Feb 2001 12:41:46 +0100
On 02/21/01 Gregory S Hayes wrote:
When inserting text into a textbox I get the following error:
Gtk-CRITICAL **: file gtktext.c: line 879 (gtk_text_set_point):
assertion `index <= TEXT_LENGTH (text)' failed.
I figured it out, see below:
sub on_fileselection_ok_button_clicked {
my $filename = $fileselection->get_filename;
my $index = 0;
$textbox->freeze;
$textbox->delete_text;
open (FILE, $filename);
while (<FILE>) {
$textbox->insert_text($_, $index);
$index = $textbox->get_point();
}
$textbox->thaw;
}
When I coded Gtk::Editable::text_insert() I assumed it accepted
-1 as the index to mean end of buffer like all the other gtk_editable_*()
functions. This would be a useful DWIM fuctionality. It turn out it is a
bit inconsistent and Owen doesn't want to change it in gtk+ 1.2.x for
compatibility reasons (it will be fixed in Gtk 2.0, though).
I just fixed cvs to do the right thing anyway fro Gtk::Entry and Gtk::Text
widgets.
Also note that insert_text() returns the new position, so you can just use:
$index = $textbox->insert_text($_, $index);
instead of calling get_point() later.
lupus
--
-----------------------------------------------------------------
lupus debian org debian/rules
lupus ximian com Monkeys do it better
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]