Monday, November 08, 2010 at 12:03 AM.

system.verbs.builtins.Frontier.tools.windowTypes.isFileMenuItemEnabled

on isFileMenuItemEnabled (cmd) {
	<<Changes:
		<<12/2/01; 6:55:44 PM by JES
			<<if user.radio.settings.flExpired is defined, and true, disable all commands except quit.
		<<Archive
			<<2/19/01; 2:46:08 PM by PBS
				<<The Close menu item is always enabled.
			<<2/2/01; 11:32:23 AM by PBS
				<<Save is now always enabled.
			<<1/28/01; 11:29:50 AM by DW
				<<See comment at the head of system.menus.agent. We use the cached version of window.frontmost, to work around a performance bottleneck.
			<<12/26/00; 4:02:39 PM by PBS
				<<Always enable View in Browser, Save As HTML, and Save As Plain Text if the frontmost window is an outline.
			<<12/15/00; 6:39:02 PM by PBS
				<<Enable Save As HTML and Save As Plain Text if the frontmost outline is a local outline.
			<<12/14/00; 12:22:23 AM by PBS
				<<Enable the View in Browser command if the frontmost window is a local outline or an outline from a Manila site.
			<<10/16/00; 7:16:33 PM by PBS
				<<Support Open Manila Site item.
				<<Open URL... and Update Radio.root are disabled when working offline.
			<<09/23/00; 4:22:31 PM by PBS
				<<Handle the Work Offline File menu item.
			<<08/30/00; 9:58:54 PM by PBS
				<<Backtrack on Save-always-enabled.
			<<08/30/00; 4:55:37 PM by PBS
				<<Save is always enabled -- so you can save the object database, at least.
				<<Added case for Open URL command.
			<<07/27/00; 10:58:35 PM by PBS
				<<Save As is now enabled for outline objects in the odb, such as the Notepad.
			<<07/27/00; 3:42:57 PM by PBS
				<<This script now gets called for the Update Radio.root File menu item. It always returns true, it's enabled.
			<<07/24/00; 12:40:14 PM by PBS
				<<Updated for local XML outline documents.
			<<Fri, Jul 7, 2000 at 11:00:09 PM by AR
				<<Return true if a File menu item should be enabled, false otherwise.
				<<Call any scripts in user.pike.commandCallbacks.isMenuItemEnabled
				<<If one of the scripts returns true, we're done
	if defined (user.radio.settings.flExpired) {
		if user.radio.settings.flExpired {
			case cmd {
				"close" {
					return (true)}};
			return (false)}};
	
	local (windowFrontmost = window.frontmost ());
	on getCursorAddress () {
		<<Special version that uses cached version of window.frontmost.
		local (adrobject = address (windowFrontmost));
		if adrobject == nil {
			return (nil)};
		if typeOf (adrobject^) == tabletype {
			adrobject = table.getCursor ()};
		return (adrobject)};
	<<scratchpad.ctfilemenuitemenable++
	on runCallbacks (adrtable) {
		if defined (adrtable^) {
			try {
				local (adrcallback);
				for adrcallback in @user.pike.commandCallbacks.isMenuItemEnabled {
					try {
						if adrcallback^ (cmd) {
							return (true)}}};
				return (false)}}};
	if defined (user.tools.commandCallbacks.isMenuItemEnabled) {
		if runCallbacks (@user.tools.commandCallbacks.isMenuItemEnabled) {
			return (true)}};
	if system.environment.isRadio {
		if defined (user.pike.commandCallbacks.isMenuItemEnabled) {
			if runCallbacks (@user.pike.commandCallbacks.isMenuItemEnabled) {
				return (true)}}};
	local (type, adrtype, isWindowTypesWindow);
	if window.attributes.getOne ("type", @type, windowFrontmost) {
		isWindowTypesWindow = Frontier.tools.windowTypes.findWindowType (type, @adrtype, windowFrontmost)};
	case cmd {
		"whatisthis" {
			return (true)};
		"openurl" {
			if defined (tcp.isOffline) {
				if tcp.isOffline () {
					return (false)}};
			return (true)};
		"close" {
			return (true)}; //PBS 02/19/01: always enabled
			<<local (adr = windowFrontmost)
			<<return ((adr != "") and (not window.ishidden (adr)))
		"save" {
			return (true)}; //PBS 02/02/01: save is always enabled
			<<local (adr = getCursorAddress ())
			<<local (windowType = pike.getWindowType (adr))
			<<if windowType == ""
				<<return (true)
			<<return (pike.isItemDirty (parentOf (adr^)))
		"revert" {
			if isWindowTypesWindow {
				if defined (adrtype^.revert) {
					if Frontier.tools.windowTypes.isWindowDirty (windowFrontmost) {
						return (true)}}};
			return (false)};
			<<bundle //old code
				<<local (adr = getCursorAddress ())
				<<if pike.isLocalOutline (adr) //PBS 07/24/00: check local outlines
					<<return (pike.isItemDirty (parentOf (adr^)))
				<<local (windowType = pike.getWindowType (adr))
				<<case windowType
					<<"savedStories"
					<<"advancedItems"
						<<return (pike.isItemDirty (parentOf (adr^)))
					<<"newStories"
						<<return (false)
				<<return (false)
		"viewinbrowser";
		"saveashtml";
		"saveasplaintext" { //PBS 12/15/00: enable all outlines
			if isWindowTypesWindow {
				if defined (adrtype^.viewInBrowser) {
					return (true)}};
			local (adr = getCursorAddress ());
			case typeOf (adr^) {
				scriptType;
				outlineType {
					return (true)}}};
		"saveas"; //PBS 07/24/00: Save As now is the same as Change Title
			<<return (true) //uncomment this line to make the Save As command equivalent to the Export Object command.
		"changetitle" {
			if isWindowTypesWindow {
				if defined (adrtype^.saveAs) {
					return (true)}};
			local (adr = getCursorAddress ());
			if typeOf (adr^) == outlineType {
				return (true)};
			return (false)};
			<<bundle //old code
				<<local (adr = getCursorAddress ())
				<<if pike.isLocalOutline (adr) //PBS 07/24/00
					<<return (true)
				<<case pike.getWindowType (adr)
					<<"savedStories"
					<<"newStories"
						<<return (true)
					<<"advancedItems"
						<<return (false)
				<<if typeOf (adr^) == outlineType
					<<return (true)
				<<return (false)
		"update" {
			if defined (tcp.isOffline) {
				if tcp.isOffline () {
					return (false)}};
			return (true)};
		"workoffline" { //PBS 09/23/00: work offline menu item
			if defined (tcp.setOffline) {
				return (true)}};
		"openmanilasite" { //PBS 10/16/00: enable/disable Open Manila Site command
			if defined (tcp.isOffline) {
				if tcp.isOffline () {
					return (false)}};
			return (true)}};
	return (false)};

bundle { //debugging
	isFileMenuItemEnabled ("revert")}



This listing is for code that runs in the OPML Editor environment. I created these listings because I wanted the search engines to index it, so that when I want to look up something in my codebase I don't have to use the much slower search functionality in my object database. Dave Winer.