Skip to content

Commit

Permalink
remove a lot of code conditional of R < 2.10.0
Browse files Browse the repository at this point in the history
remove use of PrivateHeaders


git-svn-id: https://svn.r-project.org/R-packages/trunk/Mac-GUI@6408 694ef91d-65df-0310-b7bb-92e67a308ead
  • Loading branch information
Prof Brian Ripley committed Dec 17, 2012
1 parent d1f62b0 commit d7e99a1
Show file tree
Hide file tree
Showing 22 changed files with 31 additions and 1,753 deletions.
6 changes: 1 addition & 5 deletions DataManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*
* R Copyright notes:
* Copyright (C) 1995-1996 Robert Gentleman and Ross Ihaka
* Copyright (C) 1998-2001 The R Development Core Team
* Copyright (C) 1998-2012 The R Development Core Team
* Copyright (C) 2002-2004 The R Foundation
*
* This program is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -209,9 +209,6 @@ - (IBAction)showHelp:(id)sender

SLog(@"DataManager showHelp: %@", selectedItem);

#if R_VERSION < R_Version(2, 10, 0)
NSString *urlText = [NSString stringWithFormat:@"file://%@", [selectedItem objectForKey:kDataManagerURL]];
#else
NSString *urlText = nil;
int port = [[RController sharedController] helpServerPort];
if (port == 0) {
Expand All @@ -225,7 +222,6 @@ - (IBAction)showHelp:(id)sender
topic = [topic substringWithRange: NSMakeRange(r.location + 2, [topic length] - r.location - 3)];

urlText = [NSString stringWithFormat:@"http://127.0.0.1:%d/library/%@/html/%@.html", port, [selectedItem objectForKey:kDataManagerPackage], topic];
#endif

[[dataInfoView mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:urlText]]];

Expand Down
18 changes: 0 additions & 18 deletions HelpManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,6 @@ - (void)showHelpUsingFile: (NSString *)file topic: (NSString*) topic
{
if (!file) return;
if (!topic) topic=@"<unknown>";
#if R_VERSION < R_Version(2, 10, 0)
NSString *url = [NSString stringWithFormat:@"file://%@",file];
SLog(@"HelpManager.showHelpUsingFile:\"%@\", topic=%@, URL=%@", file, topic, url);
#else
NSString *url = nil;
if ([file hasPrefix:@"http://"])
url = file;
Expand All @@ -98,7 +94,6 @@ - (void)showHelpUsingFile: (NSString *)file topic: (NSString*) topic
url = [NSString stringWithFormat:@"http://127.0.0.1:%d%@", port, file];
}
SLog(@"HelpManager.showHelpUsingFile:\"%@\", topic=%@, URL=%@", file, topic, url);
#endif
if(url != nil) {
if ([Preferences flagForKey:kExternalHelp withDefault:NO])
[[REngine mainEngine] executeString:[NSString stringWithFormat:@"browseURL(\"%@\")", url]];
Expand Down Expand Up @@ -139,11 +134,7 @@ - (void)showHelpFor:(NSString *)topic
}

REngine *re = [REngine mainEngine];
#if R_VERSION < R_Version(2, 10, 0)
RSEXP *x= [re evaluateString:[NSString stringWithFormat:@"as.character(help(\"%@\", htmlhelp=TRUE))",searchString]];
#else
RSEXP *x= [re evaluateString:[NSString stringWithFormat:@"as.character(help(\"%@\", help_type='html'))",searchString]];
#endif
if ((x==nil) || ([x string]==NULL)) {
NSString *topicString = [NSString stringWithFormat:@"Topic: %@", searchString];
int res = NSRunInformationalAlertPanel(NLS(@"Can't find help for topic, would you like to expand the search?"), topicString, NLS(@"No"), NLS(@"Yes"), nil);
Expand All @@ -162,17 +153,8 @@ - (void)showHelpFor:(NSString *)topic
}
return;
}
#if R_VERSION < R_Version(2, 10, 0)
NSString *url = [NSString stringWithFormat:@"file://%@",[x string]];
if(url != nil)
[[HelpView mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:url]]];

[helpWindow makeKeyAndOrderFront:self];
[x release];
#else
[x release];
[re executeString:[NSString stringWithFormat:@"print(help(\"%@\", help_type='html'))",searchString]];
#endif
}

- (NSWindow*) window
Expand Down
5 changes: 5 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
NEWS for R.app GUI for Mac OS X

Last-update: 2012-12-16 [BDR]
* Change version tests for R-devel to 3.0.0.
* More cleanup of conditional code for R < 2.10.0.
* Private copies of R headers are no longer used.

Last-update: 2012-10-26 [BDR]
* Add stubs for loadhistory() and savehistory() so the
readline-based ones are not used.
Expand Down
17 changes: 0 additions & 17 deletions PackageInstaller.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
#import "REngine/REngine.h"
#import "Tools/Authorization.h"
#import "Preferences.h"
#import <Rversion.h>
#include <unistd.h>

static id sharedController;
Expand Down Expand Up @@ -289,19 +288,12 @@ - (IBAction)installSelected:(id)sender

- (void) checkOptions
{
#if (R_VERSION >= R_Version(2,1,0))
// in 2.1.0 release the proxy functions were not updated to accomodate for changes in
// package installation - so we need to set options for backward compati-
// bility
if (!optionsChecked) {
RSEXP *x;
BOOL hadToChoose=NO;
#if (R_VERSION < R_Version(2,2,0))
x = [[REngine mainEngine] evaluateString:@"getOption('CRAN')"];
if (!x || ![x string]) { // CRAN is not set - let's try the repos
SLog(@"PackageInstaller.reloadURL: checking options - CRAN is not set!");
if (x) [x release];
#endif
x = [[REngine mainEngine] evaluateString:@"getOption('repos')['CRAN']"];
if (!x || ![x string] || [[x string] isEqualToString:@"@CRAN@"]) { // repos is not set
if (x) [x release];
Expand All @@ -311,20 +303,12 @@ - (void) checkOptions
x = [[REngine mainEngine] evaluateString:@"getOption('repos')['CRAN']"];
}
if (x && [x string] && ![[x string] isEqualToString:@"@CRAN@"]) { // repos is set now - push it to CRAN
#if (R_VERSION < R_Version(2,2,0))
[x release];
[[REngine mainEngine] evaluateString:@"options(CRAN=getOption('repos')['CRAN'])"];
x = [[REngine mainEngine] evaluateString:@"getOption('CRAN')"];
#endif
if (hadToChoose && ![Preferences flagForKey:stopAskingAboutDefaultMirrorSavingKey withDefault:NO])
NSBeginAlertSheet(NLS(@"Set as default?"), NLS(@"Yes"), NLS(@"Never"), NLS(@"No"), [self window], self, @selector(mirrorSaveAskSheetDidEnd:returnCode:contextInfo:), NULL, NULL, NLS(@"Do you want me to remember the mirror you selected for future sessions?"));
} else {
if (x) [x release]; // set x to nil - we need that in case x is @CRAN@
x=nil;
}
#if (R_VERSION < R_Version(2,2,0))
}
#endif
if (!x || ![x string]) { // CRAN is still not set - bail out with an error
[self busy:NO];
NSRunAlertPanel(NLS(@"No CRAN Mirror Found"),NLS(@"No valid CRAN mirror was selected.\nYou won't be able to install any CRAN packages unless you set the CRAN option to a valid mirror URL."),NLS(@"OK"),nil,nil);
Expand All @@ -333,7 +317,6 @@ - (void) checkOptions
if (x) [x release];
optionsChecked = YES;
}
#endif
}

- (IBAction)reloadURL:(id)sender
Expand Down
4 changes: 0 additions & 4 deletions PackageManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -123,17 +123,13 @@ - (IBAction) showInfo:(id)sender
{
int row = [sender selectedRow];
if (row < 0) return;
#if R_VERSION < R_Version(2, 10, 0)
NSString *urlText = [NSString stringWithFormat:@"file://%@",package[row].url];
#else
NSString *urlText = nil;
int port = [[RController sharedController] helpServerPort];
if (port == 0) {
NSRunInformationalAlertPanel(NLS(@"Cannot start HTML help server."), NLS(@"Help"), NLS(@"Ok"), nil, nil);
return;
}
urlText = [NSString stringWithFormat:@"http://127.0.0.1:%d/library/%@/html/00Index.html", port, package[row].name];
#endif
SLog(@"PackageManager.showInfo: URL=%@", urlText);
[[PackageInfoView mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:urlText]]];
}
Expand Down
3 changes: 0 additions & 3 deletions PrefPanes/QuartzPrefPane.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
#import "PreferenceKeys.h"
#import "Preferences.h"
#import "REngine.h"
#include <Rversion.h>

@interface QuartzPrefPane (Private)
- (void)setIdentifier:(NSString *)newIdentifier;
Expand Down Expand Up @@ -200,11 +199,9 @@ - (void) updatePreferences
[Preferences stringForKey:quartzPrefPaneHeightKey withDefault: @"5"]];
[quartzPrefPaneDPI setStringValue:
[Preferences stringForKey:quartzPrefPaneDPIKey withDefault: @""]];
#if R_VERSION >= R_Version(2,7,0)
if (flag)
[[REngine mainEngine] executeString:[NSString stringWithFormat:@"quartz.options(width=%@,height=%@,dpi=%@)", [quartzPrefPaneWidth stringValue],
[quartzPrefPaneHeight stringValue], ([[quartzPrefPaneDPI stringValue] length] == 0) ? @"NA_real_" : [quartzPrefPaneDPI stringValue]]];
#endif

[quartzPrefPaneLocation setEnabled:NSOnState];
NSString *i = [Preferences stringForKey:quartzPrefPaneLocationKey withDefault: @"Top Left"];
Expand Down
Loading

0 comments on commit d7e99a1

Please sign in to comment.