Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Final changes for upcoming release #198

Merged
merged 7 commits into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion container/runx11docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ $SCRIPT_DIR/x11docker/x11docker \
--network \
--init=systemd \
--user=RETAIN \
--runasuser="journalctl -f &" \
--runasuser="gnome-extensions enable [email protected]; journalctl -f &" \
-- --mount type=bind,source=$SRC_DIR,target=$DST_DIR,readonly -- \
$1
9 changes: 8 additions & 1 deletion src/historyMenuElements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ import {Logger} from './logger.js';
Gio._promisify(Gio.File.prototype, 'copy_async', 'copy_finish');
Gio._promisify(Gio.File.prototype, 'replace_contents_bytes_async', 'replace_contents_finish');

import * as Config from 'resource:///org/gnome/shell/misc/config.js';
const [MAJOR, unused_MINOR] = Config.PACKAGE_VERSION.split('.').map(s => Number(s));

// FIXME: Generated static class code produces a no-unused-expressions rule error
/* eslint-disable no-unused-expressions */

Expand Down Expand Up @@ -595,7 +598,11 @@ class HistorySection extends PopupMenu.PopupMenuSection {
overlay_scrollbars: true,
});

this.actor.add_child(this.box);
// https://gjs.guide/extensions/upgrading/gnome-shell-46.html#clutter-container
if (MAJOR < 46)
this.actor.add_actor(this.box);
else
this.actor.add_child(this.box);
}

/**
Expand Down
12 changes: 7 additions & 5 deletions src/manager/defaultWallpaperManager.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as Utils from '../utils.js';

import {WallpaperManager, getZoomModeEnum} from './wallpaperManager.js';
import {WallpaperManager} from './wallpaperManager.js';
import {Logger} from '../logger.js';
import {Settings} from '../settings.js';

Expand Down Expand Up @@ -50,11 +50,12 @@ class DefaultWallpaperManager extends WallpaperManager {
* @returns {Promise<void>} Only resolves
*/
static setSingleBackground(wallpaperURI: string, backgroundSettings: Settings): Promise<void> {
const storedScalingMode = new Settings().getString('scaling-mode');
if (Utils.isImageMerged(wallpaperURI))
// merged wallpapers need mode "spanned"
backgroundSettings.setString('picture-options', 'spanned');
else
backgroundSettings.setString('picture-options', getZoomModeEnum()[new Settings().getInt('zoom-mode')]);
else if (storedScalingMode)
backgroundSettings.setString('picture-options', storedScalingMode);

Utils.setPictureUriOfSettingsObject(backgroundSettings, wallpaperURI);
return Promise.resolve();
Expand All @@ -69,11 +70,12 @@ class DefaultWallpaperManager extends WallpaperManager {
* @returns {Promise<void>} Only resolves
*/
static setSingleLockScreen(wallpaperURI: string, backgroundSettings: Settings, screensaverSettings: Settings): Promise<void> {
const storedScalingMode = new Settings().getString('scaling-mode');
if (Utils.isImageMerged(wallpaperURI))
// merged wallpapers need mode "spanned"
screensaverSettings.setString('picture-options', 'spanned');
else
screensaverSettings.setString('picture-options', getZoomModeEnum()[new Settings().getInt('zoom-mode')]);
else if (storedScalingMode)
screensaverSettings.setString('picture-options', storedScalingMode);

Utils.setPictureUriOfSettingsObject(screensaverSettings, wallpaperURI);
return Promise.resolve();
Expand Down
25 changes: 10 additions & 15 deletions src/manager/wallpaperManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,25 +112,20 @@ function getModeNameList(): string[] {
*
* @returns {string[]} Array of string containing valid enum values
*/
function getZoomModeEnum(): string[] {
return getEnumFromSettings(new Settings('org.gnome.desktop.background'), 'picture-options').filter(s => {
const negatives = [
'none', // No wallpaper
'wallpaper', // Tiled wallpapers, repeating pattern
'stretched', // Ignoring aspect ratio
'spanned', // Ignoring aspect ratio
];

if (negatives.includes(s))
return false;

return true;
});
function getScalingModeEnum(): string[] {
const excludes = [
'none', // No wallpaper
'wallpaper', // Tiled wallpapers, repeating pattern
'spanned', // Ignoring aspect ratio
];

return getEnumFromSettings(new Settings('org.gnome.desktop.background'), 'picture-options')
.filter(s => !excludes.includes(s));
}

export {
WallpaperManager,
Mode,
getModeNameList,
getZoomModeEnum
getScalingModeEnum
};
4 changes: 2 additions & 2 deletions src/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"settings-schema": "org.gnome.shell.extensions.space.iflow.randomwallpaper",
"name": "Random Wallpaper",
"description": "Load new desktop wallpapers from various online sources with ease!",
"version": 34,
"semantic-version": "3.0.1",
"version": 35,
"semantic-version": "3.0.2",
"url": "https://github.com/ifl0w/RandomWallpaperGnome3",
"issue-url": "https://github.com/ifl0w/RandomWallpaperGnome3/issues"
}
24 changes: 18 additions & 6 deletions src/prefs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,24 @@ class RandomWallpaperSettings extends ExtensionPreferences {
'selected',
Gio.SettingsBindFlags.DEFAULT);

const comboZoomMode = this._getAs<Adw.ComboRow>(builder, 'combo_zoom_mode');
comboZoomMode.model = Gtk.StringList.new(WallpaperManager.getZoomModeEnum());
settings.bind('zoom-mode',
comboZoomMode,
'selected',
Gio.SettingsBindFlags.DEFAULT);
const comboScalingMode = this._getAs<Adw.ComboRow>(builder, 'combo_scaling_mode');
comboScalingMode.model = Gtk.StringList.new(WallpaperManager.getScalingModeEnum());
const gnomeDesktopSettings = new Settings.Settings('org.gnome.desktop.background');
const gnomeScreensaverSettings = new Settings.Settings('org.gnome.desktop.screensaver');

let storedScalingModeIdx = WallpaperManager.getScalingModeEnum().indexOf(settings.getString('scaling-mode'));
if (storedScalingModeIdx < 0)
// fallback to the current value set in gnome-shell for the desktop
storedScalingModeIdx = WallpaperManager.getScalingModeEnum().indexOf(gnomeDesktopSettings.getString('picture-options'));

// can't bind a string to "selected" and "active-item" is not available on Adw.ComboRow, binding is implemented manually below
comboScalingMode.selected = storedScalingModeIdx >= 0 ? storedScalingModeIdx : Gtk.INVALID_LIST_POSITION;
comboScalingMode.connect('notify::selected', () => {
const selectedString = WallpaperManager.getScalingModeEnum()[comboScalingMode.selected];
gnomeDesktopSettings.setString('picture-options', selectedString);
gnomeScreensaverSettings.setString('picture-options', selectedString);
settings.setString('scaling-mode', selectedString);
});

const comboLogLevel = this._getAs<Adw.ComboRow>(builder, 'log_level');
comboLogLevel.model = Gtk.StringList.new(Logger.getLogLevelNameList());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@
<description>Allows to choose what backgrounds will be changed.</description>
</key>

<key type='i' name='zoom-mode'>
<default>4</default>
<key type='s' name='scaling-mode'>
<default>""</default>
<summary>Choose which zoom mode wallpapers get</summary>
<description>Allows to choose what setting 'picture-options' will get.</description>
</key>
Expand Down
4 changes: 2 additions & 2 deletions src/ui/pageGeneral.blp
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ Adw.PreferencesPage page_general {
use-subtitle: true;
}

Adw.ComboRow combo_zoom_mode {
title: _("Wallpaper Zoom Mode");
Adw.ComboRow combo_scaling_mode {
title: _("Wallpaper Scaling Mode");
use-subtitle: true;
}

Expand Down
4 changes: 4 additions & 0 deletions types/misc/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,7 @@ declare module 'resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js' {
getPreferencesWidget(): Gtk.Widget;
}
}

declare module 'resource:///org/gnome/shell/misc/config.js' {
export const PACKAGE_VERSION: string;
}
Loading