Skip to content

Commit

Permalink
version 14: enable translations, customize animations, settings expor…
Browse files Browse the repository at this point in the history
…t, more keybindings, delay window restore
  • Loading branch information
domferr committed Oct 24, 2024
1 parent 218ca48 commit 86bc333
Show file tree
Hide file tree
Showing 26 changed files with 1,961 additions and 227 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<img src="https://raw.githubusercontent.com/domferr/tilingshell/main/logo.png" align="right" width="76"/>

![](https://img.shields.io/github/v/release/domferr/tilingshell)
![](https://img.shields.io/badge/GNOME-42--46-e04196)
![](https://img.shields.io/badge/GNOME-42--47-e04196)
![](https://img.shields.io/github/downloads/domferr/tilingshell/total)
![](https://img.shields.io/badge/Built%20with-Typescript-blue)
![](https://img.shields.io/github/license/domferr/tilingshell)
Expand Down
15 changes: 14 additions & 1 deletion esbuild.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,14 @@ Mtk.Rectangle.$gtype = imports.gi.Meta.Rectangle.$gtype;

const extensionFooter = `
function init(meta) {
imports.misc.extensionUtils.initTranslations();
return new TilingShellExtension(meta);
}
`;

const prefsBanner = `// For GNOME Shell version before 45
const Config = imports.misc.config;
class ExtensionPreferences {
constructor(metadata) {
this.metadata = metadata;
Expand All @@ -47,7 +50,7 @@ class ExtensionPreferences {

const prefsFooter = `
function init() {
imports.misc.extensionUtils.initTranslations();
}
function fillPreferencesWindow(window) {
Expand All @@ -73,6 +76,16 @@ function convertImports(text) {
// drop import of ExtensionPreferences class
text = text.replaceAll('import { ExtensionPreferences } from "resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js";', "");

// drop import of Config from preferences
text = text.replaceAll('import * as Config from "resource:///org/gnome/Shell/Extensions/js/misc/config.js";', "");

// replace import of translation related code
const regexTranslation = new RegExp(`import {(.*|\n.*)?gettext as _[^from]*[^;]*;`, 'gm');
text = text.replaceAll(regexTranslation, "const { gettext: _, ngettext, pgettext } = imports.misc.extensionUtils;");

// replace import of all translation stuff made in translation.ts
//text = text.replaceAll('import { gettext as _, ngettext, pgettext } from "resource:///org/gnome/shell/extensions/extension.js";', "const { gettext: _, ngettext, pgettext } = imports.misc.extensionUtils;");

const regexExportExtension = new RegExp(`export {((.|\n)*)(.+) as default((.|\n)*)};`, 'gm');
text = text.replaceAll(regexExportExtension, "");

Expand Down
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
{
"name": "tilingshell",
"version": "13.0",
"version": "14",
"author": "Domenico Ferraro <[email protected]>",
"private": true,
"license": "GPL v2.0",
"scripts": {
"build": "npm run clean && node esbuild.mjs && npm run build:schema",
"clean": "rm -rf dist; rm -rf dist_legacy",
"update-translations": "npm run create:translations && npm run merge:translations && npm run build:translations",
"build:schema": "npm run clean:schema && glib-compile-schemas ./resources/schemas --targetdir=./dist/schemas/ && cp ./dist/schemas/ ./dist_legacy/ -r",
"clean:schema": "rm -rf ./dist/schemas/*.compiled; rm -rf ./dist_legacy/schemas/*.compiled",
"build:package": "npm run clean:package; npm run build && cd ./dist && zip -qr ../[email protected] * && cd ../dist_legacy && zip -qr ../[email protected] *",
"clean:package": "rm -rf './dist/[email protected]'; rm -rf './dist_legacy/[email protected]'",
"install:extension": "mkdir -p ~/.local/share/gnome-shell/extensions/[email protected] && cp ./dist$([ $(gnome-shell --version | grep -o -E '[0-9]+' | head -n 1) -le 44 ] && echo '_legacy')/* ~/.local/share/gnome-shell/extensions/[email protected]/ -r",
"wayland-session": "dbus-run-session -- gnome-shell --nested --wayland",
"dev:wayland": "npm run build && npm run install:extension && npm run wayland-session",
"build:translations": "for file in $(ls translations/*.po); do mkdir -p resources/locale/$(basename $file .po)/LC_MESSAGES; msgfmt -c $file -o resources/locale/$(basename $file .po)/LC_MESSAGES/tilingshell.mo; done",
"create:translations": "xgettext --from-code=UTF-8 --output=translations/[email protected] -j --language=javascript --force-po dist/prefs.js dist/extension.js",
"merge:translations": "for file in $(ls translations/*.po); do msgmerge -U $file translations/[email protected] --backup=none; done",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"prettier:check": "prettier --check \"**/*.{ts,scss}\"",
Expand Down
Binary file added resources/locale/it/LC_MESSAGES/tilingshell.mo
Binary file not shown.
3 changes: 2 additions & 1 deletion resources/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
"47"
],
"version": 99,
"version-name": "13.1",
"version-name": "14",
"url": "https://github.com/domferr/tilingshell",
"settings-schema": "org.gnome.shell.extensions.tilingshell",
"gettext-domain": "tilingshell",
"donations": {
"kofi": "domferr"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,16 @@
<summary>Focused window border width</summary>
<description>The width of the focused window's border.</description>
</key>
<key name="snap-assistant-animation-time" type="u">
<default>180</default>
<summary>Snap assistant animation time (milliseconds)</summary>
<description>Animation time in milliseconds of the snap assistant</description>
</key>
<key name="tile-preview-animation-time" type="u">
<default>100</default>
<summary>Tile animation time (milliseconds)</summary>
<description>Animation time in milliseconds of the tiles</description>
</key>

<!-- keybindings -->
<key type="as" name="move-window-right">
Expand Down Expand Up @@ -169,6 +179,26 @@
<default><![CDATA[['']]]></default>
<summary>Untile the focused window</summary>
</key>
<key type="as" name="move-window-center">
<default><![CDATA[['']]]></default>
<summary>Move the focused window to the center of the screen</summary>
</key>
<key type="as" name="focus-window-right">
<default><![CDATA[['']]]></default>
<summary>Focus the window to the right the current focused window</summary>
</key>
<key type="as" name="focus-window-left">
<default><![CDATA[['']]]></default>
<summary>Focus the window to the left of the current focused window</summary>
</key>
<key type="as" name="focus-window-up">
<default><![CDATA[['']]]></default>
<summary>Focus the window above the current focused window</summary>
</key>
<key type="as" name="focus-window-down">
<default><![CDATA[['']]]></default>
<summary>Focus the window below the current focused window</summary>
</key>
</schema>

</schemalist>
17 changes: 9 additions & 8 deletions src/components/editor/editorDialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import Tile from '@/components/layout/Tile';
import * as ModalDialog from 'resource:///org/gnome/shell/ui/modalDialog.js';
import * as Main from 'resource:///org/gnome/shell/ui/main.js';
import { enableScalingFactorSupport, getMonitorScalingFactor } from '@utils/ui';
import { _ } from '../../translations';

@registerGObjectClass
export default class EditorDialog extends ModalDialog.ModalDialog {
Expand Down Expand Up @@ -44,7 +45,7 @@ export default class EditorDialog extends ModalDialog.ModalDialog {

this.contentLayout.add_child(
new St.Label({
text: 'Select the layout to edit',
text: _('Select the layout to edit'),
xAlign: Clutter.ActorAlign.CENTER,
xExpand: true,
styleClass: 'editor-dialog-title',
Expand All @@ -69,7 +70,7 @@ export default class EditorDialog extends ModalDialog.ModalDialog {
}

this.addButton({
label: 'Close',
label: _('Close'),
default: true,
key: Clutter.KEY_Escape,
action: () => params.onClose(),
Expand Down Expand Up @@ -98,7 +99,7 @@ export default class EditorDialog extends ModalDialog.ModalDialog {
);
suggestion1.add_child(
new St.Label({
text: ' to split a tile.',
text: ` ${_('to split a tile')}.`,
xAlign: Clutter.ActorAlign.CENTER,
yAlign: Clutter.ActorAlign.CENTER,
styleClass: '',
Expand Down Expand Up @@ -139,7 +140,7 @@ export default class EditorDialog extends ModalDialog.ModalDialog {
);
suggestion2.add_child(
new St.Label({
text: ' to split a tile vertically.',
text: ` ${_('to split a tile vertically')}.`,
xAlign: Clutter.ActorAlign.CENTER,
yAlign: Clutter.ActorAlign.CENTER,
styleClass: '',
Expand All @@ -161,7 +162,7 @@ export default class EditorDialog extends ModalDialog.ModalDialog {
);
suggestion3.add_child(
new St.Label({
text: ' to delete a tile.',
text: ` ${_('to delete a tile')}.`,
xAlign: Clutter.ActorAlign.CENTER,
yAlign: Clutter.ActorAlign.CENTER,
styleClass: '',
Expand All @@ -188,7 +189,7 @@ export default class EditorDialog extends ModalDialog.ModalDialog {
);
suggestion4.add_child(
new St.Label({
text: ' use the indicator button to save or cancel.',
text: ` ${_('use the indicator button to save or cancel')}.`,
xAlign: Clutter.ActorAlign.CENTER,
yAlign: Clutter.ActorAlign.CENTER,
styleClass: '',
Expand All @@ -208,7 +209,7 @@ export default class EditorDialog extends ModalDialog.ModalDialog {
this.contentLayout.destroy_all_children();
this.contentLayout.add_child(
new St.Label({
text: 'How to use the editor',
text: _('How to use the editor'),
xAlign: Clutter.ActorAlign.CENTER,
xExpand: true,
styleClass: 'editor-dialog-title',
Expand All @@ -218,7 +219,7 @@ export default class EditorDialog extends ModalDialog.ModalDialog {

this.clearButtons();
this.addButton({
label: 'Start editing',
label: _('Start editing'),
default: true,
key: Clutter.KEY_Escape,
action: params.onClose,
Expand Down
27 changes: 23 additions & 4 deletions src/components/snapassist/snapAssist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import {
} from '@utils/ui';

export const SNAP_ASSIST_SIGNAL = 'snap-assist';
export const SNAP_ASSIST_ANIMATION_TIME = 180;
const GAPS = 4;

@registerGObjectClass
Expand All @@ -45,6 +44,15 @@ class SnapAssistContent extends St.BoxLayout {
240,
16,
),
snapAssistantAnimationTime: GObject.ParamSpec.uint(
'snapAssistantAnimationTime',
'snapAssistantAnimationTime',
'Animation time in milliseconds',
GObject.ParamFlags.READWRITE,
0,
2000,
180,
),
},
};

Expand All @@ -58,6 +66,7 @@ class SnapAssistContent extends St.BoxLayout {
private _bottomPadding: number;
private _blur: boolean;
private _snapAssistantThreshold: number;
private _snapAssistantAnimationTime: number;
private _monitorIndex: number;

constructor(container: St.Widget, monitorIndex: number) {
Expand All @@ -78,6 +87,7 @@ class SnapAssistContent extends St.BoxLayout {
this._showing = true;
this._bottomPadding = 0;
this._blur = false;
this._snapAssistantAnimationTime = 100;
this._monitorIndex = monitorIndex;
this._snapAssistantThreshold =
54 * getMonitorScalingFactor(this._monitorIndex);
Expand All @@ -88,13 +98,18 @@ class SnapAssistContent extends St.BoxLayout {
'blur',
Gio.SettingsBindFlags.GET,
);

Settings.bind(
Settings.SETTING_SNAP_ASSISTANT_THRESHOLD,
this,
'snapAssistantThreshold',
Gio.SettingsBindFlags.GET,
);
Settings.bind(
Settings.SETTING_SNAP_ASSISTANT_ANIMATION_TIME,
this,
'snapAssistantAnimationTime',
Gio.SettingsBindFlags.GET,
);

this._applyStyle();
this._signals.connect(
Expand Down Expand Up @@ -132,6 +147,10 @@ class SnapAssistContent extends St.BoxLayout {
value * getMonitorScalingFactor(this._monitorIndex);
}

private set snapAssistantAnimationTime(value: number) {
this._snapAssistantAnimationTime = value;
}

get showing(): boolean {
return this._showing;
}
Expand Down Expand Up @@ -175,7 +194,7 @@ class SnapAssistContent extends St.BoxLayout {
this.ease({
y: this._desiredY,
opacity: 0,
duration: ease ? SNAP_ASSIST_ANIMATION_TIME : 0,
duration: ease ? this._snapAssistantAnimationTime : 0,
mode: Clutter.AnimationMode.EASE_OUT_QUAD,
onComplete: () => {
this.hide();
Expand Down Expand Up @@ -207,7 +226,7 @@ class SnapAssistContent extends St.BoxLayout {
this.ease({
y: this._desiredY,
opacity: 255,
duration: ease ? SNAP_ASSIST_ANIMATION_TIME : 0,
duration: ease ? this._snapAssistantAnimationTime : 0,
mode: Clutter.AnimationMode.EASE_OUT_QUAD,
});
}
Expand Down
9 changes: 4 additions & 5 deletions src/components/tilepreview/tilePreview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import Mtk from 'gi://Mtk';
import { registerGObjectClass } from '@/utils/gjs';
import Clutter from 'gi://Clutter';
import { buildRectangle, getScalingFactorOf } from '@utils/ui';

export const WINDOW_ANIMATION_TIME = 100;
import GlobalState from '@utils/globalState';

// export module TilePreview {
export interface TilePreviewConstructorProperties
Expand Down Expand Up @@ -97,15 +96,15 @@ export default class TilePreview extends St.Widget {
width: this.innerWidth,
height: this.innerHeight,
opacity: 255,
duration: ease ? WINDOW_ANIMATION_TIME : 0,
duration: ease ? GlobalState.get().tilePreviewAnimationTime : 0,
mode: Clutter.AnimationMode.EASE_OUT_QUAD,
});
} else {
this.set_position(this.innerX, this.innerY);
this.set_size(this.innerWidth, this.innerHeight);
this.ease({
opacity: 255,
duration: ease ? WINDOW_ANIMATION_TIME : 0,
duration: ease ? GlobalState.get().tilePreviewAnimationTime : 0,
mode: Clutter.AnimationMode.EASE_OUT_QUAD,
});
}
Expand Down Expand Up @@ -147,7 +146,7 @@ export default class TilePreview extends St.Widget {
this._showing = false;
this.ease({
opacity: 0,
duration: ease ? WINDOW_ANIMATION_TIME : 0,
duration: ease ? GlobalState.get().tilePreviewAnimationTime : 0,
mode: Clutter.AnimationMode.EASE_OUT_QUAD,
onComplete: () => this.hide(),
});
Expand Down
Loading

0 comments on commit 86bc333

Please sign in to comment.