settings.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. // Gnome imports
  2. import Adw from "gi://Adw";
  3. import Gtk from "gi://Gtk";
  4. import GObject from "gi://GObject";
  5. // Shared state
  6. import { Logger } from "../shared/logger.js";
  7. import { production } from "../shared/settings.js";
  8. // Prefs UI
  9. import { DropDownRow, SwitchRow, PreferencesPage, EntryRow } from "./widgets.js";
  10. // Extension imports
  11. import { gettext as _ } from "resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js";
  12. import { PACKAGE_VERSION } from "resource:///org/gnome/Shell/Extensions/js/misc/config.js";
  13. import { developers } from "./metadata.js";
  14. function showAboutWindow(parent, { version, description: comments }) {
  15. const abt = new Adw.AboutWindow({
  16. ...(parent && { transient_for: parent }),
  17. // TODO: fetch these from github at build time
  18. application_name: _("Forge"),
  19. application_icon: "forge-logo-symbolic",
  20. version: `${PACKAGE_VERSION}-${version.toString()}`,
  21. copyright: `© 2021-${new Date().getFullYear()} jmmaranan`,
  22. issue_url: "https://github.com/forge-ext/forge/issues/new",
  23. license_type: Gtk.License.GPL_3_0,
  24. website: "https://github.com/forge-ext/forge",
  25. developers,
  26. comments,
  27. designers: [],
  28. translator_credits: _("translator-credits"),
  29. });
  30. abt.present();
  31. }
  32. function makeAboutButton(parent, metadata) {
  33. const button = new Gtk.Button({
  34. icon_name: "help-about-symbolic",
  35. tooltip_text: _("About"),
  36. valign: Gtk.Align.CENTER,
  37. });
  38. button.connect("clicked", () => showAboutWindow(parent, metadata));
  39. return button;
  40. }
  41. export class SettingsPage extends PreferencesPage {
  42. static {
  43. GObject.registerClass(this);
  44. }
  45. constructor({ settings, window, metadata }) {
  46. super({ title: _("Tiling"), icon_name: "view-grid-symbolic" });
  47. this.add_group({
  48. title: _("Behavior"),
  49. description: _("Change how the tiling behaves"),
  50. header_suffix: makeAboutButton(window, metadata),
  51. children: [
  52. new SwitchRow({
  53. title: _("Focus on Hover"),
  54. subtitle: _("Window focus follows the pointer"),
  55. experimental: true,
  56. settings,
  57. bind: "focus-on-hover-enabled",
  58. }),
  59. new SwitchRow({
  60. title: _("Move pointer with focused window"),
  61. subtitle: _("Moves the pointer when focusing or swapping via keyboard"),
  62. experimental: true,
  63. settings,
  64. bind: "move-pointer-focus-enabled",
  65. }),
  66. new SwitchRow({
  67. title: _("Quarter tiling"),
  68. subtitle: _("Places new windows in a clock-wise fashion"),
  69. experimental: true,
  70. settings,
  71. bind: "auto-split-enabled",
  72. }),
  73. new SwitchRow({
  74. title: _("Stacked tiling"),
  75. subtitle: _("Stacks windows on top of each other while still tiling them"),
  76. experimental: true,
  77. settings,
  78. bind: "stacked-tiling-mode-enabled",
  79. }),
  80. new SwitchRow({
  81. title: _("Tabbed tiling"),
  82. subtitle: _("Groups windows as tabs"),
  83. experimental: true,
  84. settings,
  85. bind: "tabbed-tiling-mode-enabled",
  86. }),
  87. new SwitchRow({
  88. title: _("Auto exit tabbed tiling"),
  89. subtitle: _("Exit tabbed tiling mode when only a single tab remains"),
  90. settings,
  91. bind: "auto-exit-tabbed",
  92. bind: "move-pointer-focus-enabled",
  93. }),
  94. new DropDownRow({
  95. title: _("Drag-and-drop behavior"),
  96. subtitle: _("What to do when dragging one window on top of another"),
  97. settings,
  98. type: "s",
  99. bind: "dnd-center-layout",
  100. items: [
  101. { id: "swap", name: _("Swap") },
  102. { id: "tabbed", name: _("Tabbed") },
  103. { id: "stacked", name: _("Stacked") },
  104. ],
  105. }),
  106. new SwitchRow({
  107. title: _("Always on Top mode for floating windows"),
  108. subtitle: _("Makes floating windows appear above tiled windows"),
  109. experimental: true,
  110. settings,
  111. bind: "float-always-on-top-enabled",
  112. }),
  113. ],
  114. });
  115. this.add_group({
  116. title: _("Non-tiling workspaces"),
  117. description: _("Disables tiling on specified workspaces. Starts from 0, separated by commas"),
  118. children: [
  119. new EntryRow({
  120. title: _("Example: 0,1,2"),
  121. settings,
  122. bind: "workspace-skip-tile",
  123. }),
  124. ],
  125. });
  126. if (!production) {
  127. this.add_group({
  128. title: _("Logger"),
  129. children: [
  130. new DropDownRow({
  131. title: _("Logger Level"),
  132. settings,
  133. bind: "log-level",
  134. items: Object.entries(Logger.LOG_LEVELS).map(([name, id]) => ({ id, name })),
  135. type: "u",
  136. }),
  137. ],
  138. });
  139. }
  140. }
  141. }