From 8d02cb48b205ca5b588928d2f5eb8ba0ee4d7b55 Mon Sep 17 00:00:00 2001 From: Florian Müllner Date: Mar 19 2023 23:29:12 +0000 Subject: [PATCH 1/6] cleanup: Remove unnecessary constructor We don't need to provide _init() if all we do is chaining up to the parent. --- diff --git a/extension.js b/extension.js index 2d5b7c3..6f393a2 100644 --- a/extension.js +++ b/extension.js @@ -23,10 +23,6 @@ const Main = imports.ui.main; var IconContainer = GObject.registerClass( class IconContainer extends St.Widget { - _init(params) { - super._init(params); - } - vfunc_get_preferred_width(forHeight) { let width = super.vfunc_get_preferred_width(forHeight); return width.map(w => w * this.scale_x); From 1a30313ea2eb19793a5fd1ef5fe4223c44150e90 Mon Sep 17 00:00:00 2001 From: Florian Müllner Date: Mar 19 2023 23:30:48 +0000 Subject: [PATCH 2/6] cleanup: Remove unnecessary parentheses --- diff --git a/prefs.js b/prefs.js index f2eada9..6dd8d69 100644 --- a/prefs.js +++ b/prefs.js @@ -121,7 +121,7 @@ class PreviewGroup extends Adw.PreferencesGroup { if (position.endsWith('left')) x = scaledBorder; else if (position.endsWith('right')) - x = (width - this._logo.get_width() - scaledBorder); + x = width - this._logo.get_width() - scaledBorder; else x = (width - this._logo.get_width()) / 2; From 8c2e2cbe62957b776c23d685242949b23e6f04f1 Mon Sep 17 00:00:00 2001 From: Florian Müllner Date: Aug 06 2023 14:31:38 +0000 Subject: [PATCH 3/6] cleanup: Adapt to gnome-shell style change gnome-shell now follows gjs and doesn't use any spaces inside braces. --- diff --git a/extension.js b/extension.js index 6f393a2..5c3bd6e 100644 --- a/extension.js +++ b/extension.js @@ -15,7 +15,7 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, see . */ -const { Clutter, Gio, GLib, GObject, Meta, St } = imports.gi; +const {Clutter, Gio, GLib, GObject, Meta, St} = imports.gi; const Background = imports.ui.background; const ExtensionUtils = imports.misc.extensionUtils; @@ -85,7 +85,7 @@ class BackgroundLogo extends St.Widget { this._backgroundActor.content.connect('notify::brightness', this._updateOpacity.bind(this)); - this._bin = new IconContainer({ x_expand: true, y_expand: true }); + this._bin = new IconContainer({x_expand: true, y_expand: true}); this.add_actor(this._bin); this._bin.connect('resource-scale-changed', this._updateLogoTexture.bind(this)); @@ -124,7 +124,7 @@ class BackgroundLogo extends St.Widget { } _getWidthForRelativeSize(size) { - let { width } = this._getMonitorArea(); + let {width} = this._getMonitorArea(); return width * size / 100; } @@ -132,7 +132,7 @@ class BackgroundLogo extends St.Widget { if (!this.has_allocation()) return 1; - let { width } = this._getMonitorArea(); + let {width} = this._getMonitorArea(); return this.allocation.get_width() / width; } @@ -181,7 +181,7 @@ class BackgroundLogo extends St.Widget { else yAlign = Clutter.ActorAlign.CENTER; - this._bin.set({ xAlign, yAlign }); + this._bin.set({xAlign, yAlign}); } _updateBorder() { @@ -196,7 +196,7 @@ class BackgroundLogo extends St.Widget { } _updateVisibility() { - const { background } = this._backgroundActor.content; + const {background} = this._backgroundActor.content; const colorScheme = this._ifaceSettings.get_string('color-scheme'); const uriKey = colorScheme === 'prefer-dark' ? 'picture-uri-dark' @@ -260,7 +260,7 @@ class Extension { } enable() { - const { _createBackgroundOrig } = this; + const {_createBackgroundOrig} = this; this._bgManagerProto._createBackgroundActor = function () { const backgroundActor = _createBackgroundOrig.call(this); const logo_ = new BackgroundLogo(backgroundActor); diff --git a/lint/eslintrc-shell.yml b/lint/eslintrc-shell.yml index beb003e..30fb077 100644 --- a/lint/eslintrc-shell.yml +++ b/lint/eslintrc-shell.yml @@ -9,9 +9,6 @@ rules: - mode: minimum beforeColon: false afterColon: true - object-curly-spacing: - - error - - always prefer-arrow-callback: error globals: global: readonly diff --git a/prefs.js b/prefs.js index 6dd8d69..edf0677 100644 --- a/prefs.js +++ b/prefs.js @@ -1,5 +1,5 @@ /* exported init, buildPrefsWidget */ -const { Adw, Gdk, GdkPixbuf, Gio, GLib, GObject, Gtk } = imports.gi; +const {Adw, Gdk, GdkPixbuf, Gio, GLib, GObject, Gtk} = imports.gi; const ByteArray = imports.byteArray; imports.gi.versions.GnomeDesktop = '4.0'; @@ -47,7 +47,7 @@ class PreviewGroup extends Adw.PreferencesGroup { }); this._preview.set_draw_func(this._drawPreview.bind(this)); - const previewRow = new Adw.PreferencesRow({ activatable: false }); + const previewRow = new Adw.PreferencesRow({activatable: false}); previewRow.set_child(this._preview); this.add(previewRow); } @@ -68,7 +68,7 @@ class PreviewGroup extends Adw.PreferencesGroup { _getSlideShowSlide(file, width, height) { if (GnomeDesktop) { - const slideShow = new GnomeDesktop.BGSlideShow({ file }); + const slideShow = new GnomeDesktop.BGSlideShow({file}); slideShow.load(); const [progress_, duration_, isFixed_, filename1, filename2_] = @@ -83,7 +83,7 @@ class PreviewGroup extends Adw.PreferencesGroup { } _createBackgroundThumbnail(width, height) { - let settings = new Gio.Settings({ schema_id: BACKGROUND_SCHEMA }); + let settings = new Gio.Settings({schema_id: BACKGROUND_SCHEMA}); const bgKey = this._styleManager.dark ? 'picture-uri-dark' : 'picture-uri'; @@ -149,14 +149,14 @@ const LogoPosition = GObject.registerClass({ }, }, class LogoPosition extends GObject.Object { _init(name, value) { - super._init({ name, value }); + super._init({name, value}); } }); const LogoGroup = GObject.registerClass( class LogoGroup extends Adw.PreferencesGroup { _init(settings) { - super._init({ title: 'Logo' }); + super._init({title: 'Logo'}); this._settings = settings; this._fileChooserKey = ''; @@ -208,7 +208,7 @@ class LogoGroup extends Adw.PreferencesGroup { filenameDarkRow.add_suffix(this._filenameDarkLabel); this.add(filenameDarkRow); - const positionModel = new Gio.ListStore({ item_type: LogoPosition }); + const positionModel = new Gio.ListStore({item_type: LogoPosition}); positionModel.append(new LogoPosition('Center', 'center')); positionModel.append(new LogoPosition('Bottom left', 'bottom-left')); positionModel.append(new LogoPosition('Bottom center', 'bottom-center')); @@ -224,7 +224,7 @@ class LogoGroup extends Adw.PreferencesGroup { this.add(this._positionRow); this._positionRow.connect('notify::selected-item', () => { - const { selectedItem } = this._positionRow; + const {selectedItem} = this._positionRow; this._settings.set_string('logo-position', selectedItem.value); }); this._settings.connect('changed::logo-position', @@ -253,7 +253,7 @@ class LogoGroup extends Adw.PreferencesGroup { _updateSelectedPosition() { const position = this._settings.get_string('logo-position'); - const { model } = this._positionRow; + const {model} = this._positionRow; for (let i = 0; i < model.get_n_items(); i++) { const item = model.get_item(i); if (item.value === position) { @@ -297,7 +297,7 @@ class LogoGroup extends Adw.PreferencesGroup { const OptionsGroup = GObject.registerClass( class OptionsGroup extends Adw.PreferencesGroup { _init(settings) { - super._init({ title: 'Options' }); + super._init({title: 'Options'}); this._settings = settings; const alwaysShowSwitch = new Gtk.Switch({ From d47661f3e5e39a6ec14f716b135289e77f5e1b16 Mon Sep 17 00:00:00 2001 From: Florian Müllner Date: Aug 06 2023 14:34:21 +0000 Subject: [PATCH 4/6] cleanup: Remove old compatibility code gnome-shell itself now requires GnomeDesktop 4.0, so we can safely assume it's available. --- diff --git a/prefs.js b/prefs.js index edf0677..1e5b0fb 100644 --- a/prefs.js +++ b/prefs.js @@ -1,16 +1,7 @@ /* exported init, buildPrefsWidget */ -const {Adw, Gdk, GdkPixbuf, Gio, GLib, GObject, Gtk} = imports.gi; +const {Adw, Gdk, GdkPixbuf, Gio, GLib, GnomeDesktop, GObject, Gtk} = imports.gi; const ByteArray = imports.byteArray; -imports.gi.versions.GnomeDesktop = '4.0'; - -let GnomeDesktop = null; -try { - GnomeDesktop = imports.gi.GnomeDesktop; -} catch (e) { - // not compatible with GTK4 yet -} - const ExtensionUtils = imports.misc.extensionUtils; const BACKGROUND_SCHEMA = 'org.gnome.desktop.background'; From 1c86f0c329c362f18d4d3530bbc5c6bb72c41b93 Mon Sep 17 00:00:00 2001 From: Florian Müllner Date: Aug 06 2023 14:35:53 +0000 Subject: [PATCH 5/6] build: Replace custom post-install script Meson's gnome module has provided a post_install() method for a while now, use that instead of a custom script. --- diff --git a/meson-postinstall.sh b/meson-postinstall.sh deleted file mode 100755 index 400edee..0000000 --- a/meson-postinstall.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh - -# Package managers set this so we don't need to run -if [ -z "$DESTDIR" ]; then - echo Compiling GSettings schemas... - glib-compile-schemas ${MESON_INSTALL_PREFIX}/share/glib-2.0/schemas -fi diff --git a/meson.build b/meson.build index 4ff9516..2f5e092 100644 --- a/meson.build +++ b/meson.build @@ -1,8 +1,10 @@ project('background-logo-extension', version: '44.0', - meson_version: '>= 0.40.0' + meson_version: '>= 0.58.0' ) +gnome = import('gnome') + sources = [ 'extension.js', 'prefs.js' @@ -51,9 +53,9 @@ foreach s : schemas ) endforeach -if have_schemas - meson.add_install_script('meson-postinstall.sh') -endif +gnome.post_install( + glib_compile_schemas: true, +) extension_tool = find_program('gnome-extensions', required: false) if extension_tool.found() From ef133a93b0c8fd5c6e99102f2187bccc3d523db4 Mon Sep 17 00:00:00 2001 From: Florian Müllner Date: Aug 06 2023 14:35:53 +0000 Subject: [PATCH 6/6] build: Simplify shell version handling gnome-shell only considers the major version nowadays, regardless of whether the version is a development release or not. --- diff --git a/meson.build b/meson.build index 2f5e092..a9a197f 100644 --- a/meson.build +++ b/meson.build @@ -16,11 +16,7 @@ schemas = ['org.fedorahosted.background-logo-extension'] uuid = 'background-logo@fedorahosted.org' ver_arr = meson.project_version().split('.') -if ver_arr[1].version_compare('>=0') - shell_version = ver_arr[0] -else # pre-release (alpha, beta, rc) - shell_version = '.'.join(ver_arr) -endif +shell_version = ver_arr[0] datadir = get_option('datadir') extensiondir = join_paths(datadir, 'gnome-shell', 'extensions')