Skip to content
Open
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
1 change: 1 addition & 0 deletions gpaste-reloaded@feuerfuchs.eu/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -254,6 +255,8 @@ class GPasteApplet extends Applet.IconApplet {

this.msepBottom2.actor.visible = this.displayGPasteUI;
this.mitemUI.actor.visible = this.displayGPasteUI;

this._onSettingsUpdated();
}

/*
Expand All @@ -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);
}

Expand Down Expand Up @@ -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 {
Expand All @@ -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);
Expand All @@ -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;");
}
});
}
Expand All @@ -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();
Expand All @@ -417,7 +424,6 @@ class GPasteApplet extends Applet.IconApplet {

this._searchResults = [];
this.refresh(0);
this._historyItems[0].actor.set_style("font-weight: bold;");
}
}

Expand Down Expand Up @@ -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
// ---------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading