From ce75e3f3fccedd0d080cf2d6276640d86c78715d Mon Sep 17 00:00:00 2001 From: MeowcaTheoRange Date: Tue, 3 Oct 2023 09:55:56 -0500 Subject: [PATCH 1/9] Add "auto unstack" switch --- .prettierignore | 1 + ...ome.shell.extensions.pop-shell.gschema.xml | 5 + src/auto_tiler.ts | 6 +- src/forest.ts | 34 +- src/prefs.ts | 498 +++++++++--------- src/settings.ts | 372 ++++++------- src/tiling.ts | 19 +- 7 files changed, 503 insertions(+), 432 deletions(-) create mode 100644 .prettierignore diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 00000000..fa29cdff --- /dev/null +++ b/.prettierignore @@ -0,0 +1 @@ +** \ No newline at end of file diff --git a/schemas/org.gnome.shell.extensions.pop-shell.gschema.xml b/schemas/org.gnome.shell.extensions.pop-shell.gschema.xml index fc766da7..9c08724c 100644 --- a/schemas/org.gnome.shell.extensions.pop-shell.gschema.xml +++ b/schemas/org.gnome.shell.extensions.pop-shell.gschema.xml @@ -64,6 +64,11 @@ Hide the outer gap when a tree contains only one window + + false + Destroy a window stack when it contains only one window + + false Snaps windows to the tiling grid on drop diff --git a/src/auto_tiler.ts b/src/auto_tiler.ts index d193b9c6..d7b0fb84 100644 --- a/src/auto_tiler.ts +++ b/src/auto_tiler.ts @@ -1,12 +1,12 @@ const Me = imports.misc.extensionUtils.getCurrentExtension(); import * as ecs from 'ecs'; +import * as geom from 'geom'; import * as lib from 'lib'; import * as log from 'log'; import * as node from 'node'; import * as result from 'result'; import * as stack from 'stack'; -import * as geom from 'geom'; import * as tiling from 'tiling'; import type { Entity } from 'ecs'; @@ -232,9 +232,9 @@ export class AutoTiler { } /** Detaches the window from a tiling branch, if it is attached to one. */ - detach_window(ext: Ext, win: Entity) { + detach_window(ext: Ext, win: Entity, destroy_stack: boolean = true) { this.attached.take_with(win, (prev_fork: Entity) => { - const reflow_fork = this.forest.detach(ext, prev_fork, win); + const reflow_fork = this.forest.detach(ext, prev_fork, win, destroy_stack); if (reflow_fork) { const fork = reflow_fork[1]; diff --git a/src/forest.ts b/src/forest.ts index cf88d526..b8df4557 100644 --- a/src/forest.ts +++ b/src/forest.ts @@ -3,19 +3,19 @@ const Me = imports.misc.extensionUtils.getCurrentExtension(); import * as arena from 'arena'; import * as Ecs from 'ecs'; +import * as Fork from 'fork'; +import * as geom from 'geom'; import * as Lib from 'lib'; import * as log from 'log'; import * as movement from 'movement'; -import * as Rect from 'rectangle'; import * as Node from 'node'; -import * as Fork from 'fork'; -import * as geom from 'geom'; +import * as Rect from 'rectangle'; import type { Entity } from 'ecs'; -import type { Rectangle } from './rectangle'; -import type { ShellWindow } from './window'; import type { Ext } from './extension'; +import type { Rectangle } from './rectangle'; import { Stack } from './stack'; +import type { ShellWindow } from './window'; const { Arena } = arena; const { Meta } = imports.gi; @@ -350,7 +350,7 @@ export class Forest extends Ecs.World { } /** Detaches an entity from the a fork, re-arranging the fork's tree as necessary */ - detach(ext: Ext, fork_entity: Entity, window: Entity): [Entity, Fork.Fork] | null { + detach(ext: Ext, fork_entity: Entity, window: Entity, destroy_stack: boolean = false): [Entity, Fork.Fork] | null { const fork = this.forks.get(fork_entity); if (!fork) return null; @@ -387,8 +387,11 @@ export class Forest extends Ecs.World { ext, fork.left.inner as Node.NodeStack, window, - () => { - if (fork.right) { + destroy_stack, + (window: undefined | Entity) => { + if (window) + fork.left = Node.Node.window(window); + else if (fork.right) { fork.left = fork.right fork.right = null if (parent) { @@ -428,9 +431,14 @@ export class Forest extends Ecs.World { ext, fork.right.inner as Node.NodeStack, window, - () => { - fork.right = null + destroy_stack, + (window) => { + if (window) + fork.right = Node.Node.window(window); + else { + fork.right = null; this.reassign_to_parent(fork, fork.left) + } }, ); } @@ -714,7 +722,7 @@ export class Forest extends Ecs.World { } /** Removes window from stack, destroying the stack if it was the last window. */ - private remove_from_stack(ext: Ext, stack: Node.NodeStack, window: Entity, on_last: () => void) { + private remove_from_stack(ext: Ext, stack: Node.NodeStack, window: Entity, destroy_stack: boolean, on_last: (win?: Entity) => void) { if (stack.entities.length === 1) { this.stacks.remove(stack.idx)?.destroy(); on_last(); @@ -723,6 +731,10 @@ export class Forest extends Ecs.World { if (s) { Node.stack_remove(this, stack, window) } + if (destroy_stack && stack.entities.length === 1) { + on_last(stack.entities[0]) + this.stacks.remove(stack.idx)?.destroy() + } } const win = ext.windows.get(window); diff --git a/src/prefs.ts b/src/prefs.ts index 7d326283..04a5385e 100644 --- a/src/prefs.ts +++ b/src/prefs.ts @@ -1,4 +1,4 @@ -export { } +export { }; const ExtensionUtils = imports.misc.extensionUtils; // @ts-ignore @@ -8,270 +8,294 @@ const { Gtk } = imports.gi; const { Settings } = imports.gi.Gio; -import * as settings from 'settings'; -import * as log from 'log'; import * as focus from 'focus'; +import * as log from 'log'; +import * as settings from 'settings'; interface AppWidgets { - fullscreen_launcher: any, - stacking_with_mouse: any, - inner_gap: any, - mouse_cursor_follows_active_window: any, - outer_gap: any, - show_skip_taskbar: any, - smart_gaps: any, - snap_to_grid: any, - window_titles: any, - mouse_cursor_focus_position: any, - log_level: any, + fullscreen_launcher: any; + stacking_with_mouse: any; + inner_gap: any; + mouse_cursor_follows_active_window: any; + outer_gap: any; + show_skip_taskbar: any; + smart_gaps: any; + auto_unstack: any; + snap_to_grid: any; + window_titles: any; + mouse_cursor_focus_position: any; + log_level: any; } // @ts-ignore -function init() { } +function init() {} function settings_dialog_new(): Gtk.Container { - let [app, grid] = settings_dialog_view(); - - let ext = new settings.ExtensionSettings(); - - app.window_titles.set_active(ext.show_title()); - app.window_titles.connect('state-set', (_widget: any, state: boolean) => { - ext.set_show_title(state); - Settings.sync(); - }); - - app.snap_to_grid.set_active(ext.snap_to_grid()); - app.snap_to_grid.connect('state-set', (_widget: any, state: boolean) => { - ext.set_snap_to_grid(state); - Settings.sync(); - }); - - app.smart_gaps.set_active(ext.smart_gaps()); - app.smart_gaps.connect('state-set', (_widget: any, state: boolean) => { - ext.set_smart_gaps(state); - Settings.sync(); - }) - - app.outer_gap.set_text(String(ext.gap_outer())); - app.outer_gap.connect('activate', (widget: any) => { - let parsed = parseInt((widget.get_text() as string).trim()); - if (!isNaN(parsed)) { - ext.set_gap_outer(parsed); - Settings.sync(); - }; - }); - - app.inner_gap.set_text(String(ext.gap_inner())); - app.inner_gap.connect('activate', (widget: any) => { - let parsed = parseInt((widget.get_text() as string).trim()); - if (!isNaN(parsed)) { - ext.set_gap_inner(parsed); - Settings.sync(); - } - }); - - app.log_level.set_active(ext.log_level()); - app.log_level.connect("changed", () => { - let active_id = app.log_level.get_active_id(); - ext.set_log_level(active_id); - }); - - app.show_skip_taskbar.set_active(ext.show_skiptaskbar()); - app.show_skip_taskbar.connect('state-set', (_widget: any, state: boolean) => { - ext.set_show_skiptaskbar(state); - Settings.sync(); - }); - - app.mouse_cursor_follows_active_window.set_active(ext.mouse_cursor_follows_active_window()); - app.mouse_cursor_follows_active_window.connect('state-set', (_widget: any, state: boolean) => { - ext.set_mouse_cursor_follows_active_window(state); - Settings.sync(); - }); - - app.mouse_cursor_focus_position.set_active(ext.mouse_cursor_focus_location()); - app.mouse_cursor_focus_position.connect("changed", () => { - let active_id = app.mouse_cursor_focus_position.get_active_id(); - ext.set_mouse_cursor_focus_location(active_id); - }); - - app.fullscreen_launcher.set_active(ext.fullscreen_launcher()) - app.fullscreen_launcher.connect('state-set', (_widget: any, state: boolean) => { - ext.set_fullscreen_launcher(state) - Settings.sync() - }); - - app.stacking_with_mouse.set_active(ext.stacking_with_mouse()) - app.stacking_with_mouse.connect('state-set', (_widget: any, state: boolean) => { - ext.set_stacking_with_mouse(state) - Settings.sync() - }); - - return grid; -} - -function settings_dialog_view(): [AppWidgets, Gtk.Container] { - const grid = new Gtk.Grid({ - column_spacing: 12, - row_spacing: 12, - margin_start: 10, - margin_end: 10, - margin_bottom: 10, - margin_top: 10, - }) - - const win_label = new Gtk.Label({ - label: "Show Window Titles", - xalign: 0.0, - hexpand: true - }) - - const snap_label = new Gtk.Label({ - label: "Snap to Grid (Floating Mode)", - xalign: 0.0 - }) - - const smart_label = new Gtk.Label({ - label: "Smart Gaps", - xalign: 0.0 - }) - - const show_skip_taskbar_label = new Gtk.Label({ - label: "Show Minimize to Tray Windows", - xalign: 0.0 - }) - - const mouse_cursor_follows_active_window_label = new Gtk.Label({ - label: "Mouse Cursor Follows Active Window", - xalign: 0.0 - }) - - const fullscreen_launcher_label = new Gtk.Label({ - label: "Allow launcher over fullscreen window", - xalign: 0.0 - }) - - const stacking_with_mouse = new Gtk.Label({ - label: "Allow stacking with mouse", - xalign: 0.0 - }) - - const [inner_gap, outer_gap] = gaps_section(grid, 9); - - const settings = { - inner_gap, - outer_gap, - fullscreen_launcher: new Gtk.Switch({ halign: Gtk.Align.END }), - stacking_with_mouse: new Gtk.Switch({ halign: Gtk.Align.END }), - smart_gaps: new Gtk.Switch({ halign: Gtk.Align.END }), - snap_to_grid: new Gtk.Switch({ halign: Gtk.Align.END }), - window_titles: new Gtk.Switch({ halign: Gtk.Align.END }), - show_skip_taskbar: new Gtk.Switch({ halign: Gtk.Align.END }), - mouse_cursor_follows_active_window: new Gtk.Switch({ halign: Gtk.Align.END }), - mouse_cursor_focus_position: build_combo( - grid, - 7, - focus.FocusPosition, - 'Mouse Cursor Focus Position', - ), - log_level: build_combo( - grid, - 8, - log.LOG_LEVELS, - 'Log Level', - ) + let [app, grid] = settings_dialog_view(); + + let ext = new settings.ExtensionSettings(); + + app.window_titles.set_active(ext.show_title()); + app.window_titles.connect("state-set", (_widget: any, state: boolean) => { + ext.set_show_title(state); + Settings.sync(); + }); + + app.snap_to_grid.set_active(ext.snap_to_grid()); + app.snap_to_grid.connect("state-set", (_widget: any, state: boolean) => { + ext.set_snap_to_grid(state); + Settings.sync(); + }); + + app.smart_gaps.set_active(ext.smart_gaps()); + app.smart_gaps.connect("state-set", (_widget: any, state: boolean) => { + ext.set_smart_gaps(state); + Settings.sync(); + }); + + app.auto_unstack.set_active(ext.auto_unstack()); + app.auto_unstack.connect("state-set", (_widget: any, state: boolean) => { + ext.set_auto_unstack(state); + Settings.sync(); + }); + + app.outer_gap.set_text(String(ext.gap_outer())); + app.outer_gap.connect("activate", (widget: any) => { + let parsed = parseInt((widget.get_text() as string).trim()); + if (!isNaN(parsed)) { + ext.set_gap_outer(parsed); + Settings.sync(); } + }); + + app.inner_gap.set_text(String(ext.gap_inner())); + app.inner_gap.connect("activate", (widget: any) => { + let parsed = parseInt((widget.get_text() as string).trim()); + if (!isNaN(parsed)) { + ext.set_gap_inner(parsed); + Settings.sync(); + } + }); + + app.log_level.set_active(ext.log_level()); + app.log_level.connect("changed", () => { + let active_id = app.log_level.get_active_id(); + ext.set_log_level(active_id); + }); + + app.show_skip_taskbar.set_active(ext.show_skiptaskbar()); + app.show_skip_taskbar.connect("state-set", (_widget: any, state: boolean) => { + ext.set_show_skiptaskbar(state); + Settings.sync(); + }); + + app.mouse_cursor_follows_active_window.set_active( + ext.mouse_cursor_follows_active_window() + ); + app.mouse_cursor_follows_active_window.connect( + "state-set", + (_widget: any, state: boolean) => { + ext.set_mouse_cursor_follows_active_window(state); + Settings.sync(); + } + ); + + app.mouse_cursor_focus_position.set_active(ext.mouse_cursor_focus_location()); + app.mouse_cursor_focus_position.connect("changed", () => { + let active_id = app.mouse_cursor_focus_position.get_active_id(); + ext.set_mouse_cursor_focus_location(active_id); + }); + + app.fullscreen_launcher.set_active(ext.fullscreen_launcher()); + app.fullscreen_launcher.connect( + "state-set", + (_widget: any, state: boolean) => { + ext.set_fullscreen_launcher(state); + Settings.sync(); + } + ); + + app.stacking_with_mouse.set_active(ext.stacking_with_mouse()); + app.stacking_with_mouse.connect( + "state-set", + (_widget: any, state: boolean) => { + ext.set_stacking_with_mouse(state); + Settings.sync(); + } + ); - grid.attach(win_label, 0, 0, 1, 1) - grid.attach(settings.window_titles, 1, 0, 1, 1) - - grid.attach(snap_label, 0, 1, 1, 1) - grid.attach(settings.snap_to_grid, 1, 1, 1, 1) - - grid.attach(smart_label, 0, 2, 1, 1) - grid.attach(settings.smart_gaps, 1, 2, 1, 1) - - grid.attach(fullscreen_launcher_label, 0, 3, 1, 1) - grid.attach(settings.fullscreen_launcher, 1, 3, 1, 1) - - grid.attach(stacking_with_mouse, 0, 4, 1, 1) - grid.attach(settings.stacking_with_mouse, 1, 4, 1, 1) - - grid.attach(show_skip_taskbar_label, 0, 5, 1, 1) - grid.attach(settings.show_skip_taskbar, 1, 5, 1, 1) - - grid.attach(mouse_cursor_follows_active_window_label, 0, 6, 1, 1) - grid.attach(settings.mouse_cursor_follows_active_window, 1, 6, 1, 1) + return grid; +} - return [settings, grid] +function settings_dialog_view(): [AppWidgets, Gtk.Container] { + const grid = new Gtk.Grid({ + column_spacing: 12, + row_spacing: 12, + margin_start: 10, + margin_end: 10, + margin_bottom: 10, + margin_top: 10, + }); + + const win_label = new Gtk.Label({ + label: "Show Window Titles", + xalign: 0.0, + hexpand: true, + }); + + const snap_label = new Gtk.Label({ + label: "Snap to Grid (Floating Mode)", + xalign: 0.0, + }); + + const smart_label = new Gtk.Label({ + label: "Smart Gaps", + xalign: 0.0, + }); + + const unstack_label = new Gtk.Label({ + label: "Automatically destroy single-window stacks", + xalign: 0.0, + }); + + const show_skip_taskbar_label = new Gtk.Label({ + label: "Show Minimize to Tray Windows", + xalign: 0.0, + }); + + const mouse_cursor_follows_active_window_label = new Gtk.Label({ + label: "Mouse Cursor Follows Active Window", + xalign: 0.0, + }); + + const fullscreen_launcher_label = new Gtk.Label({ + label: "Allow launcher over fullscreen window", + xalign: 0.0, + }); + + const stacking_with_mouse = new Gtk.Label({ + label: "Allow stacking with mouse", + xalign: 0.0, + }); + + const [inner_gap, outer_gap] = gaps_section(grid, 10); + + const settings = { + inner_gap, + outer_gap, + fullscreen_launcher: new Gtk.Switch({ halign: Gtk.Align.END }), + stacking_with_mouse: new Gtk.Switch({ halign: Gtk.Align.END }), + smart_gaps: new Gtk.Switch({ halign: Gtk.Align.END }), + auto_unstack: new Gtk.Switch({ halign: Gtk.Align.END }), + snap_to_grid: new Gtk.Switch({ halign: Gtk.Align.END }), + window_titles: new Gtk.Switch({ halign: Gtk.Align.END }), + show_skip_taskbar: new Gtk.Switch({ halign: Gtk.Align.END }), + mouse_cursor_follows_active_window: new Gtk.Switch({ + halign: Gtk.Align.END, + }), + mouse_cursor_focus_position: build_combo( + grid, + 8, + focus.FocusPosition, + "Mouse Cursor Focus Position" + ), + log_level: build_combo(grid, 9, log.LOG_LEVELS, "Log Level"), + }; + + grid.attach(win_label, 0, 0, 1, 1); + grid.attach(settings.window_titles, 1, 0, 1, 1); + + grid.attach(snap_label, 0, 1, 1, 1); + grid.attach(settings.snap_to_grid, 1, 1, 1, 1); + + grid.attach(smart_label, 0, 2, 1, 1); + grid.attach(settings.smart_gaps, 1, 2, 1, 1); + + grid.attach(unstack_label, 0, 3, 1, 1); + grid.attach(settings.auto_unstack, 1, 3, 1, 1); + + grid.attach(fullscreen_launcher_label, 0, 4, 1, 1); + grid.attach(settings.fullscreen_launcher, 1, 4, 1, 1); + + grid.attach(stacking_with_mouse, 0, 5, 1, 1); + grid.attach(settings.stacking_with_mouse, 1, 5, 1, 1); + + grid.attach(show_skip_taskbar_label, 0, 6, 1, 1); + grid.attach(settings.show_skip_taskbar, 1, 6, 1, 1); + + grid.attach(mouse_cursor_follows_active_window_label, 0, 7, 1, 1); + grid.attach(settings.mouse_cursor_follows_active_window, 1, 7, 1, 1); + + return [settings, grid]; } function gaps_section(grid: any, top: number): [any, any] { - let outer_label = new Gtk.Label({ - label: "Outer", - xalign: 0.0, - margin_start: 24 - }); - - let outer_entry = number_entry(); - - let inner_label = new Gtk.Label({ - label: "Inner", - xalign: 0.0, - margin_start: 24 - }); - - let inner_entry = number_entry(); - - let section_label = new Gtk.Label({ - label: "Gaps", - xalign: 0.0 - }); - - grid.attach(section_label, 0, top, 1, 1); - grid.attach(outer_label, 0, top + 1, 1, 1); - grid.attach(outer_entry, 1, top + 1, 1, 1); - grid.attach(inner_label, 0, top + 2, 1, 1); - grid.attach(inner_entry, 1, top + 2, 1, 1); - - return [inner_entry, outer_entry]; + let outer_label = new Gtk.Label({ + label: "Outer", + xalign: 0.0, + margin_start: 24, + }); + + let outer_entry = number_entry(); + + let inner_label = new Gtk.Label({ + label: "Inner", + xalign: 0.0, + margin_start: 24, + }); + + let inner_entry = number_entry(); + + let section_label = new Gtk.Label({ + label: "Gaps", + xalign: 0.0, + }); + + grid.attach(section_label, 0, top, 1, 1); + grid.attach(outer_label, 0, top + 1, 1, 1); + grid.attach(outer_entry, 1, top + 1, 1, 1); + grid.attach(inner_label, 0, top + 2, 1, 1); + grid.attach(inner_entry, 1, top + 2, 1, 1); + + return [inner_entry, outer_entry]; } function number_entry(): Gtk.Widget { - return new Gtk.Entry({ input_purpose: Gtk.InputPurpose.NUMBER }); + return new Gtk.Entry({ input_purpose: Gtk.InputPurpose.NUMBER }); } function build_combo( - grid: any, - top_index: number, - iter_enum: any, - label: string, + grid: any, + top_index: number, + iter_enum: any, + label: string ) { - let label_ = new Gtk.Label({ - label: label, - halign: Gtk.Align.START - }); + let label_ = new Gtk.Label({ + label: label, + halign: Gtk.Align.START, + }); - grid.attach(label_, 0, top_index, 1, 1); + grid.attach(label_, 0, top_index, 1, 1); - let combo = new Gtk.ComboBoxText(); + let combo = new Gtk.ComboBoxText(); - for (const [index, key] of Object.keys(iter_enum).entries()) { - if (typeof iter_enum[key] == 'string') { - combo.append(`${index}`, iter_enum[key]); - } + for (const [index, key] of Object.keys(iter_enum).entries()) { + if (typeof iter_enum[key] == "string") { + combo.append(`${index}`, iter_enum[key]); } + } - grid.attach(combo, 1, top_index, 1, 1); - return combo + grid.attach(combo, 1, top_index, 1, 1); + return combo; } // @ts-ignore function buildPrefsWidget() { - let dialog = settings_dialog_new(); - if (dialog.show_all) { - dialog.show_all() - } else { - dialog.show(); - } - return dialog; + let dialog = settings_dialog_new(); + if (dialog.show_all) { + dialog.show_all(); + } else { + dialog.show(); + } + return dialog; } diff --git a/src/settings.ts b/src/settings.ts index 39a6a784..c172ccde 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -2,49 +2,58 @@ const Me = imports.misc.extensionUtils.getCurrentExtension(); const { Gio, Gdk } = imports.gi; -const DARK = ["dark", "adapta", "plata", "dracula"] +const DARK = ["dark", "adapta", "plata", "dracula"]; interface Settings extends GObject.Object { - get_boolean(key: string): boolean; - set_boolean(key: string, value: boolean): void; + get_boolean(key: string): boolean; + set_boolean(key: string, value: boolean): void; - get_uint(key: string): number; - set_uint(key: string, value: number): void; + get_uint(key: string): number; + set_uint(key: string, value: number): void; - get_string(key: string): string; - set_string(key: string, value: string): void; + get_string(key: string): string; + set_string(key: string, value: string): void; - bind(key: string, object: GObject.Object, property: string, flags: any): void + bind(key: string, object: GObject.Object, property: string, flags: any): void; } function settings_new_id(schema_id: string): Settings | null { - try { - return new Gio.Settings({ schema_id }); - } catch (why) { - if (schema_id !== "org.gnome.shell.extensions.user-theme") { - global.log(`failed to get settings for ${schema_id}: ${why}`) - } - - return null + try { + return new Gio.Settings({ schema_id }); + } catch (why) { + if (schema_id !== "org.gnome.shell.extensions.user-theme") { + global.log(`failed to get settings for ${schema_id}: ${why}`); } + + return null; + } } function settings_new_schema(schema: string): Settings { - const GioSSS = Gio.SettingsSchemaSource; - const schemaDir = Me.dir.get_child("schemas"); - - let schemaSource = schemaDir.query_exists(null) ? - GioSSS.new_from_directory(schemaDir.get_path(), GioSSS.get_default(), false) : - GioSSS.get_default(); - - const schemaObj = schemaSource.lookup(schema, true); - - if (!schemaObj) { - throw new Error("Schema " + schema + " could not be found for extension " - + Me.metadata.uuid + ". Please check your installation.") - } - - return new Gio.Settings({ settings_schema: schemaObj }); + const GioSSS = Gio.SettingsSchemaSource; + const schemaDir = Me.dir.get_child("schemas"); + + let schemaSource = schemaDir.query_exists(null) + ? GioSSS.new_from_directory( + schemaDir.get_path(), + GioSSS.get_default(), + false + ) + : GioSSS.get_default(); + + const schemaObj = schemaSource.lookup(schema, true); + + if (!schemaObj) { + throw new Error( + "Schema " + + schema + + " could not be found for extension " + + Me.metadata.uuid + + ". Please check your installation." + ); + } + + return new Gio.Settings({ settings_schema: schemaObj }); } const ACTIVE_HINT = "active-hint"; @@ -52,208 +61,219 @@ const ACTIVE_HINT_BORDER_RADIUS = "active-hint-border-radius"; const STACKING_WITH_MOUSE = "stacking-with-mouse"; const COLUMN_SIZE = "column-size"; const EDGE_TILING = "edge-tiling"; -const FULLSCREEN_LAUNCHER = "fullscreen-launcher" +const FULLSCREEN_LAUNCHER = "fullscreen-launcher"; const GAP_INNER = "gap-inner"; const GAP_OUTER = "gap-outer"; const ROW_SIZE = "row-size"; const SHOW_TITLE = "show-title"; const SMART_GAPS = "smart-gaps"; +const AUTO_UNSTACK = "auto-unstack"; const SNAP_TO_GRID = "snap-to-grid"; const TILE_BY_DEFAULT = "tile-by-default"; const HINT_COLOR_RGBA = "hint-color-rgba"; const DEFAULT_RGBA_COLOR = "rgba(251, 184, 108, 1)"; //pop-orange const LOG_LEVEL = "log-level"; const SHOW_SKIPTASKBAR = "show-skip-taskbar"; -const MOUSE_CURSOR_FOLLOWS_ACTIVE_WINDOW = "mouse-cursor-follows-active-window" +const MOUSE_CURSOR_FOLLOWS_ACTIVE_WINDOW = "mouse-cursor-follows-active-window"; const MOUSE_CURSOR_FOCUS_LOCATION = "mouse-cursor-focus-location"; export class ExtensionSettings { - ext: Settings = settings_new_schema(Me.metadata["settings-schema"]); - int: Settings | null = settings_new_id("org.gnome.desktop.interface"); - mutter: Settings | null = settings_new_id("org.gnome.mutter"); - shell: Settings | null = settings_new_id("org.gnome.shell.extensions.user-theme"); + ext: Settings = settings_new_schema(Me.metadata["settings-schema"]); + int: Settings | null = settings_new_id("org.gnome.desktop.interface"); + mutter: Settings | null = settings_new_id("org.gnome.mutter"); + shell: Settings | null = settings_new_id( + "org.gnome.shell.extensions.user-theme" + ); - // Getters + // Getters + + active_hint(): boolean { + return this.ext.get_boolean(ACTIVE_HINT); + } + + active_hint_border_radius(): number { + return this.ext.get_uint(ACTIVE_HINT_BORDER_RADIUS); + } - active_hint(): boolean { - return this.ext.get_boolean(ACTIVE_HINT); - } + stacking_with_mouse(): boolean { + return this.ext.get_boolean(STACKING_WITH_MOUSE); + } - active_hint_border_radius(): number { - return this.ext.get_uint(ACTIVE_HINT_BORDER_RADIUS); - } + column_size(): number { + return this.ext.get_uint(COLUMN_SIZE); + } - stacking_with_mouse(): boolean { - return this.ext.get_boolean(STACKING_WITH_MOUSE); - } + dynamic_workspaces(): boolean { + return this.mutter ? this.mutter.get_boolean("dynamic-workspaces") : false; + } - column_size(): number { - return this.ext.get_uint(COLUMN_SIZE); - } + fullscreen_launcher(): boolean { + return this.ext.get_boolean(FULLSCREEN_LAUNCHER); + } - dynamic_workspaces(): boolean { - return this.mutter ? this.mutter.get_boolean("dynamic-workspaces") : false; - } + gap_inner(): number { + return this.ext.get_uint(GAP_INNER); + } - fullscreen_launcher(): boolean { - return this.ext.get_boolean(FULLSCREEN_LAUNCHER) - } + gap_outer(): number { + return this.ext.get_uint(GAP_OUTER); + } - gap_inner(): number { - return this.ext.get_uint(GAP_INNER); - } + hint_color_rgba() { + let rgba = this.ext.get_string(HINT_COLOR_RGBA); + let valid_color = new Gdk.RGBA().parse(rgba); - gap_outer(): number { - return this.ext.get_uint(GAP_OUTER); - } + if (!valid_color) { + return DEFAULT_RGBA_COLOR; + } - hint_color_rgba() { - let rgba = this.ext.get_string(HINT_COLOR_RGBA); - let valid_color = new Gdk.RGBA().parse(rgba); + return rgba; + } - if (!valid_color) { - return DEFAULT_RGBA_COLOR; - } + theme(): string { + return this.shell + ? this.shell.get_string("name") + : this.int + ? this.int.get_string("gtk-theme") + : "Adwaita"; + } - return rgba; - } + is_dark(): boolean { + const theme = this.theme().toLowerCase(); + return DARK.some((dark) => theme.includes(dark)); + } - theme(): string { - return this.shell - ? this.shell.get_string("name") - : this.int - ? this.int.get_string("gtk-theme") - : "Adwaita" - } + is_high_contrast(): boolean { + return this.theme().toLowerCase() === "highcontrast"; + } - is_dark(): boolean { - const theme = this.theme().toLowerCase() - return DARK.some(dark => theme.includes(dark)) - } + row_size(): number { + return this.ext.get_uint(ROW_SIZE); + } - is_high_contrast(): boolean { - return this.theme().toLowerCase() === "highcontrast" - } + show_title(): boolean { + return this.ext.get_boolean(SHOW_TITLE); + } - row_size(): number { - return this.ext.get_uint(ROW_SIZE); - } + smart_gaps(): boolean { + return this.ext.get_boolean(SMART_GAPS); + } - show_title(): boolean { - return this.ext.get_boolean(SHOW_TITLE); - } + auto_unstack(): boolean { + return this.ext.get_boolean(AUTO_UNSTACK); + } - smart_gaps(): boolean { - return this.ext.get_boolean(SMART_GAPS); - } + snap_to_grid(): boolean { + return this.ext.get_boolean(SNAP_TO_GRID); + } - snap_to_grid(): boolean { - return this.ext.get_boolean(SNAP_TO_GRID); - } + tile_by_default(): boolean { + return this.ext.get_boolean(TILE_BY_DEFAULT); + } - tile_by_default(): boolean { - return this.ext.get_boolean(TILE_BY_DEFAULT); - } + workspaces_only_on_primary(): boolean { + return this.mutter + ? this.mutter.get_boolean("workspaces-only-on-primary") + : false; + } - workspaces_only_on_primary(): boolean { - return this.mutter - ? this.mutter.get_boolean("workspaces-only-on-primary") - : false; - } + log_level(): number { + return this.ext.get_uint(LOG_LEVEL); + } - log_level(): number { - return this.ext.get_uint(LOG_LEVEL); - } + show_skiptaskbar(): boolean { + return this.ext.get_boolean(SHOW_SKIPTASKBAR); + } - show_skiptaskbar(): boolean { - return this.ext.get_boolean(SHOW_SKIPTASKBAR); - } + mouse_cursor_follows_active_window(): boolean { + return this.ext.get_boolean(MOUSE_CURSOR_FOLLOWS_ACTIVE_WINDOW); + } - mouse_cursor_follows_active_window(): boolean { - return this.ext.get_boolean(MOUSE_CURSOR_FOLLOWS_ACTIVE_WINDOW); - } + mouse_cursor_focus_location(): number { + return this.ext.get_uint(MOUSE_CURSOR_FOCUS_LOCATION); + } - mouse_cursor_focus_location(): number { - return this.ext.get_uint(MOUSE_CURSOR_FOCUS_LOCATION); - } + // Setters - // Setters + set_active_hint(set: boolean) { + this.ext.set_boolean(ACTIVE_HINT, set); + } - set_active_hint(set: boolean) { - this.ext.set_boolean(ACTIVE_HINT, set); - } + set_active_hint_border_radius(set: number) { + this.ext.set_uint(ACTIVE_HINT_BORDER_RADIUS, set); + } - set_active_hint_border_radius(set: number) { - this.ext.set_uint(ACTIVE_HINT_BORDER_RADIUS, set); - } + set_stacking_with_mouse(set: boolean) { + this.ext.set_boolean(STACKING_WITH_MOUSE, set); + } - set_stacking_with_mouse(set: boolean) { - this.ext.set_boolean(STACKING_WITH_MOUSE, set); - } + set_column_size(size: number) { + this.ext.set_uint(COLUMN_SIZE, size); + } - set_column_size(size: number) { - this.ext.set_uint(COLUMN_SIZE, size); - } + set_edge_tiling(enable: boolean) { + this.mutter?.set_boolean(EDGE_TILING, enable); + } - set_edge_tiling(enable: boolean) { - this.mutter?.set_boolean(EDGE_TILING, enable) - } + set_fullscreen_launcher(enable: boolean) { + this.ext.set_boolean(FULLSCREEN_LAUNCHER, enable); + } - set_fullscreen_launcher(enable: boolean) { - this.ext.set_boolean(FULLSCREEN_LAUNCHER, enable) - } + set_gap_inner(gap: number) { + this.ext.set_uint(GAP_INNER, gap); + } - set_gap_inner(gap: number) { - this.ext.set_uint(GAP_INNER, gap); - } + set_gap_outer(gap: number) { + this.ext.set_uint(GAP_OUTER, gap); + } - set_gap_outer(gap: number) { - this.ext.set_uint(GAP_OUTER, gap); - } + set_hint_color_rgba(rgba: string) { + let valid_color = new Gdk.RGBA().parse(rgba); - set_hint_color_rgba(rgba: string) { - let valid_color = new Gdk.RGBA().parse(rgba); - - if (valid_color) { - this.ext.set_string(HINT_COLOR_RGBA, rgba); - } else { - this.ext.set_string(HINT_COLOR_RGBA, DEFAULT_RGBA_COLOR); - } + if (valid_color) { + this.ext.set_string(HINT_COLOR_RGBA, rgba); + } else { + this.ext.set_string(HINT_COLOR_RGBA, DEFAULT_RGBA_COLOR); } + } - set_row_size(size: number) { - this.ext.set_uint(ROW_SIZE, size); - } + set_row_size(size: number) { + this.ext.set_uint(ROW_SIZE, size); + } - set_show_title(set: boolean) { - this.ext.set_boolean(SHOW_TITLE, set); - } + set_show_title(set: boolean) { + this.ext.set_boolean(SHOW_TITLE, set); + } - set_smart_gaps(set: boolean) { - this.ext.set_boolean(SMART_GAPS, set); - } + set_smart_gaps(set: boolean) { + this.ext.set_boolean(SMART_GAPS, set); + } - set_snap_to_grid(set: boolean) { - this.ext.set_boolean(SNAP_TO_GRID, set); - } + set_auto_unstack(set: boolean) { + this.ext.set_boolean(AUTO_UNSTACK, set); + } - set_tile_by_default(set: boolean) { - this.ext.set_boolean(TILE_BY_DEFAULT, set); - } + set_snap_to_grid(set: boolean) { + this.ext.set_boolean(SNAP_TO_GRID, set); + } - set_log_level(set: number) { - this.ext.set_uint(LOG_LEVEL, set); - } + set_tile_by_default(set: boolean) { + this.ext.set_boolean(TILE_BY_DEFAULT, set); + } - set_show_skiptaskbar(set: boolean) { - this.ext.set_boolean(SHOW_SKIPTASKBAR, set); - } + set_log_level(set: number) { + this.ext.set_uint(LOG_LEVEL, set); + } - set_mouse_cursor_follows_active_window(set: boolean) { - this.ext.set_boolean(MOUSE_CURSOR_FOLLOWS_ACTIVE_WINDOW, set); - } + set_show_skiptaskbar(set: boolean) { + this.ext.set_boolean(SHOW_SKIPTASKBAR, set); + } - set_mouse_cursor_focus_location(set: number) { - this.ext.set_uint(MOUSE_CURSOR_FOCUS_LOCATION, set); - } + set_mouse_cursor_follows_active_window(set: boolean) { + this.ext.set_boolean(MOUSE_CURSOR_FOLLOWS_ACTIVE_WINDOW, set); + } + + set_mouse_cursor_focus_location(set: number) { + this.ext.set_uint(MOUSE_CURSOR_FOCUS_LOCATION, set); + } } diff --git a/src/tiling.ts b/src/tiling.ts index c5c16dce..c12afb85 100644 --- a/src/tiling.ts +++ b/src/tiling.ts @@ -2,6 +2,8 @@ const Me = imports.misc.extensionUtils.getCurrentExtension(); // import * as Ecs from 'ecs'; +import * as exec from 'executor'; +import * as geom from 'geom'; import * as GrabOp from 'grab_op'; import * as Lib from 'lib'; import * as Log from 'log'; @@ -9,15 +11,13 @@ import * as Node from 'node'; import * as Rect from 'rectangle'; import * as Tags from 'tags'; import * as window from 'window'; -import * as geom from 'geom'; -import * as exec from 'executor'; +import { AutoTiler } from './auto_tiler'; import type { Entity } from './ecs'; -import type { Rectangle } from './rectangle'; import type { Ext } from './extension'; -import type { NodeStack } from './node'; -import { AutoTiler } from './auto_tiler'; import { Fork } from './fork'; +import type { NodeStack } from './node'; +import type { Rectangle } from './rectangle'; const { Meta } = imports.gi; const Main = imports.ui.main; @@ -392,6 +392,15 @@ export class Tiler { detach(Lib.Orientation.VERTICAL, true) break } + if (ext.moved_by_mouse && inner.entities.length === 1 && ext.settings.auto_unstack()) { + const ent = inner.entities[0] + const win = ext.windows.get(ent) + const fork = ext.auto_tiler.get_parent_fork(ent) + if (fork && win) { + ext.auto_tiler.unstack(ext, fork, win) + ext.auto_tiler.tile(ext, fork, fork.area) + } + } } move_auto_(ext: Ext, mov1: Rectangle, mov2: Rectangle, callback: (m: Rectangle, a: Rectangle, mov: Rectangle) => boolean) { From c89145491de87a9d2bc8a48cb32d5aeb0216ae5c Mon Sep 17 00:00:00 2001 From: MeowcaTheoRange <58280776+MeowcaTheoRange@users.noreply.github.com> Date: Wed, 4 Oct 2023 08:16:39 -0500 Subject: [PATCH 2/9] Delete .prettierignore --- .prettierignore | 1 - 1 file changed, 1 deletion(-) delete mode 100644 .prettierignore diff --git a/.prettierignore b/.prettierignore deleted file mode 100644 index fa29cdff..00000000 --- a/.prettierignore +++ /dev/null @@ -1 +0,0 @@ -** \ No newline at end of file From 662b2ed44c5d76416d889298932c2d1406dd9fc9 Mon Sep 17 00:00:00 2001 From: MeowcaTheoRange <58280776+MeowcaTheoRange@users.noreply.github.com> Date: Wed, 4 Oct 2023 08:20:10 -0500 Subject: [PATCH 3/9] Update prefs.ts --- src/prefs.ts | 522 +++++++++++++++++++++++++-------------------------- 1 file changed, 261 insertions(+), 261 deletions(-) diff --git a/src/prefs.ts b/src/prefs.ts index 04a5385e..91074ffc 100644 --- a/src/prefs.ts +++ b/src/prefs.ts @@ -8,294 +8,294 @@ const { Gtk } = imports.gi; const { Settings } = imports.gi.Gio; -import * as focus from 'focus'; -import * as log from 'log'; -import * as settings from 'settings'; +import * as focus from "focus"; +import * as log from "log"; +import * as settings from "settings"; interface AppWidgets { - fullscreen_launcher: any; - stacking_with_mouse: any; - inner_gap: any; - mouse_cursor_follows_active_window: any; - outer_gap: any; - show_skip_taskbar: any; - smart_gaps: any; - auto_unstack: any; - snap_to_grid: any; - window_titles: any; - mouse_cursor_focus_position: any; - log_level: any; + fullscreen_launcher: any; + stacking_with_mouse: any; + inner_gap: any; + mouse_cursor_follows_active_window: any; + outer_gap: any; + show_skip_taskbar: any; + smart_gaps: any; + auto_unstack: any; + snap_to_grid: any; + window_titles: any; + mouse_cursor_focus_position: any; + log_level: any; } // @ts-ignore -function init() {} +function init() { } function settings_dialog_new(): Gtk.Container { - let [app, grid] = settings_dialog_view(); - - let ext = new settings.ExtensionSettings(); - - app.window_titles.set_active(ext.show_title()); - app.window_titles.connect("state-set", (_widget: any, state: boolean) => { - ext.set_show_title(state); - Settings.sync(); - }); - - app.snap_to_grid.set_active(ext.snap_to_grid()); - app.snap_to_grid.connect("state-set", (_widget: any, state: boolean) => { - ext.set_snap_to_grid(state); - Settings.sync(); - }); - - app.smart_gaps.set_active(ext.smart_gaps()); - app.smart_gaps.connect("state-set", (_widget: any, state: boolean) => { - ext.set_smart_gaps(state); - Settings.sync(); - }); - - app.auto_unstack.set_active(ext.auto_unstack()); - app.auto_unstack.connect("state-set", (_widget: any, state: boolean) => { - ext.set_auto_unstack(state); - Settings.sync(); - }); - - app.outer_gap.set_text(String(ext.gap_outer())); - app.outer_gap.connect("activate", (widget: any) => { - let parsed = parseInt((widget.get_text() as string).trim()); - if (!isNaN(parsed)) { - ext.set_gap_outer(parsed); - Settings.sync(); - } - }); - - app.inner_gap.set_text(String(ext.gap_inner())); - app.inner_gap.connect("activate", (widget: any) => { - let parsed = parseInt((widget.get_text() as string).trim()); - if (!isNaN(parsed)) { - ext.set_gap_inner(parsed); - Settings.sync(); - } - }); - - app.log_level.set_active(ext.log_level()); - app.log_level.connect("changed", () => { - let active_id = app.log_level.get_active_id(); - ext.set_log_level(active_id); - }); - - app.show_skip_taskbar.set_active(ext.show_skiptaskbar()); - app.show_skip_taskbar.connect("state-set", (_widget: any, state: boolean) => { - ext.set_show_skiptaskbar(state); - Settings.sync(); - }); - - app.mouse_cursor_follows_active_window.set_active( - ext.mouse_cursor_follows_active_window() - ); - app.mouse_cursor_follows_active_window.connect( - "state-set", - (_widget: any, state: boolean) => { - ext.set_mouse_cursor_follows_active_window(state); - Settings.sync(); - } - ); - - app.mouse_cursor_focus_position.set_active(ext.mouse_cursor_focus_location()); - app.mouse_cursor_focus_position.connect("changed", () => { - let active_id = app.mouse_cursor_focus_position.get_active_id(); - ext.set_mouse_cursor_focus_location(active_id); - }); - - app.fullscreen_launcher.set_active(ext.fullscreen_launcher()); - app.fullscreen_launcher.connect( - "state-set", - (_widget: any, state: boolean) => { - ext.set_fullscreen_launcher(state); - Settings.sync(); - } - ); - - app.stacking_with_mouse.set_active(ext.stacking_with_mouse()); - app.stacking_with_mouse.connect( - "state-set", - (_widget: any, state: boolean) => { - ext.set_stacking_with_mouse(state); - Settings.sync(); - } - ); - - return grid; + let [app, grid] = settings_dialog_view(); + + let ext = new settings.ExtensionSettings(); + + app.window_titles.set_active(ext.show_title()); + app.window_titles.connect("state-set", (_widget: any, state: boolean) => { + ext.set_show_title(state); + Settings.sync(); + }); + + app.snap_to_grid.set_active(ext.snap_to_grid()); + app.snap_to_grid.connect("state-set", (_widget: any, state: boolean) => { + ext.set_snap_to_grid(state); + Settings.sync(); + }); + + app.smart_gaps.set_active(ext.smart_gaps()); + app.smart_gaps.connect("state-set", (_widget: any, state: boolean) => { + ext.set_smart_gaps(state); + Settings.sync(); + }); + + app.auto_unstack.set_active(ext.auto_unstack()); + app.auto_unstack.connect("state-set", (_widget: any, state: boolean) => { + ext.set_auto_unstack(state); + Settings.sync(); + }); + + app.outer_gap.set_text(String(ext.gap_outer())); + app.outer_gap.connect("activate", (widget: any) => { + let parsed = parseInt((widget.get_text() as string).trim()); + if (!isNaN(parsed)) { + ext.set_gap_outer(parsed); + Settings.sync(); + } + }); + + app.inner_gap.set_text(String(ext.gap_inner())); + app.inner_gap.connect("activate", (widget: any) => { + let parsed = parseInt((widget.get_text() as string).trim()); + if (!isNaN(parsed)) { + ext.set_gap_inner(parsed); + Settings.sync(); + } + }); + + app.log_level.set_active(ext.log_level()); + app.log_level.connect("changed", () => { + let active_id = app.log_level.get_active_id(); + ext.set_log_level(active_id); + }); + + app.show_skip_taskbar.set_active(ext.show_skiptaskbar()); + app.show_skip_taskbar.connect("state-set", (_widget: any, state: boolean) => { + ext.set_show_skiptaskbar(state); + Settings.sync(); + }); + + app.mouse_cursor_follows_active_window.set_active( + ext.mouse_cursor_follows_active_window() + ); + app.mouse_cursor_follows_active_window.connect( + "state-set", + (_widget: any, state: boolean) => { + ext.set_mouse_cursor_follows_active_window(state); + Settings.sync(); + } + ); + + app.mouse_cursor_focus_position.set_active(ext.mouse_cursor_focus_location()); + app.mouse_cursor_focus_position.connect("changed", () => { + let active_id = app.mouse_cursor_focus_position.get_active_id(); + ext.set_mouse_cursor_focus_location(active_id); + }); + + app.fullscreen_launcher.set_active(ext.fullscreen_launcher()); + app.fullscreen_launcher.connect( + "state-set", + (_widget: any, state: boolean) => { + ext.set_fullscreen_launcher(state); + Settings.sync(); + } + ); + + app.stacking_with_mouse.set_active(ext.stacking_with_mouse()); + app.stacking_with_mouse.connect( + "state-set", + (_widget: any, state: boolean) => { + ext.set_stacking_with_mouse(state); + Settings.sync(); + } + ); + + return grid; } function settings_dialog_view(): [AppWidgets, Gtk.Container] { - const grid = new Gtk.Grid({ - column_spacing: 12, - row_spacing: 12, - margin_start: 10, - margin_end: 10, - margin_bottom: 10, - margin_top: 10, - }); - - const win_label = new Gtk.Label({ - label: "Show Window Titles", - xalign: 0.0, - hexpand: true, - }); - - const snap_label = new Gtk.Label({ - label: "Snap to Grid (Floating Mode)", - xalign: 0.0, - }); - - const smart_label = new Gtk.Label({ - label: "Smart Gaps", - xalign: 0.0, - }); - - const unstack_label = new Gtk.Label({ - label: "Automatically destroy single-window stacks", - xalign: 0.0, - }); - - const show_skip_taskbar_label = new Gtk.Label({ - label: "Show Minimize to Tray Windows", - xalign: 0.0, - }); - - const mouse_cursor_follows_active_window_label = new Gtk.Label({ - label: "Mouse Cursor Follows Active Window", - xalign: 0.0, - }); - - const fullscreen_launcher_label = new Gtk.Label({ - label: "Allow launcher over fullscreen window", - xalign: 0.0, - }); - - const stacking_with_mouse = new Gtk.Label({ - label: "Allow stacking with mouse", - xalign: 0.0, - }); - - const [inner_gap, outer_gap] = gaps_section(grid, 10); - - const settings = { - inner_gap, - outer_gap, - fullscreen_launcher: new Gtk.Switch({ halign: Gtk.Align.END }), - stacking_with_mouse: new Gtk.Switch({ halign: Gtk.Align.END }), - smart_gaps: new Gtk.Switch({ halign: Gtk.Align.END }), - auto_unstack: new Gtk.Switch({ halign: Gtk.Align.END }), - snap_to_grid: new Gtk.Switch({ halign: Gtk.Align.END }), - window_titles: new Gtk.Switch({ halign: Gtk.Align.END }), - show_skip_taskbar: new Gtk.Switch({ halign: Gtk.Align.END }), - mouse_cursor_follows_active_window: new Gtk.Switch({ - halign: Gtk.Align.END, - }), - mouse_cursor_focus_position: build_combo( - grid, - 8, - focus.FocusPosition, - "Mouse Cursor Focus Position" - ), - log_level: build_combo(grid, 9, log.LOG_LEVELS, "Log Level"), - }; - - grid.attach(win_label, 0, 0, 1, 1); - grid.attach(settings.window_titles, 1, 0, 1, 1); - - grid.attach(snap_label, 0, 1, 1, 1); - grid.attach(settings.snap_to_grid, 1, 1, 1, 1); - - grid.attach(smart_label, 0, 2, 1, 1); - grid.attach(settings.smart_gaps, 1, 2, 1, 1); - - grid.attach(unstack_label, 0, 3, 1, 1); - grid.attach(settings.auto_unstack, 1, 3, 1, 1); - - grid.attach(fullscreen_launcher_label, 0, 4, 1, 1); - grid.attach(settings.fullscreen_launcher, 1, 4, 1, 1); - - grid.attach(stacking_with_mouse, 0, 5, 1, 1); - grid.attach(settings.stacking_with_mouse, 1, 5, 1, 1); - - grid.attach(show_skip_taskbar_label, 0, 6, 1, 1); - grid.attach(settings.show_skip_taskbar, 1, 6, 1, 1); - - grid.attach(mouse_cursor_follows_active_window_label, 0, 7, 1, 1); - grid.attach(settings.mouse_cursor_follows_active_window, 1, 7, 1, 1); - - return [settings, grid]; + const grid = new Gtk.Grid({ + column_spacing: 12, + row_spacing: 12, + margin_start: 10, + margin_end: 10, + margin_bottom: 10, + margin_top: 10, + }); + + const win_label = new Gtk.Label({ + label: "Show Window Titles", + xalign: 0.0, + hexpand: true, + }); + + const snap_label = new Gtk.Label({ + label: "Snap to Grid (Floating Mode)", + xalign: 0.0, + }); + + const smart_label = new Gtk.Label({ + label: "Smart Gaps", + xalign: 0.0, + }); + + const unstack_label = new Gtk.Label({ + label: "Automatically destroy single-window stacks", + xalign: 0.0, + }); + + const show_skip_taskbar_label = new Gtk.Label({ + label: "Show Minimize to Tray Windows", + xalign: 0.0, + }); + + const mouse_cursor_follows_active_window_label = new Gtk.Label({ + label: "Mouse Cursor Follows Active Window", + xalign: 0.0, + }); + + const fullscreen_launcher_label = new Gtk.Label({ + label: "Allow launcher over fullscreen window", + xalign: 0.0, + }); + + const stacking_with_mouse = new Gtk.Label({ + label: "Allow stacking with mouse", + xalign: 0.0, + }); + + const [inner_gap, outer_gap] = gaps_section(grid, 10); + + const settings = { + inner_gap, + outer_gap, + fullscreen_launcher: new Gtk.Switch({ halign: Gtk.Align.END }), + stacking_with_mouse: new Gtk.Switch({ halign: Gtk.Align.END }), + smart_gaps: new Gtk.Switch({ halign: Gtk.Align.END }), + auto_unstack: new Gtk.Switch({ halign: Gtk.Align.END }), + snap_to_grid: new Gtk.Switch({ halign: Gtk.Align.END }), + window_titles: new Gtk.Switch({ halign: Gtk.Align.END }), + show_skip_taskbar: new Gtk.Switch({ halign: Gtk.Align.END }), + mouse_cursor_follows_active_window: new Gtk.Switch({ + halign: Gtk.Align.END, + }), + mouse_cursor_focus_position: build_combo( + grid, + 8, + focus.FocusPosition, + "Mouse Cursor Focus Position" + ), + log_level: build_combo(grid, 9, log.LOG_LEVELS, "Log Level"), + }; + + grid.attach(win_label, 0, 0, 1, 1); + grid.attach(settings.window_titles, 1, 0, 1, 1); + + grid.attach(snap_label, 0, 1, 1, 1); + grid.attach(settings.snap_to_grid, 1, 1, 1, 1); + + grid.attach(smart_label, 0, 2, 1, 1); + grid.attach(settings.smart_gaps, 1, 2, 1, 1); + + grid.attach(unstack_label, 0, 3, 1, 1); + grid.attach(settings.auto_unstack, 1, 3, 1, 1); + + grid.attach(fullscreen_launcher_label, 0, 4, 1, 1); + grid.attach(settings.fullscreen_launcher, 1, 4, 1, 1); + + grid.attach(stacking_with_mouse, 0, 5, 1, 1); + grid.attach(settings.stacking_with_mouse, 1, 5, 1, 1); + + grid.attach(show_skip_taskbar_label, 0, 6, 1, 1); + grid.attach(settings.show_skip_taskbar, 1, 6, 1, 1); + + grid.attach(mouse_cursor_follows_active_window_label, 0, 7, 1, 1); + grid.attach(settings.mouse_cursor_follows_active_window, 1, 7, 1, 1); + + return [settings, grid]; } function gaps_section(grid: any, top: number): [any, any] { - let outer_label = new Gtk.Label({ - label: "Outer", - xalign: 0.0, - margin_start: 24, - }); - - let outer_entry = number_entry(); - - let inner_label = new Gtk.Label({ - label: "Inner", - xalign: 0.0, - margin_start: 24, - }); - - let inner_entry = number_entry(); - - let section_label = new Gtk.Label({ - label: "Gaps", - xalign: 0.0, - }); - - grid.attach(section_label, 0, top, 1, 1); - grid.attach(outer_label, 0, top + 1, 1, 1); - grid.attach(outer_entry, 1, top + 1, 1, 1); - grid.attach(inner_label, 0, top + 2, 1, 1); - grid.attach(inner_entry, 1, top + 2, 1, 1); - - return [inner_entry, outer_entry]; + let outer_label = new Gtk.Label({ + label: "Outer", + xalign: 0.0, + margin_start: 24, + }); + + let outer_entry = number_entry(); + + let inner_label = new Gtk.Label({ + label: "Inner", + xalign: 0.0, + margin_start: 24, + }); + + let inner_entry = number_entry(); + + let section_label = new Gtk.Label({ + label: "Gaps", + xalign: 0.0, + }); + + grid.attach(section_label, 0, top, 1, 1); + grid.attach(outer_label, 0, top + 1, 1, 1); + grid.attach(outer_entry, 1, top + 1, 1, 1); + grid.attach(inner_label, 0, top + 2, 1, 1); + grid.attach(inner_entry, 1, top + 2, 1, 1); + + return [inner_entry, outer_entry]; } function number_entry(): Gtk.Widget { - return new Gtk.Entry({ input_purpose: Gtk.InputPurpose.NUMBER }); + return new Gtk.Entry({ input_purpose: Gtk.InputPurpose.NUMBER }); } function build_combo( - grid: any, - top_index: number, - iter_enum: any, - label: string + grid: any, + top_index: number, + iter_enum: any, + label: string ) { - let label_ = new Gtk.Label({ - label: label, - halign: Gtk.Align.START, - }); + let label_ = new Gtk.Label({ + label: label, + halign: Gtk.Align.START, + }); - grid.attach(label_, 0, top_index, 1, 1); + grid.attach(label_, 0, top_index, 1, 1); - let combo = new Gtk.ComboBoxText(); + let combo = new Gtk.ComboBoxText(); - for (const [index, key] of Object.keys(iter_enum).entries()) { - if (typeof iter_enum[key] == "string") { - combo.append(`${index}`, iter_enum[key]); + for (const [index, key] of Object.keys(iter_enum).entries()) { + if (typeof iter_enum[key] == "string") { + combo.append(`${index}`, iter_enum[key]); + } } - } - grid.attach(combo, 1, top_index, 1, 1); - return combo; + grid.attach(combo, 1, top_index, 1, 1); + return combo; } // @ts-ignore function buildPrefsWidget() { - let dialog = settings_dialog_new(); - if (dialog.show_all) { - dialog.show_all(); - } else { - dialog.show(); - } - return dialog; + let dialog = settings_dialog_new(); + if (dialog.show_all) { + dialog.show_all(); + } else { + dialog.show(); + } + return dialog; } From 1e84233a4c6a2132eb7b0af57f3b1e2a9291725d Mon Sep 17 00:00:00 2001 From: MeowcaTheoRange <58280776+MeowcaTheoRange@users.noreply.github.com> Date: Wed, 4 Oct 2023 08:22:26 -0500 Subject: [PATCH 4/9] Update settings.ts --- src/settings.ts | 380 ++++++++++++++++++++++++------------------------ 1 file changed, 190 insertions(+), 190 deletions(-) diff --git a/src/settings.ts b/src/settings.ts index c172ccde..1d38adaf 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -5,55 +5,55 @@ const { Gio, Gdk } = imports.gi; const DARK = ["dark", "adapta", "plata", "dracula"]; interface Settings extends GObject.Object { - get_boolean(key: string): boolean; - set_boolean(key: string, value: boolean): void; + get_boolean(key: string): boolean; + set_boolean(key: string, value: boolean): void; - get_uint(key: string): number; - set_uint(key: string, value: number): void; + get_uint(key: string): number; + set_uint(key: string, value: number): void; - get_string(key: string): string; - set_string(key: string, value: string): void; + get_string(key: string): string; + set_string(key: string, value: string): void; - bind(key: string, object: GObject.Object, property: string, flags: any): void; + bind(key: string, object: GObject.Object, property: string, flags: any): void; } function settings_new_id(schema_id: string): Settings | null { - try { - return new Gio.Settings({ schema_id }); - } catch (why) { - if (schema_id !== "org.gnome.shell.extensions.user-theme") { - global.log(`failed to get settings for ${schema_id}: ${why}`); + try { + return new Gio.Settings({ schema_id }); + } catch (why) { + if (schema_id !== "org.gnome.shell.extensions.user-theme") { + global.log(`failed to get settings for ${schema_id}: ${why}`); + } + + return null; } - - return null; - } } function settings_new_schema(schema: string): Settings { - const GioSSS = Gio.SettingsSchemaSource; - const schemaDir = Me.dir.get_child("schemas"); - - let schemaSource = schemaDir.query_exists(null) - ? GioSSS.new_from_directory( - schemaDir.get_path(), - GioSSS.get_default(), - false - ) - : GioSSS.get_default(); - - const schemaObj = schemaSource.lookup(schema, true); - - if (!schemaObj) { - throw new Error( - "Schema " + - schema + - " could not be found for extension " + - Me.metadata.uuid + - ". Please check your installation." - ); - } + const GioSSS = Gio.SettingsSchemaSource; + const schemaDir = Me.dir.get_child("schemas"); + + let schemaSource = schemaDir.query_exists(null) + ? GioSSS.new_from_directory( + schemaDir.get_path(), + GioSSS.get_default(), + false + ) + : GioSSS.get_default(); + + const schemaObj = schemaSource.lookup(schema, true); + + if (!schemaObj) { + throw new Error( + "Schema " + + schema + + " could not be found for extension " + + Me.metadata.uuid + + ". Please check your installation." + ); + } - return new Gio.Settings({ settings_schema: schemaObj }); + return new Gio.Settings({ settings_schema: schemaObj }); } const ACTIVE_HINT = "active-hint"; @@ -78,202 +78,202 @@ const MOUSE_CURSOR_FOLLOWS_ACTIVE_WINDOW = "mouse-cursor-follows-active-window"; const MOUSE_CURSOR_FOCUS_LOCATION = "mouse-cursor-focus-location"; export class ExtensionSettings { - ext: Settings = settings_new_schema(Me.metadata["settings-schema"]); - int: Settings | null = settings_new_id("org.gnome.desktop.interface"); - mutter: Settings | null = settings_new_id("org.gnome.mutter"); - shell: Settings | null = settings_new_id( - "org.gnome.shell.extensions.user-theme" - ); + ext: Settings = settings_new_schema(Me.metadata["settings-schema"]); + int: Settings | null = settings_new_id("org.gnome.desktop.interface"); + mutter: Settings | null = settings_new_id("org.gnome.mutter"); + shell: Settings | null = settings_new_id( + "org.gnome.shell.extensions.user-theme" + ); - // Getters - - active_hint(): boolean { - return this.ext.get_boolean(ACTIVE_HINT); - } - - active_hint_border_radius(): number { - return this.ext.get_uint(ACTIVE_HINT_BORDER_RADIUS); - } + // Getters - stacking_with_mouse(): boolean { - return this.ext.get_boolean(STACKING_WITH_MOUSE); - } + active_hint(): boolean { + return this.ext.get_boolean(ACTIVE_HINT); + } - column_size(): number { - return this.ext.get_uint(COLUMN_SIZE); - } + active_hint_border_radius(): number { + return this.ext.get_uint(ACTIVE_HINT_BORDER_RADIUS); + } - dynamic_workspaces(): boolean { - return this.mutter ? this.mutter.get_boolean("dynamic-workspaces") : false; - } + stacking_with_mouse(): boolean { + return this.ext.get_boolean(STACKING_WITH_MOUSE); + } - fullscreen_launcher(): boolean { - return this.ext.get_boolean(FULLSCREEN_LAUNCHER); - } + column_size(): number { + return this.ext.get_uint(COLUMN_SIZE); + } - gap_inner(): number { - return this.ext.get_uint(GAP_INNER); - } + dynamic_workspaces(): boolean { + return this.mutter ? this.mutter.get_boolean("dynamic-workspaces") : false; + } - gap_outer(): number { - return this.ext.get_uint(GAP_OUTER); - } + fullscreen_launcher(): boolean { + return this.ext.get_boolean(FULLSCREEN_LAUNCHER); + } - hint_color_rgba() { - let rgba = this.ext.get_string(HINT_COLOR_RGBA); - let valid_color = new Gdk.RGBA().parse(rgba); + gap_inner(): number { + return this.ext.get_uint(GAP_INNER); + } - if (!valid_color) { - return DEFAULT_RGBA_COLOR; - } + gap_outer(): number { + return this.ext.get_uint(GAP_OUTER); + } - return rgba; - } + hint_color_rgba() { + let rgba = this.ext.get_string(HINT_COLOR_RGBA); + let valid_color = new Gdk.RGBA().parse(rgba); - theme(): string { - return this.shell - ? this.shell.get_string("name") - : this.int - ? this.int.get_string("gtk-theme") - : "Adwaita"; - } + if (!valid_color) { + return DEFAULT_RGBA_COLOR; + } - is_dark(): boolean { - const theme = this.theme().toLowerCase(); - return DARK.some((dark) => theme.includes(dark)); - } + return rgba; + } - is_high_contrast(): boolean { - return this.theme().toLowerCase() === "highcontrast"; - } + theme(): string { + return this.shell + ? this.shell.get_string("name") + : this.int + ? this.int.get_string("gtk-theme") + : "Adwaita"; + } - row_size(): number { - return this.ext.get_uint(ROW_SIZE); - } + is_dark(): boolean { + const theme = this.theme().toLowerCase(); + return DARK.some((dark) => theme.includes(dark)); + } - show_title(): boolean { - return this.ext.get_boolean(SHOW_TITLE); - } + is_high_contrast(): boolean { + return this.theme().toLowerCase() === "highcontrast"; + } - smart_gaps(): boolean { - return this.ext.get_boolean(SMART_GAPS); - } + row_size(): number { + return this.ext.get_uint(ROW_SIZE); + } - auto_unstack(): boolean { - return this.ext.get_boolean(AUTO_UNSTACK); - } + show_title(): boolean { + return this.ext.get_boolean(SHOW_TITLE); + } - snap_to_grid(): boolean { - return this.ext.get_boolean(SNAP_TO_GRID); - } + smart_gaps(): boolean { + return this.ext.get_boolean(SMART_GAPS); + } - tile_by_default(): boolean { - return this.ext.get_boolean(TILE_BY_DEFAULT); - } + auto_unstack(): boolean { + return this.ext.get_boolean(AUTO_UNSTACK); + } - workspaces_only_on_primary(): boolean { - return this.mutter - ? this.mutter.get_boolean("workspaces-only-on-primary") - : false; - } + snap_to_grid(): boolean { + return this.ext.get_boolean(SNAP_TO_GRID); + } - log_level(): number { - return this.ext.get_uint(LOG_LEVEL); - } + tile_by_default(): boolean { + return this.ext.get_boolean(TILE_BY_DEFAULT); + } - show_skiptaskbar(): boolean { - return this.ext.get_boolean(SHOW_SKIPTASKBAR); - } + workspaces_only_on_primary(): boolean { + return this.mutter + ? this.mutter.get_boolean("workspaces-only-on-primary") + : false; + } - mouse_cursor_follows_active_window(): boolean { - return this.ext.get_boolean(MOUSE_CURSOR_FOLLOWS_ACTIVE_WINDOW); - } + log_level(): number { + return this.ext.get_uint(LOG_LEVEL); + } - mouse_cursor_focus_location(): number { - return this.ext.get_uint(MOUSE_CURSOR_FOCUS_LOCATION); - } + show_skiptaskbar(): boolean { + return this.ext.get_boolean(SHOW_SKIPTASKBAR); + } - // Setters + mouse_cursor_follows_active_window(): boolean { + return this.ext.get_boolean(MOUSE_CURSOR_FOLLOWS_ACTIVE_WINDOW); + } - set_active_hint(set: boolean) { - this.ext.set_boolean(ACTIVE_HINT, set); - } + mouse_cursor_focus_location(): number { + return this.ext.get_uint(MOUSE_CURSOR_FOCUS_LOCATION); + } - set_active_hint_border_radius(set: number) { - this.ext.set_uint(ACTIVE_HINT_BORDER_RADIUS, set); - } + // Setters - set_stacking_with_mouse(set: boolean) { - this.ext.set_boolean(STACKING_WITH_MOUSE, set); - } + set_active_hint(set: boolean) { + this.ext.set_boolean(ACTIVE_HINT, set); + } - set_column_size(size: number) { - this.ext.set_uint(COLUMN_SIZE, size); - } + set_active_hint_border_radius(set: number) { + this.ext.set_uint(ACTIVE_HINT_BORDER_RADIUS, set); + } - set_edge_tiling(enable: boolean) { - this.mutter?.set_boolean(EDGE_TILING, enable); - } + set_stacking_with_mouse(set: boolean) { + this.ext.set_boolean(STACKING_WITH_MOUSE, set); + } - set_fullscreen_launcher(enable: boolean) { - this.ext.set_boolean(FULLSCREEN_LAUNCHER, enable); - } + set_column_size(size: number) { + this.ext.set_uint(COLUMN_SIZE, size); + } - set_gap_inner(gap: number) { - this.ext.set_uint(GAP_INNER, gap); - } + set_edge_tiling(enable: boolean) { + this.mutter?.set_boolean(EDGE_TILING, enable); + } - set_gap_outer(gap: number) { - this.ext.set_uint(GAP_OUTER, gap); - } + set_fullscreen_launcher(enable: boolean) { + this.ext.set_boolean(FULLSCREEN_LAUNCHER, enable); + } - set_hint_color_rgba(rgba: string) { - let valid_color = new Gdk.RGBA().parse(rgba); + set_gap_inner(gap: number) { + this.ext.set_uint(GAP_INNER, gap); + } - if (valid_color) { - this.ext.set_string(HINT_COLOR_RGBA, rgba); - } else { - this.ext.set_string(HINT_COLOR_RGBA, DEFAULT_RGBA_COLOR); + set_gap_outer(gap: number) { + this.ext.set_uint(GAP_OUTER, gap); } - } - set_row_size(size: number) { - this.ext.set_uint(ROW_SIZE, size); - } + set_hint_color_rgba(rgba: string) { + let valid_color = new Gdk.RGBA().parse(rgba); - set_show_title(set: boolean) { - this.ext.set_boolean(SHOW_TITLE, set); - } + if (valid_color) { + this.ext.set_string(HINT_COLOR_RGBA, rgba); + } else { + this.ext.set_string(HINT_COLOR_RGBA, DEFAULT_RGBA_COLOR); + } + } - set_smart_gaps(set: boolean) { - this.ext.set_boolean(SMART_GAPS, set); - } + set_row_size(size: number) { + this.ext.set_uint(ROW_SIZE, size); + } - set_auto_unstack(set: boolean) { - this.ext.set_boolean(AUTO_UNSTACK, set); - } + set_show_title(set: boolean) { + this.ext.set_boolean(SHOW_TITLE, set); + } - set_snap_to_grid(set: boolean) { - this.ext.set_boolean(SNAP_TO_GRID, set); - } + set_smart_gaps(set: boolean) { + this.ext.set_boolean(SMART_GAPS, set); + } - set_tile_by_default(set: boolean) { - this.ext.set_boolean(TILE_BY_DEFAULT, set); - } + set_auto_unstack(set: boolean) { + this.ext.set_boolean(AUTO_UNSTACK, set); + } - set_log_level(set: number) { - this.ext.set_uint(LOG_LEVEL, set); - } + set_snap_to_grid(set: boolean) { + this.ext.set_boolean(SNAP_TO_GRID, set); + } - set_show_skiptaskbar(set: boolean) { - this.ext.set_boolean(SHOW_SKIPTASKBAR, set); - } + set_tile_by_default(set: boolean) { + this.ext.set_boolean(TILE_BY_DEFAULT, set); + } - set_mouse_cursor_follows_active_window(set: boolean) { - this.ext.set_boolean(MOUSE_CURSOR_FOLLOWS_ACTIVE_WINDOW, set); - } + set_log_level(set: number) { + this.ext.set_uint(LOG_LEVEL, set); + } - set_mouse_cursor_focus_location(set: number) { - this.ext.set_uint(MOUSE_CURSOR_FOCUS_LOCATION, set); - } + set_show_skiptaskbar(set: boolean) { + this.ext.set_boolean(SHOW_SKIPTASKBAR, set); + } + + set_mouse_cursor_follows_active_window(set: boolean) { + this.ext.set_boolean(MOUSE_CURSOR_FOLLOWS_ACTIVE_WINDOW, set); + } + + set_mouse_cursor_focus_location(set: number) { + this.ext.set_uint(MOUSE_CURSOR_FOCUS_LOCATION, set); + } } From fb6d6ed9bcc074576a4984609b54616e95539194 Mon Sep 17 00:00:00 2001 From: MeowcaTheoRange <58280776+MeowcaTheoRange@users.noreply.github.com> Date: Wed, 4 Oct 2023 08:28:11 -0500 Subject: [PATCH 5/9] Update prefs.ts --- src/prefs.ts | 73 ++++++++++++++++++++++++++-------------------------- 1 file changed, 37 insertions(+), 36 deletions(-) diff --git a/src/prefs.ts b/src/prefs.ts index 91074ffc..ea0cfc0f 100644 --- a/src/prefs.ts +++ b/src/prefs.ts @@ -1,4 +1,4 @@ -export { }; +export { } const ExtensionUtils = imports.misc.extensionUtils; // @ts-ignore @@ -8,23 +8,23 @@ const { Gtk } = imports.gi; const { Settings } = imports.gi.Gio; -import * as focus from "focus"; -import * as log from "log"; -import * as settings from "settings"; +import * as settings from 'settings'; +import * as log from 'log'; +import * as focus from 'focus'; interface AppWidgets { - fullscreen_launcher: any; - stacking_with_mouse: any; - inner_gap: any; - mouse_cursor_follows_active_window: any; - outer_gap: any; - show_skip_taskbar: any; - smart_gaps: any; - auto_unstack: any; - snap_to_grid: any; - window_titles: any; - mouse_cursor_focus_position: any; - log_level: any; + fullscreen_launcher: any, + stacking_with_mouse: any, + inner_gap: any, + mouse_cursor_follows_active_window: any, + outer_gap: any, + show_skip_taskbar: any, + smart_gaps: any, + auto_unstack: any, + snap_to_grid: any, + window_titles: any, + mouse_cursor_focus_position: any, + log_level: any, } // @ts-ignore @@ -36,31 +36,31 @@ function settings_dialog_new(): Gtk.Container { let ext = new settings.ExtensionSettings(); app.window_titles.set_active(ext.show_title()); - app.window_titles.connect("state-set", (_widget: any, state: boolean) => { + app.window_titles.connect('state-set', (_widget: any, state: boolean) => { ext.set_show_title(state); Settings.sync(); }); app.snap_to_grid.set_active(ext.snap_to_grid()); - app.snap_to_grid.connect("state-set", (_widget: any, state: boolean) => { + app.snap_to_grid.connect('state-set', (_widget: any, state: boolean) => { ext.set_snap_to_grid(state); Settings.sync(); }); app.smart_gaps.set_active(ext.smart_gaps()); - app.smart_gaps.connect("state-set", (_widget: any, state: boolean) => { + app.smart_gaps.connect('state-set', (_widget: any, state: boolean) => { ext.set_smart_gaps(state); Settings.sync(); }); app.auto_unstack.set_active(ext.auto_unstack()); - app.auto_unstack.connect("state-set", (_widget: any, state: boolean) => { + app.auto_unstack.connect('state-set', (_widget: any, state: boolean) => { ext.set_auto_unstack(state); Settings.sync(); }); app.outer_gap.set_text(String(ext.gap_outer())); - app.outer_gap.connect("activate", (widget: any) => { + app.outer_gap.connect('activate', (widget: any) => { let parsed = parseInt((widget.get_text() as string).trim()); if (!isNaN(parsed)) { ext.set_gap_outer(parsed); @@ -69,7 +69,7 @@ function settings_dialog_new(): Gtk.Container { }); app.inner_gap.set_text(String(ext.gap_inner())); - app.inner_gap.connect("activate", (widget: any) => { + app.inner_gap.connect('activate', (widget: any) => { let parsed = parseInt((widget.get_text() as string).trim()); if (!isNaN(parsed)) { ext.set_gap_inner(parsed); @@ -78,22 +78,20 @@ function settings_dialog_new(): Gtk.Container { }); app.log_level.set_active(ext.log_level()); - app.log_level.connect("changed", () => { + app.log_level.connect('changed', () => { let active_id = app.log_level.get_active_id(); ext.set_log_level(active_id); }); app.show_skip_taskbar.set_active(ext.show_skiptaskbar()); - app.show_skip_taskbar.connect("state-set", (_widget: any, state: boolean) => { + app.show_skip_taskbar.connect('state-set', (_widget: any, state: boolean) => { ext.set_show_skiptaskbar(state); Settings.sync(); }); - app.mouse_cursor_follows_active_window.set_active( - ext.mouse_cursor_follows_active_window() - ); + app.mouse_cursor_follows_active_window.set_active(ext.mouse_cursor_follows_active_window()); app.mouse_cursor_follows_active_window.connect( - "state-set", + 'state-set', (_widget: any, state: boolean) => { ext.set_mouse_cursor_follows_active_window(state); Settings.sync(); @@ -101,14 +99,14 @@ function settings_dialog_new(): Gtk.Container { ); app.mouse_cursor_focus_position.set_active(ext.mouse_cursor_focus_location()); - app.mouse_cursor_focus_position.connect("changed", () => { + app.mouse_cursor_focus_position.connect('changed', () => { let active_id = app.mouse_cursor_focus_position.get_active_id(); ext.set_mouse_cursor_focus_location(active_id); }); app.fullscreen_launcher.set_active(ext.fullscreen_launcher()); app.fullscreen_launcher.connect( - "state-set", + 'state-set', (_widget: any, state: boolean) => { ext.set_fullscreen_launcher(state); Settings.sync(); @@ -117,7 +115,7 @@ function settings_dialog_new(): Gtk.Container { app.stacking_with_mouse.set_active(ext.stacking_with_mouse()); app.stacking_with_mouse.connect( - "state-set", + 'state-set', (_widget: any, state: boolean) => { ext.set_stacking_with_mouse(state); Settings.sync(); @@ -190,16 +188,19 @@ function settings_dialog_view(): [AppWidgets, Gtk.Container] { snap_to_grid: new Gtk.Switch({ halign: Gtk.Align.END }), window_titles: new Gtk.Switch({ halign: Gtk.Align.END }), show_skip_taskbar: new Gtk.Switch({ halign: Gtk.Align.END }), - mouse_cursor_follows_active_window: new Gtk.Switch({ - halign: Gtk.Align.END, - }), + mouse_cursor_follows_active_window: new Gtk.Switch({halign: Gtk.Align.END,}), mouse_cursor_focus_position: build_combo( grid, 8, focus.FocusPosition, "Mouse Cursor Focus Position" ), - log_level: build_combo(grid, 9, log.LOG_LEVELS, "Log Level"), + log_level: build_combo( + grid, + 9, + log.LOG_LEVELS, + "Log Level" + ), }; grid.attach(win_label, 0, 0, 1, 1); @@ -280,7 +281,7 @@ function build_combo( let combo = new Gtk.ComboBoxText(); for (const [index, key] of Object.keys(iter_enum).entries()) { - if (typeof iter_enum[key] == "string") { + if (typeof iter_enum[key] == 'string') { combo.append(`${index}`, iter_enum[key]); } } From b29c4b981088bcc0053f81077d74a6cd8740a728 Mon Sep 17 00:00:00 2001 From: MeowcaTheoRange <58280776+MeowcaTheoRange@users.noreply.github.com> Date: Wed, 4 Oct 2023 08:30:03 -0500 Subject: [PATCH 6/9] Update settings.ts --- src/settings.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/settings.ts b/src/settings.ts index 1d38adaf..0e3311ec 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -81,9 +81,7 @@ export class ExtensionSettings { ext: Settings = settings_new_schema(Me.metadata["settings-schema"]); int: Settings | null = settings_new_id("org.gnome.desktop.interface"); mutter: Settings | null = settings_new_id("org.gnome.mutter"); - shell: Settings | null = settings_new_id( - "org.gnome.shell.extensions.user-theme" - ); + shell: Settings | null = settings_new_id("org.gnome.shell.extensions.user-theme"); // Getters From adeb0870e9b969329cf292753658442bd44a879d Mon Sep 17 00:00:00 2001 From: MeowcaTheoRange <58280776+MeowcaTheoRange@users.noreply.github.com> Date: Wed, 4 Oct 2023 08:32:21 -0500 Subject: [PATCH 7/9] Update settings.ts --- src/settings.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/settings.ts b/src/settings.ts index 0e3311ec..b13011dd 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -45,11 +45,7 @@ function settings_new_schema(schema: string): Settings { if (!schemaObj) { throw new Error( - "Schema " + - schema + - " could not be found for extension " + - Me.metadata.uuid + - ". Please check your installation." + "Schema " + schema + " could not be found for extension " + Me.metadata.uuid + ". Please check your installation." ); } From 6adc8b28654737346aa1bec672883ee4c390b833 Mon Sep 17 00:00:00 2001 From: MeowcaTheoRange <58280776+MeowcaTheoRange@users.noreply.github.com> Date: Fri, 13 Oct 2023 16:35:34 -0500 Subject: [PATCH 8/9] Update org.gnome.shell.extensions.pop-shell.gschema.xml (for now) --- schemas/org.gnome.shell.extensions.pop-shell.gschema.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/schemas/org.gnome.shell.extensions.pop-shell.gschema.xml b/schemas/org.gnome.shell.extensions.pop-shell.gschema.xml index 9c08724c..91a29e4f 100644 --- a/schemas/org.gnome.shell.extensions.pop-shell.gschema.xml +++ b/schemas/org.gnome.shell.extensions.pop-shell.gschema.xml @@ -66,7 +66,7 @@ false - Destroy a window stack when it contains only one window + Destroy stacks when separated by the mouse From 58f21274c9d88928048b5b58bff4a9782d6fa143 Mon Sep 17 00:00:00 2001 From: MeowcaTheoRange Date: Wed, 18 Oct 2023 09:38:47 -0500 Subject: [PATCH 9/9] Fix auto-formatting See "Sisyphus" for what my editor tried to do to me while changing this --- src/auto_tiler.ts | 2 +- src/forest.ts | 10 ++-- src/prefs.ts | 127 +++++++++++++++++++++------------------------- src/settings.ts | 23 ++++----- src/tiling.ts | 10 ++-- 5 files changed, 79 insertions(+), 93 deletions(-) diff --git a/src/auto_tiler.ts b/src/auto_tiler.ts index d7b0fb84..109848ac 100644 --- a/src/auto_tiler.ts +++ b/src/auto_tiler.ts @@ -1,12 +1,12 @@ const Me = imports.misc.extensionUtils.getCurrentExtension(); import * as ecs from 'ecs'; -import * as geom from 'geom'; import * as lib from 'lib'; import * as log from 'log'; import * as node from 'node'; import * as result from 'result'; import * as stack from 'stack'; +import * as geom from 'geom'; import * as tiling from 'tiling'; import type { Entity } from 'ecs'; diff --git a/src/forest.ts b/src/forest.ts index b8df4557..bbb797b7 100644 --- a/src/forest.ts +++ b/src/forest.ts @@ -3,19 +3,19 @@ const Me = imports.misc.extensionUtils.getCurrentExtension(); import * as arena from 'arena'; import * as Ecs from 'ecs'; -import * as Fork from 'fork'; -import * as geom from 'geom'; import * as Lib from 'lib'; import * as log from 'log'; import * as movement from 'movement'; -import * as Node from 'node'; import * as Rect from 'rectangle'; +import * as Node from 'node'; +import * as Fork from 'fork'; +import * as geom from 'geom'; import type { Entity } from 'ecs'; -import type { Ext } from './extension'; import type { Rectangle } from './rectangle'; -import { Stack } from './stack'; import type { ShellWindow } from './window'; +import type { Ext } from './extension'; +import { Stack } from './stack'; const { Arena } = arena; const { Meta } = imports.gi; diff --git a/src/prefs.ts b/src/prefs.ts index ea0cfc0f..4db828be 100644 --- a/src/prefs.ts +++ b/src/prefs.ts @@ -1,4 +1,4 @@ -export { } +export { }; const ExtensionUtils = imports.misc.extensionUtils; // @ts-ignore @@ -8,9 +8,9 @@ const { Gtk } = imports.gi; const { Settings } = imports.gi.Gio; -import * as settings from 'settings'; -import * as log from 'log'; import * as focus from 'focus'; +import * as log from 'log'; +import * as settings from 'settings'; interface AppWidgets { fullscreen_launcher: any, @@ -51,7 +51,7 @@ function settings_dialog_new(): Gtk.Container { app.smart_gaps.connect('state-set', (_widget: any, state: boolean) => { ext.set_smart_gaps(state); Settings.sync(); - }); + }) app.auto_unstack.set_active(ext.auto_unstack()); app.auto_unstack.connect('state-set', (_widget: any, state: boolean) => { @@ -65,7 +65,7 @@ function settings_dialog_new(): Gtk.Container { if (!isNaN(parsed)) { ext.set_gap_outer(parsed); Settings.sync(); - } + }; }); app.inner_gap.set_text(String(ext.gap_inner())); @@ -90,13 +90,10 @@ function settings_dialog_new(): Gtk.Container { }); app.mouse_cursor_follows_active_window.set_active(ext.mouse_cursor_follows_active_window()); - app.mouse_cursor_follows_active_window.connect( - 'state-set', - (_widget: any, state: boolean) => { - ext.set_mouse_cursor_follows_active_window(state); - Settings.sync(); - } - ); + app.mouse_cursor_follows_active_window.connect('state-set', (_widget: any, state: boolean) => { + ext.set_mouse_cursor_follows_active_window(state); + Settings.sync(); + }); app.mouse_cursor_focus_position.set_active(ext.mouse_cursor_focus_location()); app.mouse_cursor_focus_position.connect('changed', () => { @@ -105,22 +102,16 @@ function settings_dialog_new(): Gtk.Container { }); app.fullscreen_launcher.set_active(ext.fullscreen_launcher()); - app.fullscreen_launcher.connect( - 'state-set', - (_widget: any, state: boolean) => { - ext.set_fullscreen_launcher(state); - Settings.sync(); - } - ); + app.fullscreen_launcher.connect('state-set',(_widget: any, state: boolean) => { + ext.set_fullscreen_launcher(state); + Settings.sync() + }); app.stacking_with_mouse.set_active(ext.stacking_with_mouse()); - app.stacking_with_mouse.connect( - 'state-set', - (_widget: any, state: boolean) => { - ext.set_stacking_with_mouse(state); - Settings.sync(); - } - ); + app.stacking_with_mouse.connect('state-set', (_widget: any, state: boolean) => { + ext.set_stacking_with_mouse(state); + Settings.sync() + }); return grid; } @@ -133,48 +124,48 @@ function settings_dialog_view(): [AppWidgets, Gtk.Container] { margin_end: 10, margin_bottom: 10, margin_top: 10, - }); + }) const win_label = new Gtk.Label({ label: "Show Window Titles", xalign: 0.0, - hexpand: true, - }); + hexpand: true + }) const snap_label = new Gtk.Label({ label: "Snap to Grid (Floating Mode)", - xalign: 0.0, - }); + xalign: 0.0 + }) const smart_label = new Gtk.Label({ label: "Smart Gaps", - xalign: 0.0, - }); + xalign: 0.0 + }) const unstack_label = new Gtk.Label({ - label: "Automatically destroy single-window stacks", - xalign: 0.0, - }); + label: "Destroy stacks when separated by the mouse", + xalign: 0.0 + }) const show_skip_taskbar_label = new Gtk.Label({ label: "Show Minimize to Tray Windows", - xalign: 0.0, - }); + xalign: 0.0 + }) const mouse_cursor_follows_active_window_label = new Gtk.Label({ label: "Mouse Cursor Follows Active Window", - xalign: 0.0, - }); + xalign: 0.0 + }) const fullscreen_launcher_label = new Gtk.Label({ label: "Allow launcher over fullscreen window", - xalign: 0.0, - }); + xalign: 0.0 + }) const stacking_with_mouse = new Gtk.Label({ label: "Allow stacking with mouse", - xalign: 0.0, - }); + xalign: 0.0 + }) const [inner_gap, outer_gap] = gaps_section(grid, 10); @@ -188,7 +179,7 @@ function settings_dialog_view(): [AppWidgets, Gtk.Container] { snap_to_grid: new Gtk.Switch({ halign: Gtk.Align.END }), window_titles: new Gtk.Switch({ halign: Gtk.Align.END }), show_skip_taskbar: new Gtk.Switch({ halign: Gtk.Align.END }), - mouse_cursor_follows_active_window: new Gtk.Switch({halign: Gtk.Align.END,}), + mouse_cursor_follows_active_window: new Gtk.Switch({ halign: Gtk.Align.END }), mouse_cursor_focus_position: build_combo( grid, 8, @@ -203,29 +194,29 @@ function settings_dialog_view(): [AppWidgets, Gtk.Container] { ), }; - grid.attach(win_label, 0, 0, 1, 1); - grid.attach(settings.window_titles, 1, 0, 1, 1); + grid.attach(win_label, 0, 0, 1, 1) + grid.attach(settings.window_titles, 1, 0, 1, 1) - grid.attach(snap_label, 0, 1, 1, 1); - grid.attach(settings.snap_to_grid, 1, 1, 1, 1); + grid.attach(snap_label, 0, 1, 1, 1) + grid.attach(settings.snap_to_grid, 1, 1, 1, 1) - grid.attach(smart_label, 0, 2, 1, 1); - grid.attach(settings.smart_gaps, 1, 2, 1, 1); + grid.attach(smart_label, 0, 2, 1, 1) + grid.attach(settings.smart_gaps, 1, 2, 1, 1) - grid.attach(unstack_label, 0, 3, 1, 1); - grid.attach(settings.auto_unstack, 1, 3, 1, 1); + grid.attach(unstack_label, 0, 3, 1, 1) + grid.attach(settings.auto_unstack, 1, 3, 1, 1) - grid.attach(fullscreen_launcher_label, 0, 4, 1, 1); - grid.attach(settings.fullscreen_launcher, 1, 4, 1, 1); + grid.attach(fullscreen_launcher_label, 0, 4, 1, 1) + grid.attach(settings.fullscreen_launcher, 1, 4, 1, 1) - grid.attach(stacking_with_mouse, 0, 5, 1, 1); - grid.attach(settings.stacking_with_mouse, 1, 5, 1, 1); + grid.attach(stacking_with_mouse, 0, 5, 1, 1) + grid.attach(settings.stacking_with_mouse, 1, 5, 1, 1) - grid.attach(show_skip_taskbar_label, 0, 6, 1, 1); - grid.attach(settings.show_skip_taskbar, 1, 6, 1, 1); + grid.attach(show_skip_taskbar_label, 0, 6, 1, 1) + grid.attach(settings.show_skip_taskbar, 1, 6, 1, 1) - grid.attach(mouse_cursor_follows_active_window_label, 0, 7, 1, 1); - grid.attach(settings.mouse_cursor_follows_active_window, 1, 7, 1, 1); + grid.attach(mouse_cursor_follows_active_window_label, 0, 7, 1, 1) + grid.attach(settings.mouse_cursor_follows_active_window, 1, 7, 1, 1) return [settings, grid]; } @@ -234,7 +225,7 @@ function gaps_section(grid: any, top: number): [any, any] { let outer_label = new Gtk.Label({ label: "Outer", xalign: 0.0, - margin_start: 24, + margin_start: 24 }); let outer_entry = number_entry(); @@ -242,14 +233,14 @@ function gaps_section(grid: any, top: number): [any, any] { let inner_label = new Gtk.Label({ label: "Inner", xalign: 0.0, - margin_start: 24, + margin_start: 24 }); let inner_entry = number_entry(); let section_label = new Gtk.Label({ label: "Gaps", - xalign: 0.0, + xalign: 0.0 }); grid.attach(section_label, 0, top, 1, 1); @@ -269,11 +260,11 @@ function build_combo( grid: any, top_index: number, iter_enum: any, - label: string + label: string, ) { let label_ = new Gtk.Label({ label: label, - halign: Gtk.Align.START, + halign: Gtk.Align.START }); grid.attach(label_, 0, top_index, 1, 1); @@ -287,14 +278,14 @@ function build_combo( } grid.attach(combo, 1, top_index, 1, 1); - return combo; + return combo } // @ts-ignore function buildPrefsWidget() { let dialog = settings_dialog_new(); if (dialog.show_all) { - dialog.show_all(); + dialog.show_all() } else { dialog.show(); } diff --git a/src/settings.ts b/src/settings.ts index b13011dd..28767a14 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -34,19 +34,14 @@ function settings_new_schema(schema: string): Settings { const schemaDir = Me.dir.get_child("schemas"); let schemaSource = schemaDir.query_exists(null) - ? GioSSS.new_from_directory( - schemaDir.get_path(), - GioSSS.get_default(), - false - ) - : GioSSS.get_default(); + ? GioSSS.new_from_directory(schemaDir.get_path(), GioSSS.get_default(), false) : + GioSSS.get_default(); const schemaObj = schemaSource.lookup(schema, true); if (!schemaObj) { - throw new Error( - "Schema " + schema + " could not be found for extension " + Me.metadata.uuid + ". Please check your installation." - ); + throw new Error("Schema " + schema + " could not be found for extension " + + Me.metadata.uuid + ". Please check your installation."); } return new Gio.Settings({ settings_schema: schemaObj }); @@ -126,15 +121,15 @@ export class ExtensionSettings { theme(): string { return this.shell - ? this.shell.get_string("name") - : this.int - ? this.int.get_string("gtk-theme") - : "Adwaita"; + ? this.shell.get_string("name") + : this.int + ? this.int.get_string("gtk-theme") + : "Adwaita" } is_dark(): boolean { const theme = this.theme().toLowerCase(); - return DARK.some((dark) => theme.includes(dark)); + return DARK.some(dark => theme.includes(dark)); } is_high_contrast(): boolean { diff --git a/src/tiling.ts b/src/tiling.ts index c12afb85..6717f9b2 100644 --- a/src/tiling.ts +++ b/src/tiling.ts @@ -2,8 +2,6 @@ const Me = imports.misc.extensionUtils.getCurrentExtension(); // import * as Ecs from 'ecs'; -import * as exec from 'executor'; -import * as geom from 'geom'; import * as GrabOp from 'grab_op'; import * as Lib from 'lib'; import * as Log from 'log'; @@ -11,13 +9,15 @@ import * as Node from 'node'; import * as Rect from 'rectangle'; import * as Tags from 'tags'; import * as window from 'window'; +import * as geom from 'geom'; +import * as exec from 'executor'; -import { AutoTiler } from './auto_tiler'; import type { Entity } from './ecs'; +import type { Rectangle } from './rectangle'; import type { Ext } from './extension'; -import { Fork } from './fork'; import type { NodeStack } from './node'; -import type { Rectangle } from './rectangle'; +import { AutoTiler } from './auto_tiler'; +import { Fork } from './fork'; const { Meta } = imports.gi; const Main = imports.ui.main;