[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: GTK app without gtk_main() valid?
- From: Chris Vine <chris cvine freeserve co uk>
- To: Andrew Smith <asmith15 littlesvr ca>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: GTK app without gtk_main() valid?
- Date: Sat, 06 Oct 2007 23:31:56 +0100
On Sat, 2007-10-06 at 12:12 -0400, Andrew Smith wrote:
> 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()?
You have not called gtk_widget_show_all().
gtk_dialog_run() calls gtk_main_loop_new() and gtk_main_loop_run()
itself (it creates a nested main loop), which is what gtk_main() would
(amongst other things) do, so in this simple case it should work.
Chris
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]