для этого я использую сигнал, который излучает Gtk.Window, когда вы изменяете его размер, через gsettings я сохраняю значения и восстанавливаю его, чтобы запустить приложение таким же образом. Вот пример в vala + GTK +:
using Gtk;
using GLib;
public class Prueba : Window {
public void on_resize (Window win)
{
int width;
int height;
win.get_size (out width, out height);
/* GSETTINGS CONFIG */
string settings_dir = Path.get_dirname (".");
SettingsSchemaSource sss = new SettingsSchemaSource.from_directory (settings_dir, null, false);
SettingsSchema schema = sss.lookup ("apps.test-gs", false);
if (sss.lookup == null)
{
stdout.printf ("GLIB.GIO.SCHEMA: ID not found.");
}
GLib.Settings config = new GLib.Settings.full (schema, null, null);
/* GSETTINGS FIN */
stdout.printf ("RESOLUTION: %dx%d\n", width, height);
config.set_int ("width", width);
config.set_int ("height", height);
}
public void on_destroy (Window ventana)
{
stderr.printf ("APPLICATION EXIT!\n");
Gtk.main_quit ();
}
public Prueba ()
{
this.title = "Prueba GTK+";
string settings_dir = Path.get_dirname (".");
SettingsSchemaSource sss = new SettingsSchemaSource.from_directory (settings_dir, null, false);
SettingsSchema schema = sss.lookup ("apps.test-gs", false);
if (sss.lookup == null)
{
stdout.printf ("GLIB.GIO.SCHEMA: ID not found.");
}
GLib.Settings settings = new GLib.Settings.full (schema, null, null);
this.set_default_size (settings.get_int("width"), settings.get_int("height"));
this.border_width = 10;
this.window_position = WindowPosition.CENTER;
Button b = new Button.with_label ("SALIR");
b.clicked.connect (()=>{
this.on_destroy (this);
});
this.add (b);
this.show_all ();
}
public static int main (string[] args)
{
Gtk.init (ref args);
Prueba app = new Prueba ();
app.destroy.connect (()=> {
app.on_destroy (app);
});
app.size_allocate.connect (()=>{
app.on_resize (app);
});
Gtk.main ();
return 0;
}
}
И схема для этого:
<?xml version="1.0" encoding="UTF-8"?>
<schemalist>
<schema id="apps.test-gs" path="/apps/test-gs/">
<key type="b" name="check-test">
<default>false</default>
<summary>Check de mi app TEST</summary>
<description>Es un ejemplo de BOOLEANO de mi APP TEST</description>
</key>
<key type="i" name="width">
<default>300</default>
<summary>Pixels del Ancho</summary>
<description>Valor del Ancho del Programa TEST</description>
</key>
<key type="i" name="height">
<default>100</default>
<summary>Pixels del Alto</summary>
<description>Valor del Alto del Programa TEST</description>
</key>
</schema>
</schemalist>
Удачи!