🔧 Port effect profiles to GS 42

This commit is contained in:
Simon Schneegans
2023-01-30 14:50:25 +01:00
parent 99b90377c5
commit 88168553f8
2 changed files with 49 additions and 24 deletions
+33 -7
View File
@@ -467,16 +467,36 @@ var PreferencesDialog = class PreferencesDialog {
group.add_action(newProfileAction);
// This action shows a confirmation dialog. Upon user approval, the currently
// active profile is deleted.
const deleteProfileAction = Gio.SimpleAction.new('profile-delete', null);
deleteProfileAction.connect('activate', () => {
this._builder.get_object('profile-delete-dialog').show();
});
// active profile is deleted. We use the more beautiful Adw.MessageDialog if it is
// available (usually on GNOME 43 and beyond).
let deleteProfileDialog;
const dialogTitle = _('Delete this Profile?');
const dialogSubtitle = _('The current effect profile will be permanently lost.');
const deleteProfileDialog = this._builder.get_object('profile-delete-dialog');
if (Adw.MessageDialog) {
deleteProfileDialog =
new Adw.MessageDialog({heading: dialogTitle, body: dialogSubtitle});
deleteProfileDialog.add_response('cancel', _('Cancel'));
deleteProfileDialog.add_response('delete', _('Delete'));
deleteProfileDialog.set_response_appearance('delete',
Adw.ResponseAppearance.DESTRUCTIVE);
deleteProfileDialog.set_default_response('cancel');
deleteProfileDialog.set_close_response('cancel');
} else {
deleteProfileDialog = new Gtk.MessageDialog({
text: dialogTitle,
secondary_text: dialogSubtitle,
modal: true,
title: '',
buttons: Gtk.ButtonsType.OK_CANCEL
});
}
deleteProfileDialog.set_hide_on_close(true);
deleteProfileDialog.set_transient_for(window);
deleteProfileDialog.connect('response', (d, response) => {
if (response == 'delete') {
if (response == 'delete' || response == Gtk.ResponseType.OK) {
// Stop editing the current profile.
this._builder.get_object('edit-profile-button').active = false;
@@ -491,8 +511,14 @@ var PreferencesDialog = class PreferencesDialog {
// selection menu.
this._updateProfileMenu();
}
d.hide();
});
const deleteProfileAction = Gio.SimpleAction.new('profile-delete', null);
deleteProfileAction.connect('activate', () => {
deleteProfileDialog.show();
});
group.add_action(deleteProfileAction);
}
});
+16 -17
View File
@@ -8,20 +8,6 @@ SPDX-License-Identifier: GPL-3.0-or-later
<interface domain="burn-my-windows">
<requires lib="gtk" version="4.0" />
<!-- This is shown when a profile is going to be deleted. -->
<object class="AdwMessageDialog" id="profile-delete-dialog">
<property name="modal">true</property>
<property name="hide-on-close">true</property>
<property name="heading" translatable="yes">Delete this Profile?</property>
<property name="body" translatable="yes">The current effect profile will be permanently lost.</property>
<property name="default-response">cancel</property>
<property name="close-response">cancel</property>
<responses>
<response id="cancel" translatable="yes">Cancel</response>
<response id="delete" translatable="yes" appearance="destructive">Delete</response>
</responses>
</object>
<!-- This will be added to the header bar. -->
<object class="GtkBox" id="profile-button">
<property name="halign">center</property>
@@ -74,12 +60,25 @@ SPDX-License-Identifier: GPL-3.0-or-later
<property name="description" translatable="yes">Define when the current effect settings should be used.</property>
<child>
<object class="AdwEntryRow" id="profile-app">
<object class="AdwActionRow">
<property name="title" translatable="yes">Application Name</property>
<child>
<object class="GtkButton" id="profile-choose-app-button">
<property name="icon-name">bmw-select-app-symbolic</property>
<object class="GtkBox">
<property name="valign">center</property>
<style>
<class name="linked" />
</style>
<child>
<object class="GtkEntry" id="profile-app"></object>
</child>
<child>
<object class="GtkButton" id="profile-choose-app-button">
<property name="icon-name">bmw-select-app-symbolic</property>
<property name="valign">center</property>
</object>
</child>
</object>
</child>
</object>