From 21fa557f3350d65e524133dbef987e286f93be6a Mon Sep 17 00:00:00 2001 From: Octopus Date: Sun, 22 Oct 2023 21:20:29 +0200 Subject: [PATCH 1/4] =?UTF-8?q?=E2=AD=90=EF=B8=8F=20Start=20updating=20to?= =?UTF-8?q?=20GNOME=2045?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixed the imports. --- extension.js | 31 ++++++++++++++++--------------- js/config.js | 6 +++--- js/manager.js | 12 ++++++------ js/snowflake.js | 10 +++++----- js/utils.js | 2 +- metadata.json | 11 ++++------- 6 files changed, 35 insertions(+), 37 deletions(-) diff --git a/extension.js b/extension.js index 962c316..87e410e 100644 --- a/extension.js +++ b/extension.js @@ -1,20 +1,21 @@ -const { GLib } = imports.gi -const Utils = imports.misc.extensionUtils -const Extension = Utils.getCurrentExtension() -const { Config } = Extension.imports.js.config -const { Manager } = Extension.imports.js.manager +import GLib from 'gi://GLib' +import {Extension} from 'resource:///org/gnome/shell/extensions/extension.js' +//constimportExtension = Utils.getCurrentExtension() +import * as Config from './js/config.js' +import * as Manager from './js/manager.js' let manager = null +export default class snowy { + function init() {} -function init() {} + function enable() { + const config = new Config('org.gnome.shell.extensions.snowy') + manager = new Manager() + manager.startSnowing(config) + } -function enable() { - const config = new Config('org.gnome.shell.extensions.snowy') - manager = new Manager() - manager.startSnowing(config) -} - -function disable() { - manager.stopSnowing() - manager = null + function disable() { + manager.stopSnowing() + manager = null + } } diff --git a/js/config.js b/js/config.js index 0a719ef..6dbbd5a 100644 --- a/js/config.js +++ b/js/config.js @@ -1,7 +1,7 @@ -const GObject = imports.gi.GObject +import GObject from 'gi://GObject' -const Utils = imports.misc.extensionUtils -const Extension = Utils.getCurrentExtension() +import {Extension} from 'resource:///org/gnome/shell/extensions/extension.js' +//const Extension = Utils.getCurrentExtension() var Config = class Config { constructor(id) { diff --git a/js/manager.js b/js/manager.js index 66d8d92..86843d0 100644 --- a/js/manager.js +++ b/js/manager.js @@ -1,10 +1,10 @@ -const { GLib } = imports.gi -const Main = imports.ui.main +import GLib from 'gi://GLib' +import Main from 'resource:///org/gnome/shell/ui/main.js' -const Utils = imports.misc.extensionUtils -const Extension = Utils.getCurrentExtension() -const { Snowflake } = Extension.imports.js.snowflake -const { random, setInterval } = Extension.imports.js.utils +//const Utils = imports.misc.extensionUtils +//const Extension = Utils.getCurrentExtension() +import * as Snowflake from './snowflake.js' +import * as from './utils.js' var Manager = class Manager { constructor() { diff --git a/js/snowflake.js b/js/snowflake.js index 13ab892..04e16e3 100644 --- a/js/snowflake.js +++ b/js/snowflake.js @@ -1,10 +1,10 @@ -const { St, Clutter } = imports.gi -const Main = imports.ui.main +import { St, Clutter } from 'gi://GLib' +import Main from 'resource:///org/gnome/shell/ui/main.js' -const Utils = imports.misc.extensionUtils -const Extension = Utils.getCurrentExtension() +import {Extension} from 'resource:///org/gnome/shell/extensions/extension.js' +//const Extension = Utils.getCurrentExtension() -const { random } = Extension.imports.js.utils +import { random } = './utils.js' var Snowflake = class Snowflake { constructor(config) { diff --git a/js/utils.js b/js/utils.js index 6f3b53e..b6db47e 100644 --- a/js/utils.js +++ b/js/utils.js @@ -1,4 +1,4 @@ -const { GLib } = imports.gi +import GLib from 'gi://GLib' function random(min, max) { return Math.floor(Math.random() * (max - min + 1)) + min diff --git a/metadata.json b/metadata.json index cdbd865..ef8960a 100644 --- a/metadata.json +++ b/metadata.json @@ -1,14 +1,11 @@ { + "_generated": "Generated by SweetTooth, do not edit", "description": "Make you festive mood with falling snow on your GNOME DE system", "name": "Snowy", "shell-version": [ - "43", - "42", - "41", - "40", - "3" + "45" ], "url": "https://github.com/ExposedCat/snowy", "uuid": "snowy@exposedcat", - "version": 3.1 -} \ No newline at end of file + "version": 16 +} From 41012a92367e22858246f233ab91994f2d507380 Mon Sep 17 00:00:00 2001 From: Octopus Date: Mon, 23 Oct 2023 18:24:22 +0200 Subject: [PATCH 2/4] =?UTF-8?q?=F0=9F=90=9B=20Fix=20critical=20errors?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix an error that was caused due to my misunderstanding of a part of the port tutorial. And another smaller one. --- extension.js | 25 ++++++++++++------------- js/manager.js | 4 ++-- js/snowflake.js | 2 +- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/extension.js b/extension.js index 87e410e..92773d1 100644 --- a/extension.js +++ b/extension.js @@ -1,21 +1,20 @@ import GLib from 'gi://GLib' import {Extension} from 'resource:///org/gnome/shell/extensions/extension.js' //constimportExtension = Utils.getCurrentExtension() -import * as Config from './js/config.js' -import * as Manager from './js/manager.js' +import {Config} from './js/config.js' +import {Manager} from './js/manager.js' let manager = null -export default class snowy { - function init() {} - function enable() { - const config = new Config('org.gnome.shell.extensions.snowy') - manager = new Manager() - manager.startSnowing(config) - } +function init() {} - function disable() { - manager.stopSnowing() - manager = null - } +function enable() { + const config = new Config('org.gnome.shell.extensions.snowy') + manager = new Manager() + manager.startSnowing(config) +} + +function disable() { + manager.stopSnowing() + manager = null } diff --git a/js/manager.js b/js/manager.js index 86843d0..4fb6af5 100644 --- a/js/manager.js +++ b/js/manager.js @@ -3,8 +3,8 @@ import Main from 'resource:///org/gnome/shell/ui/main.js' //const Utils = imports.misc.extensionUtils //const Extension = Utils.getCurrentExtension() -import * as Snowflake from './snowflake.js' -import * as from './utils.js' +import {Snowflake} from './snowflake.js' +import {random, setInterval} from './utils.js' var Manager = class Manager { constructor() { diff --git a/js/snowflake.js b/js/snowflake.js index 04e16e3..13cc369 100644 --- a/js/snowflake.js +++ b/js/snowflake.js @@ -4,7 +4,7 @@ import Main from 'resource:///org/gnome/shell/ui/main.js' import {Extension} from 'resource:///org/gnome/shell/extensions/extension.js' //const Extension = Utils.getCurrentExtension() -import { random } = './utils.js' +import {random} from './utils.js' var Snowflake = class Snowflake { constructor(config) { From b8f13cd2fe0b38f9cedfec45e2487aecc26278d5 Mon Sep 17 00:00:00 2001 From: Artem Prokop Date: Mon, 30 Oct 2023 02:14:38 +0100 Subject: [PATCH 3/4] =?UTF-8?q?=F0=9F=A7=B9=20Refactor=20project,=20fix=20?= =?UTF-8?q?small=20issues?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 11 +---------- extension.js | 33 +++++++++++++++++---------------- js/config.js | 15 +++++---------- js/manager.js | 11 ++++------- js/snowflake.js | 7 ++----- js/utils.js | 7 +++---- metadata.json | 3 +-- 7 files changed, 33 insertions(+), 54 deletions(-) diff --git a/README.md b/README.md index 2da5274..7ec3b16 100644 --- a/README.md +++ b/README.md @@ -26,16 +26,7 @@ glib-compile-schemas snowy/schemas
 mv snowy ~/.local/share/gnome-shell/extensions/snowy@exposedcat
 
-3. Restart shell -
    -
  • On X11: restart shell
  • -
      -
    1. Press Alt+F2
    2. -
    3. Type r
    4. -
    5. Press Return
    6. -
    -
  • On Wayland: logout and login again
  • -
+3. Logout and login again

Configuration

GUI settings are still in development (contribution is highly appreciated), but you can tweak nearly everything using gsettings command:
diff --git a/extension.js b/extension.js
index 92773d1..a432c88 100644
--- a/extension.js
+++ b/extension.js
@@ -1,20 +1,21 @@
-import GLib from 'gi://GLib'
-import {Extension} from 'resource:///org/gnome/shell/extensions/extension.js'
-//constimportExtension = Utils.getCurrentExtension()
-import {Config} from './js/config.js'
-import {Manager} from './js/manager.js'
+import { Extension } from 'resource:///org/gnome/shell/extensions/extension.js'
 
-let manager = null
+import { Config } from './js/config.js'
+import { Manager } from './js/manager.js'
 
-function init() {}
+export default class SnowyExtension extends Extension {
+	constructor() {
+		this.manager = new Manager()
+	}
 
-function enable() {
-	const config = new Config('org.gnome.shell.extensions.snowy')
-	manager = new Manager()
-	manager.startSnowing(config)
-}
-
-function disable() {
-	manager.stopSnowing()
-	manager = null
+	enable() {
+		const settings = this.getSettings();
+		const config = new Config(settings)
+		this.manager.startSnowing(config)
+	}
+	
+	disable() {
+		this.manager.stopSnowing()
+		this.manager = null
+	}
 }
diff --git a/js/config.js b/js/config.js
index 6dbbd5a..3056561 100644
--- a/js/config.js
+++ b/js/config.js
@@ -1,18 +1,13 @@
-import GObject from 'gi://GObject'
-
-import {Extension} from 'resource:///org/gnome/shell/extensions/extension.js'
-//const Extension = Utils.getCurrentExtension()
-
-var Config = class Config {
-	constructor(id) {
-		this.data = Utils.getSettings(id)
+export class Config {
+	constructor(settings) {
+		this.settings = settings
 	}
 
 	int(name) {
-		return this.data.get_int(name)
+		return this.settings.get_int(name)
 	}
 
 	string(name) {
-		return this.data.get_string(name)
+		return this.settings.get_string(name)
 	}
 }
diff --git a/js/manager.js b/js/manager.js
index 4fb6af5..2e8e881 100644
--- a/js/manager.js
+++ b/js/manager.js
@@ -1,12 +1,10 @@
 import GLib from 'gi://GLib'
 import Main from 'resource:///org/gnome/shell/ui/main.js'
 
-//const Utils = imports.misc.extensionUtils
-//const Extension = Utils.getCurrentExtension()
-import {Snowflake} from './snowflake.js' 
-import {random, setInterval} from './utils.js'
+import { Snowflake } from './snowflake.js' 
+import { random, setInterval } from './utils.js'
 
-var Manager = class Manager {
+export class Manager {
 	constructor() {
 		this.timerId = null
 		this.snowing = false
@@ -51,8 +49,7 @@ var Manager = class Manager {
 				)
 				for (
 					let i = 0;
-					i < newSnowflakesCount &&
-					this.snowflakesCount <= config.int('flakes-limit');
+					i < newSnowflakesCount && this.snowflakesCount <= config.int('flakes-limit');
 					++i
 				) {
 					const snowflake = new Snowflake(config)
diff --git a/js/snowflake.js b/js/snowflake.js
index 13cc369..0b80d44 100644
--- a/js/snowflake.js
+++ b/js/snowflake.js
@@ -1,12 +1,9 @@
 import { St, Clutter } from 'gi://GLib'
 import Main from 'resource:///org/gnome/shell/ui/main.js'
 
-import {Extension} from 'resource:///org/gnome/shell/extensions/extension.js'
-//const Extension = Utils.getCurrentExtension()
+import { random } from './utils.js'
 
-import {random} from './utils.js'
-
-var Snowflake = class Snowflake {
+export class Snowflake {
 	constructor(config) {
 		const icons = config.string('flake-icons').split(',')
 		const iconNumber = random(0, icons.length - 1)
diff --git a/js/utils.js b/js/utils.js
index b6db47e..00b2794 100644
--- a/js/utils.js
+++ b/js/utils.js
@@ -1,13 +1,12 @@
 import GLib from 'gi://GLib'
 
-function random(min, max) {
+export function random(min, max) {
 	return Math.floor(Math.random() * (max - min + 1)) + min
 }
 
-function setInterval(mainFunc, endFunc, delay) {
+export function setInterval(mainFunc, endFunc, delay) {
 	return GLib.timeout_add(GLib.PRIORITY_DEFAULT, delay, () => {
 		mainFunc()
-		const next = endFunc() ? GLib.SOURCE_REMOVE : GLib.SOURCE_CONTINUE
-		return next
+		return endFunc() ? GLib.SOURCE_REMOVE : GLib.SOURCE_CONTINUE
 	})
 }
diff --git a/metadata.json b/metadata.json
index ef8960a..0cb79ba 100644
--- a/metadata.json
+++ b/metadata.json
@@ -1,5 +1,4 @@
 {
-  "_generated": "Generated by SweetTooth, do not edit",
   "description": "Make you festive mood with falling snow on your GNOME DE system",
   "name": "Snowy",
   "shell-version": [
@@ -7,5 +6,5 @@
   ],
   "url": "https://github.com/ExposedCat/snowy",
   "uuid": "snowy@exposedcat",
-  "version": 16
+  "version": 3.2
 }

From 485b573331d059915cb2b7f4d26ff9cfd461c0d3 Mon Sep 17 00:00:00 2001
From: Artem Prokop 
Date: Sat, 4 Nov 2023 21:54:45 +0100
Subject: [PATCH 4/4] Finish G45 port

---
 extension.js    | 11 ++++++-----
 js/manager.js   |  2 +-
 js/snowflake.js |  5 +++--
 metadata.json   |  2 +-
 4 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/extension.js b/extension.js
index a432c88..dde504d 100644
--- a/extension.js
+++ b/extension.js
@@ -4,12 +4,13 @@ import { Config } from './js/config.js'
 import { Manager } from './js/manager.js'
 
 export default class SnowyExtension extends Extension {
-	constructor() {
-		this.manager = new Manager()
-	}
-
+	manager = null
+	
 	enable() {
-		const settings = this.getSettings();
+		if (this.manager === null) {
+			this.manager = new Manager()
+		}
+		const settings = this.getSettings('org.gnome.shell.extensions.snowy');
 		const config = new Config(settings)
 		this.manager.startSnowing(config)
 	}
diff --git a/js/manager.js b/js/manager.js
index 2e8e881..311028b 100644
--- a/js/manager.js
+++ b/js/manager.js
@@ -1,5 +1,5 @@
 import GLib from 'gi://GLib'
-import Main from 'resource:///org/gnome/shell/ui/main.js'
+import * as Main from 'resource:///org/gnome/shell/ui/main.js'
 
 import { Snowflake } from './snowflake.js' 
 import { random, setInterval } from './utils.js'
diff --git a/js/snowflake.js b/js/snowflake.js
index 0b80d44..96a67e4 100644
--- a/js/snowflake.js
+++ b/js/snowflake.js
@@ -1,5 +1,6 @@
-import { St, Clutter } from 'gi://GLib'
-import Main from 'resource:///org/gnome/shell/ui/main.js'
+import St from 'gi://St'
+import Clutter from 'gi://Clutter'
+import * as Main from 'resource:///org/gnome/shell/ui/main.js'
 
 import { random } from './utils.js'
 
diff --git a/metadata.json b/metadata.json
index 0cb79ba..ef6a1e0 100644
--- a/metadata.json
+++ b/metadata.json
@@ -6,5 +6,5 @@
   ],
   "url": "https://github.com/ExposedCat/snowy",
   "uuid": "snowy@exposedcat",
-  "version": 3.2
+  "version": 3.3
 }