I am writing application in C# using GTK# GUI framework to make it cross-platform.
Many things are being done in GTK# not like in WPF/Windows.Forms, but most of them I was able to solve on my own.
There is a “little” problem, what became not that “little” when I tried to solve it.
I am saving window position and maximized flag to config file when application is being closed.
But when I am trying to restore window parameters, they are being restored not correctly.
Methods I tried to use:
SetSizeRequest():
this.SetSizeRequest((int)config["windowwidth"], (int)config["windowheight"]);
SetDefaultSize():
this.SetDefaultSize((int)config["windowwidth"], (int)config["windowheight"]);
Resize():
this.Resize((int)config["windowwidth"], (int)config["windowheight"]);
The problem is:
Some of these methods does not work at all (change nothing). Others behave strangely: set window size to not the one was loaded from config, make window continuously expanding, etc.
I am also adding a constraint on size of one specific widget:
Gdk.Geometry geom = new Gdk.Geometry();
geom.MinWidth = 800;
geom.MinHeight = 400;
this.SetGeometryHints(BoxNotebook, geom, Gdk.WindowHints.MinSize);
When I use all this together, it is becoming a complete mess.
What is the correct way to restore window size at program startup ?
Resizeworks in my application. Are you sure that the correct values are being loaded from the config file?EDIT
Here is a Glade file that seems to do what you want: