mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 03:30:56 +00:00
Extend tool to open URLs
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@28104 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
d8d8156943
commit
d115384ecc
2 changed files with 49 additions and 25 deletions
|
@ -1,7 +1,12 @@
|
|||
2009-03-20 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Tools/gopen.m: Extend to open URLs as well as files.
|
||||
|
||||
2009-03-20 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/NSOutlineView.m (-drawRow:clipRect:): Changed order of
|
||||
expresions in condition to avoid possible access to uninitialized memory.
|
||||
expresions in condition to avoid possible access to uninitialized
|
||||
memory.
|
||||
* Source/NSScrollView.m (-initWithCoder:): Don't set _hasCornerView.
|
||||
|
||||
2009-03-18 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include <Foundation/NSFileManager.h>
|
||||
#include <Foundation/NSFileHandle.h>
|
||||
#include <Foundation/NSPathUtilities.h>
|
||||
#include <Foundation/NSURL.h>
|
||||
#include <Foundation/NSValue.h>
|
||||
#include <Foundation/NSUserDefaults.h>
|
||||
#include <AppKit/NSApplication.h>
|
||||
|
@ -66,6 +67,9 @@ main(int argc, char** argv, char **env_c)
|
|||
NSString *filetoopen = nil;
|
||||
NSString *filetoprint = nil;
|
||||
NSString *nxhost = nil;
|
||||
BOOL isDir;
|
||||
BOOL exists;
|
||||
NSURL *u;
|
||||
|
||||
#ifdef GS_PASS_ARGUMENTS
|
||||
[NSProcessInfo initializeWithArguments:argv count:argc environment:env_c];
|
||||
|
@ -96,9 +100,21 @@ main(int argc, char** argv, char **env_c)
|
|||
|
||||
if (filetoopen)
|
||||
{
|
||||
filetoopen = absolutePath(fm, filetoopen);
|
||||
[workspace openFile: filetoopen
|
||||
withApplication: application];
|
||||
exists = [fm fileExistsAtPath: arg isDirectory: &isDir];
|
||||
if (exists == NO)
|
||||
{
|
||||
if ([filetoopen hasPrefix: @"/"] == NO
|
||||
&& (u = [NSURL URLWithString: filetoopen]) != nil)
|
||||
{
|
||||
[workspace openURL: u];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
filetoopen = absolutePath(fm, filetoopen);
|
||||
[workspace openFile: filetoopen
|
||||
withApplication: application];
|
||||
}
|
||||
}
|
||||
|
||||
if (filetoprint)
|
||||
|
@ -144,38 +160,41 @@ main(int argc, char** argv, char **env_c)
|
|||
{
|
||||
NS_DURING
|
||||
{
|
||||
BOOL isDir = NO, exists = NO;
|
||||
|
||||
exists = [fm fileExistsAtPath: arg isDirectory: &isDir];
|
||||
if (exists == YES)
|
||||
{
|
||||
arg = absolutePath(fm, arg);
|
||||
}
|
||||
if (exists && !isDir && [fm isExecutableFileAtPath: arg])
|
||||
{
|
||||
[workspace openFile: arg withApplication: terminal];
|
||||
}
|
||||
else // no argument specified
|
||||
{
|
||||
// First check to see if it's an application
|
||||
if ([ext isEqualToString: @"app"]
|
||||
|| [ext isEqualToString: @"debug"]
|
||||
|| [ext isEqualToString: @"profile"])
|
||||
if (isDir == NO && [fm isExecutableFileAtPath: arg])
|
||||
{
|
||||
[workspace launchApplication: arg];
|
||||
[workspace openFile: arg withApplication: terminal];
|
||||
}
|
||||
else
|
||||
else // no argument specified
|
||||
{
|
||||
if (![workspace openFile: arg
|
||||
withApplication: application])
|
||||
// First check to see if it's an application
|
||||
if ([ext isEqualToString: @"app"]
|
||||
|| [ext isEqualToString: @"debug"]
|
||||
|| [ext isEqualToString: @"profile"])
|
||||
{
|
||||
// no recognized extension,
|
||||
// run application indicated by environment var.
|
||||
NSLog(@"Opening %@ with %@",arg,editor);
|
||||
[workspace openFile: arg withApplication: editor];
|
||||
[workspace launchApplication: arg];
|
||||
}
|
||||
else
|
||||
{
|
||||
if (![workspace openFile: arg
|
||||
withApplication: application])
|
||||
{
|
||||
// no recognized extension,
|
||||
// run application indicated by environment var.
|
||||
NSLog(@"Opening %@ with %@",arg,editor);
|
||||
[workspace openFile: arg withApplication: editor];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ([arg hasPrefix: @"/"] == NO
|
||||
&& (u = [NSURL URLWithString: arg]) != nil)
|
||||
{
|
||||
[workspace openURL: u];
|
||||
}
|
||||
}
|
||||
NS_HANDLER
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue