Add a separate section of search results that shows system preferences
System preferences should not be mixed in with applications in search results.
This commit is contained in:
parent
d8cabbee0b
commit
458778bcfd
@ -191,17 +191,22 @@ Signals.addSignalMethods(MenuItem.prototype);
|
|||||||
/* This class represents a display containing a collection of application items.
|
/* This class represents a display containing a collection of application items.
|
||||||
* The applications are sorted based on their popularity by default, and based on
|
* The applications are sorted based on their popularity by default, and based on
|
||||||
* their name if some search filter is applied.
|
* their name if some search filter is applied.
|
||||||
|
*
|
||||||
|
* showPrefs - a boolean indicating if this AppDisplay should contain preference
|
||||||
|
* applets, rather than applications
|
||||||
*/
|
*/
|
||||||
function AppDisplay() {
|
function AppDisplay(showPrefs) {
|
||||||
this._init();
|
this._init(showPrefs);
|
||||||
}
|
}
|
||||||
|
|
||||||
AppDisplay.prototype = {
|
AppDisplay.prototype = {
|
||||||
__proto__: GenericDisplay.GenericDisplay.prototype,
|
__proto__: GenericDisplay.GenericDisplay.prototype,
|
||||||
|
|
||||||
_init : function() {
|
_init : function(showPrefs) {
|
||||||
GenericDisplay.GenericDisplay.prototype._init.call(this);
|
GenericDisplay.GenericDisplay.prototype._init.call(this);
|
||||||
|
|
||||||
|
this._showPrefs = showPrefs;
|
||||||
|
|
||||||
this._menus = [];
|
this._menus = [];
|
||||||
this._menuDisplays = [];
|
this._menuDisplays = [];
|
||||||
|
|
||||||
@ -359,30 +364,32 @@ AppDisplay.prototype = {
|
|||||||
this._allItems = {};
|
this._allItems = {};
|
||||||
this._appCategories = {};
|
this._appCategories = {};
|
||||||
|
|
||||||
// Loop over the toplevel menu items, load the set of desktop file ids
|
if (this._showPrefs) {
|
||||||
// associated with each one, skipping empty menus
|
// Get the desktop file ids for settings/preferences.
|
||||||
let allMenus = this._appSystem.get_menus();
|
// These are used for search results, but not in the app menus.
|
||||||
this._menus = [];
|
let settings = this._appSystem.get_all_settings();
|
||||||
for (let i = 0; i < allMenus.length; i++) {
|
for (let i = 0; i < settings.length; i++) {
|
||||||
let menu = allMenus[i];
|
let app = settings[i];
|
||||||
let menuApps = this._appSystem.get_applications_for_menu(menu.id);
|
|
||||||
let hasVisibleApps = menuApps.some(function (app) { return !app.get_is_nodisplay(); });
|
|
||||||
if (!hasVisibleApps) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
this._menus.push(menu);
|
|
||||||
for (let j = 0; j < menuApps.length; j++) {
|
|
||||||
let app = menuApps[j];
|
|
||||||
this._addApp(app);
|
this._addApp(app);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
|
// Loop over the toplevel menu items, load the set of desktop file ids
|
||||||
// Now grab the desktop file ids for settings/preferences.
|
// associated with each one, skipping empty menus
|
||||||
// These show up in search, but not with the rest of apps.
|
let allMenus = this._appSystem.get_menus();
|
||||||
let settings = this._appSystem.get_all_settings();
|
this._menus = [];
|
||||||
for (let i = 0; i < settings.length; i++) {
|
for (let i = 0; i < allMenus.length; i++) {
|
||||||
let app = settings[i];
|
let menu = allMenus[i];
|
||||||
this._addApp(app);
|
let menuApps = this._appSystem.get_applications_for_menu(menu.id);
|
||||||
|
let hasVisibleApps = menuApps.some(function (app) { return !app.get_is_nodisplay(); });
|
||||||
|
if (!hasVisibleApps) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
this._menus.push(menu);
|
||||||
|
for (let j = 0; j < menuApps.length; j++) {
|
||||||
|
let app = menuApps[j];
|
||||||
|
this._addApp(app);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this._appsStale = false;
|
this._appsStale = false;
|
||||||
|
@ -70,6 +70,10 @@ const PANE_BORDER_WIDTH = 2;
|
|||||||
const PANE_BACKGROUND_COLOR = new Clutter.Color();
|
const PANE_BACKGROUND_COLOR = new Clutter.Color();
|
||||||
PANE_BACKGROUND_COLOR.from_pixel(0x000000f4);
|
PANE_BACKGROUND_COLOR.from_pixel(0x000000f4);
|
||||||
|
|
||||||
|
const APPS = "apps";
|
||||||
|
const PREFS = "prefs";
|
||||||
|
const DOCS = "docs";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Returns the index in an array of a given length that is obtained
|
* Returns the index in an array of a given length that is obtained
|
||||||
* if the provided index is incremented by an increment and the array
|
* if the provided index is incremented by an increment and the array
|
||||||
@ -83,6 +87,17 @@ function _getIndexWrapped(index, increment, length) {
|
|||||||
return (index + increment + length) % length;
|
return (index + increment + length) % length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function _createDisplay(displayType) {
|
||||||
|
if (displayType == APPS)
|
||||||
|
return new AppDisplay.AppDisplay();
|
||||||
|
else if (displayType == PREFS)
|
||||||
|
return new AppDisplay.AppDisplay(true);
|
||||||
|
else if (displayType == DOCS)
|
||||||
|
return new DocDisplay.DocDisplay();
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
function Pane() {
|
function Pane() {
|
||||||
this._init();
|
this._init();
|
||||||
}
|
}
|
||||||
@ -158,12 +173,12 @@ Pane.prototype = {
|
|||||||
}
|
}
|
||||||
Signals.addSignalMethods(Pane.prototype);
|
Signals.addSignalMethods(Pane.prototype);
|
||||||
|
|
||||||
function ResultArea(displayClass, enableNavigation) {
|
function ResultArea(displayType, enableNavigation) {
|
||||||
this._init(displayClass, enableNavigation);
|
this._init(displayType, enableNavigation);
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultArea.prototype = {
|
ResultArea.prototype = {
|
||||||
_init : function(displayClass, enableNavigation) {
|
_init : function(displayType, enableNavigation) {
|
||||||
this.actor = new Big.Box({ orientation: Big.BoxOrientation.VERTICAL });
|
this.actor = new Big.Box({ orientation: Big.BoxOrientation.VERTICAL });
|
||||||
this.resultsContainer = new Big.Box({ orientation: Big.BoxOrientation.HORIZONTAL,
|
this.resultsContainer = new Big.Box({ orientation: Big.BoxOrientation.HORIZONTAL,
|
||||||
spacing: DEFAULT_PADDING
|
spacing: DEFAULT_PADDING
|
||||||
@ -172,7 +187,7 @@ ResultArea.prototype = {
|
|||||||
this.navContainer = new Big.Box({ orientation: Big.BoxOrientation.VERTICAL });
|
this.navContainer = new Big.Box({ orientation: Big.BoxOrientation.VERTICAL });
|
||||||
this.resultsContainer.append(this.navContainer, Big.BoxPackFlags.NONE);
|
this.resultsContainer.append(this.navContainer, Big.BoxPackFlags.NONE);
|
||||||
|
|
||||||
this.display = new displayClass();
|
this.display = _createDisplay(displayType);
|
||||||
|
|
||||||
this.navArea = this.display.getNavigationArea();
|
this.navArea = this.display.getNavigationArea();
|
||||||
if (enableNavigation && this.navArea)
|
if (enableNavigation && this.navArea)
|
||||||
@ -229,10 +244,10 @@ ResultPane.prototype = {
|
|||||||
this._dash = dash;
|
this._dash = dash;
|
||||||
},
|
},
|
||||||
|
|
||||||
// Create an instance of displayClass and pack it into this pane's
|
// Create a display of displayType and pack it into this pane's
|
||||||
// content area. Return the displayClass instance.
|
// content area. Return the display.
|
||||||
packResults: function(displayClass, enableNavigation) {
|
packResults: function(displayType, enableNavigation) {
|
||||||
let resultArea = new ResultArea(displayClass, enableNavigation);
|
let resultArea = new ResultArea(displayType, enableNavigation);
|
||||||
|
|
||||||
createPaneForDetails(this._dash, resultArea.display);
|
createPaneForDetails(this._dash, resultArea.display);
|
||||||
|
|
||||||
@ -726,7 +741,7 @@ Dash.prototype = {
|
|||||||
this._appsSection.header.moreLink.connect('activated', Lang.bind(this, function (link) {
|
this._appsSection.header.moreLink.connect('activated', Lang.bind(this, function (link) {
|
||||||
if (this._moreAppsPane == null) {
|
if (this._moreAppsPane == null) {
|
||||||
this._moreAppsPane = new ResultPane(this);
|
this._moreAppsPane = new ResultPane(this);
|
||||||
this._moreAppsPane.packResults(AppDisplay.AppDisplay, true);
|
this._moreAppsPane.packResults(APPS, true);
|
||||||
this._addPane(this._moreAppsPane);
|
this._addPane(this._moreAppsPane);
|
||||||
link.setPane(this._moreAppsPane);
|
link.setPane(this._moreAppsPane);
|
||||||
}
|
}
|
||||||
@ -754,7 +769,7 @@ Dash.prototype = {
|
|||||||
this._docsSection.header.moreLink.connect('activated', Lang.bind(this, function (link) {
|
this._docsSection.header.moreLink.connect('activated', Lang.bind(this, function (link) {
|
||||||
if (this._moreDocsPane == null) {
|
if (this._moreDocsPane == null) {
|
||||||
this._moreDocsPane = new ResultPane(this);
|
this._moreDocsPane = new ResultPane(this);
|
||||||
this._moreDocsPane.packResults(DocDisplay.DocDisplay, true);
|
this._moreDocsPane.packResults(DOCS, true);
|
||||||
this._addPane(this._moreDocsPane);
|
this._addPane(this._moreDocsPane);
|
||||||
link.setPane(this._moreDocsPane);
|
link.setPane(this._moreDocsPane);
|
||||||
}
|
}
|
||||||
@ -773,17 +788,20 @@ Dash.prototype = {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
this._searchSections = [
|
this._searchSections = [
|
||||||
{ type: "apps",
|
{ type: APPS,
|
||||||
title: _("APPLICATIONS"),
|
title: _("APPLICATIONS"),
|
||||||
header: null,
|
header: null,
|
||||||
resultArea: null,
|
resultArea: null
|
||||||
displayClass: AppDisplay.AppDisplay
|
|
||||||
},
|
},
|
||||||
{ type: "docs",
|
{ type: PREFS,
|
||||||
|
title: _("PREFERENCES"),
|
||||||
|
header: null,
|
||||||
|
resultArea: null
|
||||||
|
},
|
||||||
|
{ type: DOCS,
|
||||||
title: _("RECENT DOCUMENTS"),
|
title: _("RECENT DOCUMENTS"),
|
||||||
header: null,
|
header: null,
|
||||||
resultArea: null,
|
resultArea: null
|
||||||
displayClass: DocDisplay.DocDisplay
|
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -795,7 +813,7 @@ Dash.prototype = {
|
|||||||
this._showSingleSearchSection(section.type);
|
this._showSingleSearchSection(section.type);
|
||||||
}));
|
}));
|
||||||
this._searchResultsSection.content.append(section.header.actor, Big.BoxPackFlags.NONE);
|
this._searchResultsSection.content.append(section.header.actor, Big.BoxPackFlags.NONE);
|
||||||
section.resultArea = new ResultArea(section.displayClass, false);
|
section.resultArea = new ResultArea(section.type, false);
|
||||||
section.resultArea.controlBox.hide();
|
section.resultArea.controlBox.hide();
|
||||||
this._searchResultsSection.content.append(section.resultArea.actor, Big.BoxPackFlags.EXPAND);
|
this._searchResultsSection.content.append(section.resultArea.actor, Big.BoxPackFlags.EXPAND);
|
||||||
createPaneForDetails(this, section.resultArea.display);
|
createPaneForDetails(this, section.resultArea.display);
|
||||||
|
Loading…
Reference in New Issue
Block a user