[gnome-shell/T27795: 76/138] overview: Show dialog when toggling to showing windows with no apps running



commit 4ca24f85e6fddef8c54e47e02d8ea5ce21667f1f
Author: Mario Sanchez Prada <mario endlessm com>
Date:   Tue Sep 12 15:55:03 2017 +0100

    overview: Show dialog when toggling to showing windows with no apps running
    
    When there are no applications opened and the user presses the super key,
    clicks on the Endless button or uses the hot corner, we show a dialog with
    a message informing about that.
    
    https://phabricator.endlessm.com/T17227

 js/ui/overview.js | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 81 insertions(+), 3 deletions(-)
---
diff --git a/js/ui/overview.js b/js/ui/overview.js
index 212e30bdbe..c7f51db1aa 100644
--- a/js/ui/overview.js
+++ b/js/ui/overview.js
@@ -1,7 +1,7 @@
 // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
 /* exported Overview */
 
-const { Clutter, GLib, Meta, Shell, St } = imports.gi;
+const { Clutter, GLib, GObject, Meta, Pango, Shell, St } = imports.gi;
 const Signals = imports.signals;
 
 const Background = imports.ui.background;
@@ -10,6 +10,7 @@ const LayoutManager = imports.ui.layout;
 const Lightbox = imports.ui.lightbox;
 const Main = imports.ui.main;
 const MessageTray = imports.ui.messageTray;
+const ModalDialog = imports.ui.modalDialog;
 const Monitor = imports.ui.monitor;
 const OverviewControls = imports.ui.overviewControls;
 const Params = imports.misc.params;
@@ -28,6 +29,8 @@ var DND_WINDOW_SWITCH_TIMEOUT = 750;
 
 var OVERVIEW_ACTIVATION_TIMEOUT = 0.5;
 
+var NO_WINDOWS_OPEN_DIALOG_TIMEOUT = 2000; // ms
+
 var ShellInfo = class {
     constructor() {
         this._source = null;
@@ -95,11 +98,69 @@ var ShellInfo = class {
     }
 };
 
+var NoWindowsDialog = GObject.registerClass(
+class NoWindowsDialog extends ModalDialog.ModalDialog {
+    _init() {
+        super._init({
+            styleClass: 'prompt-dialog',
+            shellReactive: true,
+            destroyOnClose: false,
+        });
+
+        this._timeoutId = 0;
+
+        let descriptionLabel = new St.Label({
+            style_class: 'prompt-dialog-headline headline',
+            text: _('No apps are open'),
+        });
+        descriptionLabel.clutter_text.line_wrap = true;
+        descriptionLabel.clutter_text.ellipsize = Pango.EllipsizeMode.NONE;
+
+        this.contentLayout.add(descriptionLabel, {
+            x_fill: false,
+            y_fill: false,
+            x_align: St.Align.MIDDLE,
+            y_align: St.Align.MIDDLE,
+        });
+
+        this.connect('key-press-event', () => {
+            this.close(global.get_current_time());
+            return Clutter.EVENT_PROPAGATE;
+        });
+    }
+
+    show() {
+        if (this._timeoutId != 0)
+            GLib.source_remove(this._timeoutId);
+
+        this._timeoutId =
+            GLib.timeout_add(
+                GLib.PRIORITY_DEFAULT,
+                NO_WINDOWS_OPEN_DIALOG_TIMEOUT,
+                () => {
+                    this.hide();
+                    return GLib.SOURCE_REMOVE;
+                }
+            );
+        this.open(global.get_current_time());
+    }
+
+    hide() {
+        if (this._timeoutId != 0) {
+            GLib.source_remove(this._timeoutId);
+            this._timeoutId = 0;
+        }
+        this.close(global.get_current_time());
+    }
+});
+
 var Overview = class {
     constructor() {
         this._overviewCreated = false;
         this._initCalled = false;
 
+        this._noWindowsDialog = new NoWindowsDialog();
+
         Main.sessionMode.connect('updated', this._sessionUpdated.bind(this));
         this._sessionUpdated();
     }
@@ -495,6 +556,11 @@ var Overview = class {
             return;
         }
 
+        if (!Main.workspaceMonitor.hasActiveWindows) {
+            this._noWindowsDialog.show();
+            return;
+        }
+
         if (!Main.workspaceMonitor.hasVisibleWindows) {
             // There are active windows but all of them are hidden, so activate
             // the most recently used one before hiding the overview.
@@ -512,8 +578,17 @@ var Overview = class {
         if (this.isDummy)
             return;
 
-        if (!this.visible ||
-            this.viewSelector.getActivePage() !== ViewSelector.ViewPage.WINDOWS) {
+        if (!this.visible) {
+            this.showWindows();
+            return;
+        }
+
+        if (!Main.workspaceMonitor.hasActiveWindows) {
+            this._noWindowsDialog.show();
+            return;
+        }
+
+        if (this.viewSelector.getActivePage() !== ViewSelector.ViewPage.WINDOWS) {
             this.showWindows();
             return;
         }
@@ -666,6 +741,9 @@ var Overview = class {
 
         this._shown = false;
 
+        // Hide the 'No windows dialog' in case it is open
+        this._noWindowsDialog.hide();
+
         this._animateNotVisible();
         this._syncGrab();
     }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]