[gnome-shell/wip/swarm: 2/3] 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: 2/3] search: Allow providers to return the complete result object
- Date: Fri, 29 Aug 2014 23:12:30 +0000 (UTC)
commit 7d158ebce4990244c53d8e8ea582147ff00fa952
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.
data/theme/gnome-shell.css | 1 +
js/ui/appDisplay.js | 27 +++++++++++------------
js/ui/search.js | 50 +++++++++++++++++++------------------------
3 files changed, 36 insertions(+), 42 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 f88ba5d..a37cf62 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;
@@ -1089,18 +1090,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 });
@@ -1111,7 +1100,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;
}
});
@@ -1688,7 +1680,7 @@ const AppIcon = new Lang.Class({
_onClicked: function(actor, button) {
this._removeMenuTimeout();
- this.activate(button);
+ this.activate(button)
},
_onKeyboardPopupMenu: function() {
@@ -1760,6 +1752,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..a10ab5c 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,14 @@ const SearchResultsBase = new Lang.Class({
this._terms = [];
},
- _clearResultDisplay: function() {
+ _createResultDisplay: function(meta) {
+ if (this.provider.createResultObject) {
+ let result = this.provider.createResultObject(meta);
+ if (!result instanceof SearchResult)
+ throw new Error('Provided result object is not a SearchResult');
+ return result;
+ }
+ return null;
},
clear: function() {
@@ -332,8 +322,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 +442,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 +490,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]