Bug#221596: gtk_text_view_get_iter_location() always returns incorrect y value

Andrew Pam Andrew Pam <xanni@glasswings.com.au>, 221596@bugs.debian.org
Wed, 19 Nov 2003 19:54:24 +1100


Package: libgtk2.0-0
Version: 2.2.4-2

Please note:  This bug supercedes bug #220547
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=220547

gtk_text_view_get_iter_location() always returns rect.y == rect.height
rather than the correct value, as demonstrated by this test program:

----- cut here -----

// Test GTK2 get_iter_location()
// written 2003/11/13 by Andrew Pam <andrew@sericyb.com.au>
// ported from python to C++ 2003/11/19 by Andrew Pam <andrew@sericyb.com.au>
// demonstrates that textview.get_iter_location() always
// returns rect.y == rect.height rather than the correct value

#include <gtk/gtk.h>

// Define global variables
GdkRectangle rect;
gchar *text = "\
* The total area of the M-DB is about 1,000,000 square Km\n\
or approximately one-seventh (14%) of Australia\n\
\n\
* The M-DB is 1450Km long and 1000Km wide\n\
\n\
* The M-DB consists largely of plains, but rises to the\n\
Great Dividing Range on its eastern and southern rim\n\
\n\
* One of the world's major river systems\n\
";

static void quit( GtkWidget *widget, gpointer data )
{
	char string[80];

	snprintf(string, 80, "x = %d, y = %d\n", rect.x, rect.y);
	g_print (string);
	snprintf(string, 80, "w = %d, h = %d\n", rect.width, rect.height);
	g_print (string);
	gtk_main_quit ();
}

int main( int argc, char *argv[] )
{
	GtkWidget *window;
	GtkTextBuffer *textbuffer;
	GtkWidget *textview;
	GtkWidget *box;
	GtkWidget *button;
	GtkTextIter iter;

        gtk_init (&argc, &argv);
	        
	window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
	g_signal_connect (G_OBJECT (window), "destroy",
			  G_CALLBACK (quit), NULL);
	textbuffer = gtk_text_buffer_new ( NULL );
	textview = gtk_text_view_new_with_buffer ( textbuffer );
	box = gtk_vbox_new ( FALSE, 0 );
	gtk_container_add (GTK_CONTAINER (box), textview );
	button = gtk_button_new_with_label ("Quit");
	g_signal_connect (G_OBJECT (button), "clicked",
		          G_CALLBACK (quit), NULL);
	gtk_container_add (GTK_CONTAINER (box), button);
	gtk_container_add (GTK_CONTAINER (window), box);
	gtk_widget_show_all (window);
	gtk_text_buffer_set_text ( textbuffer, text, strlen(text) );
	gtk_text_buffer_get_end_iter( textbuffer, &iter );
	// Move the cursor to the letter "s" in the last word "systems"
	gtk_text_iter_backward_word_start ( &iter );
	gtk_text_view_get_iter_location (GTK_TEXT_VIEW (textview),
					 &iter, &rect );
		        
	gtk_main ();
	return 0;
}

----- cut here -----

I am using Debian GNU/Linux Sarge, kernel 2.4.22 and libc6 2.3.2.ds1-10.
libgtk2.0-0 is version 2.2.4-2.

Regards,
	Andrew Pam
-- 
mailto:xanni@xanadu.net                         Andrew Pam
http://www.xanadu.com.au/                       Chief Scientist, Xanadu
http://www.glasswings.com.au/                   Technology Manager, Glass Wings
http://www.sericyb.com.au/                      Manager, Serious Cybernetics