diff --git a/Gestr.xcodeproj/project.pbxproj b/Gestr.xcodeproj/project.pbxproj index 7ffd7e4..1f7b112 100644 --- a/Gestr.xcodeproj/project.pbxproj +++ b/Gestr.xcodeproj/project.pbxproj @@ -62,7 +62,6 @@ D040287719CA591100E372E7 /* CoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D040287619CA591100E372E7 /* CoreServices.framework */; }; D040287919CA591500E372E7 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D040287819CA591500E372E7 /* Carbon.framework */; }; D040287B19CA591900E372E7 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D040287A19CA591900E372E7 /* Cocoa.framework */; }; - D040287D19CA597200E372E7 /* ScriptingBridge.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D040287C19CA597200E372E7 /* ScriptingBridge.framework */; }; D05227061A33BBEE00AAF6FD /* NSImage+M5Darkable.m in Sources */ = {isa = PBXBuildFile; fileRef = D05227051A33BBEE00AAF6FD /* NSImage+M5Darkable.m */; }; /* End PBXBuildFile section */ @@ -98,7 +97,6 @@ 0029FDAB18557DE600BDBA25 /* AppTextFieldCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppTextFieldCell.h; sourceTree = ""; }; 0029FDAC18557DE600BDBA25 /* AppTextFieldCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppTextFieldCell.m; sourceTree = ""; }; 0029FDAE18557DE600BDBA25 /* background2.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = background2.png; sourceTree = ""; }; - 0029FDAF18557DE600BDBA25 /* Chrome.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Chrome.h; sourceTree = ""; }; 0029FDB018557DE600BDBA25 /* ChromePage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ChromePage.h; sourceTree = ""; }; 0029FDB118557DE600BDBA25 /* ChromePage.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ChromePage.m; sourceTree = ""; }; 0029FDB218557DE600BDBA25 /* Gestr-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "Gestr-Info.plist"; sourceTree = ""; }; @@ -156,7 +154,6 @@ 0029FDE618557DE600BDBA25 /* NSStatusItemPrioritizer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NSStatusItemPrioritizer.m; sourceTree = ""; }; 0029FDE718557DE600BDBA25 /* RepeatedImageView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RepeatedImageView.h; sourceTree = ""; }; 0029FDE818557DE600BDBA25 /* RepeatedImageView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RepeatedImageView.m; sourceTree = ""; }; - 0029FDE918557DE600BDBA25 /* Safari.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Safari.h; sourceTree = ""; }; 0029FDEA18557DE600BDBA25 /* SafariPage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SafariPage.h; sourceTree = ""; }; 0029FDEB18557DE600BDBA25 /* SafariPage.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SafariPage.m; sourceTree = ""; }; 0029FDEC18557DE600BDBA25 /* ShadowTextFieldCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ShadowTextFieldCell.h; sourceTree = ""; }; @@ -190,7 +187,6 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - D040287D19CA597200E372E7 /* ScriptingBridge.framework in Frameworks */, D040287B19CA591900E372E7 /* Cocoa.framework in Frameworks */, D040287919CA591500E372E7 /* Carbon.framework in Frameworks */, D040287719CA591100E372E7 /* CoreServices.framework in Frameworks */, @@ -258,8 +254,6 @@ isa = PBXGroup; children = ( 0037430F1885E30600F9B53A /* Images.xcassets */, - 0029FDAF18557DE600BDBA25 /* Chrome.h */, - 0029FDE918557DE600BDBA25 /* Safari.h */, 0029FDEF18557DE600BDBA25 /* tableCellBack.png */, 0029FDF018557DE600BDBA25 /* trackpadBackground.png */, 0029FDB218557DE600BDBA25 /* Gestr-Info.plist */, @@ -637,7 +631,7 @@ CODE_SIGN_ENTITLEMENTS = Gestr/Gestr.entitlements; CODE_SIGN_IDENTITY = "Mac Developer"; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 1.88; + CURRENT_PROJECT_VERSION = 1.89; DEVELOPMENT_TEAM = EGQME33F5E; ENABLE_HARDENED_RUNTIME = YES; FRAMEWORK_SEARCH_PATHS = ( @@ -648,7 +642,7 @@ GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "Gestr/Gestr-Prefix.pch"; INFOPLIST_FILE = "Gestr/Gestr-Info.plist"; - MARKETING_VERSION = 1.88; + MARKETING_VERSION = 1.89; OTHER_CODE_SIGN_FLAGS = "--deep"; PRODUCT_BUNDLE_IDENTIFIER = "com.mhuusko5.${PRODUCT_NAME:rfc1034identifier}"; PRODUCT_NAME = Gestr; @@ -665,7 +659,7 @@ CODE_SIGN_ENTITLEMENTS = Gestr/Gestr.entitlements; CODE_SIGN_IDENTITY = "Mac Developer"; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 1.88; + CURRENT_PROJECT_VERSION = 1.89; DEVELOPMENT_TEAM = EGQME33F5E; ENABLE_HARDENED_RUNTIME = YES; FRAMEWORK_SEARCH_PATHS = ( @@ -676,7 +670,7 @@ GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "Gestr/Gestr-Prefix.pch"; INFOPLIST_FILE = "Gestr/Gestr-Info.plist"; - MARKETING_VERSION = 1.88; + MARKETING_VERSION = 1.89; OTHER_CODE_SIGN_FLAGS = "--deep"; PRODUCT_BUNDLE_IDENTIFIER = "com.mhuusko5.${PRODUCT_NAME:rfc1034identifier}"; PRODUCT_NAME = Gestr; diff --git a/Gestr/Chrome.h b/Gestr/Chrome.h deleted file mode 100644 index 46c8a00..0000000 --- a/Gestr/Chrome.h +++ /dev/null @@ -1,190 +0,0 @@ -/* - * Chrome.h - */ - -#import -#import - - -@class ChromeApplication, ChromeWindow, ChromeTab, ChromeBookmarkFolder, ChromeBookmarkItem; - - - -/* - * Standard Suite - */ - -// The application's top-level scripting object. -@interface ChromeApplication : SBApplication - -- (SBElementArray *)windows; - -@property (copy, readonly) NSString *name; // The name of the application. -@property (readonly) BOOL frontmost; // Is this the frontmost (active) application? -@property (copy, readonly) NSString *version; // The version of the application. - -- (void)open:(NSArray *)x; // Open a document. -- (void)quit; // Quit the application. -- (BOOL)exists:(id)x; // Verify if an object exists. - -@end - -// A window. -@interface ChromeWindow : SBObject - -- (SBElementArray *)tabs; - -@property (copy, readonly) NSString *name; // The full title of the window. -- (NSInteger)id; // The unique identifier of the window. -@property NSInteger index; // The index of the window, ordered front to back. -@property NSRect bounds; // The bounding rectangle of the window. -@property (readonly) BOOL closeable; // Whether the window has a close box. -@property (readonly) BOOL minimizable; // Whether the window can be minimized. -@property BOOL minimized; // Whether the window is currently minimized. -@property (readonly) BOOL resizable; // Whether the window can be resized. -@property BOOL visible; // Whether the window is currently visible. -@property (readonly) BOOL zoomable; // Whether the window can be zoomed. -@property BOOL zoomed; // Whether the window is currently zoomed. -@property (copy, readonly) ChromeTab *activeTab; // Returns the currently selected tab -@property (copy) NSString *mode; // Represents the mode of the window which can be 'normal' or 'incognito', can be set only once during creation of the window. -@property NSInteger activeTabIndex; // The index of the active tab. - -- (void)saveIn:(NSURL *)in_ as:(NSString *)as; // Save an object. -- (void)close; // Close a window. -- (void)delete; // Delete an object. -- (SBObject *)duplicateTo:(SBObject *)to withProperties:(NSDictionary *)withProperties; // Copy object(s) and put the copies at a new location. -- (SBObject *)moveTo:(SBObject *)to; // Move object(s) to a new location. -- (void)print; // Print an object. -- (void)reload; // Reload a tab. -- (void)goBack; // Go Back (If Possible). -- (void)goForward; // Go Forward (If Possible). -- (void)selectAll; // Select all. -- (void)cutSelection; // Cut selected text (If Possible). -- (void)copySelection; // Copy text. -- (void)pasteSelection; // Paste text (If Possible). -- (void)undo; // Undo the last change. -- (void)redo; // Redo the last change. -- (void)stop; // Stop the current tab from loading. -- (void)viewSource; // View the HTML source of the tab. -- (id)executeJavascript:(NSString *)javascript; // Execute a piece of javascript. -- (void)enterPresentationMode; // Enter presentation mode in window. -- (void)exitPresentationMode; // Exit presentation mode in window. - -@end - - - -/* - * Chromium Suite - */ - -// The application's top-level scripting object. -@interface ChromeApplication (ChromiumSuite) - -- (SBElementArray *)bookmarkFolders; - -@property (copy, readonly) ChromeBookmarkFolder *bookmarksBar; // The bookmarks bar bookmark folder. -@property (copy, readonly) ChromeBookmarkFolder *otherBookmarks; // The other bookmarks bookmark folder. - -@end - -// A tab. -@interface ChromeTab : SBObject - -- (NSInteger)id; // Unique ID of the tab. -@property (copy, readonly) NSString *title; // The title of the tab. -@property (copy) NSString *URL; // The url visible to the user. -@property (readonly) BOOL loading; // Is loading? - -- (void)saveIn:(NSURL *)in_ as:(NSString *)as; // Save an object. -- (void)close; // Close a window. -- (void)delete; // Delete an object. -- (SBObject *)duplicateTo:(SBObject *)to withProperties:(NSDictionary *)withProperties; // Copy object(s) and put the copies at a new location. -- (SBObject *)moveTo:(SBObject *)to; // Move object(s) to a new location. -- (void)print; // Print an object. -- (void)reload; // Reload a tab. -- (void)goBack; // Go Back (If Possible). -- (void)goForward; // Go Forward (If Possible). -- (void)selectAll; // Select all. -- (void)cutSelection; // Cut selected text (If Possible). -- (void)copySelection; // Copy text. -- (void)pasteSelection; // Paste text (If Possible). -- (void)undo; // Undo the last change. -- (void)redo; // Redo the last change. -- (void)stop; // Stop the current tab from loading. -- (void)viewSource; // View the HTML source of the tab. -- (id)executeJavascript:(NSString *)javascript; // Execute a piece of javascript. -- (void)enterPresentationMode; // Enter presentation mode in window. -- (void)exitPresentationMode; // Exit presentation mode in window. - -@end - -// A bookmarks folder that contains other bookmarks folder and bookmark items. -@interface ChromeBookmarkFolder : SBObject - -- (SBElementArray *)bookmarkFolders; -- (SBElementArray *)bookmarkItems; - -- (NSNumber *)id; // Unique ID of the bookmark folder. -@property (copy) NSString *title; // The title of the folder. -@property (copy, readonly) NSNumber *index; // Returns the index with respect to its parent bookmark folder - -- (void)saveIn:(NSURL *)in_ as:(NSString *)as; // Save an object. -- (void)close; // Close a window. -- (void)delete; // Delete an object. -- (SBObject *)duplicateTo:(SBObject *)to withProperties:(NSDictionary *)withProperties; // Copy object(s) and put the copies at a new location. -- (SBObject *)moveTo:(SBObject *)to; // Move object(s) to a new location. -- (void)print; // Print an object. -- (void)reload; // Reload a tab. -- (void)goBack; // Go Back (If Possible). -- (void)goForward; // Go Forward (If Possible). -- (void)selectAll; // Select all. -- (void)cutSelection; // Cut selected text (If Possible). -- (void)copySelection; // Copy text. -- (void)pasteSelection; // Paste text (If Possible). -- (void)undo; // Undo the last change. -- (void)redo; // Redo the last change. -- (void)stop; // Stop the current tab from loading. -- (void)viewSource; // View the HTML source of the tab. -- (id)executeJavascript:(NSString *)javascript; // Execute a piece of javascript. -- (void)enterPresentationMode; // Enter presentation mode in window. -- (void)exitPresentationMode; // Exit presentation mode in window. - -@end - -// An item consists of an URL and the title of a bookmark -@interface ChromeBookmarkItem : SBObject - -- (NSInteger)id; // Unique ID of the bookmark item. -@property (copy) NSString *title; // The title of the bookmark item. -@property (copy) NSString *URL; // The URL of the bookmark. -@property (copy, readonly) NSNumber *index; // Returns the index with respect to its parent bookmark folder - -- (void)saveIn:(NSURL *)in_ as:(NSString *)as; // Save an object. -- (void)close; // Close a window. -- (void)delete; // Delete an object. -- (SBObject *)duplicateTo:(SBObject *)to withProperties:(NSDictionary *)withProperties; // Copy object(s) and put the copies at a new location. -- (SBObject *)moveTo:(SBObject *)to; // Move object(s) to a new location. -- (void)print; // Print an object. -- (void)reload; // Reload a tab. -- (void)goBack; // Go Back (If Possible). -- (void)goForward; // Go Forward (If Possible). -- (void)selectAll; // Select all. -- (void)cutSelection; // Cut selected text (If Possible). -- (void)copySelection; // Copy text. -- (void)pasteSelection; // Paste text (If Possible). -- (void)undo; // Undo the last change. -- (void)redo; // Redo the last change. -- (void)stop; // Stop the current tab from loading. -- (void)viewSource; // View the HTML source of the tab. -- (id)executeJavascript:(NSString *)javascript; // Execute a piece of javascript. -- (void)enterPresentationMode; // Enter presentation mode in window. -- (void)exitPresentationMode; // Exit presentation mode in window. - -@end - -@interface ChromeWindow (ChromiumSuite) - -@property (readonly) BOOL presenting; // Whether the window is in presentation mode. - -@end diff --git a/Gestr/ChromePage.h b/Gestr/ChromePage.h index 20acab6..2974afe 100644 --- a/Gestr/ChromePage.h +++ b/Gestr/ChromePage.h @@ -1,10 +1,7 @@ -#import -#import "Chrome.h" #import "WebPage.h" @interface ChromePage : WebPage - (id)initWithDisplayName:(NSString *)displayName icon:(NSImage *)icon url:(NSString *)url; -- (void)launch; @end diff --git a/Gestr/ChromePage.m b/Gestr/ChromePage.m index 43a47c9..c5f65fd 100644 --- a/Gestr/ChromePage.m +++ b/Gestr/ChromePage.m @@ -3,48 +3,7 @@ @implementation ChromePage - (id)initWithDisplayName:(NSString *)displayName icon:(NSImage *)icon url:(NSString *)url { - self = [super initWithDisplayName:displayName icon:icon url:url targetBrowserId:@"com.google.Chrome"]; - - return self; -} - -- (void)launch { - ChromeApplication *chrome = [SBApplication applicationWithBundleIdentifier:@"com.google.Chrome"]; - [chrome activate]; - - if (chrome.windows.count == 0) { - [chrome.windows addObject:[[[chrome classForScriptingClass:@"window"] alloc] init]]; - ((ChromeWindow *)chrome.windows[0]).activeTab.URL = self.url; - } - else { - BOOL tabExists = NO; - int tabIndex = -1; - ChromeWindow *window = nil; - for (window in chrome.windows) { - for (int i = 0; i < window.tabs.count; i++) { - ChromeTab *tab = window.tabs[i]; - if ([[[self class] stripUrl:tab.URL] isEqualToString:[[self class] stripUrl:self.url]]) { - tabIndex = i; - tabExists = YES; - break; - } - } - if (tabExists) { - break; - } - } - - if (tabExists) { - window.activeTabIndex = tabIndex + 1; - window.index = 1; - } - else { - ChromeTab *newTab = [[[chrome classForScriptingClass:@"tab"] alloc] initWithProperties:@{ @"URL": self.url }]; - window = chrome.windows[0]; - [window.tabs addObject:newTab]; - window.index = 1; - } - } + return (self = [super initWithDisplayName:displayName icon:icon url:url targetBrowserId:@"com.google.Chrome"]); } @end diff --git a/Gestr/Safari.h b/Gestr/Safari.h deleted file mode 100644 index c906de5..0000000 --- a/Gestr/Safari.h +++ /dev/null @@ -1,264 +0,0 @@ -/* - * Safari.h - */ - -#import -#import - - -@class SafariItem, SafariApplication, SafariColor, SafariDocument, SafariWindow, SafariAttributeRun, SafariCharacter, SafariParagraph, SafariText, SafariAttachment, SafariWord, SafariTab, SafariPrintSettings; - -enum SafariSavo { - SafariSavoAsk = 'ask ' /* Ask the user whether or not to save the file. */, - SafariSavoNo = 'no ' /* Do not save the file. */, - SafariSavoYes = 'yes ' /* Save the file. */ -}; -typedef enum SafariSavo SafariSavo; - -enum SafariEnum { - SafariEnumStandard = 'lwst' /* Standard PostScript error handling */, - SafariEnumDetailed = 'lwdt' /* print a detailed report of PostScript errors */ -}; -typedef enum SafariEnum SafariEnum; - - - -/* - * Standard Suite - */ - -// A scriptable object. -@interface SafariItem : SBObject - -@property (copy) NSDictionary *properties; // All of the object's properties. - -- (void)closeSaving:(SafariSavo)saving savingIn:(NSURL *)savingIn; // Close an object. -- (void)delete; // Delete an object. -- (void)duplicateTo:(SBObject *)to withProperties:(NSDictionary *)withProperties; // Copy object(s) and put the copies at a new location. -- (BOOL)exists; // Verify if an object exists. -- (void)moveTo:(SBObject *)to; // Move object(s) to a new location. -- (void)saveAs:(NSString *)as in:(NSURL *)in_; // Save an object. -- (void)emailContentsOf:(SafariTab *)of; // Emails the contents of a tab. -- (void)searchTheWebFor:(NSString *)for_ in:(SafariTab *)in_; // Searches the web using Safari's current search provider. - -@end - -// An application's top level scripting object. -@interface SafariApplication : SBApplication - -- (SBElementArray *)documents; -- (SBElementArray *)windows; - -@property (readonly) BOOL frontmost; // Is this the frontmost (active) application? -@property (copy, readonly) NSString *name; // The name of the application. -@property (copy, readonly) NSString *version; // The version of the application. - -- (SafariDocument *)open:(NSURL *)x; // Open an object. -- (void)print:(NSURL *)x printDialog:(BOOL)printDialog withProperties:(SafariPrintSettings *)withProperties; // Print an object. -- (void)quitSaving:(SafariSavo)saving; // Quit an application. -- (void)addReadingListItem:(NSString *)x andPreviewText:(NSString *)andPreviewText withTitle:(NSString *)withTitle; // Add a new Reading List item with the given URL. Allows a custom title and preview text to be specified. -- (id)doJavaScript:(NSString *)x in:(SafariTab *)in_; // Applies a string of JavaScript code to a document. -- (void)showBookmarks; // Shows Safari's bookmarks. - -@end - -// A color. -@interface SafariColor : SafariItem - - -@end - -// A document. -@interface SafariDocument : SafariItem - -@property (readonly) BOOL modified; // Has the document been modified since the last save? -@property (copy) NSString *name; // The document's name. -@property (copy) NSString *path; // The document's path. - - -@end - -// A window. -@interface SafariWindow : SafariItem - -@property NSRect bounds; // The bounding rectangle of the window. -@property (readonly) BOOL closeable; // Whether the window has a close box. -@property (copy, readonly) SafariDocument *document; // The document whose contents are being displayed in the window. -@property (readonly) BOOL floating; // Whether the window floats. -- (NSInteger)id; // The unique identifier of the window. -@property NSInteger index; // The index of the window, ordered front to back. -@property (readonly) BOOL miniaturizable; // Whether the window can be miniaturized. -@property BOOL miniaturized; // Whether the window is currently miniaturized. -@property (readonly) BOOL modal; // Whether the window is the application's current modal window. -@property (copy) NSString *name; // The full title of the window. -@property (readonly) BOOL resizable; // Whether the window can be resized. -@property (readonly) BOOL titled; // Whether the window has a title bar. -@property BOOL visible; // Whether the window is currently visible. -@property (readonly) BOOL zoomable; // Whether the window can be zoomed. -@property BOOL zoomed; // Whether the window is currently zoomed. - - -@end - - - -/* - * Text Suite - */ - -// This subdivides the text into chunks that all have the same attributes. -@interface SafariAttributeRun : SafariItem - -- (SBElementArray *)attachments; -- (SBElementArray *)attributeRuns; -- (SBElementArray *)characters; -- (SBElementArray *)paragraphs; -- (SBElementArray *)words; - -@property (copy) NSColor *color; // The color of the first character. -@property (copy) NSString *font; // The name of the font of the first character. -@property NSInteger size; // The size in points of the first character. - - -@end - -// This subdivides the text into characters. -@interface SafariCharacter : SafariItem - -- (SBElementArray *)attachments; -- (SBElementArray *)attributeRuns; -- (SBElementArray *)characters; -- (SBElementArray *)paragraphs; -- (SBElementArray *)words; - -@property (copy) NSColor *color; // The color of the first character. -@property (copy) NSString *font; // The name of the font of the first character. -@property NSInteger size; // The size in points of the first character. - - -@end - -// This subdivides the text into paragraphs. -@interface SafariParagraph : SafariItem - -- (SBElementArray *)attachments; -- (SBElementArray *)attributeRuns; -- (SBElementArray *)characters; -- (SBElementArray *)paragraphs; -- (SBElementArray *)words; - -@property (copy) NSColor *color; // The color of the first character. -@property (copy) NSString *font; // The name of the font of the first character. -@property NSInteger size; // The size in points of the first character. - - -@end - -// Rich (styled) text -@interface SafariText : SafariItem - -- (SBElementArray *)attachments; -- (SBElementArray *)attributeRuns; -- (SBElementArray *)characters; -- (SBElementArray *)paragraphs; -- (SBElementArray *)words; - -@property (copy) NSColor *color; // The color of the first character. -@property (copy) NSString *font; // The name of the font of the first character. -@property NSInteger size; // The size in points of the first character. - -- (void)addReadingListItemAndPreviewText:(NSString *)andPreviewText withTitle:(NSString *)withTitle; // Add a new Reading List item with the given URL. Allows a custom title and preview text to be specified. -- (id)doJavaScriptIn:(SafariTab *)in_; // Applies a string of JavaScript code to a document. - -@end - -// Represents an inline text attachment. This class is used mainly for make commands. -@interface SafariAttachment : SafariText - -@property (copy) NSString *fileName; // The path to the file for the attachment - - -@end - -// This subdivides the text into words. -@interface SafariWord : SafariItem - -- (SBElementArray *)attachments; -- (SBElementArray *)attributeRuns; -- (SBElementArray *)characters; -- (SBElementArray *)paragraphs; -- (SBElementArray *)words; - -@property (copy) NSColor *color; // The color of the first character. -@property (copy) NSString *font; // The name of the font of the first character. -@property NSInteger size; // The size in points of the first character. - - -@end - - - -/* - * Safari suite - */ - -// A Safari document representing the active tab in a window. -@interface SafariDocument (SafariSuite) - -@property (copy, readonly) NSString *source; // The HTML source of the web page currently loaded in the document. -@property (copy, readonly) SafariText *text; // The text of the web page currently loaded in the document. Modifications to text aren't reflected on the web page. -@property (copy) NSString *URL; // The current URL of the document. - -@end - -// A Safari window tab. -@interface SafariTab : SafariItem - -@property (readonly) NSInteger index; // The index of the tab, ordered left to right. -@property (copy, readonly) NSString *name; // The name of the tab. -@property (copy, readonly) NSString *source; // The HTML source of the web page currently loaded in the tab. -@property (copy, readonly) SafariText *text; // The text of the web page currently loaded in the tab. Modifications to text aren't reflected on the web page. -@property (copy) NSString *URL; // The current URL of the tab. -@property (readonly) BOOL visible; // Whether the tab is currently visible. - - -@end - -// A Safari window. -@interface SafariWindow (SafariSuite) - -- (SBElementArray *)tabs; - -@property (copy) SafariTab *currentTab; // The current tab. - -@end - - - -/* - * Type Definitions - */ - -@interface SafariPrintSettings : SBObject - -@property NSInteger copies; // the number of copies of a document to be printed -@property BOOL collating; // Should printed copies be collated? -@property NSInteger startingPage; // the first page of the document to be printed -@property NSInteger endingPage; // the last page of the document to be printed -@property NSInteger pagesAcross; // number of logical pages laid across a physical page -@property NSInteger pagesDown; // number of logical pages laid out down a physical page -@property (copy) NSDate *requestedPrintTime; // the time at which the desktop printer should print the document -@property SafariEnum errorHandling; // how errors are handled -@property (copy) NSString *faxNumber; // for fax number -@property (copy) NSString *targetPrinter; // for target printer - -- (void)closeSaving:(SafariSavo)saving savingIn:(NSURL *)savingIn; // Close an object. -- (void)delete; // Delete an object. -- (void)duplicateTo:(SBObject *)to withProperties:(NSDictionary *)withProperties; // Copy object(s) and put the copies at a new location. -- (BOOL)exists; // Verify if an object exists. -- (void)moveTo:(SBObject *)to; // Move object(s) to a new location. -- (void)saveAs:(NSString *)as in:(NSURL *)in_; // Save an object. -- (void)emailContentsOf:(SafariTab *)of; // Emails the contents of a tab. -- (void)searchTheWebFor:(NSString *)for_ in:(SafariTab *)in_; // Searches the web using Safari's current search provider. - -@end diff --git a/Gestr/SafariPage.h b/Gestr/SafariPage.h index 71f6f31..f3fed36 100644 --- a/Gestr/SafariPage.h +++ b/Gestr/SafariPage.h @@ -1,10 +1,7 @@ -#import -#import "Safari.h" #import "WebPage.h" @interface SafariPage : WebPage - (id)initWithDisplayName:(NSString *)displayName icon:(NSImage *)icon url:(NSString *)url; -- (void)launch; @end diff --git a/Gestr/SafariPage.m b/Gestr/SafariPage.m index 9579f8d..1aa2536 100644 --- a/Gestr/SafariPage.m +++ b/Gestr/SafariPage.m @@ -3,48 +3,7 @@ @implementation SafariPage - (id)initWithDisplayName:(NSString *)displayName icon:(NSImage *)icon url:(NSString *)url { - self = [super initWithDisplayName:displayName icon:icon url:url targetBrowserId:@"com.apple.Safari"]; - - return self; -} - -- (void)launch { - SafariApplication *safari = [SBApplication applicationWithBundleIdentifier:@"com.apple.Safari"]; - [safari activate]; - - if (safari.documents.count == 0) { - [safari.documents addObject:[[[safari classForScriptingClass:@"document"] alloc] initWithProperties:@{ @"URL": self.url }]]; - } - else { - BOOL tabExists = NO; - int tabIndex = -1; - SafariWindow *window = nil; - for (window in safari.windows) { - for (int i = 0; i < window.tabs.count; i++) { - SafariTab *tab = window.tabs[i]; - if ([[[self class] stripUrl:tab.URL] isEqualToString:[[self class] stripUrl:self.url]]) { - tabIndex = i; - tabExists = YES; - break; - } - } - if (tabExists) { - break; - } - } - - if (tabExists) { - window.currentTab = window.tabs[tabIndex]; - window.index = 1; - } - else { - SafariTab *newTab = [[[safari classForScriptingClass:@"tab"] alloc] initWithProperties:@{ @"URL": self.url }]; - window = safari.windows[0]; - [window.tabs addObject:newTab]; - window.currentTab = newTab; - window.index = 1; - } - } + return (self = [super initWithDisplayName:displayName icon:icon url:url targetBrowserId:@"com.apple.Safari"]); } @end diff --git a/Gestr/WebPage.h b/Gestr/WebPage.h index 9b19f16..cce7359 100644 --- a/Gestr/WebPage.h +++ b/Gestr/WebPage.h @@ -6,6 +6,6 @@ @property NSString *targetBrowserId; - (id)initWithDisplayName:(NSString *)displayName icon:(NSImage *)icon url:(NSString *)url targetBrowserId:(NSString *)targetBrowserId; -+ (NSString *)stripUrl:(NSString *)url; +- (void)launch; @end diff --git a/Gestr/WebPage.m b/Gestr/WebPage.m index 467676b..5b2bff2 100644 --- a/Gestr/WebPage.m +++ b/Gestr/WebPage.m @@ -13,15 +13,12 @@ - (id)initWithDisplayName:(NSString *)displayName icon:(NSImage *)icon url:(NSSt return self; } -+ (NSString *)stripUrl:(NSString *)url { - NSUInteger prefix = [url rangeOfString:@"://"].location; - if (prefix != NSNotFound) { - url = [url substringFromIndex:prefix + 3]; - } - if ([url characterAtIndex:url.length - 1] == '/') { - url = [url substringToIndex:url.length - 1]; - } - return url; +- (void)launch { + [NSWorkspace.sharedWorkspace openURLs:@[[NSURL URLWithString:self.url]] + withAppBundleIdentifier:self.targetBrowserId + options:0 + additionalEventParamDescriptor:nil + launchIdentifiers:nil]; } @end diff --git a/Sparkle2.xml b/Sparkle2.xml index f2afe99..3d7003d 100644 --- a/Sparkle2.xml +++ b/Sparkle2.xml @@ -6,9 +6,9 @@ Gestr Update en - Version 1.88 - 1.82, AppleScripts (from ~/Library/Application Support/Gestr/Scripts). 1.88, updated for Catalina!. - + Version 1.89 + 1.82, AppleScripts (from ~/Library/Application Support/Gestr/Scripts). 1.88, updated for Catalina!. 1.89, faster bookmark launching. +