knowing if an event ocurred (when running gtk_dialog_run() )
How do You determine what control/widget was clicked inside a dialog box by checking the return value of gtk_dialog_run()
This is what I have
/*toolbar test thingy*/
#include <gtk/gtk.h>
#define MESSAGE_OK 1001
void mymessage (void){
    GtkWidget *message = gtk_dialog_new_with_buttons("My dialog",
        NULL,
        GTK_DIALOG_MODAL,GTK_STOCK_OK,1001,NULL);
    gtk_window_set_default_size(GTK_WINDOW(message),200,200);
    gint result = gtk_dialog_run(GTK_DIALOG(message));
    switch(result){
        case MESSAGE_OK:
            gtk_widget_destroy(message);
            printf("you clicked message_ok");
        break;
    }
    gtk_widget_destroy(message);
}
int main(int argc,char *argv[]){
    GtkWidget *window;
    GtkWidget *vertical_box;
    GtkWidget *toolbar;
    //GtkWidget *message;
    GtkToolItem *tool_new;
    gtk_init(&argc,&argv);
开发者_运维百科    //setting up the main window.
    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_window_set_title(GTK_WINDOW(window),"rs-toolbar test");
    gtk_window_set_default_size(GTK_WINDOW(window),300,350);
    gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER_ALWAYS);
    //setting up the layout using vbox.
    vertical_box = gtk_vbox_new(FALSE,0);
    //adding the vbox layout to the Container window, window
    gtk_container_add(GTK_CONTAINER(window),vertical_box);
    toolbar = gtk_toolbar_new();
    gtk_toolbar_set_style(GTK_TOOLBAR(toolbar),GTK_TOOLBAR_ICONS);
    gtk_container_set_border_width(GTK_CONTAINER(toolbar),2);
    tool_new = gtk_tool_button_new_from_stock(GTK_STOCK_NEW);
    gtk_toolbar_insert(GTK_TOOLBAR(toolbar),tool_new,-1);
    //************************************************************************
    //************************************************************************
    gtk_box_pack_start(GTK_BOX(vertical_box),toolbar,FALSE,FALSE,0);
    gtk_widget_show_all(window);
    g_signal_connect(window,"destroy",G_CALLBACK(gtk_main_quit),NULL);
    g_signal_connect(tool_new,"clicked",G_CALLBACK(mymessage),NULL);
    gtk_main();
    return 0;
}
Is the use of the gtk_dialog_new_with_buttons() function correct?. I'm not entirely sure how to give a specific ID to a control. What I've tried to do there is make 1001 the ID of GTK_STOCK_OK. 
You're comparing the response to the wrong thing.  gtk_dialog_run returns one of the GTK_RESPONSE constants; try comparing against those in your switch to see which button was pressed.
 
         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论