Thread: Sending information to callback function GTK

  1. #1
    Registered User
    Join Date
    Oct 2007

    Sending information to callback function GTK


    I started writing code in GTK+Glade and ... I stopped.
    I don't have idea how to send information to callback function.
    Mainly in GTK the is only one place to send variables to callback function for ex:

    But trough func_data I can send only one variable. I can also other information send as global variable, but probably all my variable would be global ;-).

    I attached my example. Would be great if somebody show me how to do this different way.
    I am asking about generally idea how to connect and send information to callback function and programing with GTK-Glade.
    Somehow is possible connect and declare sending data_func in Glade ?

    GtkWidget *glowne_okno = NULL;
    int main(int argc, char **argv)
        GladeXML *gxml;
        gtk_init(&argc, &argv);
        gxml = glade_xml_new("", NULL, NULL);
        glowne_okno = glade_xml_get_widget(gxml, "glowne_okienko_programu");
    extern GtkWidget *glowne_okno;
    G_MODULE_EXPORT int on_zamkniecie_programu_activate (GtkWidget *widget, gpointer *data);
    G_MODULE_EXPORT int on_zamkniecie_programu_activate (GtkWidget *widget, gpointer *data)                    
       gint result = GTK_RESPONSE_YES;
       GtkWidget *dialog = gtk_message_dialog_new ( GTK_WINDOW (glowne_okno),GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_WARNING,
    	    GTK_BUTTONS_YES_NO,("DO You wat to Quit?"));
    	result = gtk_dialog_run (GTK_DIALOG (dialog));
    	gtk_widget_destroy (dialog);
        if (result == GTK_RESPONSE_YES)
        gtk_main_quit ();
        return (FALSE);
    Thanks in advance


  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    I don't know anything about GTK, but if I was only allowed one variable, I'd make it a pointer to a struct. Looking through the web, it looks like that gpointer is just a typedef for (void *), so you can have a pointer to anything you want in that last argument.

  3. #3
    Registered User
    Join Date
    Oct 2007


    Thanks for tips.
    I also found inforamtion about function: lookup_widget() or glade_get_widget_tree (GTK_WIDGET (....));
    It means I can find pointers to other wigets in window and use them.
    Next question is hot to use in callback function other data in my prog.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 05-13-2011, 08:28 AM
  2. Including lib in a lib
    By bibiteinfo in forum C++ Programming
    Replies: 0
    Last Post: 02-07-2006, 02:28 PM
  3. <Gulp>
    By kryptkat in forum Windows Programming
    Replies: 7
    Last Post: 01-14-2006, 01:03 PM
  4. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM
  5. I need help with passing pointers in function calls
    By vien_mti in forum C Programming
    Replies: 3
    Last Post: 04-24-2002, 10:00 AM