Re: 2 (simple?) questions



Krzysztof Magrel wrote:
> I've got Segmentation Fault :_(
> My function to change active widget looks like:
> 
> void
> przejdz (char *element, GtkWidget * mw)
> {
> // Change active widget to widget with name element
>   GtkWidget *w;
>   if ((w = lookup_widget (mw, element)) == NULL)
>     return;
>   gtk_widget_grab_focus (w);
>   return;
> }
> 
> and for example:
> 
> przejdz("entry3",main_window);
> 
> make 1 or 2 seconds without reaction (coursor doesn't) change it's
position
> (program freezes) and after this time window closes with Segmentation
Fault
> message.

Something else is broken :-( maybe you're trying to warp the focus to a 
widget that's not been built properly yet?

This works for me:

--
#include <gtk/gtk.h>

int
main (int argc, char *argv[])
{
   GtkWidget *window;
   GtkWidget *vbox;
   GtkWidget *button1;
   GtkWidget *button2;

   gtk_init (&argc, &argv);

   window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
   gtk_window_set_policy (GTK_WINDOW (window), FALSE, TRUE, FALSE);

   vbox = gtk_vbox_new (FALSE, 0);
   gtk_container_add (GTK_CONTAINER (window), vbox);

   button1 = gtk_button_new_with_label ("foo");
   gtk_box_pack_start (GTK_BOX (vbox), button1, TRUE, TRUE, 0);
   button2 = gtk_button_new_with_label ("bar");
   gtk_box_pack_start (GTK_BOX (vbox), button2, TRUE, TRUE, 0);

   gtk_signal_connect_object (GTK_OBJECT (button1), "clicked",
                              GTK_SIGNAL_FUNC (gtk_widget_grab_focus),
                              GTK_OBJECT (button2));
   gtk_signal_connect_object (GTK_OBJECT (button2), "clicked",
                              GTK_SIGNAL_FUNC (gtk_widget_grab_focus),
                              GTK_OBJECT (button1));

   gtk_widget_show_all (window);

   gtk_main ();

   return 0;
}
--

John



========================================================== 
Fabric of Vision 
Dress and Drapery in Painting 

19 June - 8 September 2002 

For information and tickets: 
http://www.nationalgallery.org.uk/exhibitions/fabric/



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