prefs.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. // Global modules
  2. const GObject = imports.gi.GObject;
  3. const Gtk = imports.gi.Gtk;
  4. const Lang = imports.lang;
  5. // Internal modules
  6. const ExtensionUtils = imports.misc.extensionUtils;
  7. const Me = ExtensionUtils.getCurrentExtension();
  8. const Settings = Me.imports.settings;
  9. const WindowCornerSettings = Settings.WindowCornerSettings;
  10. function init() {
  11. // Nothing
  12. }
  13. const WindowCornerPreviewPrefsWidget = new GObject.Class({
  14. Name: "WindowCornerPreview.Prefs.Widget",
  15. GTypeName: "WindowCornerPreviewPrefsWidget",
  16. Extends: Gtk.VBox,
  17. _init: function(params) {
  18. this.parent(params);
  19. this.margin = 24;
  20. this.spacing = 6;
  21. const settings = new WindowCornerSettings();
  22. // 1. Behavior
  23. this.add(new Gtk.Label({
  24. label: "<b>Behavior when mouse is over (UNDER DEVELOPMENT)</b>",
  25. use_markup: true,
  26. xalign: 0.0,
  27. yalign: 0.0
  28. }));
  29. let boxBehavior = new Gtk.VBox({
  30. spacing: 6,
  31. margin_top: 6,
  32. margin_left: 12
  33. });
  34. const behaviors = [
  35. {
  36. mode: "seethrough",
  37. label: "See-through (one click to drive it away)"
  38. },
  39. {
  40. mode: "autohide",
  41. label: "Hide-and-seek (vanish and turn up automatically)"
  42. }
  43. ];
  44. const currentBehaviorMode = settings.behaviorMode;
  45. let radio = null;
  46. behaviors.forEach(function (behavior) {
  47. radio = new Gtk.RadioButton({
  48. active: behavior.mode === currentBehaviorMode,
  49. label: behavior.label,
  50. group: radio,
  51. sensitive: false
  52. });
  53. radio.connect("toggled", Lang.bind(this, function(button) {
  54. if (button.active) {
  55. settings.behaviorMode = behavior.mode;
  56. }
  57. }));
  58. boxBehavior.add(radio);
  59. });
  60. this.add(boxBehavior);
  61. // 2. Hide on top
  62. let checkHideOnFocus = new Gtk.CheckButton({
  63. label: "Hide when the mirrored window is on top",
  64. active: settings.focusHidden
  65. });
  66. checkHideOnFocus.connect("toggled", function(button) {
  67. settings.focusHidden = button.active;
  68. });
  69. let boxHideOnFocus = new Gtk.VBox({margin_top: 12});
  70. boxHideOnFocus.add(checkHideOnFocus);
  71. this.add(boxHideOnFocus);
  72. }
  73. });
  74. function buildPrefsWidget() {
  75. let widget = new WindowCornerPreviewPrefsWidget();
  76. widget.show_all();
  77. return widget;
  78. }