From b7429bada33652d993013d9fdc408ef6632bd081 Mon Sep 17 00:00:00 2001 From: Simon Schneegans Date: Wed, 29 Mar 2023 20:24:28 +0200 Subject: [PATCH] :wrench: Allow effects with no settings --- prefs.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/prefs.js b/prefs.js index d992ae8..82d7614 100644 --- a/prefs.js +++ b/prefs.js @@ -227,8 +227,16 @@ var PreferencesDialog = class PreferencesDialog { const [minMajor, minMinor] = effect.getMinShellVersion(); if (utils.shellVersionIsAtLeast(minMajor, minMinor)) { - const uiFile = `/ui/${utils.getUIDir()}/${effect.getNick()}.ui`; - const [hasPrefs] = Gio.resources_get_info(uiFile, 0); + const uiFile = `/ui/${utils.getUIDir()}/${effect.getNick()}.ui`; + + // Is there a better way to test for the existence of a resource file? + let hasPrefs = false; + try { + Gio.resources_get_info(uiFile, 0); + hasPrefs = true; + } catch (e) { + // Nothing todo, there + } // Add the settings page to the builder. if (hasPrefs) { @@ -288,9 +296,11 @@ var PreferencesDialog = class PreferencesDialog { } }); this._effectRows.push(row); + row.add_action(previewButton); + } else { + row.add_suffix(previewButton); } - row.add_action(previewButton); row.add_prefix(button); group.add(row);