Skip to content

Commit

Permalink
fix broken preferences and timeouts
Browse files Browse the repository at this point in the history
  • Loading branch information
khimaros committed Apr 22, 2024
1 parent 154922a commit b86d6d6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
8 changes: 4 additions & 4 deletions smart-auto-move@khimaros.com/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ function handleTimeoutSave() {
GLib.Source.remove(timeoutSaveSignal);
timeoutSaveSignal = null;
saveSettings();
timeoutSaveSignal = GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, saveFrequencyMs, handleTimeoutSave);
timeoutSaveSignal = GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, saveFrequencyMs / 1000.0, handleTimeoutSave);
return GLib.SOURCE_CONTINUE;
}

Expand All @@ -401,7 +401,7 @@ function handleTimeoutSync() {
GLib.Source.remove(timeoutSyncSignal);
timeoutSyncSignal = null;
syncWindows();
timeoutSyncSignal = GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, syncFrequencyMs, handleTimeoutSync);
timeoutSyncSignal = GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, syncFrequencyMs / 1000.0, handleTimeoutSync);
return GLib.SOURCE_CONTINUE;
}

Expand Down Expand Up @@ -480,9 +480,9 @@ function disconnectSignals() {

function addTimeouts() {
timeoutSyncSignal = GLib.timeout_add_seconds(
GLib.PRIORITY_DEFAULT, syncFrequencyMs, handleTimeoutSync);
GLib.PRIORITY_DEFAULT, syncFrequencyMs / 1000.0, handleTimeoutSync);
timeoutSaveSignal = GLib.timeout_add_seconds(
GLib.PRIORITY_DEFAULT, saveFrequencyMs, handleTimeoutSave);
GLib.PRIORITY_DEFAULT, saveFrequencyMs / 1000.0, handleTimeoutSave);
}

function removeTimeouts() {
Expand Down
2 changes: 1 addition & 1 deletion smart-auto-move@khimaros.com/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
"description": "Smart Auto Move learns the position, size, and workspace of your application windows and restores them on subsequent launches. Supports Wayland.\n\nNOTE: Optimized for use with static workspaces. For more control, set the default behavior to IGNORE and then selectively RESTORE only desired apps.\n\nKNOWN ISSUES: Multi-monitor is not yet well supported. You may need to manually delete Saved Windows in preferences after adding or removing a display.",
"settings-schema": "org.gnome.shell.extensions.smart-auto-move",
"original-author": "khimaros",
"version": "24",
"version": "25",
"shell-version": ["45", "46"]
}
16 changes: 10 additions & 6 deletions smart-auto-move@khimaros.com/prefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,10 @@ function buildPrefsWidget(extension) {

let saved_windows_list_widget = builder.get_object('saved-windows-listbox');
let saved_windows_list_objects = [];
loadSavedWindowsSetting(saved_windows_list_widget, saved_windows_list_objects);
changedSavedWindowsSignal = settings.connect('changed::' + Common.SETTINGS_KEY_SAVED_WINDOWS, function () { loadSavedWindowsSetting(saved_windows_list_widget, saved_windows_list_objects); });
loadSavedWindowsSetting(extension, saved_windows_list_widget, saved_windows_list_objects);
changedSavedWindowsSignal = settings.connect('changed::' + Common.SETTINGS_KEY_SAVED_WINDOWS, function () {
loadSavedWindowsSetting(extension, saved_windows_list_widget, saved_windows_list_objects);
});

/// OVERRIDES

Expand All @@ -145,13 +147,15 @@ function buildPrefsWidget(extension) {
overrides_add_application_widget.connect('clicked', function () {
// TODO
});
loadOverridesSetting(overrides_list_widget, overrides_list_objects);
changedOverridesSignal = settings.connect('changed::' + Common.SETTINGS_KEY_OVERRIDES, function () { loadOverridesSetting(overrides_list_widget, overrides_list_objects); });
loadOverridesSetting(extension, overrides_list_widget, overrides_list_objects);
changedOverridesSignal = settings.connect('changed::' + Common.SETTINGS_KEY_OVERRIDES, function () {
loadOverridesSetting(extension, overrides_list_widget, overrides_list_objects);
});

return root;
}

function loadOverridesSetting(list_widget, list_objects) {
function loadOverridesSetting(extension, list_widget, list_objects) {
let settings = extension.getSettings();

let overrides = JSON.parse(settings.get_string(Common.SETTINGS_KEY_OVERRIDES));
Expand Down Expand Up @@ -237,7 +241,7 @@ function loadOverridesSetting(list_widget, list_objects) {
});
}

function loadSavedWindowsSetting(list_widget, list_objects) {
function loadSavedWindowsSetting(extension, list_widget, list_objects) {
let settings = extension.getSettings();

let saved_windows = JSON.parse(settings.get_string(Common.SETTINGS_KEY_SAVED_WINDOWS));
Expand Down

0 comments on commit b86d6d6

Please sign in to comment.