Skip to content

Commit

Permalink
Merge branch 'gpaste-3.12'
Browse files Browse the repository at this point in the history
* gpaste-3.12:
  gnome-shell: invalidate match when text changes
  gnome-shell: couple of fixes
  • Loading branch information
Keruspe committed Jul 12, 2014
2 parents 5364089 + 3947df6 commit 0b312c9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
24 changes: 14 additions & 10 deletions src/applets/gnome-shell/indicator.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,9 @@ const GPasteIndicator = new Lang.Class({

this._dummyHistoryItem = new DummyHistoryItem.GPasteDummyHistoryItem();

this._settingsMaxSizeChangedId = this._settings.connect('changed::max-displayed-history-size', Lang.bind(this, this._resetMaxDisplayedSize));
this._resetMaxDisplayedSize(true);

this._searchItem = new SearchItem.GPasteSearchItem();
this._setMaxDisplayedSize();
this._settingsMaxSizeChangedId = this._settings.connect('changed::max-displayed-history-size', Lang.bind(this, this._resetMaxDisplayedSize));
this._searchItem.connect('text-changed', Lang.bind(this, this._onSearch));

this._settingsSizeChangedId = this._settings.connect('changed::element-size', Lang.bind(this, this._resetEntrySize));
Expand Down Expand Up @@ -102,14 +101,15 @@ const GPasteIndicator = new Lang.Class({

_onSearch: function() {
let search = this._searchItem.text;
let maxSize = this._maxSize;
let i = 0;

this._history.map(function(item) {
if (i < this._maxSize) {
if (i < maxSize) {
if (item.match(search)) {
++i;
item.actor.show();
continue;
return;
}
}
item.actor.hide();
Expand All @@ -120,19 +120,23 @@ const GPasteIndicator = new Lang.Class({
this._searchItem.resetSize(this._settings.get_element_size()/2);
},

_resetMaxDisplayedSize: function(fromInit) {
_setMaxDisplayedSize: function() {
this._maxSize = this._settings.get_max_displayed_history_size();
if (!fromInit) {
this._onSearch();
}
},

_resetMaxDisplayedSize: function() {
this._setMaxDisplayedSize();
this._onSearch();
},

_refresh: function() {
this._client.get_history_size(Lang.bind(this, function(client, result) {
let size = client.get_history_size_finish(result);
this._updateVisibility(size == 0);
for (let index = this._history.length; index < size; ++index) {
this._addToHistory(new Item.GPasteItem(this._client, this._settings, index));
let item = new Item.GPasteItem(this._client, this._settings, index);
item.connect('changed', Lang.bind(this, this._onSearch));
this._addToHistory(item);
}
for (let index = size, length = this._history.length; index < length; ++index) {
this._history.pop().destroy();
Expand Down
4 changes: 3 additions & 1 deletion src/applets/gnome-shell/item.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ const GPasteItem = new Lang.Class({
this._client.get_element(this._index, Lang.bind(this, function(client, result) {
let text = client.get_element_finish(result);
this.label.clutter_text.set_text(text.replace(/[\t\n\r]/g, ' '));
this._onSearch();
/* reset match stuff */
this.match("");
this.emit('changed');
}));
},

Expand Down

0 comments on commit 0b312c9

Please sign in to comment.