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
This commit is contained in:
@@ -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++) {
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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")
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user