| 1 |
// SPDX-FileCopyrightText: 2013 Florian Müllner <[email protected]> |
| 2 |
// SPDX-FileCopyrightText: 2014 Sylvain Pasche <[email protected]> |
| 3 |
// |
| 4 |
// SPDX-License-Identifier: GPL-2.0-or-later |
| 5 |
|
| 6 |
import Adw from 'gi://Adw'; |
| 7 |
import Gio from 'gi://Gio'; |
| 8 |
import GLib from 'gi://GLib'; |
| 9 |
import GObject from 'gi://GObject'; |
| 10 |
import Gtk from 'gi://Gtk'; |
| 11 |
|
| 12 |
import {ExtensionPreferences, gettext as _} from 'resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js'; |
| 13 |
|
| 14 |
import {WorkspacesPage} from './workspacePrefs.js'; |
| 15 |
|
| 16 |
class WindowListPage extends Adw.PreferencesPage { |
| 17 |
static { |
| 18 |
GObject.registerClass(this); |
| 19 |
} |
| 20 |
|
| 21 |
constructor(settings) { |
| 22 |
super({ |
| 23 |
title: _('Window List'), |
| 24 |
icon_name: 'focus-windows-symbolic', |
| 25 |
}); |
| 26 |
|
| 27 |
this._actionGroup = new Gio.SimpleActionGroup(); |
| 28 |
this.insert_action_group('window-list', this._actionGroup); |
| 29 |
|
| 30 |
this._settings = settings; |
| 31 |
this._actionGroup.add_action( |
| 32 |
this._settings.create_action('grouping-mode')); |
| 33 |
this._actionGroup.add_action( |
| 34 |
this._settings.create_action('show-on-all-monitors')); |
| 35 |
this._actionGroup.add_action( |
| 36 |
this._settings.create_action('display-all-workspaces')); |
| 37 |
this._actionGroup.add_action( |
| 38 |
this._settings.create_action('embed-previews')); |
| 39 |
|
| 40 |
const groupingGroup = new Adw.PreferencesGroup({ |
| 41 |
title: _('Window Grouping'), |
| 42 |
}); |
| 43 |
this.add(groupingGroup); |
| 44 |
|
| 45 |
const modes = [ |
| 46 |
{mode: 'never', title: _('Never group windows')}, |
| 47 |
{mode: 'auto', title: _('Group windows when space is limited')}, |
| 48 |
{mode: 'always', title: _('Always group windows')}, |
| 49 |
]; |
| 50 |
|
| 51 |
for (const {mode, title} of modes) { |
| 52 |
const check = new Gtk.CheckButton({ |
| 53 |
action_name: 'window-list.grouping-mode', |
| 54 |
action_target: new GLib.Variant('s', mode), |
| 55 |
}); |
| 56 |
const row = new Adw.ActionRow({ |
| 57 |
activatable_widget: check, |
| 58 |
title, |
| 59 |
}); |
| 60 |
row.add_prefix(check); |
| 61 |
groupingGroup.add(row); |
| 62 |
} |
| 63 |
|
| 64 |
const miscGroup = new Adw.PreferencesGroup(); |
| 65 |
this.add(miscGroup); |
| 66 |
|
| 67 |
let row = new Adw.SwitchRow({ |
| 68 |
title: _('Show on all monitors'), |
| 69 |
action_name: 'window-list.show-on-all-monitors', |
| 70 |
}); |
| 71 |
miscGroup.add(row); |
| 72 |
|
| 73 |
row = new Adw.SwitchRow({ |
| 74 |
title: _('Show windows from all workspaces'), |
| 75 |
action_name: 'window-list.display-all-workspaces', |
| 76 |
}); |
| 77 |
miscGroup.add(row); |
| 78 |
} |
| 79 |
} |
| 80 |
|
| 81 |
export default class WindowListPrefs extends ExtensionPreferences { |
| 82 |
fillPreferencesWindow(window) { |
| 83 |
const settings = this.getSettings(); |
| 84 |
window.add(new WindowListPage(settings)); |
| 85 |
window.add(new WorkspacesPage(settings)); |
| 86 |
} |
| 87 |
} |