🔧 Support multiple apps per profile

This commit is contained in:
Simon Schneegans
2023-02-08 10:33:03 +01:00
parent 3020fec2bc
commit dd5801c0f7
2 changed files with 28 additions and 8 deletions
+5 -1
View File
@@ -490,7 +490,11 @@ class Extension {
// If that was the case, we also check the application name.
if (matches && profileApp != '') {
const app = actor.meta_window.get_wm_class().toLowerCase();
matches = app == profileApp.toLowerCase();
// Split app names at |, remove any whitespace, and transform to lower case.
const profileApps =
profileApp.split('|').map(item => item.trim().toLowerCase());
matches = profileApps.includes(app);
}
// If the profile is still matching, we also check the color scheme.
+21 -5
View File
@@ -150,14 +150,30 @@ var PreferencesDialog = class PreferencesDialog {
null, null, Gio.DBusCallFlags.NO_AUTO_START, -1, null, null);
});
// If the window picking was successful, this D-Bus signal will be emitted.
// If the window picking was successful, this D-Bus signal will be emitted. If a
// window was picked, we add it to the list of window name.
this._dbusConnection = Gio.DBus.session.signal_subscribe(
'org.gnome.Shell', 'org.gnome.shell.extensions.BurnMyWindows', 'WindowPicked',
'/org/gnome/shell/extensions/BurnMyWindows', null, Gio.DBusSignalFlags.NONE,
(conn, sender, obj_path, iface, signal, params) => {
const val = params.get_child_value(0).get_string()[0];
if (val != 'window-not-found') {
this._builder.get_object('profile-app').text = val;
const entry = this._builder.get_object('profile-app');
// Split the current value at each |, trim spaces, and remove empty components.
let apps = entry.text.split('|').map(item => item.trim()).filter(v => v != '');
// If the list is empty, we simply use the name of the picked window.
if (apps.length == 0) {
entry.text = val;
} else {
// Else we append the new application name, remove any duplicates, and sort
// the resulting list alphabetically.
apps.push(val);
apps = [...new Set(apps)].sort();
entry.text = apps.join(' | ');
}
}
});
@@ -356,9 +372,9 @@ var PreferencesDialog = class PreferencesDialog {
() => this._settings.set_int('last-version', Me.metadata.version));
window.add_toast(toast);
}else {
const infoBar = this._builder.get_object("update-info");
infoBar.connect("response", i => {
} else {
const infoBar = this._builder.get_object('update-info');
infoBar.connect('response', i => {
this._settings.set_int('last-version', Me.metadata.version);
i.set_revealed(false);
});