search: Replace 'icon' property in metaInfo with a function
Search results' meta info currently is expected to have an 'icon' property holding a Clutter.Texture of a fixed icon size. This property is used to implement the createIcon() function of BaseIcon, which is used to actually display the result, ignoring the size parameter due to the fixed icon size. Given that all available search providers create this property for the desired icon size using a function with the same signature, it appears logical to replace the fixed-sized 'icon' property with such a function, so that the icon size will be defined by the display actor rather than the search system. https://bugzilla.gnome.org/show_bug.cgi?id=643632
This commit is contained in:
parent
7f5135016e
commit
7723e59a72
@ -251,7 +251,10 @@ BaseAppSearchProvider.prototype = {
|
|||||||
return null;
|
return null;
|
||||||
return { 'id': resultId,
|
return { 'id': resultId,
|
||||||
'name': app.get_name(),
|
'name': app.get_name(),
|
||||||
'icon': app.create_icon_texture(Search.RESULT_ICON_SIZE)};
|
'createIcon': function(size) {
|
||||||
|
return app.create_icon_texture(size);
|
||||||
|
}
|
||||||
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
activateResult: function(id, params) {
|
activateResult: function(id, params) {
|
||||||
|
@ -26,7 +26,10 @@ DocSearchProvider.prototype = {
|
|||||||
return null;
|
return null;
|
||||||
return { 'id': resultId,
|
return { 'id': resultId,
|
||||||
'name': docInfo.name,
|
'name': docInfo.name,
|
||||||
'icon': docInfo.createIcon(Search.RESULT_ICON_SIZE)};
|
'createIcon': function(size) {
|
||||||
|
return docInfo.createIcon(size);
|
||||||
|
}
|
||||||
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
activateResult: function(id, params) {
|
activateResult: function(id, params) {
|
||||||
|
@ -415,7 +415,10 @@ PlaceSearchProvider.prototype = {
|
|||||||
return null;
|
return null;
|
||||||
return { 'id': resultId,
|
return { 'id': resultId,
|
||||||
'name': placeInfo.name,
|
'name': placeInfo.name,
|
||||||
'icon': placeInfo.iconFactory(Search.RESULT_ICON_SIZE) };
|
'createIcon': function(size) {
|
||||||
|
return placeInfo.iconFactory(size);
|
||||||
|
}
|
||||||
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
activateResult: function(id, params) {
|
activateResult: function(id, params) {
|
||||||
|
@ -15,8 +15,6 @@ const Main = imports.ui.main;
|
|||||||
|
|
||||||
const DISABLED_OPEN_SEARCH_PROVIDERS_KEY = 'disabled-open-search-providers';
|
const DISABLED_OPEN_SEARCH_PROVIDERS_KEY = 'disabled-open-search-providers';
|
||||||
|
|
||||||
const RESULT_ICON_SIZE = 48;
|
|
||||||
|
|
||||||
// Not currently referenced by the search API, but
|
// Not currently referenced by the search API, but
|
||||||
// this enumeration can be useful for provider
|
// this enumeration can be useful for provider
|
||||||
// implementations.
|
// implementations.
|
||||||
@ -165,8 +163,9 @@ SearchProvider.prototype = {
|
|||||||
* getResultInfo:
|
* getResultInfo:
|
||||||
* @id: Result identifier string
|
* @id: Result identifier string
|
||||||
*
|
*
|
||||||
* Return an object with 'id', 'name', (both strings) and 'icon' (Clutter.Texture)
|
* Return an object with 'id', 'name', (both strings) and 'createIcon'
|
||||||
* properties which describe the given search result.
|
* (function(size) returning a Clutter.Texture) properties which describe
|
||||||
|
* the given search result.
|
||||||
*/
|
*/
|
||||||
getResultMeta: function(id) {
|
getResultMeta: function(id) {
|
||||||
throw new Error('Not implemented');
|
throw new Error('Not implemented');
|
||||||
|
@ -36,9 +36,7 @@ SearchResult.prototype = {
|
|||||||
reactive: true,
|
reactive: true,
|
||||||
track_hover: true });
|
track_hover: true });
|
||||||
let icon = new IconGrid.BaseIcon(this.metaInfo['name'],
|
let icon = new IconGrid.BaseIcon(this.metaInfo['name'],
|
||||||
{ createIcon: Lang.bind(this, function(size) {
|
{ createIcon: this.metaInfo['createIcon'] });
|
||||||
return this.metaInfo['icon'];
|
|
||||||
})});
|
|
||||||
content.set_child(icon.actor);
|
content.set_child(icon.actor);
|
||||||
}
|
}
|
||||||
this._content = content;
|
this._content = content;
|
||||||
|
Loading…
Reference in New Issue
Block a user