mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1094844 - Use new keywords API in search service. r=jaws
This commit is contained in:
parent
24165193a1
commit
b2ac788793
@ -3,7 +3,10 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Components.utils.import("resource://gre/modules/PlacesUtils.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "PlacesUtils",
|
||||
"resource://gre/modules/PlacesUtils.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "Task",
|
||||
"resource://gre/modules/Task.jsm");
|
||||
|
||||
const ENGINE_FLAVOR = "text/x-moz-search-engine";
|
||||
|
||||
@ -191,19 +194,13 @@ var gSearchPane = {
|
||||
document.getElementById("engineList").focus();
|
||||
},
|
||||
|
||||
editKeyword: function(aEngine, aNewKeyword) {
|
||||
editKeyword: Task.async(function* (aEngine, aNewKeyword) {
|
||||
if (aNewKeyword) {
|
||||
let bduplicate = false;
|
||||
let eduplicate = false;
|
||||
let dupName = "";
|
||||
|
||||
try {
|
||||
let bmserv =
|
||||
Components.classes["@mozilla.org/browser/nav-bookmarks-service;1"]
|
||||
.getService(Components.interfaces.nsINavBookmarksService);
|
||||
if (bmserv.getURIForKeyword(aNewKeyword))
|
||||
bduplicate = true;
|
||||
} catch(ex) {}
|
||||
// Check for duplicates in Places keywords.
|
||||
let bduplicate = !!(yield PlacesUtils.keywords.fetch(aNewKeyword));
|
||||
|
||||
// Check for duplicates in changes we haven't committed yet
|
||||
let engines = gEngineView._engineStore.engines;
|
||||
@ -231,7 +228,7 @@ var gSearchPane = {
|
||||
gEngineView._engineStore.changeEngine(aEngine, "alias", aNewKeyword);
|
||||
gEngineView.invalidate();
|
||||
return true;
|
||||
},
|
||||
}),
|
||||
|
||||
saveOneClickEnginesList: function () {
|
||||
let hiddenList = [];
|
||||
@ -519,11 +516,11 @@ EngineView.prototype = {
|
||||
},
|
||||
setCellText: function(index, column, value) {
|
||||
if (column.id == "engineKeyword") {
|
||||
if (!gSearchPane.editKeyword(this._engineStore.engines[index], value)) {
|
||||
setTimeout(() => {
|
||||
gSearchPane.editKeyword(this._engineStore.engines[index], value)
|
||||
.then(valid => {
|
||||
if (!valid)
|
||||
document.getElementById("engineList").startEditing(index, column);
|
||||
}, 0);
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
performAction: function(action) { },
|
||||
|
@ -3,7 +3,10 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Components.utils.import("resource://gre/modules/PlacesUtils.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "PlacesUtils",
|
||||
"resource://gre/modules/PlacesUtils.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "Task",
|
||||
"resource://gre/modules/Task.jsm");
|
||||
|
||||
const ENGINE_FLAVOR = "text/x-moz-search-engine";
|
||||
|
||||
@ -123,19 +126,13 @@ var gSearchPane = {
|
||||
document.getElementById("engineList").focus();
|
||||
},
|
||||
|
||||
editKeyword: function(aEngine, aNewKeyword) {
|
||||
editKeyword: Task.async(function* (aEngine, aNewKeyword) {
|
||||
if (aNewKeyword) {
|
||||
let bduplicate = false;
|
||||
let eduplicate = false;
|
||||
let dupName = "";
|
||||
|
||||
try {
|
||||
let bmserv =
|
||||
Components.classes["@mozilla.org/browser/nav-bookmarks-service;1"]
|
||||
.getService(Components.interfaces.nsINavBookmarksService);
|
||||
if (bmserv.getURIForKeyword(aNewKeyword))
|
||||
bduplicate = true;
|
||||
} catch(ex) {}
|
||||
// Check for duplicates in Places keywords.
|
||||
let bduplicate = !!(yield PlacesUtils.keywords.fetch(aNewKeyword));
|
||||
|
||||
// Check for duplicates in changes we haven't committed yet
|
||||
let engines = gEngineView._engineStore.engines;
|
||||
@ -163,7 +160,7 @@ var gSearchPane = {
|
||||
gEngineView._engineStore.changeEngine(aEngine, "alias", aNewKeyword);
|
||||
gEngineView.invalidate();
|
||||
return true;
|
||||
},
|
||||
}),
|
||||
|
||||
saveOneClickEnginesList: function () {
|
||||
let hiddenList = [];
|
||||
@ -534,11 +531,11 @@ EngineView.prototype = {
|
||||
},
|
||||
setCellText: function(index, column, value) {
|
||||
if (column.id == "engineKeyword") {
|
||||
if (!gSearchPane.editKeyword(this._engineStore.engines[index], value)) {
|
||||
setTimeout(() => {
|
||||
gSearchPane.editKeyword(this._engineStore.engines[index], value)
|
||||
.then(valid => {
|
||||
if (!valid)
|
||||
document.getElementById("engineList").startEditing(index, column);
|
||||
}, 0);
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
performAction: function(action) { },
|
||||
|
@ -2,7 +2,12 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Components.utils.import("resource://gre/modules/Services.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "PlacesUtils",
|
||||
"resource://gre/modules/PlacesUtils.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "Task",
|
||||
"resource://gre/modules/Task.jsm");
|
||||
|
||||
const Ci = Components.interfaces;
|
||||
const Cc = Components.classes;
|
||||
@ -105,7 +110,7 @@ var gEngineManagerDialog = {
|
||||
document.getElementById("engineList").focus();
|
||||
},
|
||||
|
||||
editKeyword: function engineManager_editKeyword() {
|
||||
editKeyword: Task.async(function* () {
|
||||
var selectedEngine = gEngineView.selectedEngine;
|
||||
if (!selectedEngine)
|
||||
return;
|
||||
@ -121,12 +126,8 @@ var gEngineManagerDialog = {
|
||||
var dupName = "";
|
||||
|
||||
if (alias.value != "") {
|
||||
try {
|
||||
let bmserv = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].
|
||||
getService(Ci.nsINavBookmarksService);
|
||||
if (bmserv.getURIForKeyword(alias.value))
|
||||
bduplicate = true;
|
||||
} catch(ex) {}
|
||||
// Check for duplicates in Places keywords.
|
||||
bduplicate = !!(yield PlacesUtils.keywords.fetch(alias.value));
|
||||
|
||||
// Check for duplicates in changes we haven't committed yet
|
||||
let engines = gEngineView._engineStore.engines;
|
||||
@ -154,7 +155,7 @@ var gEngineManagerDialog = {
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
}),
|
||||
|
||||
onSelect: function engineManager_onSelect() {
|
||||
// Buttons only work if an engine is selected and it's not the last engine,
|
||||
|
@ -36,7 +36,7 @@
|
||||
oncommand="gEngineManagerDialog.bump(-1);"
|
||||
disabled="true"/>
|
||||
<command id="cmd_editkeyword"
|
||||
oncommand="gEngineManagerDialog.editKeyword();"
|
||||
oncommand="gEngineManagerDialog.editKeyword().catch(Components.utils.reportError);"
|
||||
disabled="true"/>
|
||||
</commandset>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user