Bug 1748096 Allow multi word search on Gnome shell search provider; r=stransky

Differential Revision: https://phabricator.services.mozilla.com/D148132
This commit is contained in:
Jan Horak 2022-06-07 11:09:06 +00:00
Родитель a7c2ee8534
Коммит 502017c6cb
2 изменённых файлов: 18 добавлений и 5 удалений

Просмотреть файл

@ -32,7 +32,7 @@ static bool GetGnomeSearchTitle(const char* aSearchedTerm,
CopyUTF8toUTF16(nsCString(aSearchedTerm), *formatStrings.AppendElement());
nsAutoString gnomeSearchTitle;
bundle->FormatStringFromName("gnomeSearchProviderSearch", formatStrings,
bundle->FormatStringFromName("gnomeSearchProviderSearchWeb", formatStrings,
gnomeSearchTitle);
AppendUTF16toUTF8(gnomeSearchTitle, aGnomeSearchTitle);
return true;
@ -99,6 +99,15 @@ int DBusGetIndexFromIDKey(const char* aIDKey) {
return atoi(tmp);
}
static void ConcatArray(nsACString& aOutputStr, const char** aStringArray) {
for (const char** term = aStringArray; *term; term++) {
aOutputStr.Append(*term);
if (*(term + 1)) {
aOutputStr.Append(" ");
}
}
}
DBusHandlerResult DBusHandleInitialResultSet(
RefPtr<nsGNOMEShellHistorySearchResult> aSearchResult, DBusMessage* aMsg) {
DBusMessage* reply;
@ -113,7 +122,9 @@ DBusHandlerResult DBusHandleInitialResultSet(
dbus_message_unref(reply);
} else {
aSearchResult->SetReply(dbus_message_new_method_return(aMsg));
aSearchResult->SetSearchTerm(stringArray[0]);
nsAutoCString searchTerm;
ConcatArray(searchTerm, const_cast<const char**>(stringArray));
aSearchResult->SetSearchTerm(searchTerm.get());
GetGNOMEShellHistoryService()->QueryHistory(aSearchResult);
// DBus reply will be send asynchronously by
// nsGNOMEShellHistorySearchResult::SendDBusSearchResultReply()
@ -144,7 +155,9 @@ DBusHandlerResult DBusHandleSubsearchResultSet(
dbus_message_unref(reply);
} else {
aSearchResult->SetReply(dbus_message_new_method_return(aMsg));
aSearchResult->SetSearchTerm(stringArray[0]);
nsAutoCString searchTerm;
ConcatArray(searchTerm, const_cast<const char**>(stringArray));
aSearchResult->SetSearchTerm(searchTerm.get());
GetGNOMEShellHistoryService()->QueryHistory(aSearchResult);
// DBus reply will be send asynchronously by
// nsGNOMEShellHistorySearchResult::SendDBusSearchResultReply()

Просмотреть файл

@ -999,6 +999,6 @@ confirmationHint.passwordSaved.label = Password saved!
confirmationHint.loginRemoved.label = Login removed!
confirmationHint.breakageReport.label = Report sent. Thank you!
# LOCALIZATION NOTE (gnomeSearchProviderSearch):
# LOCALIZATION NOTE (gnomeSearchProviderSearchWeb):
# Used for search by Gnome Shell activity screen, %S is a searched string.
gnomeSearchProviderSearch=Search the web for %S
gnomeSearchProviderSearchWeb=Search the web for %S