search: Allow providers to return the complete result object
This makes the existing createResultObject() match its name better and avoids oddities like nested StButtons in app search results. https://bugzilla.gnome.org/show_bug.cgi?id=734726
This commit is contained in:
parent
e933302ae4
commit
67c216a6fe
@ -1159,6 +1159,7 @@ StScrollBar StButton#vhandle:active {
|
||||
.show-apps:checked > .overview-icon,
|
||||
.show-apps:active > .overview-icon,
|
||||
.search-provider-icon:active,
|
||||
.grid-search-result:active .overview-icon,
|
||||
.list-search-result:active {
|
||||
background-gradient-start: rgba(255, 255, 255, .05);
|
||||
background-gradient-end: rgba(255, 255, 255, .15);
|
||||
|
@ -1054,18 +1054,6 @@ const AppSearchProvider = new Lang.Class({
|
||||
this.getInitialResultSet(terms, callback, cancellable);
|
||||
},
|
||||
|
||||
activateResult: function(result) {
|
||||
let app = this._appSys.lookup_app(result);
|
||||
let event = Clutter.get_current_event();
|
||||
let modifiers = event ? event.get_state() : 0;
|
||||
let openNewWindow = modifiers & Clutter.ModifierType.CONTROL_MASK;
|
||||
|
||||
if (openNewWindow)
|
||||
app.open_new_window(-1);
|
||||
else
|
||||
app.activate();
|
||||
},
|
||||
|
||||
dragActivateResult: function(id, params) {
|
||||
params = Params.parse(params, { workspace: -1,
|
||||
timestamp: 0 });
|
||||
@ -1650,13 +1638,7 @@ const AppIcon = new Lang.Class({
|
||||
|
||||
_onClicked: function(actor, button) {
|
||||
this._removeMenuTimeout();
|
||||
|
||||
if (button == 0 || button == 1) {
|
||||
this._onActivate(Clutter.get_current_event());
|
||||
} else if (button == 2) {
|
||||
this.app.open_new_window(-1);
|
||||
Main.overview.hide();
|
||||
}
|
||||
this.activate(button);
|
||||
},
|
||||
|
||||
_onKeyboardPopupMenu: function() {
|
||||
@ -1710,15 +1692,17 @@ const AppIcon = new Lang.Class({
|
||||
this.emit('menu-state-changed', false);
|
||||
},
|
||||
|
||||
_onActivate: function (event) {
|
||||
let modifiers = event.get_state();
|
||||
activate: function (button) {
|
||||
let event = Clutter.get_current_event();
|
||||
let modifiers = event ? event.get_state() : 0;
|
||||
let openNewWindow = modifiers & Clutter.ModifierType.CONTROL_MASK &&
|
||||
this.app.state == Shell.AppState.RUNNING ||
|
||||
button && button == 2;
|
||||
|
||||
if (modifiers & Clutter.ModifierType.CONTROL_MASK
|
||||
&& this.app.state == Shell.AppState.RUNNING) {
|
||||
if (openNewWindow)
|
||||
this.app.open_new_window(-1);
|
||||
} else {
|
||||
else
|
||||
this.app.activate();
|
||||
}
|
||||
|
||||
Main.overview.hide();
|
||||
},
|
||||
|
@ -164,13 +164,6 @@ const SearchResult = new Lang.Class({
|
||||
|
||||
activate: function() {
|
||||
this.emit('activate', this.metaInfo.id);
|
||||
},
|
||||
|
||||
setSelected: function(selected) {
|
||||
if (selected)
|
||||
this.actor.add_style_pseudo_class('selected');
|
||||
else
|
||||
this.actor.remove_style_pseudo_class('selected');
|
||||
}
|
||||
});
|
||||
Signals.addSignalMethods(SearchResult.prototype);
|
||||
@ -231,25 +224,11 @@ const GridSearchResult = new Lang.Class({
|
||||
|
||||
this.actor.style_class = 'grid-search-result';
|
||||
|
||||
let content = provider.createResultObject(metaInfo);
|
||||
let dragSource = null;
|
||||
|
||||
if (content == null) {
|
||||
let actor = new St.Bin();
|
||||
let icon = new IconGrid.BaseIcon(this.metaInfo['name'],
|
||||
this.icon = new IconGrid.BaseIcon(this.metaInfo['name'],
|
||||
{ createIcon: this.metaInfo['createIcon'] });
|
||||
actor.set_child(icon.actor);
|
||||
actor.label_actor = icon.label;
|
||||
dragSource = icon.icon;
|
||||
content = { actor: actor, icon: icon };
|
||||
} else {
|
||||
if (content.getDragActorSource)
|
||||
dragSource = content.getDragActorSource();
|
||||
}
|
||||
|
||||
this.actor.set_child(content.actor);
|
||||
this.actor.label_actor = content.actor.label_actor;
|
||||
this.icon = content.icon;
|
||||
let content = new St.Bin({ child: this.icon.actor });
|
||||
this.actor.set_child(content);
|
||||
this.actor.label_actor = this.icon.label;
|
||||
|
||||
let draggable = DND.makeDraggable(this.actor);
|
||||
draggable.connect('drag-begin',
|
||||
@ -265,10 +244,7 @@ const GridSearchResult = new Lang.Class({
|
||||
Main.overview.endItemDrag(this);
|
||||
}));
|
||||
|
||||
if (!dragSource)
|
||||
// not exactly right, but alignment problems are hard to notice
|
||||
dragSource = content.actor;
|
||||
this._dragActorSource = dragSource;
|
||||
this._dragActorSource = content;
|
||||
},
|
||||
|
||||
getDragActorSource: function() {
|
||||
@ -315,7 +291,11 @@ const SearchResultsBase = new Lang.Class({
|
||||
this._terms = [];
|
||||
},
|
||||
|
||||
_clearResultDisplay: function() {
|
||||
_createResultDisplay: function(meta) {
|
||||
if (this.provider.createResultObject)
|
||||
return this.provider.createResultObject(meta);
|
||||
|
||||
return null;
|
||||
},
|
||||
|
||||
clear: function() {
|
||||
@ -446,7 +426,7 @@ const ListSearchResults = new Lang.Class({
|
||||
},
|
||||
|
||||
_createResultDisplay: function(meta) {
|
||||
return new ListSearchResult(this.provider, meta);
|
||||
return this.parent(meta) || new ListSearchResult(this.provider, meta);
|
||||
},
|
||||
|
||||
_addItem: function(display) {
|
||||
@ -494,7 +474,7 @@ const GridSearchResults = new Lang.Class({
|
||||
},
|
||||
|
||||
_createResultDisplay: function(meta) {
|
||||
return new GridSearchResult(this.provider, meta);
|
||||
return this.parent(meta) || new GridSearchResult(this.provider, meta);
|
||||
},
|
||||
|
||||
_addItem: function(display) {
|
||||
@ -630,13 +610,8 @@ const SearchResults = new Lang.Class({
|
||||
}
|
||||
|
||||
if (newDefaultResult != this._defaultResult) {
|
||||
if (this._defaultResult)
|
||||
this._defaultResult.setSelected(false);
|
||||
if (newDefaultResult) {
|
||||
newDefaultResult.setSelected(this._highlightDefault);
|
||||
if (this._highlightDefault)
|
||||
Util.ensureActorVisibleInScrollView(this._scrollView, newDefaultResult.actor);
|
||||
}
|
||||
this._setSelected(this._defaultResult, false);
|
||||
this._setSelected(newDefaultResult, this._highlightDefault);
|
||||
|
||||
this._defaultResult = newDefaultResult;
|
||||
}
|
||||
@ -673,11 +648,7 @@ const SearchResults = new Lang.Class({
|
||||
|
||||
highlightDefault: function(highlight) {
|
||||
this._highlightDefault = highlight;
|
||||
if (this._defaultResult) {
|
||||
this._defaultResult.setSelected(highlight);
|
||||
if (highlight)
|
||||
Util.ensureActorVisibleInScrollView(this._scrollView, this._defaultResult.actor);
|
||||
}
|
||||
this._setSelected(this._defaultResult, highlight);
|
||||
},
|
||||
|
||||
navigateFocus: function(direction) {
|
||||
@ -692,6 +663,18 @@ const SearchResults = new Lang.Class({
|
||||
|
||||
let from = this._defaultResult ? this._defaultResult.actor : null;
|
||||
this.actor.navigate_focus(from, direction, false);
|
||||
},
|
||||
|
||||
_setSelected: function(result, selected) {
|
||||
if (!result)
|
||||
return;
|
||||
|
||||
if (selected) {
|
||||
result.actor.add_style_pseudo_class('selected');
|
||||
Util.ensureActorVisibleInScrollView(this._scrollView, result.actor);
|
||||
} else {
|
||||
result.actor.remove_style_pseudo_class('selected');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user