🔧 Port effect profiles to GS 42
This commit is contained in:
@@ -467,16 +467,36 @@ var PreferencesDialog = class PreferencesDialog {
|
|||||||
group.add_action(newProfileAction);
|
group.add_action(newProfileAction);
|
||||||
|
|
||||||
// This action shows a confirmation dialog. Upon user approval, the currently
|
// This action shows a confirmation dialog. Upon user approval, the currently
|
||||||
// active profile is deleted.
|
// active profile is deleted. We use the more beautiful Adw.MessageDialog if it is
|
||||||
const deleteProfileAction = Gio.SimpleAction.new('profile-delete', null);
|
// available (usually on GNOME 43 and beyond).
|
||||||
deleteProfileAction.connect('activate', () => {
|
let deleteProfileDialog;
|
||||||
this._builder.get_object('profile-delete-dialog').show();
|
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.set_transient_for(window);
|
||||||
|
|
||||||
deleteProfileDialog.connect('response', (d, response) => {
|
deleteProfileDialog.connect('response', (d, response) => {
|
||||||
if (response == 'delete') {
|
if (response == 'delete' || response == Gtk.ResponseType.OK) {
|
||||||
// Stop editing the current profile.
|
// Stop editing the current profile.
|
||||||
this._builder.get_object('edit-profile-button').active = false;
|
this._builder.get_object('edit-profile-button').active = false;
|
||||||
|
|
||||||
@@ -491,8 +511,14 @@ var PreferencesDialog = class PreferencesDialog {
|
|||||||
// selection menu.
|
// selection menu.
|
||||||
this._updateProfileMenu();
|
this._updateProfileMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
d.hide();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const deleteProfileAction = Gio.SimpleAction.new('profile-delete', null);
|
||||||
|
deleteProfileAction.connect('activate', () => {
|
||||||
|
deleteProfileDialog.show();
|
||||||
|
});
|
||||||
group.add_action(deleteProfileAction);
|
group.add_action(deleteProfileAction);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
+16
-17
@@ -8,20 +8,6 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||||||
<interface domain="burn-my-windows">
|
<interface domain="burn-my-windows">
|
||||||
<requires lib="gtk" version="4.0" />
|
<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. -->
|
<!-- This will be added to the header bar. -->
|
||||||
<object class="GtkBox" id="profile-button">
|
<object class="GtkBox" id="profile-button">
|
||||||
<property name="halign">center</property>
|
<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>
|
<property name="description" translatable="yes">Define when the current effect settings should be used.</property>
|
||||||
|
|
||||||
<child>
|
<child>
|
||||||
<object class="AdwEntryRow" id="profile-app">
|
<object class="AdwActionRow">
|
||||||
<property name="title" translatable="yes">Application Name</property>
|
<property name="title" translatable="yes">Application Name</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkButton" id="profile-choose-app-button">
|
<object class="GtkBox">
|
||||||
<property name="icon-name">bmw-select-app-symbolic</property>
|
|
||||||
<property name="valign">center</property>
|
<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>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
|
|||||||
Reference in New Issue
Block a user