tootle-linux-client/src/Dialogs/ISavedWindow.vala

39 lines
798 B
Vala
Raw Normal View History

2019-03-09 19:20:11 +01:00
using Gtk;
2019-03-11 15:14:37 +01:00
public interface Tootle.Dialogs.ISavedWindow : Window {
2019-03-09 19:20:11 +01:00
public void restore_state () {
2019-03-11 15:14:37 +01:00
var settings = new Settings ();
2019-03-09 19:20:11 +01:00
configure_window (settings);
configure_event.connect ((ev) => on_configure (ev, settings));
}
public bool on_configure (Gdk.EventConfigure event, Settings settings) {
int x, y, w, h;
get_position (out x, out y);
get_size (out w, out h);
2019-03-11 15:14:37 +01:00
2019-03-09 19:20:11 +01:00
settings.window_x = x;
settings.window_y = y;
settings.window_w = w;
settings.window_h = h;
return false;
}
public void configure_window (Settings settings) {
var x = settings.window_x;
var y = settings.window_y;
var w = settings.window_w;
var h = settings.window_h;
2019-03-11 15:14:37 +01:00
2019-03-09 19:20:11 +01:00
if (x + y > 0)
this.move (x, y);
2019-03-11 15:14:37 +01:00
2019-03-09 19:20:11 +01:00
if (h + w > 0) {
this.default_width = w;
this.default_height = h;
}
}
}