[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: gtk_text_insert problem



I guess you should try this:
  gtk_text_insert(GTK_TEXT(widget),
                            NULL,
                            NULL,
                            NULL,
                            HELP_TEXT,
                            strlen(HELP_TEXT));

The last parameter of the function must be the length of the string.

Jiang




Jorge JUAN CHICO wrote:

> I've almost finished my first gtk program (a very simple one which draws a
> curve in a window based in three parameters). Now I try to put Help button
> to display a help window with some information. Everything goes right
> except for the call to the gtk_text_insert function.
>
> This is the function to create the help window:
>
> GtkWidget *help_window_create(void)
> {
>   GtkWidget *window;
>   GtkWidget *widget;
>   GtkWidget *box;
>
>   window = gtk_window_new(GTK_WINDOW_DIALOG);
>   gtk_container_border_width(GTK_CONTAINER(window), 10);
>   gtk_window_set_title(GTK_WINDOW(window), HELP_WINDOW_TITLE);
>
>   box = gtk_vbox_new(FALSE, 0);
>
>   widget = gtk_label_new(VERSION);
>   gtk_box_pack_start(GTK_BOX(box), widget, FALSE, FALSE, 0);
>   gtk_widget_show(widget);
>
>   widget = gtk_hseparator_new();
>   gtk_box_pack_start(GTK_BOX(box), widget, FALSE, FALSE, 0);
>   gtk_widget_show(widget);
>
>   widget = gtk_text_new(NULL, NULL);
>   gtk_widget_set_usize(widget, 200, 200);
>   gtk_text_set_word_wrap(GTK_TEXT(widget), TRUE);
>   gtk_text_set_editable(GTK_TEXT(widget), TRUE);
>   gtk_widget_show(widget);
>
>   /* does not work and don't know why */
>   gtk_text_insert(GTK_TEXT(widget),
>                             NULL,
>                             NULL,
>                             NULL,
>                             HELP_TEXT,
>                             -1);
>
>   gtk_text_set_editable(GTK_TEXT(widget), FALSE);
>   gtk_box_pack_start(GTK_BOX(box), widget, FALSE, FALSE, 0);
>
>   widget = gtk_button_new_with_label(" Close ");
>   gtk_signal_connect_object(GTK_OBJECT(widget), "clicked",
>                             GTK_SIGNAL_FUNC(gtk_widget_hide),
>                             GTK_OBJECT(window));
>   gtk_box_pack_end(GTK_BOX(box), widget, FALSE, FALSE, 0);
>   gtk_widget_show(widget);
>
>   gtk_container_add(GTK_CONTAINER(window), box);
>   gtk_widget_show(box);
>
>   return window;
> }
>
> And the way I pop it up:
>
>   ...
>   button = gtk_button_new_with_label(" Help ");
>   gtk_signal_connect_object(GTK_OBJECT(button), "clicked",
>                             GTK_SIGNAL_FUNC(gtk_widget_show),
>                             GTK_OBJECT(help_window));
>   ...
>
> I get the following error:
>
> ** ERROR **: file gtktext.c: line 697 (gtk_text_insert):
> "GTK_WIDGET_REALIZED(text)"
> Abort
>
> on Sun Solaris using gtk 1.0 or
>
> ** ERROR **: sigsegv cought.
>
> on Linux using gtk 1.2
>
> If I ommit the call to gtk_set_text everythig goes OK and I get a blank
> text frame where I can put and delete text.
>
> What's wrong?
>
> Please help.
>
> jorge
>
> --
>          To unsubscribe: mail gtk-app-devel-list-request@redhat.com with
>                        "unsubscribe" as the Subject.
>
>         Mailing list concerns should be mailed to <listmaster@redhat.com>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]