GTK app without gtk_main() valid?



Hi

I accidentally learned that it's possible to have a working GTK application without a call to gtk_main():

int main()
{
    GtkWidget* mainDialog;
    int rc;

    gtk_init(&argc, &argv);

    /* main window */
    mainDialog = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL,
             GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE,
             _("some question"));
    gtk_window_set_title(GTK_WINDOW(mainDialog), "question?");
    gtk_dialog_add_buttons(GTK_DIALOG(mainDialog),
                           _("yes"), GTK_RESPONSE_OK,
                           _("no"), GTK_RESPONSE_CANCEL,
                           NULL);

    rc = gtk_dialog_run(GTK_DIALOG(mainDialog));

    if(rc == GTK_RESPONSE_OK)
    {
        //do something
    }

    return 0;
}

This works fine except I don't see the dialog in the taskbar or the tast switcher. That's my first question - can I still only use a GtkDialog or do I need to make a GtkWindow to have it show up in the taskbar?

And the second question - is there anything obviously wrong with not calling gtk_main()?

Thanks

Andrew



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