settings.js 4.7 KB

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