Hello,

I've done something similar, setting the parent window as transient for the child one. A problem I found is that, unless I grab keyboard and mouse for the child window, the keyboard cursor doesn't show properly.


        [...]

        [Widget] private Gtk.Window windowParent;
        [Widget] private Gtk.Window windowChild;

        [...]

private void BuildProperties()
{

        windowChild.TransientFor = windowParent;
        windowParent.Realize();
        windowChild.Realize();
                
        windowChild.ShowAll();
        windowParent.ShowAll();

        SetGrabbing(windowChild, false);
                                        
        windowChild.Move( 100, 300);
}

private bool SetGrabbing(Widget widget, bool confined)
        {
                Gdk.Window widgetGdkWin = widget.GdkWindow;
                Gdk.Window widgetConfinedGdkWin;
                
                if (confined) {
                        widgetConfinedGdkWin = widget.GdkWindow;
                } else {
                        widgetConfinedGdkWin = null;
                }
                
                Grab.Add(widget);
                
                if (Gdk.Keyboard.Grab(widgetGdkWin, true, 0) != 
Gdk.GrabStatus.Success)
                {
                        Grab.Remove(widget);
                        return false;
                }
                
if (Gdk.Pointer.Grab(widgetGdkWin, true, Gdk.EventMask.ButtonPressMask | Gdk.EventMask.ButtonReleaseMask | Gdk.EventMask.PointerMotionMask, widgetConfinedGdkWin, null, 0) != Gdk.GrabStatus.Success)
                {
                        Console.WriteLine("Grab de mouse no conseguido.");
                        Grab.Remove(widget);
                        Gdk.Keyboard.Ungrab(0);
                        return false;
                }
                
                return true;
                
        }


Both windows are in the same glade file.
HTH :-)

Mariano.

Evgeny Pirogov wrote:
Hello.

If possible, I need simple example for running Gtk.Window instance as modal dialog for other Gtk.Window.

Thanks.


------------------------------------------------------------------------

_______________________________________________
Gtk-sharp-list maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/gtk-sharp-list

--
Mariano Benedettini
Ad Network SA
[EMAIL PROTECTED]

_______________________________________________
Gtk-sharp-list maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/gtk-sharp-list

Reply via email to