1
function goQuitApplication()
3
var ObserverService = Components.classes["@mozilla.org/observer-service;1"].getService();
4
ObserverService = ObserverService.QueryInterface(Components.interfaces.nsIObserverService);
9
// XXX FIX! we should have a way to cancel a requested quit; see
10
// bugzilla bug 149764
11
ObserverService.notifyObservers(null, "quit-application-requested", null);
15
// dump("no observer found \n");
19
var windowManager = Components.classes['@mozilla.org/appshell/window-mediator;1'].getService();
20
var windowManagerInterface = windowManager.QueryInterface( Components.interfaces.nsIWindowMediator);
21
var enumerator = windowManagerInterface.getEnumerator( null );
22
var appShell = Components.classes['@mozilla.org/appshell/appShellService;1'].getService();
23
appShell = appShell.QueryInterface( Components.interfaces.nsIAppShellService );
25
var nativeAppSupport = null;
27
nativeAppSupport = appShell.nativeAppSupport;
32
while ( enumerator.hasMoreElements() )
34
var domWindow = enumerator.getNext();
35
if (("tryToClose" in domWindow) && !domWindow.tryToClose())
39
if (!nativeAppSupport || !nativeAppSupport.isServerMode)
40
appShell.quit(Components.interfaces.nsIAppShellService.eAttemptQuit);
45
// Command Updater functions
47
function goUpdateCommand(command)
50
var controller = top.document.commandDispatcher.getControllerForCommand(command);
55
enabled = controller.isCommandEnabled(command);
57
goSetCommandEnabled(command, enabled);
60
dump("An error occurred updating the "+command+" command\n");
64
function goDoCommand(command)
67
var controller = top.document.commandDispatcher.getControllerForCommand(command);
68
if ( controller && controller.isCommandEnabled(command))
69
controller.doCommand(command);
72
dump("An error occurred executing the "+command+" command\n");
77
function goSetCommandEnabled(id, enabled)
79
var node = document.getElementById(id);
84
node.removeAttribute("disabled");
86
node.setAttribute('disabled', 'true');
90
function goSetMenuValue(command, labelAttribute)
92
var commandNode = top.document.getElementById(command);
95
var label = commandNode.getAttribute(labelAttribute);
97
commandNode.setAttribute('label', label);
101
function goSetAccessKey(command, valueAttribute)
103
var commandNode = top.document.getElementById(command);
106
var value = commandNode.getAttribute(valueAttribute);
108
commandNode.setAttribute('accesskey', value);
112
// this function is used to inform all the controllers attached to a node that an event has occurred
113
// (e.g. the tree controllers need to be informed of blur events so that they can change some of the
114
// menu items back to their default values)
115
function goOnEvent(node, event)
117
var numControllers = node.controllers.getControllerCount();
120
for ( var controllerIndex = 0; controllerIndex < numControllers; controllerIndex++ )
122
controller = node.controllers.getControllerAt(controllerIndex);
124
controller.onEvent(event);
128
function setTooltipText(aID, aTooltipText)
130
var element = document.getElementById(aID);
132
element.setAttribute("tooltiptext", aTooltipText);
135
function FillInTooltip ( tipElement )
138
var textNode = document.getElementById("TOOLTIP-tooltipText");
140
while (textNode.hasChildNodes())
141
textNode.removeChild(textNode.firstChild);
142
var tipText = tipElement.getAttribute("tooltiptext");
144
var node = document.createTextNode(tipText);
145
textNode.appendChild(node);