const GObject = imports.gi.GObject; const Gtk = imports.gi.Gtk; const Gettext = imports.gettext.domain('move-workspaceswitcherpopup'); const _ = Gettext.gettext; const ExtensionUtils = imports.misc.extensionUtils; const Me = ExtensionUtils.getCurrentExtension(); const Convenience = Me.imports.convenience; //------------------------------------------------------------------------------ const WSPSettingsWidget = GObject.registerClass( class WSPSettingsWidget extends Gtk.Grid { _init() { super._init({ row_homogeneous: true, margin_top: 25, margin_bottom: 25, margin_start: 25, margin_end: 25, row_spacing: 30, column_spacing: 20, halign: Gtk.Align.FILL, visible: true }); this.SETTINGS = Convenience.getSettings('org.gnome.shell.extensions.move-workspaceSwitcherPopup'); //---------------------------------------------------------------------- let horizontalPercentageLabel = new Gtk.Label({ label: _("Horizontal position (percentage)"), use_markup: true, halign: Gtk.Align.START, visible: true }); let horizontalPercentage = new Gtk.Scale({ orientation: Gtk.Orientation.HORIZONTAL, draw_value: true, has_origin: false, digits: 0, halign: Gtk.Align.FILL, hexpand: true, visible: true }); horizontalPercentage.add_mark(50, Gtk.PositionType.BOTTOM, null); horizontalPercentage.set_range(0, 100); horizontalPercentage.set_value(this.SETTINGS.get_int('horizontal')); horizontalPercentage.set_increments(1, 1); horizontalPercentage.connect('value-changed', function(w) { var value = w.get_value(); this.SETTINGS.set_int('horizontal', value); }.bind(this)); //---------------------------------------------------------------------- let verticalPercentageLabel = new Gtk.Label({ label: _("Vertical position (percentage)"), use_markup: true, halign: Gtk.Align.START, visible: true }); let verticalPercentage = new Gtk.Scale({ orientation: Gtk.Orientation.VERTICAL, draw_value: true, has_origin: false, value_pos: Gtk.PositionType.LEFT, digits: 0, valign: Gtk.Align.FILL, halign: Gtk.Align.CENTER, hexpand: false, vexpand: true, visible: true }); verticalPercentage.add_mark(50, Gtk.PositionType.RIGHT, null); verticalPercentage.set_range(0, 100); verticalPercentage.set_value(this.SETTINGS.get_int('vertical')); verticalPercentage.set_increments(1, 1); verticalPercentage.connect('value-changed', function(w) { var value = w.get_value(); this.SETTINGS.set_int('vertical', value); }.bind(this)); //---------------------------------------------------------------------- let hideSwitchLabel = new Gtk.Label({ label: _("Hide Workspace Switcher Popup Window"), use_markup: true, halign: Gtk.Align.START, visible: true }); let hideSwitch = new Gtk.Switch({ visible: true, hexpand: true, halign: Gtk.Align.CENTER, valign: Gtk.Align.CENTER }); hideSwitch.set_state(false); hideSwitch.set_halign(Gtk.Align.START) hideSwitch.set_state(this.SETTINGS.get_boolean('hide')); hideSwitch.connect('notify::active', function(widget) { this.SETTINGS.set_boolean('hide', widget.active); }.bind(this)); //---------------------------------------------------------------------- this.attach(horizontalPercentageLabel, 0, 0, 1, 1); this.attach(horizontalPercentage, 1, 0, 1, 1); this.attach(verticalPercentageLabel, 0, 1, 1, 2); this.attach(verticalPercentage, 1, 1, 1, 2); this.attach(hideSwitchLabel, 0, 3, 1, 1); this.attach(hideSwitch, 1, 3, 1, 1); } }); //------------------------------------------------------------------------------ function init() { Convenience.initTranslations(); } // This is like the "enable" in extension.js : something called each time the // user tries to access the settings' window function buildPrefsWidget() { let widget = new WSPSettingsWidget(); return widget; }