[Sciviews-commits] r464 - in pkg: SciViews SciViews/R svDialogs svDialogs/R svDialogs/inst svDialogs/inst/gui svDialogs/man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Apr 4 18:55:02 CEST 2012


Author: phgrosjean
Date: 2012-04-04 18:55:01 +0200 (Wed, 04 Apr 2012)
New Revision: 464

Added:
   pkg/svDialogs/inst/gui/RCtxMenuLinux.txt
   pkg/svDialogs/inst/gui/RMenuLinux.txt
Removed:
   pkg/svDialogs/inst/gui/RCtxMenu.txt
   pkg/svDialogs/inst/gui/RMenu.txt
Modified:
   pkg/SciViews/NAMESPACE
   pkg/SciViews/R/SciViews-internal.R
   pkg/SciViews/R/misc.R
   pkg/svDialogs/DESCRIPTION
   pkg/svDialogs/NEWS
   pkg/svDialogs/R/menu.R
   pkg/svDialogs/R/svDialogs-internal.R
   pkg/svDialogs/inst/NEWS.Rd
   pkg/svDialogs/man/menu.Rd
   pkg/svDialogs/man/svDialogs-package.Rd
Log:
svDialogs: rework of menus to match CRAN policies, SciViews: small changes

Modified: pkg/SciViews/NAMESPACE
===================================================================
--- pkg/SciViews/NAMESPACE	2012-04-02 14:09:28 UTC (rev 463)
+++ pkg/SciViews/NAMESPACE	2012-04-04 16:55:01 UTC (rev 464)
@@ -90,6 +90,7 @@
 	   ":=",
 	   "%:%",
 	   "%else%",
+	   ".",
 	   package,
 	   enum,
 	   timing,

Modified: pkg/SciViews/R/SciViews-internal.R
===================================================================
--- pkg/SciViews/R/SciViews-internal.R	2012-04-02 14:09:28 UTC (rev 463)
+++ pkg/SciViews/R/SciViews-internal.R	2012-04-04 16:55:01 UTC (rev 464)
@@ -59,3 +59,7 @@
     if (isTRUE(replace.existing) || !exists(x, envir = .TempEnv(), mode = "any",
 		inherits = FALSE))
         assign(x, value, envir = .TempEnv())
+
+## This is for convenience: . == .GlobalEnv
+.assignTemp(".", base::.GlobalEnv)
+

Modified: pkg/SciViews/R/misc.R
===================================================================
--- pkg/SciViews/R/misc.R	2012-04-02 14:09:28 UTC (rev 463)
+++ pkg/SciViews/R/misc.R	2012-04-04 16:55:01 UTC (rev 464)
@@ -2,6 +2,10 @@
 
 # is.wholenumber(), see ?as.integer => define isWholeInt?
 
+## A convenient starting object for holding items: . == .GlobalEnv
+## TODO: take care there is no clash with proto objects!
+. <- base::.GlobalEnv
+
 ## This should be nice:
 ## Define a valid method to be applied to S3 objects to make sure they are
 ## correct

Modified: pkg/svDialogs/DESCRIPTION
===================================================================
--- pkg/svDialogs/DESCRIPTION	2012-04-02 14:09:28 UTC (rev 463)
+++ pkg/svDialogs/DESCRIPTION	2012-04-04 16:55:01 UTC (rev 464)
@@ -1,7 +1,7 @@
 Package: svDialogs
 Type: Package
-Version: 0.9-51
-Date: 2012-04-02
+Version: 0.9-52
+Date: 2012-04-04
 Title: SciViews GUI API - Dialog boxes
 Authors at R: c(person("Philippe", "Grosjean", role = c("aut", "cre"),
   email = "phgrosjean at sciviews.org"))

Modified: pkg/svDialogs/NEWS
===================================================================
--- pkg/svDialogs/NEWS	2012-04-02 14:09:28 UTC (rev 463)
+++ pkg/svDialogs/NEWS	2012-04-04 16:55:01 UTC (rev 464)
@@ -1,5 +1,17 @@
 = svDialogs News
 
+== Changes in svDialogs 0.9-52
+
+* menuXXX() functions do not generate files in \tmp dir on Linux, unless in
+  interactive() session, and with explicit user's acknowledgement. Moreover,
+  the user name is not used anymore as part of the name of the temporary menu
+  files generated (cf CRAN policies and following B. Ripley's request).
+  
+* Code to manage menuXXX() items on Mac OS X is considered still experimental
+  (on R-forge, not CRAN) and is now commented out. Will be further developed in
+  a future version of the svDialogs package.
+
+
 == Changes in svDialogs 0.9-51
 
 * NEWS file reworked to use the new Rd format.

Modified: pkg/svDialogs/R/menu.R
===================================================================
--- pkg/svDialogs/R/menu.R	2012-04-02 14:09:28 UTC (rev 463)
+++ pkg/svDialogs/R/menu.R	2012-04-04 16:55:01 UTC (rev 464)
@@ -129,7 +129,7 @@
 .winMenuAddItem <- function (menuname, itemname, action)
 {
 	## As in R 2.14.1, the original winMenuAddItem() does things I don't like
-	## much when usin 'enable' or 'disable' for action, on a non existing menu:
+	## much when using 'enable' or 'disable' for action, on a non existing menu:
 	## it creates it with the action being 'enable' or 'disable'... I suppose
 	## if is a feature, but I want a different behaviour here: to ignore such
 	## a command applied to a non-existing menu item!
@@ -165,18 +165,20 @@
 }
 
 .macMenuClear <- function () {
-    ## To be called when svDialogs package loads: make sure to zap all
-    ## custom menu items that may have been previously defined
-    ## (also call it when the package closes)
-    odir <- getwd()
-    on.exit(setwd(odir))
-    setwd(.macMenuFolder())
-	setwd("..")
-    folder <- file.path(".", basename(.macMenuFolder()))
-	unlink(folder, recursive = TRUE)
-    dir.create(folder, recursive = TRUE)
-    ## Now, I can assume that the dir is created and is empty
-    return(invisible(NULL))
+    stop("Not implemented yet!")
+	
+#	## To be called when svDialogs package loads: make sure to zap all
+#    ## custom menu items that may have been previously defined
+#    ## (also call it when the package closes)
+#    odir <- getwd()
+#    on.exit(setwd(odir))
+#    setwd(.macMenuFolder())
+#	setwd("..")
+#    folder <- file.path(".", basename(.macMenuFolder()))
+#	unlink(folder, recursive = TRUE)
+#    dir.create(folder, recursive = TRUE)
+#    ## Now, I can assume that the dir is created and is empty
+#    return(invisible(NULL))
 }
 
 .macMenuNames <- function ()
@@ -191,74 +193,84 @@
 
 .macMenuAdd <- function (menuname)
 {
-    ## Menus are folders created in ~/Scripts/Applications/R/Custom
-    ## I just need to create (recursively) the directories
-    dir.create(file.path(.macMenuFolder(), menuname),
-		showWarnings = FALSE, recursive = TRUE)
-    return(invisible(NULL))
+    stop("Not implemented yet!")
+	
+#	## Menus are folders created in ~/Scripts/Applications/R/Custom
+#    ## I just need to create (recursively) the directories
+#    dir.create(file.path(.macMenuFolder(), menuname),
+#		showWarnings = FALSE, recursive = TRUE)
+#    return(invisible(NULL))
 }
 
 .macMenuAddItem <- function (menuname, itemname, action)
 {
-    ## TODO: manage 'enable' and 'disable'!!!
-	## Make sure that the dir is created
-    .macMenuAdd(menuname)
-    ## Switch to this folder
-	odir <- getwd()
-    on.exit(setwd(odir))
-    setwd(file.path(.macMenuFolder(), menuname))
-	## Add an executable file in it with 'itemname' name
-	## that contains AppleScript code to run action in R
-	## Determine if R is run in R.app or in a terminal window
-	if (.Platform$GUI == "AQUA") {
-		## Can be R or R64 or SciViews R or SciViews R64!
-		app <- paste('"', system("osascript -e 'name of application \"R\"'",
-			intern = TRUE), '"', sep = "")
-	} else app <- "\"Terminal\""
-	## Define action accordingly
-	if (action == "none") {
-		cmd <- "to activate"
-	} else {
-		## Make sure to quote "
-		action <- gsub('"', '\\\\"', action)
-		## Also replace \n, \r and \t
-		action <- gsub('\n', '\\\\\\\\n', action)
-		action <- gsub('\r', '\\\\\\\\r', action)
-		action <- gsub('\t', '\\\\\\\\t', action)
-		if (app == "\"Terminal\"") {
-			cmd <- paste("to do script \"", action, "\" in window 1", sep = "")	
-		} else {
-			cmd <- paste("to cmd \"", action, "\"", sep = "")
-		}
-	}
-	## Compile applescript item
-	system(paste("osacompile -e 'tell application ", app, " ", cmd,
-		"' -o \"", itemname, ".app\"", sep = ""), ignore.stdout = TRUE,
-		ignore.stderr = TRUE)
-    return(invisible(NULL))
+    stop("Not implemented yet!")
+	
+#	## TODO: manage 'enable' and 'disable'!!!
+#	## Make sure that the dir is created
+#    .macMenuAdd(menuname)
+#    ## Switch to this folder
+#	odir <- getwd()
+#    on.exit(setwd(odir))
+#    setwd(file.path(.macMenuFolder(), menuname))
+#	## Add an executable file in it with 'itemname' name
+#	## that contains AppleScript code to run action in R
+#	## Determine if R is run in R.app or in a terminal window
+#	if (.Platform$GUI == "AQUA") {
+#		## Can be R or R64 or SciViews R or SciViews R64!
+#		app <- paste('"', system("osascript -e 'name of application \"R\"'",
+#			intern = TRUE), '"', sep = "")
+#	} else app <- "\"Terminal\""
+#	## Define action accordingly
+#	if (action == "none") {
+#		cmd <- "to activate"
+#	} else {
+#		## Make sure to quote "
+#		action <- gsub('"', '\\\\"', action)
+#		## Also replace \n, \r and \t
+#		action <- gsub('\n', '\\\\\\\\n', action)
+#		action <- gsub('\r', '\\\\\\\\r', action)
+#		action <- gsub('\t', '\\\\\\\\t', action)
+#		if (app == "\"Terminal\"") {
+#			cmd <- paste("to do script \"", action, "\" in window 1", sep = "")	
+#		} else {
+#			cmd <- paste("to cmd \"", action, "\"", sep = "")
+#		}
+#	}
+#	## Compile applescript item
+#	system(paste("osacompile -e 'tell application ", app, " ", cmd,
+#		"' -o \"", itemname, ".app\"", sep = ""), ignore.stdout = TRUE,
+#		ignore.stderr = TRUE)
+#    return(invisible(NULL))
 }
 
 .macMenuDel <- function (menuname)
 {
-    ## Unlink does not like ~ => change working dir first
-    odir <- getwd()
-    on.exit(setwd(odir))
-    setwd(.macMenuFolder())
-    unlink(menuname, recursive = TRUE)
-    return(invisible(NULL))
+    stop("Not implemented yet!")
+	
+#	## Unlink does not like ~ => change working dir first
+#    odir <- getwd()
+#    on.exit(setwd(odir))
+#    setwd(.macMenuFolder())
+#    unlink(menuname, recursive = TRUE)
+#    return(invisible(NULL))
 }
 
 .macMenuDelItem <- function (menuname, itemname)
 {
-    ## Unlink does not like ~ => change working dir first
-    odir <- getwd()
-    on.exit(setwd(odir))
-    setwd(file.path(.macMenuFolder()))
-	unlink(file.path(".", menuname, paste(itemname, "app", sep = ".")),
-		recursive = TRUE) 
-    return(invisible(NULL))    
+	stop("Not implemented yet!")
+
+#    ## Unlink does not like ~ => change working dir first
+#    odir <- getwd()
+#    on.exit(setwd(odir))
+#    setwd(file.path(.macMenuFolder()))
+#	unlink(file.path(".", menuname, paste(itemname, "app", sep = ".")),
+#		recursive = TRUE) 
+#    return(invisible(NULL))    
 }
 
+
+
 ## This holds the custom menu structure in an R object
 .Rmenu <- function ()
 {
@@ -267,35 +279,67 @@
 }
 
 ## Linux/Unix version
-## To use R custom context menu, you have to install xvkbd and xdotool
-## You need also to compile and install myGtkmenu
+## To use R custom context menu, you have to install xvkbd, xdotool,
+## zenity (and, possibly, yad)
+## You need also to compile and install ctxmenu
 ## On Ubuntu:
-## sudo apt-get install xvkbd xdotool
-## Warning, you need to insqtall the English (US) keymap, even if you don't use
+## sudo apt-get install xvkbd xdotool zenity
+## Warning, you need to insstall the English (US) keymap, even if you don't use
 ## it. Otherwise, xvkbd will issue strange things in your R console!
 ## TODO: install and configure ctxmenu... + add shortcut keys!
 ## Use xbindkeys to bind shell commands to keyboard and mouse keys
 ## chmod +x ctxmenu
-##
-## THIS IS THE OLD VERSION (COMMENTED CODE BELLOW!)
-## Explanation: to run this, you need to install xvkbd and file-browser-applet
-## for Gnome. Under Ubuntu, you make:
-## sudo apt-get install file-browser-apple
-## sudo apt-get install xvkbd
-## You need to log out and in again to make the applet available
-## Then, you need to install and configure a file browser applet in a panel
-## right-click in a panel, select 'add to Panel...' and drag&drop a 'File Browser'
-## Right-click on the file browser and select 'Preferences'. In the preference
-## box, eliminate the default entry (Home) and add all subdirectories from
-## ~/Scripts/Applications/R. You can access R menus from there, and it sends
-## corresponding commands to the focused window (e.g., a terminal running R)
-## TODO: find a similar item for KDE and new Ubuntu unity interface!
-## winMenuAdd(), winMenuAddItem(), winMenuDel() and winMenuDelItem() already
-## defined for windows RGui, but need a substitution for Rterm!
+
+## We need to write menu files in /tmp... but CRAN policies do not allow this
+## unless we got acknowledgement by the user in the interactive session.
+## This function checks that R runs in interactive mode and the user gave
+## acknowledgement, either interactively,  or by defining the option
+## 'svDialogs.tmpfiles' to TRUE
+.tmpfilesAllowed <- function ()
+	return(interactive() && isTRUE(getOption("svDialogs.tmpfiles", FALSE)))
+
+.unixTmpfilesAsk <- function ()
+{
+	if (!interactive()) return(FALSE)
+	
+	## Make sure the user gave explicit right to create custom menus temp
+	## files, either interactively, or through the setting of an option
+	## options(svDialogs.tmpfiles = TRUE)
+	opt <- getOption("svDialogs.tmpfiles")
+	if (is.null(opt)) { # Ask user interactively
+		if (okCancelBox("Install custom menu configuration files in ~/.ctxmenu/tmp/?")) {
+			options(svDialogs.tmpfiles = TRUE)
+			## Make sure to clear old menus, and to install new ones
+			.menuClear()
+			.menuFileInit()
+			.ctxMenuFileInit()	
+			## Make sure that ctxmenu is installed
+			if (Sys.which("ctxmenu") == "") {
+				warning("Menus will not be displayed if you do not install ctxmenu properly, see: http://www.sciviews.org/SciViews-R/ctxmenu.zip")
+				return(FALSE)
+			} else return(TRUE) # Everything should be ok!
+		} else {
+			options(svDialogs.tmpfiles = FALSE)
+			## Indicate that it will not be possible to use custom menus before
+			## allowed by the corresponding option
+			warning("Menus will not be displayed unless you agree to create config files using options(svDialogs.tmpfiles = TRUE)")
+			return(FALSE)
+		}
+	} else if (!isTRUE(opt)) {
+		warning("Menus will not be displayed unless you agree to create config files using options(svDialogs.tmpfiles = TRUE)")
+		return(FALSE)
+	} else return(TRUE) # Note: we do not check again for ctxmenu here!
+}
+
 .unixMenuFolder <- function ()
 {
 	## Get the root folder for the R menus
-	return(getOption("menuFolder", default = "/tmp"))
+	mnudir <- getOption("menuFolder", default = "~/.ctxmenu/tmp")
+	## Make sure this directory exists, in one can write to it!
+	if (.tmpfilesAllowed() && !file.exists(mnudir))
+		try(dir.create(mnudir, showWarnings = FALSE, recursive = TRUE),
+			silent = TRUE)
+	return(mnudir)
 }
 
 .unixMenuFile <- function ()
@@ -303,14 +347,20 @@
 	## Get the name of the file that contains the R menu
 	winid <- getTemp(".winid", default = Sys.getenv("WINDOWID"))
 	assignTemp(".winid", winid)
-	user <- getTemp(".user", default = Sys.getenv("USER"))
-	assignTemp(".user", user)
-	return(file.path(.unixMenuFolder(), paste(user, winid,
+	## Do not use user name in the filename (B. Ripley's request)
+	#user <- getTemp(".user", default = Sys.getenv("USER"))
+	#assignTemp(".user", user)
+	#return(file.path(.unixMenuFolder(), paste(user, winid,
+	#	"Menu.txt", sep = "")))
+	return(file.path(.unixMenuFolder(), paste(winid,
 		"Menu.txt", sep = "")))
 }
 
 .unixMenuFileInit <- function ()
 {
+	## Can we generate files in /tmp?
+	if (!.tmpfilesAllowed()) return(invisible(NULL))
+	
 	## Initialize the R menu file with default items
 	fil <- .unixMenuFile()
 	## Get the default R menu and start from there
@@ -318,8 +368,8 @@
 		default = file.path("~", ".ctxmenu", "RMenu.txt"))
 	if (file.exists(def)) {
 		file.copy(def, fil, overwrite = TRUE)
-	} else file.copy(system.file("gui", "RMenu.txt", package = "svDialogs"),
-		fil, overwrite = TRUE)
+	} else file.copy(system.file("gui", "RMenuLinux.txt",
+		package = "svDialogs"), fil, overwrite = TRUE)
 	return(invisible(NULL))
 }
 
@@ -328,14 +378,20 @@
 	## Get the name of the file that contains the R context menu
 	winid <- getTemp(".winid", default = Sys.getenv("WINDOWID"))
 	assignTemp(".winid", winid)
-	user <- getTemp(".user", default = Sys.getenv("USER"))
-	assignTemp(".user", user)
-	return(file.path(.unixMenuFolder(), paste(user, winid,
+	## Do not use user name in the filename (B. Ripley's request)
+	#user <- getTemp(".user", default = Sys.getenv("USER"))
+	#assignTemp(".user", user)
+	#return(file.path(.unixMenuFolder(), paste(user, winid,
+	#	"CtxMenu.txt", sep = "")))
+	return(file.path(.unixMenuFolder(), paste(winid,
 		"CtxMenu.txt", sep = "")))
 }
 
 .unixCtxMenuFileInit <- function ()
 {
+	## Can we generate files in /tmp?
+	if (!.tmpfilesAllowed()) return(invisible(NULL))
+	
 	## Initialize the R context menu file with default items
 	fil <- .unixCtxMenuFile()
 	## Get the default R context menu and start from there
@@ -343,8 +399,8 @@
 		default = file.path("~", ".ctxmenu", "RCtxMenu.txt"))
 	if (file.exists(def)) {
 		file.copy(def, fil, overwrite = TRUE)
-	} else file.copy(system.file("gui", "RCtxMenu.txt", package = "svDialogs"),
-		fil, overwrite = TRUE)
+	} else file.copy(system.file("gui", "RCtxMenuLinux.txt",
+		package = "svDialogs"), fil, overwrite = TRUE)
 	return(invisible(NULL))
 }
 
@@ -354,6 +410,9 @@
 	## mnu is either a list of lists with menu entries, or NULL to delete all
 	## custom menus
 	assignTemp("Rmenu", mnu)
+	
+	# Do nothing on files, unless interactive() and got user's acceptation
+	if (!.tmpfilesAllowed()) return(invisible(NULL))
 	if (!isTRUE(file)) return(invisible(NULL))
 	## The menu file is:
 	fil <- .unixMenuFile()
@@ -418,26 +477,10 @@
     ## To be called when svDialogs package loads: make sure to zap all
     ## custom menu items that may have been previously defined
     ## (also call it when the package closes)
-#    odir <- getwd()
-#    on.exit(setwd(odir))
-#    res <- try(setwd(.unixMenuFolder()), silent = TRUE)
-#	if (inherits(res, "try-error")) {
-#		## The directory does not exists yet... create it!
-#		dir.create(.unixMenuFolder(), recursive = TRUE)
-#		## TODO: put the default R menu there...
-#	} else {
-#		## The directory already exists... clear it now
-#		setwd("..")
-#		folder <- file.path(".", basename(.unixMenuFolder()))
-#		unlink(folder, recursive = TRUE)
-#		dir.create(folder, recursive = TRUE)
-#		## TODO: a different procedure that does not delete the default R menu
-#	}
-    ## Now, I can assume that the dir is created and is empty
 
-	## Make also sure that 'Rmenu' application is installed
-	## TODO...
-
+	# Do nothing on files, unless interactive() and got user's acceptation
+	if (!.tmpfilesAllowed()) return(invisible(NULL))
+	
 	## Also clear the local object
 	.unixMenuSave(NULL)
 	unlink(.unixMenuFile())
@@ -485,14 +528,13 @@
 }
 
 .unixMenuAdd <- function (menuname, itemname = NULL, action = "none") {
-#    ## I just need to create (recursively) the directories
-#    dir.create(file.path(.unixMenuFolder(), menuname),
-#		showWarnings = FALSE, recursive = TRUE)
-
+	## Make sure we can install required files in ~/.ctxmenu/tmp/
+	.unixTmpfilesAsk()
+	
 	## Add this menu to our Rmenu object
 	mnu <- .Rmenu()
 	items <- strsplit(as.character(menuname), "/", fixed = TRUE)[[1]]
-	## allow for a maximum of 5 sublevels (should be largely enough!)
+	## Allow for a maximum of 5 sublevels (should be largely enough!)
 	l <- length(items)
 	if (l == 1) {
 		if (!is.null(mnu[[items[1]]])) {
@@ -558,6 +600,9 @@
 }
 
 .unixMenuAddItem <- function (menuname, itemname, action) {
+	## Make sure we can install required files in ~/.ctxmenu/tmp/
+	.unixTmpfilesAsk()
+	
 	if (action %in% c("enable", "disable")) {
 		## Enable or disable an existing menu item
 		if (action == "enable") action <- NULL # To eliminate the attribute
@@ -587,25 +632,6 @@
 		.unixMenuSave(mnu)
 		return(invisible(NULL))
 	} else return(.unixMenuAdd(menuname, itemname, action))
-#    ## Make sure that the dir is created
-#    .unixMenuAdd(menuname)
-#    ## Add an executable file in it with 'itemname' name
-#    ## and containing: xvkbd -text "action\r" except if action is "none"
-#    cmdFile <- file.path(.unixMenuFolder(), menuname, itemname)
-#	if (action == "none") {
-#		cat("\n", file = cmdFile)
-#    } else {
-#		## Make sure to quote "
-#		action <- gsub('"', '\\\\"', action)
-#		## Also replace \n, \r and \t (and wait 200ms between lines)
-#		action <- gsub('\n', '\\\\r\\\\D2', action)
-#		action <- gsub('\r', '\\\\r\\\\D2', action)
-#		action <- gsub('\t', '    ', action)
-#		cat("xvkbd -text \"", action, "\\r\"\n", sep = "", file = cmdFile)
-#    }
-#    ## Make this file executable
-#    Sys.chmod(cmdFile, mode = "755")
-#    return(invisible(NULL))
 }
 
 .unixMenuDel <- function (menuname) {
@@ -627,13 +653,6 @@
 	## Save these changes
 	.unixMenuSave(mnu)
 	return(invisible(NULL))	
-		
-#    ## Unlink does not like ~ => change working dir first
-#    odir <- getwd()
-#    on.exit(setwd(odir))
-#    setwd(.unixMenuFolder())
-#    unlink(menuname, recursive = TRUE)
-#    return(invisible(NULL))
 }
 
 .unixMenuDelItem <- function (menuname, itemname) {
@@ -654,15 +673,5 @@
 	} else return(invisible(NULL))
 	## Save these changes
 	.unixMenuSave(mnu)
-	return(invisible(NULL))	
-	
-#    ## Unlink does not like ~ => change working dir first
-#    path <- file.path(.unixMenuFolder(), menuname)
-#    if (file.exists(path) && file.info(path)$isdir) {
-#		odir <- getwd()
-#		on.exit(setwd(odir))
-#		setwd(path)
-#		unlink(itemname)
-#    }
-#    return(invisible(NULL))    
+	return(invisible(NULL))	  
 }

Modified: pkg/svDialogs/R/svDialogs-internal.R
===================================================================
--- pkg/svDialogs/R/svDialogs-internal.R	2012-04-02 14:09:28 UTC (rev 463)
+++ pkg/svDialogs/R/svDialogs-internal.R	2012-04-04 16:55:01 UTC (rev 464)
@@ -1,22 +1,24 @@
 .onLoad <- function (lib, pkg)
 {
-	## Clear menus
-	.menuClear()
-	## ... and create the default one
-	.menuFileInit()
-	.ctxMenuFileInit()
+	if (.tmpfilesAllowed()) {
+		## Clear menus
+		.menuClear()
+		## ... and create the default one
+		.menuFileInit()
+		.ctxMenuFileInit()	
+	}
 }
 
 .onUnload <- function (libpath)
 {
 	## Clear menus
-	try(.menuClear())
+	if (interactive()) try(.menuClear())
 }
 
 .Last.lib <- function (libpath)
 {
 	## Clear menus
-	try(.menuClear())
+	if (interactive()) try(.menuClear())
 }
 
 .packageName <- "svDialogs"

Modified: pkg/svDialogs/inst/NEWS.Rd
===================================================================
--- pkg/svDialogs/inst/NEWS.Rd	2012-04-02 14:09:28 UTC (rev 463)
+++ pkg/svDialogs/inst/NEWS.Rd	2012-04-04 16:55:01 UTC (rev 464)
@@ -1,8 +1,22 @@
 \name{NEWS}
 \title{NEWS file for the svDialogs package}
 
-\section{Changes in version 0.9-50}{
+\section{Changes in version 0.9-52}{
 	\itemize{
+    \item{ \code{menuXXX()} functions do not generate files in
+			\preformatted{tmp} dir on Linux, unless in \code{interactive()} session,
+			and with explicit user's acknowledgement. Moreover, the user name is not
+			used anymore as part of the name of the temporary files generated (cf CRAN
+			policies and following B. Ripley's request). }
+	
+		\item{ Code to manage \code{menuXXX()} items on Mac OS X is considered
+			still experimental (on R-forge, not CRAN) and is now commented out. Will
+			be further developed in a future version of the \pkg{svDialogs} package. }
+	}
+}
+
+\section{Changes in version 0.9-51}{
+	\itemize{
     \item{ NEWS file reworked to use the new Rd format. }
 	}
 }

Deleted: pkg/svDialogs/inst/gui/RCtxMenu.txt
===================================================================
--- pkg/svDialogs/inst/gui/RCtxMenu.txt	2012-04-02 14:09:28 UTC (rev 463)
+++ pkg/svDialogs/inst/gui/RCtxMenu.txt	2012-04-04 16:55:01 UTC (rev 464)
@@ -1,18 +0,0 @@
-@@@ R context menu
-
-item=_Copy
-cmd=xvkbd -text "\CC" @@@ Default shortcut in gnome-terminal is Ctrl-Shift-C
-@@@ Note: this will not work if shortcut is changed!
-
-item=_Paste
-cmd=xvkbd -text "\CV" @@@ Default shortcut in gnome-terminal is Ctrl-Shift-V
-@@@ Note: this will not work if shortcut is changed!
-
-item=Paste commands _only
-cmd=NULL
-
-item=Copy _and paste
-cmd=xvkbd -text "\CC\CV" @@@ Same note as for copy / paste
-
-item=_Select all
-cmd=NULL

Added: pkg/svDialogs/inst/gui/RCtxMenuLinux.txt
===================================================================
--- pkg/svDialogs/inst/gui/RCtxMenuLinux.txt	                        (rev 0)
+++ pkg/svDialogs/inst/gui/RCtxMenuLinux.txt	2012-04-04 16:55:01 UTC (rev 464)
@@ -0,0 +1,18 @@
+@@@ R context menu
+
+item=_Copy
+cmd=xvkbd -text "\CC" @@@ Default shortcut in gnome-terminal is Ctrl-Shift-C
+@@@ Note: this will not work if shortcut is changed!
+
+item=_Paste
+cmd=xvkbd -text "\CV" @@@ Default shortcut in gnome-terminal is Ctrl-Shift-V
+@@@ Note: this will not work if shortcut is changed!
+
+item=Paste commands _only
+cmd=NULL
+
+item=Copy _and paste
+cmd=xvkbd -text "\CC\CV" @@@ Same note as for copy / paste
+
+item=_Select all
+cmd=NULL

Deleted: pkg/svDialogs/inst/gui/RMenu.txt
===================================================================
--- pkg/svDialogs/inst/gui/RMenu.txt	2012-04-02 14:09:28 UTC (rev 463)
+++ pkg/svDialogs/inst/gui/RMenu.txt	2012-04-04 16:55:01 UTC (rev 464)
@@ -1,332 +0,0 @@
-@@@ R default menu
-
-menupos= 0 0
-
-item=SciViews R
-cmd=NULL
-
-separator
-
-submenu=File
-	
-	item=_Source R code...
-	cmd=sh -c 'Rfile=`zenity --file-selection --title="Select file to source" --file-filter="R files (*.R) | *.R *.r" --file-filter="S files (*.q, *.ssc, *.S) | *.q *.ssc *.S" --file-filter="All files (*.*) | *.*"` && xvkbd -text "source(\""$Rfile"\")\r"'
-	
-	item=_New script
-	cmd=gedit # Should be nice to set syntax highlighting to R directly, but how?
-	
-	item=_Open script...
-	cmd=sh -c 'Rfile=`zenity --file-selection --title="Open script" --file-filter="R files (*.R) | *.R *.r"  --file-filter="S files (*.q, *.ssc, *.S) | *.q *.ssc *.S" --file-filter="All files (*.*) | *.*"` && gedit "$Rfile"'
-	
-	item=_Display file...
-	cmd=sh -c 'File=`zenity --file-selection --title="Select a file"` && zenity --text-info --title="R Pager - $File" --filename="$File" --width=500 --height=500 --ok-label=" Close " --cancel-label="   "'
-	@@@ We should use R pager instead: file.show("$File", header="$File", title= "")
-
-	separator
-	
-	item=_Load Workspace...
-	cmd=sh -c 'Rfile=`zenity --file-selection --title="Select image to load" --file-filter="R images (*.RData) | *.RData *.Rdata" --file-filter="R image - old extension (*.rda) | *.rda" --file-filter="All files (*.*) | *.*" filename=".RData"` && xvkbd -text "load(\""$Rfile"\")\r"'
-	
-	item=_Save Workspace...
-	cmd=sh -c 'File=`zenity --file-selection --title="Save image in" --save --confirm-overwrite --file-filter="R images (*.RData) | *.RData *.Rdata" --file-filter="All files (*.*) | *.*" --filename=".RData"` && xvkbd -text "save.image(\"$File\")\r"'
-	
-	separator
-	
-	item=_Load History...
-	cmd=sh -c 'Rfile=`zenity --file-selection --title="Select history to load" --file-filter="All files (*.*) | *.*" --filename=".Rhistory"` && xvkbd -text "loadhistory(\""$Rfile"\")\r"'
-	
-	item=_Save History...
-	cmd=sh -c 'File=`zenity --file-selection --title="Save history in" --save --confirm-overwrite --file-filter="All files (*.*) | *.*" --filename=".Rhistory"` && xvkbd -text "savehistory(\"$File\")\r"'
-	
-	separator
-	
-	item=_Change dir...
-	cmd=sh -c 'File=`zenity --file-selection --title="Change working dir to" --directory` && xvkbd -text ".odir <- setwd(\"$File\")\r"'
-	
-	separator
-	
-	item=_Print...
-	cmd=NULL
-	
-	item=_Save to File...
-	cmd=NULL @@@ lastsave.txt - Text file (*.txt)
-	
-	separator
-	
-	item=_Exit
-	cmd=sh -c 'zenity --question --title="Exit SciViews R" --text="Are you sure?" --ok-label=OK --cancel-label=Cancel && (zenity --question --title="Exit SciViews R" --text="Save workspace image?" && xvkbd -text "q(\"yes\")\r" || xvkbd -text "q(\"no\")\r")'
-
-submenu=_Edit
-
-	item=Copy
-	cmd=xvkbd -text "\CC" @@@ Default shortcut in gnome-terminal is Ctrl-Shift-C
-	@@@ Note: this will not work if shortcut is changed!
-	
-	item=Paste
-	cmd=xvkbd -text "\CV" @@@ Default shortcut in gnome-terminal is Ctrl-Shift-V
-	@@@ Note: this will not work if shortcut is changed!
-	
-	item=Paste commands only
-	cmd=NULL
-	
-	item=Copy and Paste
-	cmd=xvkbd -text "\CC\CV" @@@ Same note as for copy / paste
-	
-	item=Select all
-	cmd=NULL
-	
-	item=Clear console
-	cmd=xvkbd -text "system(\"clear\") # Or menu Terminal -> Reset and clear\r"
-	@@@ Clear the console, but does not reset its content per se.
-	@@@ Use gnome-terminal menu entry Terminal -> Reset and Clear 
-	
-	separator
-	
-	item=Data editor...
-	cmd=sh -c 'Data=`zenity --entry --title="R data editor" --text="Name of a data frame or matrix"` && xvkbd -text "fix($Data)\r"'
-	
-submenu=_Misc
-	
-	item=Stop current computation
-	cmd=xvkbd -text "\Cc"
-	
-	item=Stop all computations
-	cmd=NULL
-	
-	separator
-	
-	item=List objects
-	cmd=xvkbd -text "ls()\r"
-	
-	item=Remove all objects
-	cmd=sh -c 'zenity --question --title="Remove all objects" --text="Are you sure?" && xvkbd -text "rm(list = ls(all = TRUE))\r"'
-	
-	item=List search path
-	cmd=xvkbd -text "search()\r"
-	
-submenu=_Packages
-	
-	item=Load package...
-	cmd=xvkbd -text "local({pkg <- select.list(sort(.packages(all.available = TRUE)), graphics = TRUE)\r    if (nchar(pkg)) library(pkg, character.only = TRUE)})\r"
-	
-	separator
-	
-	item=Set CRAN mirror...
-	cmd=xvkbd -text "chooseCRANmirror()\r"
-	
-	item=Select repositories...
-	cmd=xvkbd -text "setRepositories()\r"
-	
-	item=Install package(s)...
-	cmd=xvkbd -text "local({pkg <- select.list(rownames(available.packages()), graphics = TRUE, multiple = TRUE, title = \"Install package(s)\")\r    if (nchar(pkg[1])) install.packages(pkg)})\r"
-	
-	item=Update packages...
-	cmd=xvkbd -text "update.packages(ask = 'graphics', checkBuild = TRUE)\r"
-	
-	separator
-	
-	item=Install package from local file...
-	cmd=sh -c 'Rpackages=`zenity --file-selection --title="Select one R package" --file-filter="R package source (*.tar.gz) | *.tar.gz" file-filter="All files (*.*) | *.*"` && xvkbd -text "install.packages(\""$Rpackages"\", repos = NULL)\r"'
-	
-submenu=_Windows
-	
-	item=New graph
-	cmd=xvkbd -text "dev.new()\r"
-	
-	item=Activate next graph
-	cmd=xvkbd -text "dev.set()\r"
-	
-	item=Close all graphs
-	cmd=xvkbd -text "graphics.off()\r"
-	
-submenu=_Help
-	
-	item=Console
-	cmd=xvkbd -text "\[F1]"
-	
-	separator
-	
-	item=FAQ on R
-	cmd=R -e 'utils:::RShowDoc("R-FAQ")'
-	
-	submenu=_Manuals (in PDF)
-		
-		item=An introduction to R
-		cmd=R -e 'utils:::RShowDoc("R-intro")'
-		
-		item=R Reference Manual
-		cmd=R -e 'system2(getOption("pdfviewer"), shQuote(file.path(R.home("doc"), "manual", "refman.pdf")), wait = FALSE)'
-		
-		item=R Data Import/Export
-		cmd=R -e 'utils:::RShowDoc("R-data")'
-		
-		item=R Language Definition
-		cmd=R -e 'utils:::RShowDoc("R-lang")'
-		
-		item=Writing R Extensions
-		cmd=R -e 'utils:::RShowDoc("R-exts")'
-		
-		item=R Internals
-		cmd=R -e 'utils:::RShowDoc("R-ints")'
-		
-		item=R Installation and Administration
-		cmd=R -e 'utils:::RShowDoc("R-admin")'
-		
-		item=Sweave User
-		cmd=R -e 'system2(getOption("pdfviewer"), shQuote(system.file("doc", "Sweave.pdf", package = "utils")), wait = FALSE)'
-		
-	separator
-	
-	item=R functions (text)...
-	cmd=sh -c 'Topic=`zenity --entry --title="R help" --text="Show help for"` && xvkbd -text "help(\"$Topic\")\r"'
-	
-	item=Html help
-	cmd=xvkbd -text "help.start()\r"
-	
-	item=Search help...
-	cmd=sh -c 'Topic=`zenity --entry --title="Search help" --text="Expression to search for"` && xvkbd -text "help.search(\"$Topic\")\r"'
-	
-	item=search.r-project.org...
-	cmd=sh -c 'Topic=`zenity --entry --title="R Site Search" --text="Search for words in help list archives and documentation"` && xvkbd -text "RSiteSearch(\"$Topic\")\r"'
-	
-	separator
-	
-	item=Apropos...
-	cmd=sh -c 'Topic=`zenity --entry --title="Apropos" --text="Expression to search for"` && xvkbd -text "apropos(\"$Topic\")\r"'
-	
-	separator
-	
-	item=R project home page
-	cmd=firefox -new-window 'http://www.r-project.org'  @@@ Should use browser set in R!
-	
-	item=CRAN home page
-	cmd=firefox -new-window 'http://cran.r-project.org'  @@@ Should use browser set in R! 
-	
-	separator
-	
-	item=About
-	cmd=sh -c 'Rversion=`R --version`; zenity --info --title="About SciViews R" --text="$Rversion\n\nSciViews R extensions, version 1.0-0.\nCopyright (c) 2012 Ph. Grosjean." --timeout=10'
-	
-
-@@@ Graph device menu...
-@@@submenu=_File
-@@@
-@@@	submenu=_Save as
-@@@
-@@@		item=Metafile...
-@@@		cmd=NULL
-@@@
-@@@		item=Postscript...
-@@@		cmd=NULL
-@@@
-@@@		item=PDF...
-@@@		cmd=NULL
-@@@
-@@@		item=Png...
-@@@		cmd=NULL
-@@@
-@@@		item=Bmp...
-@@@		cmd=NULL
-@@@
-@@@		item=TIFF...
-@@@		cmd=NULL
-@@@
-@@@		submenu=_Jpeg
-@@@
-@@@			item=50% quality...
-@@@			cmd=NULL
-@@@
-@@@			item=75% quality...
-@@@			cmd=NULL
-@@@
-@@@			item=100% quality...
-@@@			cmd=NULL
-@@@
-@@@	submenu=_Copy to the clipboard
-@@@
-@@@		item=as a Bitmap
-@@@		cmd=NULL
-@@@
-@@@		item=as a Metafile
-@@@		cmd=NULL
-@@@
-@@@	separator
-@@@
-@@@	item=Print...
-@@@	cmd=NULL
-@@@
-@@@	separator
-@@@
-@@@	item=close Device
-@@@	cmd=NULL
-@@@
-@@@submenu=_History
-@@@
-@@@	item=Recording
-@@@	cmd=NULL
-@@@
-@@@	separator
-@@@
-@@@	item=Add
-@@@	cmd=NULL
-@@@
-@@@	item=Replace
-@@@	cmd=NULL
-@@@
-@@@	separator
-@@@
-@@@	item=Previous
-@@@	cmd=NULL
-@@@
-@@@	item=Next
-@@@	cmd=NULL
-@@@
-@@@	separator
-@@@
-@@@	item=Save to variable...
-@@@	cmd=NULL
-@@@
-@@@	item=Get from variable...
-@@@	cmd=NULL
-@@@
-@@@	separator
-@@@
-@@@	item=Clear history
-@@@	cmd=NULL
-@@@
-@@@submenu=_Resize
-@@@
-@@@	item=R mode
-@@@	cmd=NULL
-@@@
-@@@	item=Fit to window
-@@@	cmd=NULL
-@@@
-@@@	item=Fixed size
-@@@	cmd=NULL
-@@@
-@@@context menu:
-@@@item=Copy as metafile
-@@@cmd=NULL
-@@@
-@@@item=Copy as bitmap
-@@@cmd=NULL
-@@@
-@@@separator
-@@@
-@@@item=Save as metafile...
-@@@cmd=NULL
-@@@
-@@@item=Save as postscript...
-@@@cmd=NULL
-@@@
-@@@separator
-@@@
-@@@item=Stay on top
-@@@cmd=NULL
-@@@
-@@@separator
-@@@
-@@@item=Print...
-@@@cmd=NULL
-	

Added: pkg/svDialogs/inst/gui/RMenuLinux.txt
===================================================================
--- pkg/svDialogs/inst/gui/RMenuLinux.txt	                        (rev 0)
+++ pkg/svDialogs/inst/gui/RMenuLinux.txt	2012-04-04 16:55:01 UTC (rev 464)
@@ -0,0 +1,332 @@
+@@@ R default menu
+
+menupos= 0 0
+
+item=SciViews R
+cmd=NULL
+
+separator
+
+submenu=File
+	
+	item=_Source R code...
+	cmd=sh -c 'Rfile=`zenity --file-selection --title="Select file to source" --file-filter="R files (*.R) | *.R *.r" --file-filter="S files (*.q, *.ssc, *.S) | *.q *.ssc *.S" --file-filter="All files (*.*) | *.*"` && xvkbd -text "source(\""$Rfile"\")\r"'
+	
+	item=_New script
+	cmd=gedit # Should be nice to set syntax highlighting to R directly, but how?
+	
[TRUNCATED]

To get the complete diff run:
    svnlook diff /svnroot/sciviews -r 464


More information about the Sciviews-commits mailing list