Dialogs in middle of windows

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

 



What's the best way to get a dialog perfectly centered in the middle of a window? Currently my code seems to place the dialog in the center of the screen instead of the window.

Here's a snippet of my code:

static void about(GtkWidget *w, gpointer data)
{
        GtkWidget *dialog, *label, *button;

        dialog = gtk_dialog_new();
        gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
        gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(w));
        gtk_window_set_keep_above(GTK_WINDOW(dialog), TRUE);
        gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER);

        label = gtk_label_new(ABOUT);
        gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), label, TRUE, TRUE, 0);
        gtk_widget_show(label);

        button = gtk_button_new_with_label("OK");
        gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(dismiss), dialog);
        gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->action_area), button, TRUE, TRUE, 0);
        gtk_widget_show(button);

        gtk_widget_show(dialog);
}

I thought GTK_WIN_POST_CENTER would place it in the middle of the window?

--
http://www.munted.org.uk

Go fly your cat today!
_______________________________________________

gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list

[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux