How to use GtkText?



Hello!

I can't not figure out, how can I put a GtkText on GtkButton, the
following is my test program, which always
gives me a error message like 

    ** ERROR **: sigsegv caught 

#include <gtk/gtk.h>

int main(int argc, char *argv[])
{
  GtkWidget* window;
  GtkWidget* button;
  GtkWidget* text;
  GdkFont* font;

  gtk_init (&argc, &argv);

  font = gdk_font_load
    ("adobe-times-bold-i-normal--25-180-100-100-p-128-iso8859-1");

  text = gtk_text_new (NULL, NULL);
  gtk_widget_show (text);
  gtk_widget_realize (text);
  gtk_text_insert (GTK_TEXT (text), 0, 0, 0, "Quit", -1);
  gtk_widget_show (button);

  button = gtk_button_new ();
  gtk_container_add (GTK_CONTAINER (button), text);

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
			     GTK_SIGNAL_FUNC (gtk_widget_destroy),
			     GTK_OBJECT (window));
  gtk_container_add (GTK_CONTAINER (window), button);
  gtk_widget_show (window);

  gtk_main ();

  return 0;
}

I believe that signal is emitted from gtk_widget_realize, but I don't
know what is special by GtkText, the other Widgets don't need that
function?!

Execuse me when you think the problem is too easy.

Cheng-Chang Wu



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