[gnome-shell/wip/swarm: 4/5] search: Allow providers to return the complete result object
- From: Carlos Soriano <csoriano src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/wip/swarm: 4/5] search: Allow providers to return the complete result object
- Date: Sat, 30 Aug 2014 12:36:13 +0000 (UTC)
commit ed9dd18564b59c9758df967ec8e7c87a396a4eee
Author: Florian Müllner <fmuellner gnome org>
Date: Wed Aug 20 18:39:02 2014 +0200
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
data/theme/gnome-shell.css | 1 +
js/ui/appDisplay.js | 25 +++++++++++------------
js/ui/search.js | 46 +++++++++++++++++--------------------------
3 files changed, 31 insertions(+), 41 deletions(-)
---
diff --git a/data/theme/gnome-shell.css b/data/theme/gnome-shell.css
index 89d6909..843ed6c 100644
--- a/data/theme/gnome-shell.css
+++ b/data/theme/gnome-shell.css
@@ -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);
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index 6012b01..2005f0e 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -22,6 +22,7 @@ const Main = imports.ui.main;
const Overview = imports.ui.overview;
const OverviewControls = imports.ui.overviewControls;
const PopupMenu = imports.ui.popupMenu;
+const Search = imports.ui.search;
const Tweener = imports.ui.tweener;
const Workspace = imports.ui.workspace;
const Params = imports.misc.params;
@@ -1097,18 +1098,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 });
@@ -1119,7 +1108,10 @@ const AppSearchProvider = new Lang.Class({
createResultObject: function (resultMeta) {
let app = this._appSys.lookup_app(resultMeta['id']);
- return new AppIcon(app);
+ let appIcon = new AppIcon(app);
+ appIcon.metaInfo = resultMeta;
+ appIcon.provider = this;
+ return appIcon;
}
});
@@ -1768,6 +1760,13 @@ const AppIcon = new Lang.Class({
Main.overview.hide();
},
+ setSelected: function(selected) {
+ if (selected)
+ this.actor.add_style_pseudo_class('selected');
+ else
+ this.actor.remove_style_pseudo_class('selected');
+ },
+
animateOut: function() {
this.icon.animateOut();
},
diff --git a/js/ui/search.js b/js/ui/search.js
index 02ef689..df4826f 100644
--- a/js/ui/search.js
+++ b/js/ui/search.js
@@ -232,25 +232,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'],
- { 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;
+ this.icon = new IconGrid.BaseIcon(this.metaInfo['name'],
+ { createIcon: this.metaInfo['createIcon'] });
+ 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',
@@ -266,10 +252,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() {
@@ -316,7 +299,10 @@ const SearchResultsBase = new Lang.Class({
this._terms = [];
},
- _clearResultDisplay: function() {
+ _createResultDisplay: function(meta) {
+ if (this.provider.createResultObject)
+ return result;
+ return null;
},
clear: function() {
@@ -332,8 +318,12 @@ const SearchResultsBase = new Lang.Class({
},
_activateResult: function(result, id) {
- this.provider.activateResult(id, this._terms);
- Main.overview.toggle();
+ if (this.provider.createResultObject) {
+ result.activate();
+ } else {
+ this.provider.activateResult(id, this._terms);
+ Main.overview.toggle();
+ }
},
_setMoreIconVisible: function(visible) {
@@ -448,7 +438,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) {
@@ -496,7 +486,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) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]