Display search results in the dash
Display search results in the dash instead of showing them in a separate pane. We get dynamic allocation for the section height based on the number of results, but a lot of the problems with the previous search results display, such as displaying empty sections and paging overflow are still present. Also, we don't yet close the browse pane for applications or documents when we display the search results and only replace it if we are showing the details pane, so all that looks weird. We'll need to work out the interaction for these cases.
This commit is contained in:
parent
72b4d2a234
commit
300cefd66a
112
js/ui/dash.js
112
js/ui/dash.js
@ -473,22 +473,17 @@ Dash.prototype = {
|
|||||||
|
|
||||||
/***** Search *****/
|
/***** Search *****/
|
||||||
|
|
||||||
this._searchPane = null;
|
|
||||||
this._searchActive = false;
|
this._searchActive = false;
|
||||||
this._searchEntry = new SearchEntry();
|
this._searchEntry = new SearchEntry();
|
||||||
this.searchArea.append(this._searchEntry.actor, Big.BoxPackFlags.EXPAND);
|
this.searchArea.append(this._searchEntry.actor, Big.BoxPackFlags.EXPAND);
|
||||||
|
|
||||||
this._searchAreaApps = null;
|
|
||||||
this._searchAreaDocs = null;
|
|
||||||
|
|
||||||
this._searchTimeoutId = 0;
|
this._searchTimeoutId = 0;
|
||||||
this._searchEntry.entry.connect('text-changed', Lang.bind(this, function (se, prop) {
|
this._searchEntry.entry.connect('text-changed', Lang.bind(this, function (se, prop) {
|
||||||
let text = this._searchEntry.getText();
|
let text = this._searchEntry.getText();
|
||||||
text = text.replace(/^\s+/g, "").replace(/\s+$/g, "")
|
text = text.replace(/^\s+/g, "").replace(/\s+$/g, "")
|
||||||
this._searchActive = text != '';
|
this._searchActive = text != '';
|
||||||
|
this._updateDashActors();
|
||||||
if (!this._searchActive) {
|
if (!this._searchActive) {
|
||||||
if (this._searchPane != null)
|
|
||||||
this._searchPane.close();
|
|
||||||
if (this._searchTimeoutId > 0) {
|
if (this._searchTimeoutId > 0) {
|
||||||
Mainloop.source_remove(this._searchTimeoutId);
|
Mainloop.source_remove(this._searchTimeoutId);
|
||||||
this._searchTimeoutId = 0;
|
this._searchTimeoutId = 0;
|
||||||
@ -497,36 +492,20 @@ Dash.prototype = {
|
|||||||
}
|
}
|
||||||
if (this._searchTimeoutId > 0)
|
if (this._searchTimeoutId > 0)
|
||||||
return;
|
return;
|
||||||
if (this._searchPane == null) {
|
|
||||||
this._searchPane = new ResultPane(this);
|
|
||||||
this._searchPane.content.append(new Clutter.Text({ color: TEXT_COLOR,
|
|
||||||
font_name: 'Sans Bold 10px',
|
|
||||||
text: _("APPLICATIONS") }),
|
|
||||||
Big.BoxPackFlags.NONE);
|
|
||||||
this._searchAreaApps = this._searchPane.packResults(AppDisplay.AppDisplay, false);
|
|
||||||
this._searchPane.content.append(new Clutter.Text({ color: TEXT_COLOR,
|
|
||||||
font_name: 'Sans Bold 10px',
|
|
||||||
text: _("RECENT DOCUMENTS") }),
|
|
||||||
Big.BoxPackFlags.NONE);
|
|
||||||
this._searchAreaDocs = this._searchPane.packResults(DocDisplay.DocDisplay, false);
|
|
||||||
this._addPane(this._searchPane);
|
|
||||||
this._searchEntry.setPane(this._searchPane);
|
|
||||||
}
|
|
||||||
this._searchPane.open();
|
|
||||||
this._searchTimeoutId = Mainloop.timeout_add(150, Lang.bind(this, function() {
|
this._searchTimeoutId = Mainloop.timeout_add(150, Lang.bind(this, function() {
|
||||||
this._searchTimeoutId = 0;
|
this._searchTimeoutId = 0;
|
||||||
let text = this._searchEntry.getText();
|
let text = this._searchEntry.getText();
|
||||||
text = text.replace(/^\s+/g, "").replace(/\s+$/g, "");
|
text = text.replace(/^\s+/g, "").replace(/\s+$/g, "");
|
||||||
this._searchAreaApps.setSearch(text);
|
this._appSearchResultArea.display.setSearch(text);
|
||||||
this._searchAreaDocs.setSearch(text);
|
this._docSearchResultArea.display.setSearch(text);
|
||||||
return false;
|
return false;
|
||||||
}));
|
}));
|
||||||
}));
|
}));
|
||||||
this._searchEntry.entry.connect('activate', Lang.bind(this, function (se) {
|
this._searchEntry.entry.connect('activate', Lang.bind(this, function (se) {
|
||||||
// only one of the displays will have an item selected, so it's ok to
|
// only one of the displays will have an item selected, so it's ok to
|
||||||
// call activateSelected() on all of them
|
// call activateSelected() on all of them
|
||||||
this._searchAreaApps.activateSelected();
|
this._appSearchResultArea.display.activateSelected();
|
||||||
this._searchAreaDocs.activateSelected();
|
this._docSearchResultArea.display.activateSelected();
|
||||||
return true;
|
return true;
|
||||||
}));
|
}));
|
||||||
this._searchEntry.entry.connect('key-press-event', Lang.bind(this, function (se, e) {
|
this._searchEntry.entry.connect('key-press-event', Lang.bind(this, function (se, e) {
|
||||||
@ -551,22 +530,22 @@ Dash.prototype = {
|
|||||||
// too, but there doesn't seem to be any flickering if we first select
|
// too, but there doesn't seem to be any flickering if we first select
|
||||||
// something in one display, but then unset the selection, and move
|
// something in one display, but then unset the selection, and move
|
||||||
// it to the other display, so it's ok to do that.
|
// it to the other display, so it's ok to do that.
|
||||||
if (this._searchAreaDocs.hasSelected())
|
if (this._docSearchResultArea.display.hasSelected())
|
||||||
this._searchAreaDocs.selectUp();
|
this._docSearchResultArea.display.selectUp();
|
||||||
else if (this._searchAreaApps.hasItems())
|
else if (this._appSearchResultArea.display.hasItems())
|
||||||
this._searchAreaApps.selectUp();
|
this._appSearchResultArea.display.selectUp();
|
||||||
else
|
else
|
||||||
this._searchAreaDocs.selectUp();
|
this._docSearchResultArea.display.selectUp();
|
||||||
return true;
|
return true;
|
||||||
} else if (symbol == Clutter.Down) {
|
} else if (symbol == Clutter.Down) {
|
||||||
if (!this._searchActive)
|
if (!this._searchActive)
|
||||||
return true;
|
return true;
|
||||||
if (this._searchAreaDocs.hasSelected())
|
if (this._docSearchResultArea.display.hasSelected())
|
||||||
this._searchAreaDocs.selectDown();
|
this._docSearchResultArea.display.selectDown();
|
||||||
else if (this._searchAreaApps.hasItems())
|
else if (this._appSearchResultArea.display.hasItems())
|
||||||
this._searchAreaApps.selectDown();
|
this._appSearchResultArea.display.selectDown();
|
||||||
else
|
else
|
||||||
this._searchAreaDocs.selectDown();
|
this._docSearchResultArea.display.selectDown();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -574,12 +553,12 @@ Dash.prototype = {
|
|||||||
|
|
||||||
/***** Applications *****/
|
/***** Applications *****/
|
||||||
|
|
||||||
let appsSection = new Section(_("APPLICATIONS"));
|
this._appsSection = new Section(_("APPLICATIONS"));
|
||||||
let appWell = new AppDisplay.AppWell();
|
let appWell = new AppDisplay.AppWell();
|
||||||
appsSection.content.append(appWell.actor, Big.BoxPackFlags.EXPAND);
|
this._appsSection.content.append(appWell.actor, Big.BoxPackFlags.EXPAND);
|
||||||
|
|
||||||
this._moreAppsPane = null;
|
this._moreAppsPane = null;
|
||||||
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(AppDisplay.AppDisplay, true);
|
||||||
@ -588,26 +567,26 @@ Dash.prototype = {
|
|||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
this.sectionArea.append(appsSection.actor, Big.BoxPackFlags.NONE);
|
this.sectionArea.append(this._appsSection.actor, Big.BoxPackFlags.NONE);
|
||||||
|
|
||||||
/***** Places *****/
|
/***** Places *****/
|
||||||
|
|
||||||
/* Translators: This is in the sense of locations for documents,
|
/* Translators: This is in the sense of locations for documents,
|
||||||
network locations, etc. */
|
network locations, etc. */
|
||||||
let placesSection = new Section(_("PLACES"), true);
|
this._placesSection = new Section(_("PLACES"), true);
|
||||||
let placesDisplay = new Places.Places();
|
let placesDisplay = new Places.Places();
|
||||||
placesSection.content.append(placesDisplay.actor, Big.BoxPackFlags.EXPAND);
|
this._placesSection.content.append(placesDisplay.actor, Big.BoxPackFlags.EXPAND);
|
||||||
this.sectionArea.append(placesSection.actor, Big.BoxPackFlags.NONE);
|
this.sectionArea.append(this._placesSection.actor, Big.BoxPackFlags.NONE);
|
||||||
|
|
||||||
/***** Documents *****/
|
/***** Documents *****/
|
||||||
|
|
||||||
let docsSection = new Section(_("RECENT DOCUMENTS"));
|
this._docsSection = new Section(_("RECENT DOCUMENTS"));
|
||||||
|
|
||||||
let docDisplay = new DocDisplay.DashDocDisplay();
|
let docDisplay = new DocDisplay.DashDocDisplay();
|
||||||
docsSection.content.append(docDisplay.actor, Big.BoxPackFlags.EXPAND);
|
this._docsSection.content.append(docDisplay.actor, Big.BoxPackFlags.EXPAND);
|
||||||
|
|
||||||
this._moreDocsPane = null;
|
this._moreDocsPane = null;
|
||||||
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(DocDisplay.DocDisplay, true);
|
||||||
@ -616,7 +595,32 @@ Dash.prototype = {
|
|||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
this.sectionArea.append(docsSection.actor, Big.BoxPackFlags.EXPAND);
|
this.sectionArea.append(this._docsSection.actor, Big.BoxPackFlags.EXPAND);
|
||||||
|
|
||||||
|
/***** Search Results *****/
|
||||||
|
|
||||||
|
this._searchResultsSection = new Section(_("SEARCH RESULTS"), true);
|
||||||
|
|
||||||
|
this._searchResultsSection.content.append(new Clutter.Text({ color: TEXT_COLOR,
|
||||||
|
font_name: 'Sans Bold 10px',
|
||||||
|
text: _("APPLICATIONS") }),
|
||||||
|
Big.BoxPackFlags.NONE);
|
||||||
|
|
||||||
|
this._appSearchResultArea = new ResultArea(AppDisplay.AppDisplay, false);
|
||||||
|
this._searchResultsSection.content.append(this._appSearchResultArea.actor, Big.BoxPackFlags.EXPAND);
|
||||||
|
createPaneForDetails(this, this._appSearchResultArea.display);
|
||||||
|
|
||||||
|
this._searchResultsSection.content.append(new Clutter.Text({ color: TEXT_COLOR,
|
||||||
|
font_name: 'Sans Bold 10px',
|
||||||
|
text: _("DOCUMENTS") }),
|
||||||
|
Big.BoxPackFlags.NONE);
|
||||||
|
|
||||||
|
this._docSearchResultArea = new ResultArea(DocDisplay.DocDisplay, false);
|
||||||
|
this._searchResultsSection.content.append(this._docSearchResultArea.actor, Big.BoxPackFlags.EXPAND);
|
||||||
|
createPaneForDetails(this, this._docSearchResultArea.display);
|
||||||
|
|
||||||
|
this.sectionArea.append(this._searchResultsSection.actor, Big.BoxPackFlags.EXPAND);
|
||||||
|
this._searchResultsSection.actor.hide();
|
||||||
},
|
},
|
||||||
|
|
||||||
show: function() {
|
show: function() {
|
||||||
@ -648,6 +652,20 @@ Dash.prototype = {
|
|||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
Main.overview.addPane(pane);
|
Main.overview.addPane(pane);
|
||||||
|
},
|
||||||
|
|
||||||
|
_updateDashActors: function() {
|
||||||
|
if (!this._searchActive && this._searchResultsSection.actor.visible) {
|
||||||
|
this._searchResultsSection.actor.hide();
|
||||||
|
this._appsSection.actor.show();
|
||||||
|
this._placesSection.actor.show();
|
||||||
|
this._docsSection.actor.show();
|
||||||
|
} else if (this._searchActive && !this._searchResultsSection.actor.visible) {
|
||||||
|
this._searchResultsSection.actor.show();
|
||||||
|
this._appsSection.actor.hide();
|
||||||
|
this._placesSection.actor.hide();
|
||||||
|
this._docsSection.actor.hide();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Signals.addSignalMethods(Dash.prototype);
|
Signals.addSignalMethods(Dash.prototype);
|
||||||
|
Loading…
Reference in New Issue
Block a user