mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-01 20:31: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
70acdf46bd
commit
6d7dbe97cc
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>
|
2009-03-20 Fred Kiefer <FredKiefer@gmx.de>
|
||||||
|
|
||||||
* Source/NSOutlineView.m (-drawRow:clipRect:): Changed order of
|
* 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.
|
* Source/NSScrollView.m (-initWithCoder:): Don't set _hasCornerView.
|
||||||
|
|
||||||
2009-03-18 Richard Frith-Macdonald <rfm@gnu.org>
|
2009-03-18 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
#include <Foundation/NSFileManager.h>
|
#include <Foundation/NSFileManager.h>
|
||||||
#include <Foundation/NSFileHandle.h>
|
#include <Foundation/NSFileHandle.h>
|
||||||
#include <Foundation/NSPathUtilities.h>
|
#include <Foundation/NSPathUtilities.h>
|
||||||
|
#include <Foundation/NSURL.h>
|
||||||
#include <Foundation/NSValue.h>
|
#include <Foundation/NSValue.h>
|
||||||
#include <Foundation/NSUserDefaults.h>
|
#include <Foundation/NSUserDefaults.h>
|
||||||
#include <AppKit/NSApplication.h>
|
#include <AppKit/NSApplication.h>
|
||||||
|
@ -66,6 +67,9 @@ main(int argc, char** argv, char **env_c)
|
||||||
NSString *filetoopen = nil;
|
NSString *filetoopen = nil;
|
||||||
NSString *filetoprint = nil;
|
NSString *filetoprint = nil;
|
||||||
NSString *nxhost = nil;
|
NSString *nxhost = nil;
|
||||||
|
BOOL isDir;
|
||||||
|
BOOL exists;
|
||||||
|
NSURL *u;
|
||||||
|
|
||||||
#ifdef GS_PASS_ARGUMENTS
|
#ifdef GS_PASS_ARGUMENTS
|
||||||
[NSProcessInfo initializeWithArguments:argv count:argc environment:env_c];
|
[NSProcessInfo initializeWithArguments:argv count:argc environment:env_c];
|
||||||
|
@ -96,9 +100,21 @@ main(int argc, char** argv, char **env_c)
|
||||||
|
|
||||||
if (filetoopen)
|
if (filetoopen)
|
||||||
{
|
{
|
||||||
filetoopen = absolutePath(fm, filetoopen);
|
exists = [fm fileExistsAtPath: arg isDirectory: &isDir];
|
||||||
[workspace openFile: filetoopen
|
if (exists == NO)
|
||||||
withApplication: application];
|
{
|
||||||
|
if ([filetoopen hasPrefix: @"/"] == NO
|
||||||
|
&& (u = [NSURL URLWithString: filetoopen]) != nil)
|
||||||
|
{
|
||||||
|
[workspace openURL: u];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
filetoopen = absolutePath(fm, filetoopen);
|
||||||
|
[workspace openFile: filetoopen
|
||||||
|
withApplication: application];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filetoprint)
|
if (filetoprint)
|
||||||
|
@ -144,38 +160,41 @@ main(int argc, char** argv, char **env_c)
|
||||||
{
|
{
|
||||||
NS_DURING
|
NS_DURING
|
||||||
{
|
{
|
||||||
BOOL isDir = NO, exists = NO;
|
|
||||||
|
|
||||||
exists = [fm fileExistsAtPath: arg isDirectory: &isDir];
|
exists = [fm fileExistsAtPath: arg isDirectory: &isDir];
|
||||||
if (exists == YES)
|
if (exists == YES)
|
||||||
{
|
{
|
||||||
arg = absolutePath(fm, arg);
|
arg = absolutePath(fm, arg);
|
||||||
}
|
if (isDir == NO && [fm isExecutableFileAtPath: 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"])
|
|
||||||
{
|
{
|
||||||
[workspace launchApplication: arg];
|
[workspace openFile: arg withApplication: terminal];
|
||||||
}
|
}
|
||||||
else
|
else // no argument specified
|
||||||
{
|
{
|
||||||
if (![workspace openFile: arg
|
// First check to see if it's an application
|
||||||
withApplication: application])
|
if ([ext isEqualToString: @"app"]
|
||||||
|
|| [ext isEqualToString: @"debug"]
|
||||||
|
|| [ext isEqualToString: @"profile"])
|
||||||
{
|
{
|
||||||
// no recognized extension,
|
[workspace launchApplication: arg];
|
||||||
// run application indicated by environment var.
|
}
|
||||||
NSLog(@"Opening %@ with %@",arg,editor);
|
else
|
||||||
[workspace openFile: arg withApplication: editor];
|
{
|
||||||
|
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
|
NS_HANDLER
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue