Re: Writing to a buffer
- From: Jonathan Hayward <christos jonathan hayward gmail com>
- To: gtk-list gnome org
- Subject: Re: Writing to a buffer
- Date: Fri, 5 Aug 2005 10:05:41 -0500
It's now manifesting a different problem. I can write at the end of a
text_buffer inside a text_view, but not tell it to scroll down. The
last two calls are meant to scroll all the way down:
void new_pmsg(char* message)
{
GtkTextIter iterator;
gtk_text_buffer_insert_at_cursor(GTK_TEXT_BUFFER(pmsg_buffer), "\n",
strlen("\n"));
gtk_text_buffer_insert_at_cursor(GTK_TEXT_BUFFER(pmsg_buffer), message,
strlen(message));
gtk_text_buffer_get_end_iter(GTK_TEXT_BUFFER(pmsg_buffer), &iterator);
gtk_text_view_scroll_to_iter(GTK_TEXT_VIEW(pmsg_text_view), &iterator,
0.0f, 1, 0.0f, 1.0f);
}
Any obvious mistakes in this?
On 8/4/05, Jonathan Hayward <christos jonathan hayward gmail com> wrote:
I presently have a buffer that I create:
pmsg_buffer = GTK_WIDGET(gtk_text_buffer_new(NULL));
pmsg_text_view = gtk_text_view_new_with_buffer(GTK_TEXT_BUFFER(
pmsg_buffer));
gtk_widget_show(pmsg_text_view);
gtk_widget_show(pmsg_buffer);
and then update from a function by inserting text at the end:
GtkTextIter *iterator;
g_print("New_pmsg 1\n");
gtk_text_buffer_insert_at_cursor(GTK_TEXT_BUFFER(pmsg_buffer), "\n",
strlen("\n"));
g_print("New_pmsg 2\n");
gtk_text_buffer_insert_at_cursor(GTK_TEXT_BUFFER(pmsg_buffer), message,
strlen(message));
g_print("New_pmsg 3\n");
gtk_text_buffer_get_end_iter(GTK_TEXT_BUFFER(pmsg_buffer), iterator);
g_print("New_pmsg 4\n");
g_print("New_pmsg 5\n");
gtk_text_view_scroll_to_iter(GTK_TEXT_VIEW(pmsg_text_view), iterator,
0.0f, 1, 0.0f, 1.0f);
g_print("New_pmsg 6\n");
When I run it, the function behaves as expected the first time (the text is displayed).
On subsequent runs, it doesn't appear to display any of the new text. There are error messages:
New_pmsg 1
(gtk_tms:12510): GLib-GObject-WARNING **: invalid uninstantiatable type `GdkWindow' in cast to `GdkWindow'
(gtk_tms:12510): GLib-GObject-WARNING **: instance of invalid non-instantiatable type `GdkWindow'
(gtk_tms:12510): GLib-GObject-CRITICAL **: g_signal_emit_valist: assertion `G_TYPE_CHECK_INSTANCE (instance)' failed
New_pmsg 2
(gtk_tms:12510): GLib-GObject-WARNING **: invalid uninstantiatable type `GdkWindow' in cast to `GdkWindow'
(gtk_tms:12510): GLib-GObject-WARNING **: instance of invalid non-instantiatable type `GdkWindow'
(gtk_tms:12510): GLib-GObject-CRITICAL **: g_signal_emit_valist: assertion `G_TYPE_CHECK_INSTANCE (instance)' failed
New_pmsg 3
(gtk_tms:12510): GLib-GObject-WARNING **: invalid uninstantiatable type `GdkWindow' in cast to `GdkWindow'
New_pmsg 4
New_pmsg 5
New_pmsg 6
Is it interpreting the output of gtk_text_buffer_new() as a GdkWindow?
I don't have any other code that refers to pmsg_buffer. What should I
do next?
--
++ Jonathan Hayward, jonathan hayward pobox com
** To see an award-winning website with stories, essays, artwork,
** games, and a four-dimensional maze, why not visit my home page?
** All of this is waiting for you at http://JonathansCorner.com
** If you'd like a Google Mail (
gmail.com) account, please tell me!
--
++ Jonathan Hayward,
jonathan hayward pobox com** To see an award-winning website with stories, essays, artwork,
** games, and a four-dimensional maze, why not visit my home page?
** All of this is waiting for you at
http://JonathansCorner.com** If you'd like a Google Mail (
gmail.com) account, please tell me!
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]