diff --git a/metadata.json b/metadata.json index 11934a6..3db8a33 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "WinTile", - "description": "WinTile is a hotkey driven window tiling system for GNOME that imitates the standard Win-Arrow keys of Windows 10, allowing you to maximize, maximize to sides, or 1/4 sized to corner across a single or multiple monitors using just Super+Arrow.\n\nAs of v16, WinTile also supports:\n- 2-5 columns and 1-4 rows for standard or ultrawide monitors\n- Top/bottom half support\n- Mouse preview and snapping for placing windows\n- 'Maximize' mode, which adds/removes GNOME animations\n- 'Ultrawide-only' mode, to allow standard screens to have different cols/row than ultrawides\n- Portrait screens will automatically swap columns and rows\n- Add gaps around tiles to avoid the 'crowded elevator' feeling'\n- Ctrl+Super+Arrow to grow a tile in that direction if space is available\n- Ctrl+drag to drop a tile in a specific spot\n- Ctrl+Super+drag to draw a grid for the new tile", + "description": "WinTile is a hotkey driven window tiling system for GNOME that imitates the standard Win-Arrow keys of Windows 10, allowing you to maximize, maximize to sides, or 1/4 sized to corner across a single or multiple monitors using just Super+Arrow.\n\nAs of v16, WinTile also supports:\n- 1-5 columns and 1-5 rows for standard or ultrawide monitors\n- Top/bottom half support\n- Mouse preview and snapping for placing windows\n- 'Maximize' mode, which adds/removes GNOME animations\n- 'Ultrawide-only' mode, to allow standard screens to have different cols/row than ultrawides\n- Portrait screens will automatically swap columns and rows\n- Add gaps around tiles to avoid the 'crowded elevator' feeling'\n- Ctrl+Super+Arrow to grow a tile in that direction if space is available\n- Ctrl+drag to drop a tile in a specific spot\n- Ctrl+Super+drag to draw a grid for the new tile", "uuid": "wintile@nowsci.com", "url": "https://github.com/fmstrat/wintile", "settings-schema":"org.gnome.shell.extensions.wintile", diff --git a/prefs.js b/prefs.js index 4c31518..654dbe2 100644 --- a/prefs.js +++ b/prefs.js @@ -2,7 +2,6 @@ const Gio = imports.gi.Gio; const Gtk = imports.gi.Gtk; -const Adw = imports.gi.Adw; const ExtensionUtils = imports.misc.extensionUtils; const Me = ExtensionUtils.getCurrentExtension(); @@ -10,6 +9,8 @@ const Me = ExtensionUtils.getCurrentExtension(); const Gettext = imports.gettext; const _ = Gettext.domain('wintile').gettext; +const gsettings = ExtensionUtils.getSettings(); + /** * */ @@ -17,238 +18,36 @@ function init() { // empty } + /** * * @param {object} window - Don't worry about this. Gnome handles it for you. */ function fillPreferencesWindow(window) { - let gsettings; - gsettings = ExtensionUtils.getSettings(); - - const gridPage = new Adw.PreferencesPage({ - name: 'Dimensions', - title: 'Dimensions', - icon_name: 'preferences-desktop-apps-symbolic', - }); + let builder = Gtk.Builder.new(); + builder.add_from_file(`${Me.path}/settings.ui`); + let gridPage = builder.get_object('gridPage'); + let behaviorPage = builder.get_object('behaviorPage'); window.add(gridPage); - - const gridGroup = new Adw.PreferencesGroup({ - title: 'Grid size', - description: `Configure the rows and columns of ${Me.metadata.name}`, - }); - gridPage.add(gridGroup); - - // COLUMNS - const colsRow = new Adw.ActionRow({ - title: 'Columns', - }); - gridGroup.add(colsRow); - - let colsSettingInt = new Gtk.SpinButton({ - adjustment: new Gtk.Adjustment({ - 'lower': 1, - 'step-increment': 1, - 'upper': 5, - 'value': gsettings.get_int('cols'), - }), - }); - colsRow.add_suffix(colsSettingInt); - - // ROWS - const rowsRow = new Adw.ActionRow({ - title: 'Rows', - }); - gridGroup.add(rowsRow); - - let rowsSettingInt = new Gtk.SpinButton({ - adjustment: new Gtk.Adjustment({ - 'lower': 1, - 'step-increment': 1, - 'upper': 5, - 'value': gsettings.get_int('rows'), - }), - }); - rowsRow.add_suffix(rowsSettingInt); - - // ULTRAWIDE - const ultrawideOnlyRow = new Adw.ActionRow({ - title: 'Use different rows and columns for non-ultrawide monitors', - }); - gridGroup.add(ultrawideOnlyRow); - - const ultrawideOnlyInput = new Gtk.CheckButton(); - ultrawideOnlyRow.add_suffix(ultrawideOnlyInput); - ultrawideOnlyRow.set_activatable_widget(ultrawideOnlyInput); - ultrawideOnlyInput.active = gsettings.get_boolean('ultrawide-only'); - - // preference group - const nonUltrawideGroup = new Adw.PreferencesGroup({ - title: 'Number of columns for non-ultrawide', - description: 'Configure the separate rows and columns of non-ultrawides', - }); - gridPage.add(nonUltrawideGroup); - - // NON-ULTRAWIDE COLUMNS - const nonUltraColsRow = new Adw.ActionRow({ - title: 'Columns', - }); - nonUltrawideGroup.add(nonUltraColsRow); - - let nonUltraColsSettingInt = new Gtk.SpinButton({ - adjustment: new Gtk.Adjustment({ - 'lower': 1, - 'step-increment': 1, - 'upper': 5, - 'value': gsettings.get_int('non-ultra-cols'), - }), - }); - nonUltraColsRow.add_suffix(nonUltraColsSettingInt); - - // NON-ULTRAWIDE ROWS - const nonUltraRowsRow = new Adw.ActionRow({ - title: 'Rows', - }); - nonUltrawideGroup.add(nonUltraRowsRow); - - let nonUltraRowsSettingInt = new Gtk.SpinButton({ - adjustment: new Gtk.Adjustment({ - 'lower': 1, - 'step-increment': 1, - 'upper': 5, - 'value': gsettings.get_int('non-ultra-rows'), - }), - }); - nonUltraRowsRow.add_suffix(nonUltraRowsSettingInt); - - const behaviorPage = new Adw.PreferencesPage({ - name: 'Behavior', - title: 'Behavior', - icon_name: 'applications-system-symbolic', - }); window.add(behaviorPage); - const behaviorGroup = new Adw.PreferencesGroup({ - title: 'Behavior', - }); - behaviorPage.add(behaviorGroup); - - // Maximize setting - const maximizeRow = new Adw.ActionRow({ - title: 'Use true maximizing of windows', - }); - behaviorGroup.add(maximizeRow); - - const maximizeInput = new Gtk.CheckButton(); - maximizeRow.add_suffix(maximizeInput); - maximizeRow.set_activatable_widget(maximizeInput); - maximizeInput.active = gsettings.get_boolean('use-maximize'); - - // Minimize setting - const minimizeRow = new Adw.ActionRow({ - title: 'Use true miniming of windows', - }); - behaviorGroup.add(minimizeRow); - - const minimizeInput = new Gtk.CheckButton(); - minimizeRow.add_suffix(minimizeInput); - minimizeRow.set_activatable_widget(minimizeInput); - minimizeInput.active = gsettings.get_boolean('use-minimize'); - - // Preview settings - const previewRow = new Adw.ActionRow({ - title: 'Enable preview and snapping when dragging windows', - }); - behaviorGroup.add(previewRow); - - const previewInput = new Gtk.CheckButton(); - previewRow.add_suffix(previewInput); - previewRow.set_activatable_widget(previewInput); - previewInput.active = gsettings.get_boolean('preview'); - - // Preview distance - const previewDistanceRow = new Adw.ActionRow({ - title: 'Pixels from edge to start preview', - }); - behaviorGroup.add(previewDistanceRow); - - let previewDistanceSettingInt = new Gtk.SpinButton({ - adjustment: new Gtk.Adjustment({ - 'lower': 0, - 'step-increment': 1, - 'upper': 150, - 'value': gsettings.get_int('distance'), - }), - }); - previewDistanceRow.add_suffix(previewDistanceSettingInt); - - - // Delay - const previewDelayRow = new Adw.ActionRow({ - title: 'Delay in ms before preview displays', - }); - behaviorGroup.add(previewDelayRow); - - let previewDelaySettingInt = new Gtk.SpinButton({ - adjustment: new Gtk.Adjustment({ - 'lower': 25, - 'step-increment': 1, - 'upper': 1000, - 'value': gsettings.get_int('delay'), - }), - }); - previewDelayRow.add_suffix(previewDelaySettingInt); - - - // Double width previews - const doubleWidthRow = new Adw.ActionRow({ - title: 'Use double width previews on sides in 4 and 5 column mode', - }); - behaviorGroup.add(doubleWidthRow); - - const doubleWidthInput = new Gtk.CheckButton(); - doubleWidthRow.add_suffix(doubleWidthInput); - doubleWidthRow.set_activatable_widget(doubleWidthInput); - doubleWidthInput.active = gsettings.get_boolean('double-width'); - - // Gap setting - const gapRow = new Adw.ActionRow({ - title: 'Gap width around tiles', - }); - behaviorGroup.add(gapRow); - - let gapSettingInt = new Gtk.SpinButton({ - adjustment: new Gtk.Adjustment({ - 'lower': 0, - 'step-increment': 2, - 'upper': 50, - 'value': gsettings.get_int('gap'), - }), - }); - gapRow.add_suffix(gapSettingInt); - - // Debug setting - const debugRow = new Adw.ActionRow({ - title: 'Turn on debugging', - }); - behaviorGroup.add(debugRow); - - const debugInput = new Gtk.CheckButton(); - debugRow.add_suffix(debugInput); - debugRow.set_activatable_widget(debugInput); - debugInput.active = gsettings.get_boolean('debug'); - - - + // let gsettings; + // gsettings = ExtensionUtils.getSettings(); const bindSettings = (key, input) => { - gsettings.bind(key, input, 'active', Gio.SettingsBindFlags.DEFAULT); + key.value = gsettings.get_value(input).deep_unpack(); + gsettings.bind(input, key, 'active', Gio.SettingsBindFlags.DEFAULT); }; - const connectAndSetInt = (setting, key) => { - setting.connect('value-changed', entry => { - gsettings.set_int(key, entry.value); + const connectAndSetInt = (key, input) => { + key.value = gsettings.get_value(input).deep_unpack(); + key.connect('value-changed', entry => { + gsettings.set_int(input, entry.value); }); }; + let ultrawideOnlyInput = builder.get_object('ultrawideOnlyInput'); + let nonUltrawideGroup = builder.get_object('nonUltrawideGroup'); + const toggleUltrawide = () => { if (ultrawideOnlyInput.active) { // Show rows and columns options @@ -259,23 +58,22 @@ function fillPreferencesWindow(window) { } }; - // settings that aren't toggles need a connect - connectAndSetInt(colsSettingInt, 'cols'); - connectAndSetInt(rowsSettingInt, 'rows'); - connectAndSetInt(nonUltraColsSettingInt, 'non-ultra-cols'); - connectAndSetInt(nonUltraRowsSettingInt, 'non-ultra-rows'); - connectAndSetInt(previewDistanceSettingInt, 'distance'); - connectAndSetInt(previewDelaySettingInt, 'delay'); - connectAndSetInt(gapSettingInt, 'gap'); + connectAndSetInt(builder.get_object('colsSettingInt'), 'cols'); + connectAndSetInt(builder.get_object('rowsSettingInt'), 'rows'); + connectAndSetInt(builder.get_object('nonUltraColsSettingInt'), 'non-ultra-cols'); + connectAndSetInt(builder.get_object('nonUltraRowsSettingInt'), 'non-ultra-rows'); + connectAndSetInt(builder.get_object('previewDistanceSettingInt'), 'distance'); + connectAndSetInt(builder.get_object('previewDelaySettingInt'), 'delay'); + connectAndSetInt(builder.get_object('gapSettingInt'), 'gap'); // all other settings need a bind - bindSettings('ultrawide-only', ultrawideOnlyInput); - bindSettings('use-maximize', maximizeInput); - bindSettings('use-minimize', minimizeInput); - bindSettings('preview', previewInput); - bindSettings('double-width', doubleWidthInput); - bindSettings('debug', debugInput); + bindSettings(builder.get_object('ultrawideOnlyInput'), 'ultrawide-only'); + bindSettings(builder.get_object('maximizeInput'), 'use-maximize'); + bindSettings(builder.get_object('minimizeInput'), 'use-minimize'); + bindSettings(builder.get_object('previewInput'), 'preview'); + bindSettings(builder.get_object('doubleWidthInput'), 'double-width'); + bindSettings(builder.get_object('debugInput'), 'debug'); ultrawideOnlyInput.connect('notify::active', toggleUltrawide); // make sure that the non-ultrawide menu is hidden unless it's enabled diff --git a/settings.ui b/settings.ui new file mode 100644 index 0000000..1fce634 --- /dev/null +++ b/settings.ui @@ -0,0 +1,263 @@ + + + + Dimensions + Dimensions + preferences-desktop-apps-symbolic + + + + Grid size + Configure the rows and columns of YourExtensionName + + + + Columns + + + + colsAdjustment + + + + + + 1 + 1 + 5 + 2 + + + + + + + + Rows + + + + rowsAdjustment + + + + + + 1 + 1 + 5 + 2 + + + + + + + + Use different rows and columns for non-ultrawide monitors + + + + false + + + + + + + + + + Number of columns for non-ultrawide + Configure the separate rows and columns of non-ultrawides + + + + Columns + + + + nonUltraColsAdjustment + + + + + + 1 + 1 + 5 + 2 + + + + + + + + Rows + + + + nonUltraRowsAdjustment + + + + + + 1 + 1 + 5 + 2 + + + + + + + + + + + + Behavior + Behavior + applications-system-symbolic + + + + + Behavior + + + + Use true maximizing of windows + + + + true + + + + + + + + + Use true minimizing of windows + + + + true + + + + + + + + + Enable preview and snapping when dragging windows + + + + true + + + + + + + + + Pixels from edge to start preview + + + + previewDistanceAdjustment + + + + + + 0 + 1 + 150 + 0 + + + + + + + + + Delay in ms before preview displays + + + + previewDelayAdjustment + + + + + + 25 + 1 + 1000 + 25 + + + + + + + + + Use double width previews on sides in 4 and 5 column mode + + + + true + + + + + + + + + Gap width around tiles + + + + gapAdjustment + + + + + + 0 + 2 + 50 + 0 + + + + + + + + + Turn on debugging + + + + true + + + + + + + +