prefs.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /****************************************************************************
  2. ** Auto Activities - Show activities overlay when there are no windows.
  3. ** Copyright (C) 2021 jan Sena <mi-jan-sena@proton.me> and Cleo Menezes Jr.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <https://www.gnu.org/licenses/>.
  17. ****************************************************************************/
  18. "use strict";
  19. import Gtk from "gi://Gtk";
  20. import Gio from "gi://Gio";
  21. import { ExtensionPreferences } from "resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js";
  22. export default class MyExtensionPreferences extends ExtensionPreferences {
  23. fillPreferencesWindow(window) {
  24. window._settings = this.getSettings();
  25. window.set_default_size(360, 724);
  26. const builder = new Gtk.Builder();
  27. builder.add_from_file(`${this.path}/prefs.ui`);
  28. const isolateWorkspaces = builder.get_object("IsolateWorkspacesSwitch");
  29. isolateWorkspaces.set_active(
  30. window._settings.get_boolean("isolate-workspaces"),
  31. );
  32. window._settings.bind(
  33. "isolate-workspaces",
  34. isolateWorkspaces,
  35. "active",
  36. Gio.SettingsBindFlags.DEFAULT,
  37. );
  38. const isolateMonitors = builder.get_object("IsolateMonitorsSwitch");
  39. isolateMonitors.set_active(
  40. window._settings.get_boolean("isolate-monitors"),
  41. );
  42. window._settings.bind(
  43. "isolate-monitors",
  44. isolateMonitors,
  45. "active",
  46. Gio.SettingsBindFlags.DEFAULT,
  47. );
  48. const skipTaskbar = builder.get_object("SkipTaskbarSwitch");
  49. skipTaskbar.set_active(window._settings.get_boolean("skip-taskbar"));
  50. window._settings.bind(
  51. "skip-taskbar",
  52. skipTaskbar,
  53. "active",
  54. Gio.SettingsBindFlags.DEFAULT,
  55. );
  56. const skipLastWorkspace = builder.get_object("SkipLastWorkspaceSwitch");
  57. skipLastWorkspace.set_active(
  58. window._settings.get_boolean("skip-last-workspace"),
  59. );
  60. window._settings.bind(
  61. "skip-last-workspace",
  62. skipLastWorkspace,
  63. "active",
  64. Gio.SettingsBindFlags.DEFAULT,
  65. );
  66. const detectMinimized = builder.get_object("MinimizedSwitch");
  67. detectMinimized.set_active(
  68. window._settings.get_boolean("detect-minimized"),
  69. );
  70. window._settings.bind(
  71. "detect-minimized",
  72. detectMinimized,
  73. "active",
  74. Gio.SettingsBindFlags.DEFAULT,
  75. );
  76. const hideOnNewWindow = builder.get_object("HideOnNewWindowSwitch");
  77. hideOnNewWindow.set_active(
  78. window._settings.get_boolean("hide-on-new-window"),
  79. );
  80. window._settings.bind(
  81. "hide-on-new-window",
  82. hideOnNewWindow,
  83. "active",
  84. Gio.SettingsBindFlags.DEFAULT,
  85. );
  86. const checkingDelay = builder.get_object("CheckingDelayEntry");
  87. checkingDelay.set_value(
  88. window._settings.get_int("window-checking-delay"),
  89. );
  90. window._settings.bind(
  91. "window-checking-delay",
  92. checkingDelay,
  93. "value",
  94. Gio.SettingsBindFlags.DEFAULT,
  95. );
  96. const showApps = builder.get_object("ShowAppsSwitch");
  97. showApps.set_active(window._settings.get_boolean("show-apps"));
  98. window._settings.bind(
  99. "show-apps",
  100. showApps,
  101. "active",
  102. Gio.SettingsBindFlags.DEFAULT,
  103. );
  104. const page = builder.get_object("MainWidget");
  105. window.add(page);
  106. }
  107. }