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

Re: gtk_main




Hello Havoc (and rest of list),

> 
> Nope, should be able to access widgets after quitting. What do you mean
> "failed"? Can you post the exact error message, and/or a small compilable
> program demonstrating the problem?
> 

Thanks very much for your assistance.
Below is a compilable example, followed by the output.
I use GTK 1.0, if that matters.

Alex.


========================== foo.c ==================================
/* gcc -Wall -g -o foo foo.c `gtk-config --cflags` `gtk-config --libs` */

#include <gtk/gtk.h
#include <stdio.h>

void
close_inputbox (GtkWidget *w, gpointer d)
{
   gtk_main_quit ();
}

void
inputbox (gchar *s)
{
   GtkWidget *win;
   GtkWidget *eb;
   gchar ss[80];

   win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
   gtk_signal_connect (GTK_OBJECT (win), "destroy", GTK_SIGNAL_FUNC (close_input box), NULL);
   gtk_widget_show (win);

   eb = gtk_entry_new_with_max_length (40);
   gtk_entry_set_text (GTK_ENTRY (eb), "hello");
   gtk_container_add (GTK_CONTAINER (win), eb);
   gtk_widget_show (eb);

   /* this works */
   strcpy (ss,  gtk_entry_get_text (GTK_ENTRY (eb)));
   printf ("%s\n", ss);

   gtk_main ();

   /* this doesn't work */
   strcpy (s,  gtk_entry_get_text (GTK_ENTRY (eb)));
}

void
main (int argc, char *argv[])
{
   gchar s[80];

   gtk_init (&argc, &argv);

   inputbox (s);
   printf ("%s\n", s);
}

========================== stdout/stderr of foo =========================
hello

** WARNING **: invalid cast from `(unknown)' to `GtkEntry'

** WARNING **: file gtkentry.c: line 381 (gtk_entry_get_text): "GTK_IS_ENTRY (entry)"

** ERROR **: sigsegv caught
=========================================================================



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