Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 33 additions & 3 deletions extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ let ENABLE_KEYBINDING;
let PRIVATE_MODE;
let NOTIFY_ON_COPY;
let CONFIRM_ON_CLEAR;
let CONFIRM_REMOVE_FAVORITE;
let CONFIRM_REMOVE_NON_FAVORITE;
let MAX_TOPBAR_LENGTH;
let TOPBAR_DISPLAY_MODE; // 0 - only icon, 1 - only clipboard content, 2 - both, 3 - none
let DISABLE_DOWN_ARROW;
Expand Down Expand Up @@ -579,6 +581,34 @@ class ClipboardIndicator extends PanelMenu.Button {
}
}

_confirmRemoveEntry(entry, fullyDelete, humanGenerated) {
if (
(entry.favorite && CONFIRM_REMOVE_FAVORITE) ||
(!entry.favorite && CONFIRM_REMOVE_NON_FAVORITE)
) {
const title = _('Delete Entry?');
const message = _('Are you sure you want to delete this entry?');
const sub_message = _(
'\n' +
this._truncated(entry.text, MAX_VISIBLE_CHARS) +
'\n\nThis operation cannot be undone.',
);

ConfirmDialog.openConfirmDialog(
title,
message,
sub_message,
_('Delete'),
_('Cancel'),
() => {
this._removeEntry(entry, fullyDelete, humanGenerated);
},
);
} else {
this._removeEntry(entry, fullyDelete, humanGenerated);
}
}

_pruneOldestEntries() {
let entry = this.entries.head;
while (
Expand All @@ -587,7 +617,7 @@ class ClipboardIndicator extends PanelMenu.Button {
this.entries.bytes > MAX_BYTES)
) {
const next = entry.next;
this._removeEntry(entry, true);
this._confirmRemoveEntry(entry, true);
entry = next;
}

Expand Down Expand Up @@ -886,7 +916,7 @@ class ClipboardIndicator extends PanelMenu.Button {
last.text.endsWith(text) ||
last.text.startsWith(text))
) {
this._removeEntry(last, true);
this._confirmRemoveEntry(last, true);
}
});
}
Expand Down Expand Up @@ -1020,7 +1050,7 @@ class ClipboardIndicator extends PanelMenu.Button {
}

_deleteEntryAndRestoreLatest(entry) {
this._removeEntry(entry, true, true);
this._confirmRemoveEntry(entry, true, true);

if (!this.currentlySelectedEntry) {
const nextEntry = this.entries.last();
Expand Down
16 changes: 16 additions & 0 deletions schemas/org.gnome.shell.extensions.clipboard-indicator.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,22 @@
</description>
</key>

<key name="confirm-remove-favorite" type="b">
<default>true</default>
<summary>Show confirmation dialog on removal of favorite entry</summary>
<description>
If true, a confirmation dialog is shown when attempting to remove a favorite entry.
</description>
</key>

<key name="confirm-remove-non-favorite" type="b">
<default>true</default>
<summary>Show confirmation dialog on removal of non-favorite entry</summary>
<description>
If true, a confirmation dialog is shown when attempting to remove a non-favorite entry.
</description>
</key>

<key name="strip-text" type="b">
<default>false</default>
<summary>Remove whitespace around copied plaintext items</summary>
Expand Down