Re: this is strange



and still the button stays dead?  If so, then are you sure that the function header of your callback function is correct (the correct arguments and the correct return value). If you remove the callback then does the problem stay? Did you look at the examples in the gtk-tutorial like the on printed below ?



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

/* Create a new hbox with an image and a label packed into it
 * and return the box. */

GtkWidget *xpm_label_box( gchar     *xpm_filename,
                          gchar     *label_text )
{
    GtkWidget *box;
    GtkWidget *label;
    GtkWidget *image;

    /* Create box for image and label */
    box = gtk_hbox_new (FALSE, 0);
    gtk_container_set_border_width (GTK_CONTAINER (box), 2);

    /* Now on to the image stuff */
    image = gtk_image_new_from_file (xpm_filename);

    /* Create a label for the button */
    label = gtk_label_new (label_text);

    /* Pack the image and label into the box */
    gtk_box_pack_start (GTK_BOX (box), image, FALSE, FALSE, 3);
    gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 3);

    gtk_widget_show (image);
    gtk_widget_show (label);

    return box;
}

/* Our usual callback function */
void callback( GtkWidget *widget,
               gpointer   data )
{
    g_print ("Hello again - %s was pressed\n", (char *) data);
}

int main( int   argc,
          char *argv[] )
{
    /* GtkWidget is the storage type for widgets */
    GtkWidget *window;
    GtkWidget *button;
    GtkWidget *box;

    gtk_init (&argc, &argv);

    /* Create a new window */
    window = gtk_window_new (GTK_WINDOW_TOPLEVEL);

    gtk_window_set_title (GTK_WINDOW (window), "Pixmap'd Buttons!");

    /* It's a good idea to do this for all windows. */
    g_signal_connect (G_OBJECT (window), "destroy",
                  G_CALLBACK (gtk_main_quit), NULL);

    g_signal_connect (G_OBJECT (window), "delete_event",
               G_CALLBACK (gtk_main_quit), NULL);

    /* Sets the border width of the window. */
    gtk_container_set_border_width (GTK_CONTAINER (window), 10);

    /* Create a new button */
    button = gtk_button_new ();

    /* Connect the "clicked" signal of the button to our callback */
    g_signal_connect (G_OBJECT (button), "clicked",
              G_CALLBACK (callback), (gpointer) "cool button");

    /* This calls our box creating function */
    box = xpm_label_box ("info.xpm", "cool button");

    /* Pack and show all our widgets */
    gtk_widget_show (box);

    gtk_container_add (GTK_CONTAINER (button), box);

    gtk_widget_show (button);

    gtk_container_add (GTK_CONTAINER (window), button);

    gtk_widget_show (window);

    /* Rest in gtk_main and wait for the fun to begin! */
    gtk_main ();

    return 0;
}








----- Original Message ----
From: Andres Gonzalez <gonzo agoralabs com>
To: Douwe Vos <dmvos2000 yahoo com>
Sent: Wednesday, October 1, 2008 8:34:51 PM
Subject: Re: this is strange

Yes, I did. I have a single print statement so I know when I get the 
callback.

-Andres


Douwe Vos wrote:
> Did you try commenting out all activity in your callback handler ?
> 
> 
> 
> ----- Original Message ----
> From: Andres Gonzalez <gonzo agoralabs com>
> To: "gtk-list gnome org" <gtk-list gnome org>
> Sent: Tuesday, September 30, 2008 11:29:54 PM
> Subject: this is strange
> 
> 
> I have a simple button that is working correctly except for one issue. 
> After I click on it, after the callback has been called correctly, the 
> button seems to go dead until I click on any other area in the 
> application. The sensitivity is correct, the button looks normal after 
> the 1st click. The callback never gets called until I click on any other 
> area in the app.
> 
> In other words, after the button works correctly once (the callback gets 
> called) then the callback will not be called until I first click on any 
> other area of the application. I can click on the button any number of 
> times but the callback will not get called until I first click elsewhere.
> 
> The event loop seems to working otherwise in that the rest of the 
> application which has lots of other buttons works fine.
> 
> Any idea what is going on here??
> 
> -Andres
> 
> _______________________________________________
> gtk-list mailing list
> gtk-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtk-list
> 
> 
> 
>      
> 



      


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