Skip to content

Commit

Permalink
Overview: Add empty placeholder
Browse files Browse the repository at this point in the history
  • Loading branch information
germanfr authored and clefebvre committed Oct 17, 2018
1 parent d306023 commit c4101ab
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
5 changes: 5 additions & 0 deletions data/theme/cinnamon.css
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,11 @@ StScrollBar StButton#vhandle:hover {
text-align: center;
}

.overview-empty-placeholder {
color: #ffffff;
font-size: 2em;
}

.expo-background {
background-gradient-start: #000;
background-gradient-end: #AAA;
Expand Down
25 changes: 25 additions & 0 deletions js/ui/workspace.js
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,13 @@ WorkspaceMonitor.prototype = {
}
}

let empty_label = new St.Label({ text: _("No open windows") });
this._emptyPlaceHolder = new St.Bin({
style_class: 'overview-empty-placeholder',
child: empty_label
});
this.actor.insert_child_below(this._emptyPlaceHolder, null);

// Track window changes
if (this.metaWorkspace) {
this._windowAddedId = this.metaWorkspace.connect('window-added',
Expand Down Expand Up @@ -838,6 +845,18 @@ WorkspaceMonitor.prototype = {
this._windowOverlaysGroup.hide();
},

_updateEmptyPlaceholder: function() {
let placeholder = this._emptyPlaceHolder;
if (this._windows.length > 0) {
placeholder.hide();
} else {
let x = this._monitor.x + Math.floor((this._monitor.width - placeholder.width)/2);
let y = this._monitor.y + Math.floor((this._monitor.height - placeholder.height)/2);
placeholder.set_position(x, y);
placeholder.show();
}
},

_doRemoveWindow : function(metaWin) {
let win = metaWin.get_compositor_private();

Expand Down Expand Up @@ -897,6 +916,8 @@ WorkspaceMonitor.prototype = {
if (this.isEmpty()) {
if(clone.closedFromOverview)
Main.overview.hide();
else
this._updateEmptyPlaceholder();
} else {
this._repositionWindowsId = Mainloop.timeout_add(750,
this._delayedWindowRepositioning.bind(this));
Expand Down Expand Up @@ -950,6 +971,8 @@ WorkspaceMonitor.prototype = {
clone.actor.set_position (this._x, this._y);
}

this._updateEmptyPlaceholder();

if (this.actor.get_stage()) {
this.positionWindows(WindowPositionFlags.ANIMATE);
}
Expand Down Expand Up @@ -994,6 +1017,8 @@ WorkspaceMonitor.prototype = {
this.positionWindows(WindowPositionFlags.ANIMATE | WindowPositionFlags.INITIAL);
else
this.positionWindows(WindowPositionFlags.INITIAL);

this._updateEmptyPlaceholder();
},

// Animates the return from Overview mode
Expand Down

0 comments on commit c4101ab

Please sign in to comment.