Re: gtk_window_set_transient_for just works to dialog?

On Mon, Oct 12, 2009 at 09:58:45AM +0800, Andy Stewart wrote:
> Hi all,
> I have problem with function `gtk_window_set_transient_for`, 
> I use gtk2hs (Haskell binding for Gtk+),
> so don't care gtk2hs binding problem and Haskell code format, you can test my problem in C code.

I tried to test in C code...

> I have two window: `windowA` and `windowB`, I want make `windowB`
> keep above `windowA` and make `windowB` modal, `windowA` has created.
> ------------------------------> code start <------------------------------
> windowB <- windowNew
> windowSetTransientFor windowB windowA
> windowSetModal windowB True             
> ------------------------------> code end   <------------------------------
> But above code can't work, `windowB` don't display anything, `windowB` display blank.

...and it works exactly as it should.

#include <gtk/gtk.h>

main(int argc, char *argv[])
    GtkWidget *windowA, *windowB, *entry;

    gtk_init(&argc, &argv);

    windowA = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_window_set_default_size(GTK_WINDOW(windowA), 300, 240);
    g_signal_connect(windowA, "destroy", G_CALLBACK(gtk_main_quit), NULL);
    entry = gtk_entry_new();
    gtk_entry_set_text(GTK_ENTRY(entry), "Window A");
    gtk_container_add(GTK_CONTAINER(windowA), entry);

    windowB = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_window_set_default_size(GTK_WINDOW(windowB), 200, 160);
    gtk_window_set_transient_for(GTK_WINDOW(windowB), GTK_WINDOW(windowA));
    gtk_window_set_position(GTK_WINDOW(windowB), GTK_WIN_POS_CENTER_ON_PARENT);
    gtk_window_set_modal(GTK_WINDOW(windowB), TRUE);
    entry = gtk_entry_new();
    gtk_entry_set_text(GTK_ENTRY(entry), "Window B");
    gtk_container_add(GTK_CONTAINER(windowB), entry);


    return 0;


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