diff --git a/gpaste-reloaded@feuerfuchs.eu/README.md b/gpaste-reloaded@feuerfuchs.eu/README.md index 73ef96ea4d2..96df7846899 100644 --- a/gpaste-reloaded@feuerfuchs.eu/README.md +++ b/gpaste-reloaded@feuerfuchs.eu/README.md @@ -6,6 +6,7 @@ This is a completely re-written GPaste applet based on the [gnome shell extensio * Support for multiple histories * Manually add entries to the history * Unlimited instances +* Option to reverse the history order so that new items appear at the bottom of the menu # Installation diff --git a/gpaste-reloaded@feuerfuchs.eu/files/gpaste-reloaded@feuerfuchs.eu/6.4/applet.js b/gpaste-reloaded@feuerfuchs.eu/files/gpaste-reloaded@feuerfuchs.eu/6.4/applet.js index bef90ce5f20..e3a2f356a71 100644 --- a/gpaste-reloaded@feuerfuchs.eu/files/gpaste-reloaded@feuerfuchs.eu/6.4/applet.js +++ b/gpaste-reloaded@feuerfuchs.eu/files/gpaste-reloaded@feuerfuchs.eu/6.4/applet.js @@ -146,6 +146,7 @@ class GPasteApplet extends Applet.IconApplet { this._appletSettings.bind("display-searchbar", "displaySearchBar", this._onDisplaySettingsUpdated); this._appletSettings.bind("display-gpaste-ui", "displayGPasteUI", this._onDisplaySettingsUpdated); this._appletSettings.bind("display-empty-history", "displayEmptyHistory", this._onDisplaySettingsUpdated); + this._appletSettings.bind("reverse-history-order", "reverseHistory", this._onDisplaySettingsUpdated); this._appletSettings.bind("kb-show-history", "kbShowHistory", this._onKeybindingUpdated); this._onKeybindingUpdated(); @@ -254,6 +255,8 @@ class GPasteApplet extends Applet.IconApplet { this.msepBottom2.actor.visible = this.displayGPasteUI; this.mitemUI.actor.visible = this.displayGPasteUI; + + this._onSettingsUpdated(); } /* @@ -273,10 +276,6 @@ class GPasteApplet extends Applet.IconApplet { } } - if (this.mitemSearch.entry.get_text() == '') { - this._historyItems[0].actor.set_style("font-weight: bold;"); - } - this.refresh(oldSize); } @@ -352,6 +351,8 @@ class GPasteApplet extends Applet.IconApplet { * Refresh the history items */ refresh (startID) { + this._historyItems.forEach(item => item.actor.set_style(null)); + if (this._searchResults.length > 0) { // Search field isn't empty this.search(this.mitemSearch.getText()); } else { @@ -364,7 +365,8 @@ class GPasteApplet extends Applet.IconApplet { } for (let i = startID; i < size; ++i) { - this._historyItems[i].setIndex(i); + const idx = this.reverseHistory ? (size - 1 - i) : i; + this._historyItems[i].setIndex(idx); } for (let i = size; i < maxSize; ++i) { this._historyItems[i].setIndex(-1); @@ -374,6 +376,9 @@ class GPasteApplet extends Applet.IconApplet { this.mitemHistoryIsEmpty.actor.show(); } else { this.mitemHistoryIsEmpty.actor.hide(); + const highlightPos = this.reverseHistory ? size - 1 : 0; + if (highlightPos >= 0 && highlightPos < this._historyItems.length) + this._historyItems[highlightPos].actor.set_style("font-weight: bold;"); } }); } @@ -397,14 +402,16 @@ class GPasteApplet extends Applet.IconApplet { results = maxSize; } + const ordered = this.reverseHistory ? this._searchResults.slice().reverse() : this._searchResults; + this._historyItems.slice(0, results).forEach((item, index) => { - item.setUuid(this._searchResults[index]); + item.setUuid(ordered[index]); }); this._historyItems.slice(results, maxSize).forEach((item, index) => { item.setIndex(-1); }); - this._historyItems[0].actor.set_style(null); + this._historyItems.forEach(item => item.actor.set_style(null)); if (results == 0) { // There aren't any results, display "(No results)" this.mitemNoSearchResults.actor.show(); @@ -417,7 +424,6 @@ class GPasteApplet extends Applet.IconApplet { this._searchResults = []; this.refresh(0); - this._historyItems[0].actor.set_style("font-weight: bold;"); } } @@ -572,6 +578,17 @@ class GPasteApplet extends Applet.IconApplet { this.mitemTrack.setToggleState(state); } + /* + * Called whenever settings change that affect how the history is presented + */ + _onSettingsUpdated() { + if (this._searchResults.length > 0) { + this.search(this.mitemSearch.getText()); + } else { + this.refresh(0); + } + } + // // Overrides // --------------------------------------------------------------------------------- diff --git a/gpaste-reloaded@feuerfuchs.eu/files/gpaste-reloaded@feuerfuchs.eu/6.4/settings-schema.json b/gpaste-reloaded@feuerfuchs.eu/files/gpaste-reloaded@feuerfuchs.eu/6.4/settings-schema.json index 03d9534a5cf..c47db0063c2 100644 --- a/gpaste-reloaded@feuerfuchs.eu/files/gpaste-reloaded@feuerfuchs.eu/6.4/settings-schema.json +++ b/gpaste-reloaded@feuerfuchs.eu/files/gpaste-reloaded@feuerfuchs.eu/6.4/settings-schema.json @@ -33,6 +33,11 @@ "type": "checkbox", "description": "Display 'Empty history'" }, + "reverse-history-order": { + "default": false, + "type": "checkbox", + "description": "Reverse history order (newest at bottom)" + }, "key-bindings": { "type": "header",