~darkxst/ubuntu/saucy/gnome-shell/upstart_log

« back to all changes in this revision

Viewing changes to js/ui/endSessionDialog.js

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2013-05-31 12:01:12 UTC
  • mfrom: (1.1.49) (19.1.36 experimental)
  • Revision ID: package-import@ubuntu.com-20130531120112-ew91khxf051x9i2r
Tags: 3.8.2-1ubuntu1
* Merge with Debian (LP: #1185869, #1185721). Remaining changes:
  - debian/control.in:
    + Build-depend on libsystemd-login-dev & libsystemd-daemon-dev
    + Depend on gdm instead of gdm3
    + Don't recommend gnome-session-fallback
  - debian/patches/40_change-pam-name-to-match-gdm.patch:
  - debian/patches/revert-suspend-break.patch:
    + Disabled, not needed on Ubuntu
  - debian/patches/ubuntu-lightdm-user-switching.patch:
    + Allow user switching when using LightDM. Thanks Gerhard Stein
      for rebasing against gnome-shell 3.8!
  - debian/patches/ubuntu_lock_on_suspend.patch
    + Respect Ubuntu's lock-on-suspend setting.
      Disabled until it can be rewritten.
  - debian/patches/git_relock_screen_after_crash.patch:
    + Add Upstream fix for unlocked session after crash (LP: #1064584)
* Note that the new GNOME Classic mode (which requires installing
  gnome-shell-extensions) won't work until gnome-session 3.8 is
  available in Ubuntu

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 */
20
20
 
21
21
const Lang = imports.lang;
 
22
const Mainloop = imports.mainloop;
22
23
const Signals = imports.signals;
23
24
 
24
25
const AccountsService = imports.gi.AccountsService;
50
51
    <arg type="u" direction="in" />
51
52
    <arg type="ao" direction="in" />
52
53
</method>
 
54
<method name="Close" />
53
55
<signal name="ConfirmedLogout" />
54
56
<signal name="ConfirmedReboot" />
55
57
<signal name="ConfirmedShutdown" />
105
107
    endDescription: _("Restarting the system."),
106
108
    confirmButtons: [{ signal: 'ConfirmedReboot',
107
109
                       label:  C_("button", "Restart") }],
108
 
    iconName: 'system-shutdown-symbolic',
 
110
    iconName: 'view-refresh-symbolic',
109
111
    iconStyleClass: 'end-session-dialog-shutdown-icon'
110
112
};
111
113
 
223
225
    Extends: ModalDialog.ModalDialog,
224
226
 
225
227
    _init: function() {
226
 
        this.parent({ styleClass: 'end-session-dialog' });
 
228
        this.parent({ styleClass: 'end-session-dialog',
 
229
                      destroyOnClose: false });
227
230
 
228
231
        this._user = AccountsService.UserManager.get_default().get_user(GLib.get_user_name());
229
232
 
377
380
            let signal = dialogContent.confirmButtons[i].signal;
378
381
            let label = dialogContent.confirmButtons[i].label;
379
382
            buttons.push({ action: Lang.bind(this, function() {
380
 
                                       this._confirm(signal);
 
383
                                       this.close(true);
 
384
                                       let signalId = this.connect('closed',
 
385
                                                                   Lang.bind(this, function() {
 
386
                                                                       this.disconnect(signalId);
 
387
                                                                       this._confirm(signal);
 
388
                                                                   }));
381
389
                                   }),
382
390
                           label: label });
383
391
        }
385
393
        this.setButtons(buttons);
386
394
    },
387
395
 
388
 
    close: function() {
 
396
    close: function(skipSignal) {
389
397
        this.parent();
390
 
        this._dbusImpl.emit_signal('Closed', null);
 
398
 
 
399
        if (!skipSignal)
 
400
            this._dbusImpl.emit_signal('Closed', null);
391
401
    },
392
402
 
393
403
    cancel: function() {
394
404
        this._stopTimer();
395
405
        this._dbusImpl.emit_signal('Canceled', null);
396
 
        this.close(global.get_current_time());
 
406
        this.close();
397
407
    },
398
408
 
399
409
    _confirm: function(signal) {
408
418
    },
409
419
 
410
420
    _startTimer: function() {
 
421
        let startTime = GLib.get_monotonic_time();
411
422
        this._secondsLeft = this._totalSecondsToStayOpen;
412
 
        Tweener.addTween(this,
413
 
                         { _secondsLeft: 0,
414
 
                           time: this._secondsLeft,
415
 
                           transition: 'linear',
416
 
                           onUpdate: Lang.bind(this, this._updateDescription),
417
 
                           onComplete: Lang.bind(this, function() {
418
 
                                           let dialogContent = DialogContent[this._type];
419
 
                                           let button = dialogContent.confirmButtons[dialogContent.confirmButtons.length - 1];
420
 
                                           this._confirm(button.signal);
421
 
                                       }),
422
 
                         });
 
423
 
 
424
        this._timerId = Mainloop.timeout_add_seconds(1, Lang.bind(this,
 
425
            function() {
 
426
                let currentTime = GLib.get_monotonic_time();
 
427
                let secondsElapsed = ((currentTime - startTime) / 1000000);
 
428
 
 
429
                this._secondsLeft = this._totalSecondsToStayOpen - secondsElapsed;
 
430
                if (this._secondsLeft > 0) {
 
431
                    this._updateDescription();
 
432
                    return true;
 
433
                }
 
434
 
 
435
                let dialogContent = DialogContent[this._type];
 
436
                let button = dialogContent.confirmButtons[dialogContent.confirmButtons.length - 1];
 
437
                this._confirm(button.signal);
 
438
 
 
439
                return false;
 
440
            }));
423
441
    },
424
442
 
425
443
    _stopTimer: function() {
426
 
        Tweener.removeTweens(this);
 
444
        if (this._timerId != 0) {
 
445
            Mainloop.source_remove(this._timerId);
 
446
            this._timerId = 0;
 
447
        }
 
448
 
427
449
        this._secondsLeft = 0;
428
450
    },
429
451
 
440
462
            let item = new ListItem(app, reason);
441
463
            item.connect('activate',
442
464
                         Lang.bind(this, function() {
443
 
                             this.close(global.get_current_time());
 
465
                             this.close();
444
466
                         }));
445
467
            this._applicationList.add(item.actor, { x_fill: true });
446
468
            this._stopTimer();
488
510
                                        invocation.return_value(null);
489
511
                                        this.disconnect(signalId);
490
512
                                    }));
 
513
    },
 
514
 
 
515
    Close: function(parameters, invocation) {
 
516
        this.close();
491
517
    }
492
518
});