settings.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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 } 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: _("Settings"), icon_name: "settings-symbolic" });
  47. this.add_group({
  48. title: _("Settings"),
  49. description: _("Toggle Forge's high-level features"),
  50. header_suffix: makeAboutButton(window, metadata),
  51. children: [
  52. new SwitchRow({
  53. title: _("Stacked Tiling Mode"),
  54. subtitle: _("Stack windows on top of each other while still being tiled"),
  55. experimental: true,
  56. settings,
  57. bind: "stacked-tiling-mode-enabled",
  58. }),
  59. new SwitchRow({
  60. title: _("Tabbed Tiling Mode"),
  61. subtitle: _("Group tiles windows as tabs"),
  62. experimental: true,
  63. settings,
  64. bind: "tabbed-tiling-mode-enabled",
  65. }),
  66. ],
  67. });
  68. this.add_group({
  69. title: _("Tiling"),
  70. children: [
  71. new SwitchRow({
  72. title: _("Preview Hint Toggle"),
  73. experimental: true,
  74. settings,
  75. bind: "preview-hint-enabled",
  76. }),
  77. new SwitchRow({
  78. title: _("Show Focus Hint Border"),
  79. subtitle: _("Display a colored border around the focused window"),
  80. settings,
  81. bind: "focus-border-toggle",
  82. }),
  83. new SwitchRow({
  84. title: _("Show Window Split Hint Border"),
  85. subtitle: _("Show split direction border on focused window"),
  86. settings,
  87. bind: "split-border-toggle",
  88. }),
  89. new DropDownRow({
  90. title: _("Default Drag-and-Drop Center Layout"),
  91. settings,
  92. type: "s",
  93. bind: "dnd-center-layout",
  94. items: [
  95. { id: "tabbed", name: _("Tabbed") },
  96. { id: "stacked", name: _("Stacked") },
  97. ],
  98. }),
  99. new SwitchRow({
  100. title: _("Auto Split"),
  101. subtitle: _("Quarter Tiling"),
  102. experimental: true,
  103. settings,
  104. bind: "auto-split-enabled",
  105. }),
  106. new SwitchRow({
  107. title: _("Float Mode Always On Top"),
  108. subtitle: _("Floating windows always above tiling windows"),
  109. experimental: true,
  110. settings,
  111. bind: "float-always-on-top-enabled",
  112. }),
  113. new SwitchRow({
  114. title: _("Show Tiling Quick Settings"),
  115. subtitle: _("Toggle showing Forge on quick settings"),
  116. experimental: true,
  117. settings,
  118. bind: "quick-settings-enabled",
  119. }),
  120. ],
  121. });
  122. if (!production) {
  123. this.add_group({
  124. title: _("Logger"),
  125. children: [
  126. new DropDownRow({
  127. title: _("Logger Level"),
  128. settings,
  129. bind: "log-level",
  130. items: Object.entries(Logger.LOG_LEVELS).map(([name, id]) => ({ id, name })),
  131. type: "u",
  132. }),
  133. ],
  134. });
  135. }
  136. }
  137. }