[Gtk-sharp-list] How does one set the size of a window before displaying it?

Fredrik Nilsson jymdman@home.se
Sun, 10 Apr 2005 09:19:15 +0200


Hi Kevin,

Looks like you mix creating a window on your own and using glade.

public class MainWindow : Gnome.App
{
    private Gnome.Program program;

    public MainWindow(Gnome.Program program)
    {
      this.program = program;
      Glade.XML gMain = new Glade.XML("transference.glade",
                      "MainWindow",
                      null);
      gMain.Autoconnect(this);
      this.SetSizeRequest(500, 500);
    }
}

When you override Gnome.App you create a window by your own, and when
you ShowAll () that window is displayed, NOT the window from the glade
file.

Your code should look something like:

public class MainWindow
{
    [Widget] Gtk.Window Main_Window; // Connects to Main_Window in glade

    private Gnome.Program program;

    public MainWindow(Gnome.Program program)
    {
      this.program = program;
      Glade.XML gMain = new Glade.XML("transference.glade",
                      "Main_Window",
                      null);
      gMain.Autoconnect(this);
      Main_Window.Resize (500, 500); // Resize Main_Window from glade
    }
}

You also need to rename the MainWindow in glade to something else like
Main_Window, it conflicts whith the classname.

Hope that helps.

/Fredrik


On sön, 2005-04-10 at 14:21 +0800, Kevin Francis wrote:
> Well, I managed to get the window sized before display by setting it to 
> non-visible, then doing a .Resize(). One problem though--when I 
> ShowAll() it, nothing appears except the blank window. No widgets, 
> nothing. Just the window.
> 
> Any ideas?
> 
> Kevin Francis wrote:
> > streaI am using glade to define a window, MainWindow, and I cannot seem to
> > set the size before displaying, or after either. I wish to set the size
> > to the last size before previous exit, something which I am storing in
> > GConf.
> > 
> > I did achieve partial success with some Gdk method (which I now forget)
> > and setting the window hidden in Glade, however when I displayed it with
> > Show() or ShowAll(), it displayed no widgets...
> > 
> > I've found no method/property that will do this, even though advertised
> > in the documentation.
> > 
> > My code is at these URLs:
> > http://pastebin.arslinux.com/1658
> > http://pastebin.arslinux.com/1659
> > 
> > Cheers.
>