~erasmo-marin/webby-browser/trunk

« back to all changes in this revision

Viewing changes to src/AppWindow.vala

  • Committer: Erasmo Marín
  • Date: 2015-10-22 06:59:01 UTC
  • mfrom: (15.1.1 webby-browser)
  • Revision ID: erasmo.marin@gmail.com-20151022065901-pivvlxod3kmmi6a0
Save main window state

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
public class AppWindow : Granite.Application {
2
2
 
 
3
    private Settings settings;
 
4
 
3
5
    public Gtk.Window mainwindow;
4
6
 
5
7
    private Gtk.Stack stack;
52
54
            return;
53
55
        }
54
56
 
 
57
        settings = Settings.get_default ();
 
58
 
55
59
        mainwindow = new Gtk.Window ();
56
60
 
57
61
        mainwindow.set_default_size (700, 500);
129
133
            show_assistant ();
130
134
        });
131
135
 
 
136
        mainwindow.delete_event.connect (() => {
 
137
            this.store_settings ();
 
138
            return false;
 
139
        });
 
140
 
132
141
        mainwindow.destroy.connect (Gtk.main_quit);
133
142
 
 
143
        this.restore_settings ();
134
144
        mainwindow.show_all ();
135
145
 
136
146
        if (apps_view.has_items)
172
182
        //fix ugly border at the bottom of headerbar
173
183
        mainwindow.queue_draw ();
174
184
    }
 
185
 
 
186
    private void restore_settings () {
 
187
        this.mainwindow.set_default_size (settings.window_width, settings.window_height);
 
188
 
 
189
        if (settings.window_state == Settings.WindowState.MAXIMIZED)
 
190
            this.mainwindow.maximize ();
 
191
    }
 
192
 
 
193
    private void store_settings () {
 
194
        settings.window_state = (this.mainwindow.is_maximized ? Settings.WindowState.MAXIMIZED: Settings.WindowState.NORMAL);
 
195
        if (settings.window_state == Settings.WindowState.NORMAL) {
 
196
            settings.window_height = this.mainwindow.get_allocated_height ();
 
197
            settings.window_width = this.mainwindow.get_allocated_width ();
 
198
        }
 
199
    }
175
200
}