~embik/appcenter/fix-schema-install

« back to all changes in this revision

Viewing changes to src/MainWindow.vala

  • Committer: Corentin Noël
  • Date: 2015-11-04 14:03:36 UTC
  • Revision ID: corentin@elementary.io-20151104140336-0g3wg1oytgrlfle8
Wait until all tasks are finished to close the app.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
    private Views.InstalledView installed_view;
25
25
    private Views.SearchView search_view;
26
26
    private Gtk.Button current_button;
 
27
    private ulong task_finished_connection = 0U;
27
28
 
28
29
    public MainWindow () {
29
30
        window_position = Gtk.WindowPosition.CENTER;
38
39
        show_all ();
39
40
    }
40
41
 
 
42
    public override bool delete_event (Gdk.EventAny event) {
 
43
        unowned AppCenterCore.Client client = AppCenterCore.Client.get_default ();
 
44
        if (client.has_tasks ()) {
 
45
            if (task_finished_connection != 0U) {
 
46
                client.disconnect (task_finished_connection);
 
47
            }
 
48
 
 
49
            hide ();
 
50
            task_finished_connection = client.tasks_finished.connect (() => {
 
51
                if (!visible) {
 
52
                    delete_event (event);
 
53
                }
 
54
            });
 
55
 
 
56
            return true;
 
57
        }
 
58
 
 
59
        return false;
 
60
    }
 
61
 
41
62
    private void create_headerbar () {
42
63
        headerbar = new Gtk.HeaderBar ();
43
64
        headerbar.show_close_button = true;