[gnome-shell-extensions] window-list: Add support for AUTO grouping
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell-extensions] window-list: Add support for AUTO grouping
- Date: Tue, 16 Apr 2013 19:31:29 +0000 (UTC)
commit 360ba435791b24b8b22b6168139476a82be2e55b
Author: Florian Müllner <fmuellner gnome org>
Date: Tue Feb 5 19:12:14 2013 +0100
window-list: Add support for AUTO grouping
In addition to "always" and "never", gnome-panel supported an "auto"
grouping mode, which only started to group items when running out of
available space. It makes sense for us to support the same option in
the window-list extension, so implement it.
https://bugzilla.gnome.org/show_bug.cgi?id=697157
extensions/window-list/extension.js | 32 ++++++++++++++++++----
...ome.shell.extensions.window-list.gschema.xml.in | 5 ++--
extensions/window-list/prefs.js | 1 +
3 files changed, 31 insertions(+), 7 deletions(-)
---
diff --git a/extensions/window-list/extension.js b/extensions/window-list/extension.js
index 9d21ded..360d1ff 100644
--- a/extensions/window-list/extension.js
+++ b/extensions/window-list/extension.js
@@ -21,7 +21,8 @@ const DND_ACTIVATE_TIMEOUT = 500;
const GroupingMode = {
NEVER: 0,
- ALWAYS: 1
+ AUTO: 1,
+ ALWAYS: 2
};
@@ -400,6 +401,20 @@ const WindowList = new Lang.Class({
let spacing = node.get_length('spacing');
this._windowList.layout_manager.spacing = spacing;
}));
+ this._windowList.connect('notify::allocation', Lang.bind(this,
+ function() {
+ if (this._groupingMode != GroupingMode.AUTO || this._grouped)
+ return;
+
+ let allocation = this._windowList.allocation;
+ let width = allocation.x2 - allocation.x1;
+ let [, natWidth] = this._windowList.get_preferred_width(-1);
+ if (width < natWidth) {
+ this._grouped = true;
+ Meta.later_add(Meta.LaterType.BEFORE_REDRAW,
+ Lang.bind(this, this._populateWindowList));
+ }
+ }));
this._trayButton = new TrayButton();
box.add(this._trayButton.actor);
@@ -475,13 +490,14 @@ const WindowList = new Lang.Class({
_groupingModeChanged: function() {
this._groupingMode = this._settings.get_enum('grouping-mode');
+ this._grouped = this._groupingMode == GroupingMode.ALWAYS;
this._populateWindowList();
},
_populateWindowList: function() {
this._windowList.destroy_all_children();
- if (this._groupingMode == GroupingMode.NEVER) {
+ if (!this._grouped) {
let windows = Meta.get_window_actors(global.screen);
for (let i = 0; i < windows.length; i++)
this._onWindowAdded(null, windows[i].metaWindow);
@@ -514,7 +530,7 @@ const WindowList = new Lang.Class({
},
_onAppStateChanged: function(appSys, app) {
- if (this._groupingMode != GroupingMode.ALWAYS)
+ if (!this._grouped)
return;
if (app.state == Shell.AppState.RUNNING)
@@ -545,7 +561,7 @@ const WindowList = new Lang.Class({
if (!Shell.WindowTracker.get_default().is_window_interesting(win))
return;
- if (this._groupingMode != GroupingMode.NEVER)
+ if (this._grouped)
return;
let button = new WindowButton(win);
@@ -556,8 +572,14 @@ const WindowList = new Lang.Class({
},
_onWindowRemoved: function(ws, win) {
- if (this._groupingMode != GroupingMode.NEVER)
+ if (this._grouped) {
+ if (this._groupingMode == GroupingMode.AUTO) {
+ this._grouped = false;
+ this._populateWindowList();
+ }
+
return;
+ }
let children = this._windowList.get_children();
for (let i = 0; i < children.length; i++) {
diff --git a/extensions/window-list/org.gnome.shell.extensions.window-list.gschema.xml.in
b/extensions/window-list/org.gnome.shell.extensions.window-list.gschema.xml.in
index 6930d2f..d5bbdf4 100644
--- a/extensions/window-list/org.gnome.shell.extensions.window-list.gschema.xml.in
+++ b/extensions/window-list/org.gnome.shell.extensions.window-list.gschema.xml.in
@@ -1,7 +1,8 @@
<schemalist gettext-domain="gnome-shell-extensions">
<enum id="org.gnome.shell.extensions.window-list.GroupingMode">
<value value="0" nick="never"/>
- <value value="1" nick="always"/>
+ <value value="1" nick="auto"/>
+ <value value="2" nick="always"/>
</enum>
<schema id="org.gnome.shell.extensions.window-list"
path="/org/gnome/shell/extensions/window-list/">
@@ -11,7 +12,7 @@
<_summary>When to group windows</_summary>
<_description>
Decides when to group windows from the same application on the
- window list. Possible values are "never" and "always".
+ window list. Possible values are "never", "auto" and "always".
</_description>
</key>
</schema>
diff --git a/extensions/window-list/prefs.js b/extensions/window-list/prefs.js
index 55045be..3db09c3 100644
--- a/extensions/window-list/prefs.js
+++ b/extensions/window-list/prefs.js
@@ -47,6 +47,7 @@ const WindowListPrefsWidget = new GObject.Class({
let modeLabels = {
'never': _("Never group windows"),
+ 'auto': _("Group windows when space is limited"),
'always': _("Always group windows")
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]