[gnome-shell/wip/re-search: 137/151] workspaceThumbnail: Make ThumbnailsBox track workspace changes itself
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/wip/re-search: 137/151] workspaceThumbnail: Make ThumbnailsBox track workspace changes itself
- Date: Thu, 1 Nov 2012 17:00:04 +0000 (UTC)
commit f4814d200bd39cb8b33c66b2345897d4be1a7477
Author: Tanner Doshier <doshitan gmail com>
Date: Tue Jul 24 10:45:07 2012 -0500
workspaceThumbnail: Make ThumbnailsBox track workspace changes itself
https://bugzilla.gnome.org/show_bug.cgi?id=682050
js/ui/workspaceThumbnail.js | 29 +++++++++++++++++++++++++++++
js/ui/workspacesView.js | 4 ----
2 files changed, 29 insertions(+), 4 deletions(-)
---
diff --git a/js/ui/workspaceThumbnail.js b/js/ui/workspaceThumbnail.js
index 67aef73..8487208 100644
--- a/js/ui/workspaceThumbnail.js
+++ b/js/ui/workspaceThumbnail.js
@@ -723,6 +723,9 @@ const ThumbnailsBox = new Lang.Class({
this._switchWorkspaceNotifyId =
global.window_manager.connect('switch-workspace',
Lang.bind(this, this._activeWorkspaceChanged));
+ this._nWorkspacesNotifyId =
+ global.screen.connect('notify::n-workspaces',
+ Lang.bind(this, this._workspacesChanged));
this._targetScale = 0;
this._scale = 0;
@@ -751,12 +754,38 @@ const ThumbnailsBox = new Lang.Class({
global.window_manager.disconnect(this._switchWorkspaceNotifyId);
this._switchWorkspaceNotifyId = 0;
}
+ if (this._nWorkspacesNotifyId > 0) {
+ global.screen.disconnect(this._nWorkspacesNotifyId);
+ this._nWorkspacesNotifyId = 0;
+ }
for (let w = 0; w < this._thumbnails.length; w++)
this._thumbnails[w].destroy();
this._thumbnails = [];
},
+ _workspacesChanged: function() {
+ let oldNumWorkspaces = this._thumbnails.length;
+ let newNumWorkspaces = global.screen.n_workspaces;
+ let active = global.screen.get_active_workspace_index();
+
+ if (newNumWorkspaces > oldNumWorkspaces) {
+ this.addThumbnails(oldNumWorkspaces, newNumWorkspaces - oldNumWorkspaces);
+ } else {
+ let removedIndex;
+ let removedNum = oldNumWorkspaces - newNumWorkspaces;
+ for (let w = 0; w < oldNumWorkspaces; w++) {
+ let metaWorkspace = global.screen.get_workspace_by_index(w);
+ if (this._thumbnails[w].metaWorkspace != metaWorkspace) {
+ removedIndex = w;
+ break;
+ }
+ }
+
+ this.removeThumbnails(removedIndex, removedNum);
+ }
+ },
+
addThumbnails: function(start, count) {
for (let k = start; k < start + count; k++) {
let metaWorkspace = global.screen.get_workspace_by_index(k);
diff --git a/js/ui/workspacesView.js b/js/ui/workspacesView.js
index 217cdec..79f0ff7 100644
--- a/js/ui/workspacesView.js
+++ b/js/ui/workspacesView.js
@@ -934,8 +934,6 @@ const WorkspacesDisplay = new Lang.Class({
}
m++;
}
-
- this._thumbnailsBox.addThumbnails(oldNumWorkspaces, newNumWorkspaces - oldNumWorkspaces);
} else {
// Assume workspaces are only removed sequentially
// (e.g. 2,3,4 - not 2,4,7)
@@ -958,8 +956,6 @@ const WorkspacesDisplay = new Lang.Class({
lostWorkspaces[l].destroy();
}
}
-
- this._thumbnailsBox.removeThumbnails(removedIndex, removedNum);
}
for (let i = 0; i < this._workspacesViews.length; i++)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]