Skip to content

Commit

Permalink
Merge branch 'justinkusz-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Tudmotu committed Apr 15, 2021
2 parents 867f641 + 5cbb048 commit fc9eebd
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 16 deletions.
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
MODULES = extension.js confirmDialog.js locale/ metadata.json stylesheet.css LICENSE.rst README.rst prefs.js schemas/ utils.js
INSTALLPATH=~/.local/share/gnome-shell/extensions/[email protected]/

all: compile-locales
all: compile-locales compile-settings

compile-settings:
glib-compile-schemas --strict --targetdir=schemas/ schemas

compile-locales:
Expand Down
48 changes: 33 additions & 15 deletions extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ let MOVE_ITEM_FIRST = false;
let ENABLE_KEYBINDING = true;
let PRIVATEMODE = false;
let NOTIFY_ON_COPY = true;
let CONFIRM_ON_CLEAR = true;
let MAX_TOPBAR_LENGTH = 15;
let TOPBAR_DISPLAY_MODE = 1; //0 - only icon, 1 - only clipbord content, 2 - both
let DISABLE_DOWN_ARROW = false;
Expand Down Expand Up @@ -335,27 +336,43 @@ const ClipboardIndicator = Lang.Class({

this._updateCache();
},
_removeAll: function () {

_confirmRemoveAll: function () {
const title = _("Clear all?");
const message = _("Are you sure you want to delete all clipboard items?");
const sub_message = _("This operation cannot be undone.");

ConfirmDialog.openConfirmDialog(title, message, sub_message, _("Clear"), _("Cancel"), () => {;
ConfirmDialog.openConfirmDialog(title, message, sub_message, _("Clear"), _("Cancel"), () => {
let that = this;
// We can't actually remove all items, because the clipboard still
// has data that will be re-captured on next refresh, so we remove
// all except the currently selected item
// Don't remove favorites here
that.historySection._getMenuItems().forEach(function (mItem) {
if (!mItem.currentlySelected) {
let idx = that.clipItemsRadioGroup.indexOf(mItem);
mItem.destroy();
that.clipItemsRadioGroup.splice(idx,1);
}
});
that._updateCache();
that._showNotification(_("Clipboard history cleared"));
that._clearHistory();
}
);
},

_clearHistory: function () {
let that = this;
// We can't actually remove all items, because the clipboard still
// has data that will be re-captured on next refresh, so we remove
// all except the currently selected item
// Don't remove favorites here
that.historySection._getMenuItems().forEach(function (mItem) {
if (!mItem.currentlySelected) {
let idx = that.clipItemsRadioGroup.indexOf(mItem);
mItem.destroy();
that.clipItemsRadioGroup.splice(idx, 1);
}
});
that._updateCache();
that._showNotification(_("Clipboard history cleared")); },

_removeAll: function () {
var that = this;

if (CONFIRM_ON_CLEAR) {
that._confirmRemoveAll();
} else {
that._clearHistory();
}
},

_removeEntry: function (menuItem, event) {
Expand Down Expand Up @@ -680,6 +697,7 @@ const ClipboardIndicator = Lang.Class({
DELETE_ENABLED = this._settings.get_boolean(Prefs.Fields.DELETE);
MOVE_ITEM_FIRST = this._settings.get_boolean(Prefs.Fields.MOVE_ITEM_FIRST);
NOTIFY_ON_COPY = this._settings.get_boolean(Prefs.Fields.NOTIFY_ON_COPY);
CONFIRM_ON_CLEAR = this._settings.get_boolean(Prefs.Fields.CONFIRM_ON_CLEAR);
ENABLE_KEYBINDING = this._settings.get_boolean(Prefs.Fields.ENABLE_KEYBINDING);
MAX_TOPBAR_LENGTH = this._settings.get_int(Prefs.Fields.TOPBAR_PREVIEW_SIZE);
TOPBAR_DISPLAY_MODE = this._settings.get_int(Prefs.Fields.TOPBAR_DISPLAY_MODE_ID);
Expand Down
9 changes: 9 additions & 0 deletions prefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ var Fields = {
CACHE_ONLY_FAVORITE : 'cache-only-favorites',
DELETE : 'enable-deletion',
NOTIFY_ON_COPY : 'notify-on-copy',
CONFIRM_ON_CLEAR : 'confirm-clear',
MOVE_ITEM_FIRST : 'move-item-first',
ENABLE_KEYBINDING : 'enable-keybindings',
TOPBAR_PREVIEW_SIZE : 'topbar-preview-size',
Expand Down Expand Up @@ -101,6 +102,7 @@ const App = new Lang.Class({
this.field_disable_down_arrow = new Gtk.Switch();
this.field_cache_disable = new Gtk.Switch();
this.field_notification_toggle = new Gtk.Switch();
this.field_confirm_clear_toggle = new Gtk.Switch();
this.field_strip_text = new Gtk.Switch();
this.field_move_item_first = new Gtk.Switch();
this.field_keybinding = createKeybindingWidget(SettingsSchema);
Expand Down Expand Up @@ -149,6 +151,11 @@ const App = new Lang.Class({
hexpand: true,
halign: Gtk.Align.START
});
let confirmClearLabel = new Gtk.Label({
label: _("Show confirmation on Clear History"),
hexpand: true,
halign: Gtk.Align.START
});
let moveFirstLabel = new Gtk.Label({
label: _("Move item to the top after selection"),
hexpand: true,
Expand Down Expand Up @@ -208,6 +215,7 @@ const App = new Lang.Class({
addRow(cacheSizeLabel, this.field_cache_size);
addRow(cacheDisableLabel, this.field_cache_disable);
addRow(notificationLabel, this.field_notification_toggle);
addRow(confirmClearLabel, this.field_confirm_clear_toggle);
addRow(displayModeLabel, this.field_display_mode);
addRow(disableDownArrowLabel, this.field_disable_down_arrow);
addRow(topbarPreviewLabel, this.field_topbar_preview_size);
Expand All @@ -222,6 +230,7 @@ const App = new Lang.Class({
SettingsSchema.bind(Fields.CACHE_FILE_SIZE, this.field_cache_size, 'value', Gio.SettingsBindFlags.DEFAULT);
SettingsSchema.bind(Fields.CACHE_ONLY_FAVORITE, this.field_cache_disable, 'active', Gio.SettingsBindFlags.DEFAULT);
SettingsSchema.bind(Fields.NOTIFY_ON_COPY, this.field_notification_toggle, 'active', Gio.SettingsBindFlags.DEFAULT);
SettingsSchema.bind(Fields.CONFIRM_ON_CLEAR, this.field_confirm_clear_toggle, 'active', Gio.SettingsBindFlags.DEFAULT);
SettingsSchema.bind(Fields.MOVE_ITEM_FIRST, this.field_move_item_first, 'active', Gio.SettingsBindFlags.DEFAULT);
SettingsSchema.bind(Fields.TOPBAR_DISPLAY_MODE_ID, this.field_display_mode, 'active', Gio.SettingsBindFlags.DEFAULT);
SettingsSchema.bind(Fields.DISABLE_DOWN_ARROW, this.field_disable_down_arrow, 'active', Gio.SettingsBindFlags.DEFAULT);
Expand Down
Binary file modified schemas/gschemas.compiled
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,15 @@
If true, a notification is shown when content is copied to clipboard.
</description>
</key>

<key name="confirm-clear" type="b">
<default>true</default>
<summary>Show confirmation dialog on Clear History</summary>
<description>
If true, a confirmation dialog is shown when attempting to Clear History.
</description>
</key>

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

0 comments on commit fc9eebd

Please sign in to comment.