~tkluck/ubuntu/precise/gnome-shell/lp883443

« back to all changes in this revision

Viewing changes to js/ui/messageTray.js

  • Committer: Jeremy Bicha
  • Date: 2011-09-28 00:41:45 UTC
  • mto: This revision was merged to the branch mainline in revision 43.
  • Revision ID: jbicha@ubuntu.com-20110928004145-qul9m3n18o37jvo1
ImportĀ upstreamĀ versionĀ 3.2.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
416
416
 
417
417
    _init: function(source, title, banner, params) {
418
418
        this.source = source;
 
419
        this.title = title;
419
420
        this.urgency = Urgency.NORMAL;
420
421
        this.resident = false;
421
422
        // 'transient' is a reserved keyword in JS, so we have to use an alternate variable name
503
504
 
504
505
        let oldFocus = global.stage.key_focus;
505
506
 
506
 
        if (this._icon)
 
507
        if (this._icon && (params.icon || params.clear)) {
507
508
            this._icon.destroy();
 
509
            this._icon = null;
 
510
        }
 
511
 
508
512
        // We always clear the content area if we don't have custom
509
513
        // content because it might contain the @banner that didn't
510
514
        // fit in the banner mode.
530
534
        if (!this._scrollArea && !this._actionArea && !this._imageBin)
531
535
            this._table.remove_style_class_name('multi-line-notification');
532
536
 
533
 
        this._icon = params.icon || this.source.createNotificationIcon();
534
 
        this._table.add(this._icon, { row: 0,
535
 
                                      col: 0,
536
 
                                      x_expand: false,
537
 
                                      y_expand: false,
538
 
                                      y_fill: false,
539
 
                                      y_align: St.Align.START });
 
537
        if (!this._icon) {
 
538
            this._icon = params.icon || this.source.createNotificationIcon();
 
539
            this._table.add(this._icon, { row: 0,
 
540
                                          col: 0,
 
541
                                          x_expand: false,
 
542
                                          y_expand: false,
 
543
                                          y_fill: false,
 
544
                                          y_align: St.Align.START });
 
545
        }
540
546
 
 
547
        this.title = title;
541
548
        title = title ? _fixMarkup(title.replace(/\n/g, ' '), params.titleMarkup) : '';
542
549
        this._titleLabel.clutter_text.set_markup('<b>' + title + '</b>');
543
550
 
1349
1356
        this._summaryBin.opacity = 0;
1350
1357
 
1351
1358
        this._summaryMotionId = 0;
 
1359
        this._trayMotionId = 0;
1352
1360
 
1353
1361
        this._summaryBoxPointer = new BoxPointer.BoxPointer(St.Side.BOTTOM,
1354
1362
                                                            { reactive: true,
1388
1396
           }));
1389
1397
        this._focusGrabber.connect('escape-pressed', Lang.bind(this, this._escapeTray));
1390
1398
 
 
1399
        Main.layoutManager.keyboardBox.connect('notify::hover', Lang.bind(this, this._onKeyboardHoverChanged));
 
1400
 
1391
1401
        this._trayState = State.HIDDEN;
1392
1402
        this._locked = false;
1393
1403
        this._traySummoned = false;
1394
1404
        this._useLongerTrayLeftTimeout = false;
1395
1405
        this._trayLeftTimeoutId = 0;
1396
1406
        this._pointerInTray = false;
 
1407
        this._pointerInKeyboard = false;
1397
1408
        this._summaryState = State.HIDDEN;
1398
1409
        this._summaryTimeoutId = 0;
1399
1410
        this._pointerInSummary = false;
1843
1854
        }
1844
1855
    },
1845
1856
 
 
1857
    _onKeyboardHoverChanged: function(keyboard) {
 
1858
        this._pointerInKeyboard = keyboard.hover;
 
1859
 
 
1860
        if (!keyboard.hover) {
 
1861
            let event = Clutter.get_current_event();
 
1862
            if (event && event.type() == Clutter.EventType.LEAVE) {
 
1863
                let into = event.get_related();
 
1864
                if (into && this.actor.contains(into)) {
 
1865
                    // Don't call _updateState, because pointerInTray is
 
1866
                    // still false
 
1867
                    return;
 
1868
                }
 
1869
            }
 
1870
        }
 
1871
 
 
1872
        this._updateState();
 
1873
    },
 
1874
 
1846
1875
    _onStatusChanged: function(presence, status) {
1847
1876
        this._backFromAway = (this._userStatus == GnomeSession.PresenceStatus.IDLE && this._userStatus != status);
1848
1877
        this._userStatus = status;
1907
1936
        let notificationsPending = this._notificationQueue.length > 0 && (!this._busy || notificationUrgent);
1908
1937
        let notificationPinned = this._pointerInTray && !this._pointerInSummary && !this._notificationRemoved;
1909
1938
        let notificationExpanded = this._notificationBin.y < 0;
1910
 
        let notificationExpired = (this._notificationTimeoutId == 0 && !(this._notification && this._notification.urgency == Urgency.CRITICAL) && !this._pointerInTray && !this._locked) || this._notificationRemoved;
 
1939
        let notificationExpired = (this._notificationTimeoutId == 0 && !(this._notification && this._notification.urgency == Urgency.CRITICAL) && !this._pointerInTray && !this._locked && !(this._pointerInKeyboard && notificationExpanded)) || this._notificationRemoved;
1911
1940
        let canShowNotification = notificationsPending && this._summaryState == State.HIDDEN;
1912
1941
 
1913
1942
        if (this._notificationState == State.HIDDEN) {
2265
2294
        // _clickedSummaryItem.actor can change absolute position without changing allocation
2266
2295
        this._summaryMotionId = this._summary.connect('allocation-changed',
2267
2296
                                                      Lang.bind(this, this._adjustSummaryBoxPointerPosition));
 
2297
        this._trayMotionId = Main.layoutManager.trayBox.connect('notify::anchor-y',
 
2298
                                                                Lang.bind(this, this._adjustSummaryBoxPointerPosition));
2268
2299
 
2269
2300
        this._summaryBoxPointer.actor.opacity = 0;
2270
2301
        this._summaryBoxPointer.actor.show();
2296
2327
        if (this._clickedSummaryItemAllocationChangedId) {
2297
2328
            this._clickedSummaryItem.actor.disconnect(this._clickedSummaryItemAllocationChangedId);
2298
2329
            this._summary.disconnect(this._summaryMotionId);
 
2330
            Main.layoutManager.trayBox.disconnect(this._trayMotionId);
2299
2331
            this._clickedSummaryItemAllocationChangedId = 0;
2300
2332
            this._summaryMotionId = 0;
 
2333
            this._trayMotionId = 0;
2301
2334
        }
2302
2335
 
2303
2336
        if (this._clickedSummaryItem)
2316
2349
        }
2317
2350
 
2318
2351
        this._summaryBoxPointerState = State.HIDING;
2319
 
        // Unset this._clickedSummaryItem if we are no longer showing the summary
2320
 
        if (this._summaryState != State.SHOWN)
 
2352
        // Unset this._clickedSummaryItem if we are no longer showing the summary or if
 
2353
        // this._clickedSummaryItem is still the item associated with the currently showing box pointer
 
2354
        if (this._summaryState != State.SHOWN || this._summaryBoxPointerItem == this._clickedSummaryItem)
2321
2355
            this._unsetClickedSummaryItem();
2322
2356
 
2323
2357
        this._focusGrabber.ungrabFocus();