From: Joseph Spiros Date: Mon, 2 Mar 2009 04:10:43 +0000 (-0500) Subject: Renamed the product from GrowlITTSW to ITTSW. Added image size customization options... X-Git-Tag: v1.0~2 X-Git-Url: http://git.ithinksw.org/GrowlITTSW.git/commitdiff_plain/db492e315730afc3ec7fe21f8f6102e42675e8d6 Renamed the product from GrowlITTSW to ITTSW. Added image size customization options and word wrap. --- diff --git a/English.lproj/GrowlITTSWPrefs.nib/classes.nib b/English.lproj/GrowlITTSWPrefs.nib/classes.nib index 6462c4d..c76a295 100644 --- a/English.lproj/GrowlITTSWPrefs.nib/classes.nib +++ b/English.lproj/GrowlITTSWPrefs.nib/classes.nib @@ -64,6 +64,14 @@ id setBackgroundStyle id + setBadgeImageWithAppIcon + id + setImageNoUpscale + id + setImageSize + id + setIndentWrap + id setScreen id setVanishDelay @@ -74,6 +82,10 @@ id setWindowSize id + setWrap + id + setWrapColumns + id CLASS GrowlITTSWPrefs @@ -89,6 +101,14 @@ NSColorWell backgroundStyleButton NSPopUpButton + badgeImageWithAppIconButton + NSButton + imageNoUpscaleButton + NSButton + imageSizeSlider + NSSlider + indentWrapButton + NSButton screenButton NSPopUpButton slider_opacity @@ -101,6 +121,10 @@ NSSlider windowSizeButton NSPopUpButton + wrapColumnsField + NSTextField + wrapNotificationsButton + NSButton SUPERCLASS NSPreferencePane diff --git a/English.lproj/GrowlITTSWPrefs.nib/keyedobjects.nib b/English.lproj/GrowlITTSWPrefs.nib/keyedobjects.nib index 7a1f10a..50567d2 100644 Binary files a/English.lproj/GrowlITTSWPrefs.nib/keyedobjects.nib and b/English.lproj/GrowlITTSWPrefs.nib/keyedobjects.nib differ diff --git a/GrowlITTSW.xcodeproj/project.pbxproj b/GrowlITTSW.xcodeproj/project.pbxproj index fd93ea2..1b823e0 100644 --- a/GrowlITTSW.xcodeproj/project.pbxproj +++ b/GrowlITTSW.xcodeproj/project.pbxproj @@ -81,7 +81,7 @@ 089C167FFE841241C02AAC07 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = ""; }; 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = ""; }; 32DBCF630370AF2F00C91783 /* GrowlITTSW_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GrowlITTSW_Prefix.pch; sourceTree = ""; }; - 8D5B49B6048680CD000E48DA /* GrowlITTSW.growlView */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = GrowlITTSW.growlView; sourceTree = BUILT_PRODUCTS_DIR; }; + 8D5B49B6048680CD000E48DA /* ITTSW.growlView */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ITTSW.growlView; sourceTree = BUILT_PRODUCTS_DIR; }; 8D5B49B7048680CD000E48DA /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; D2F7E65807B2D6F200F64583 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = /System/Library/Frameworks/CoreData.framework; sourceTree = ""; }; FA4A471D0F5A3C2A00F37A2B /* GrowlITTSWDisplay.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GrowlITTSWDisplay.h; sourceTree = ""; }; @@ -194,7 +194,7 @@ 19C28FB8FE9D52D311CA2CBB /* Products */ = { isa = PBXGroup; children = ( - 8D5B49B6048680CD000E48DA /* GrowlITTSW.growlView */, + 8D5B49B6048680CD000E48DA /* ITTSW.growlView */, ); name = Products; sourceTree = ""; @@ -235,9 +235,9 @@ /* End PBXGroup section */ /* Begin PBXNativeTarget section */ - 8D5B49AC048680CD000E48DA /* GrowlITTSW */ = { + 8D5B49AC048680CD000E48DA /* ITTSW */ = { isa = PBXNativeTarget; - buildConfigurationList = 1DEB913A08733D840010E9CD /* Build configuration list for PBXNativeTarget "GrowlITTSW" */; + buildConfigurationList = 1DEB913A08733D840010E9CD /* Build configuration list for PBXNativeTarget "ITTSW" */; buildPhases = ( 8D5B49AF048680CD000E48DA /* Resources */, 8D5B49B1048680CD000E48DA /* Sources */, @@ -251,10 +251,10 @@ FA4A474A0F5A3CD300F37A2B /* PBXTargetDependency */, FA4A474C0F5A3CD500F37A2B /* PBXTargetDependency */, ); - name = GrowlITTSW; + name = ITTSW; productInstallPath = "$(HOME)/Library/Bundles"; productName = GrowlITTSW; - productReference = 8D5B49B6048680CD000E48DA /* GrowlITTSW.growlView */; + productReference = 8D5B49B6048680CD000E48DA /* ITTSW.growlView */; productType = "com.apple.product-type.bundle"; }; /* End PBXNativeTarget section */ @@ -279,7 +279,7 @@ ); projectRoot = ""; targets = ( - 8D5B49AC048680CD000E48DA /* GrowlITTSW */, + 8D5B49AC048680CD000E48DA /* ITTSW */, ); }; /* End PBXProject section */ @@ -402,7 +402,7 @@ "-undefined", dynamic_lookup, ); - PRODUCT_NAME = GrowlITTSW; + PRODUCT_NAME = ITTSW; REZ_RESOURCE_MAP_READ_ONLY = YES; WRAPPER_EXTENSION = growlView; }; @@ -423,7 +423,7 @@ "-undefined", dynamic_lookup, ); - PRODUCT_NAME = GrowlITTSW; + PRODUCT_NAME = ITTSW; REZ_RESOURCE_MAP_READ_ONLY = YES; WRAPPER_EXTENSION = growlView; }; @@ -458,7 +458,7 @@ /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ - 1DEB913A08733D840010E9CD /* Build configuration list for PBXNativeTarget "GrowlITTSW" */ = { + 1DEB913A08733D840010E9CD /* Build configuration list for PBXNativeTarget "ITTSW" */ = { isa = XCConfigurationList; buildConfigurations = ( 1DEB913B08733D840010E9CD /* Debug */, diff --git a/GrowlITTSWController.h b/GrowlITTSWController.h index 469d6e5..0d6b6b1 100644 --- a/GrowlITTSWController.h +++ b/GrowlITTSWController.h @@ -12,8 +12,12 @@ @interface GrowlITTSWController : ITSharedController { GrowlITTSWWindow *_window; + float _imageSize; + BOOL _imageNoUpscale; + BOOL _wrapNotifications; + int _wrapColumns; } -- (void)showWindowWithText:(NSString *)text image:(NSImage *)image; +- (void)showWindowWithTitle:(NSString *)title text:(NSString *)text image:(NSImage *)image; @end diff --git a/GrowlITTSWController.m b/GrowlITTSWController.m index 172453a..b5c762b 100644 --- a/GrowlITTSWController.m +++ b/GrowlITTSWController.m @@ -56,6 +56,11 @@ } - (void)syncWithPrefs { + _imageSize = [GrowlITTSWPrefs imageSize]; + _imageNoUpscale = [GrowlITTSWPrefs imageNoUpscale]; + _wrapNotifications = [GrowlITTSWPrefs wrapNotifications]; + _wrapColumns = [GrowlITTSWPrefs wrapColumns]; + NSScreen *screen = [GrowlITTSWPrefs screen]; ITHorizontalWindowPosition horizontalPosition = [GrowlITTSWPrefs horizontalPosition]; ITVerticalWindowPosition verticalPosition = [GrowlITTSWPrefs verticalPosition]; @@ -107,17 +112,31 @@ } } -- (void)showWindowWithText:(NSString *)text image:(NSImage *)image { +- (void)showWindowWithTitle:(NSString *)title text:(NSString *)text image:(NSImage *)image { + if (text && ![text isEqualToString:@""] && ![text isEqualToString:@"\n"]) { + text = [title stringByAppendingFormat:@"\n%@", text]; + } + NSSize newSize; NSSize oldSize = [image size]; + BOOL wouldUpscale = ((oldSize.width <= _imageSize) && (oldSize.height <= _imageSize)); + + if (!(wouldUpscale && _imageNoUpscale)) { + if (oldSize.width > oldSize.height) { + newSize = NSMakeSize(_imageSize, (oldSize.height * (_imageSize / oldSize.width))); + } else { + newSize = NSMakeSize((oldSize.width * (_imageSize / oldSize.height)), _imageSize); + } + + image = [[[[NSImage alloc] initWithData:[image TIFFRepresentation]] autorelease] imageScaledSmoothlyToSize:newSize]; + } - if (oldSize.width > oldSize.height) { - newSize = NSMakeSize(110.0f, (oldSize.height * (110.0f / oldSize.width))); - } else { - newSize = NSMakeSize((oldSize.width * (110.0f / oldSize.height)), 110.0f); + if (_wrapNotifications) { + text = [text stringByReplacingOccurrencesOfRegex:[NSString stringWithFormat:@"(.{1,%i})(?: +|$)\\n?|(.{%i})", _wrapColumns, _wrapColumns] withString:@"$1$2\n"]; } - image = [[[[NSImage alloc] initWithData:[image TIFFRepresentation]] autorelease] imageScaledSmoothlyToSize:newSize]; + //trim trailing whitespace + text = [text stringByReplacingOccurrencesOfRegex:@"[\\s\\r\\n]+$" withString:@""]; NSArray *gothicChars = [NSArray arrayWithObjects:[NSString stringWithUTF8String:"☆"], [NSString stringWithUTF8String:"★"], nil]; NSMutableAttributedString *attributedText = [[NSMutableAttributedString alloc] initWithString:text]; @@ -125,7 +144,7 @@ if (([gothicChars count] > 0) && ([text length] > 0)) { NSMutableString *gothicRegex = [[NSMutableString alloc] init]; - [gothicRegex appendString:@"["]; + [gothicRegex appendString:@"[\\n"]; for (NSString *gothicChar in gothicChars) { [gothicRegex appendString:gothicChar]; } diff --git a/GrowlITTSWDisplay.m b/GrowlITTSWDisplay.m index b6727e8..ac9a647 100644 --- a/GrowlITTSWDisplay.m +++ b/GrowlITTSWDisplay.m @@ -31,13 +31,7 @@ NSString *title = [dict objectForKey:GROWL_NOTIFICATION_TITLE]; NSString *desc = [dict objectForKey:GROWL_NOTIFICATION_DESCRIPTION]; NSImage *image = [dict objectForKey:GROWL_NOTIFICATION_ICON]; - NSString *text; - if (desc) { - text = [title stringByAppendingFormat:@"\n%@", desc]; - } else { - text = title; - } - [[GrowlITTSWController sharedController] showWindowWithText:text image:image]; + [[GrowlITTSWController sharedController] showWindowWithTitle:title text:desc image:image]; } @end diff --git a/GrowlITTSWPrefs.h b/GrowlITTSWPrefs.h index a83d30f..bf3986c 100644 --- a/GrowlITTSWPrefs.h +++ b/GrowlITTSWPrefs.h @@ -14,6 +14,10 @@ IBOutlet NSPopUpButton *windowSizeButton; IBOutlet NSPopUpButton *screenButton; + IBOutlet NSSlider *imageSizeSlider; + IBOutlet NSButton *imageNoUpscaleButton; + IBOutlet NSButton *wrapNotificationsButton; + IBOutlet NSTextField *wrapColumnsField; } + (Class)appearanceEffect; @@ -29,6 +33,11 @@ + (ITHorizontalWindowPosition)horizontalPosition; + (ITVerticalWindowPosition)verticalPosition; ++ (float)imageSize; ++ (BOOL)imageNoUpscale; ++ (BOOL)wrapNotifications; ++ (int)wrapColumns; + - (IBAction)setAppearanceEffect:(id)sender; - (IBAction)setAppearanceSpeed:(id)sender; - (IBAction)setVanishEffect:(id)sender; @@ -40,5 +49,9 @@ - (IBAction)setWindowSize:(id)sender; - (IBAction)setScreen:(id)sender; +- (IBAction)setImageSize:(id)sender; +- (IBAction)setImageNoUpscale:(id)sender; +- (IBAction)setWrap:(id)sender; +- (IBAction)setWrapColumns:(id)sender; @end diff --git a/GrowlITTSWPrefs.m b/GrowlITTSWPrefs.m index df4f7bf..9a6eac2 100644 --- a/GrowlITTSWPrefs.m +++ b/GrowlITTSWPrefs.m @@ -127,6 +127,34 @@ } } ++ (float)imageSize { + SYNCHRONIZE_GROWL_PREFS(); + float imageSize = 110.0f; + READ_GROWL_PREF_FLOAT(@"imageSize", GrowlITTSWPrefsDomain, &imageSize); + return imageSize; +} + ++ (BOOL)imageNoUpscale { + SYNCHRONIZE_GROWL_PREFS(); + BOOL imageNoUpscale = NO; + READ_GROWL_PREF_BOOL(@"imageNoUpscale", GrowlITTSWPrefsDomain, &imageNoUpscale); + return imageNoUpscale; +} + ++ (BOOL)wrapNotifications { + SYNCHRONIZE_GROWL_PREFS(); + BOOL wrapNotifications = NO; + READ_GROWL_PREF_BOOL(@"wrapNotifications", GrowlITTSWPrefsDomain, &wrapNotifications); + return wrapNotifications; +} + ++ (int)wrapColumns { + SYNCHRONIZE_GROWL_PREFS(); + int wrapColumns = 64; + READ_GROWL_PREF_INT(@"wrapColumns", GrowlITTSWPrefsDomain, &wrapColumns); + return wrapColumns; +} + - (NSString *)mainNibName { return @"GrowlITTSWPrefs"; } @@ -165,6 +193,13 @@ [screenButton setEnabled:NO]; } [screenButton selectItemAtIndex:[screenButton indexOfItemWithRepresentedObject:[GrowlITTSWPrefs screen]]]; + [imageSizeSlider setFloatValue:[GrowlITTSWPrefs imageSize]]; + [imageNoUpscaleButton setState:([GrowlITTSWPrefs imageNoUpscale] ? NSOnState : NSOffState)]; + + BOOL wrapNotifications = [GrowlITTSWPrefs wrapNotifications]; + [wrapNotificationsButton setState:(wrapNotifications ? NSOnState : NSOffState)]; + [wrapColumnsField setIntValue:[GrowlITTSWPrefs wrapColumns]]; + [wrapColumnsField setEnabled:wrapNotifications]; } - (void)awakeFromNib { @@ -275,4 +310,34 @@ UPDATE_GROWL_PREFS(); } +- (IBAction)setImageSize:(id)sender { + SYNCHRONIZE_GROWL_PREFS(); + float imageSize = [imageSizeSlider floatValue]; + WRITE_GROWL_PREF_FLOAT(@"imageSize", imageSize, GrowlITTSWPrefsDomain); + UPDATE_GROWL_PREFS(); +} + +- (IBAction)setImageNoUpscale:(id)sender { + SYNCHRONIZE_GROWL_PREFS(); + BOOL imageNoUpscale = ([imageNoUpscaleButton state] == NSOnState) ? YES : NO; + WRITE_GROWL_PREF_BOOL(@"imageNoUpscale", imageNoUpscale, GrowlITTSWPrefsDomain); + UPDATE_GROWL_PREFS(); +} + +- (IBAction)setWrap:(id)sender { + SYNCHRONIZE_GROWL_PREFS(); + BOOL wrapNotifications = ([wrapNotificationsButton state] == NSOnState) ? YES : NO; + [wrapColumnsField setEnabled:wrapNotifications]; + WRITE_GROWL_PREF_BOOL(@"wrapNotifications", wrapNotifications, GrowlITTSWPrefsDomain); + UPDATE_GROWL_PREFS(); +} + +- (IBAction)setWrapColumns:(id)sender { + SYNCHRONIZE_GROWL_PREFS(); + int wrapColumns = [wrapColumnsField intValue]; + [wrapColumnsField setIntValue:wrapColumns]; + WRITE_GROWL_PREF_INT(@"wrapColumns", wrapColumns, GrowlITTSWPrefsDomain); + UPDATE_GROWL_PREFS(); +} + @end diff --git a/Info.plist b/Info.plist index 7bc2d5d..920e1e1 100644 --- a/Info.plist +++ b/Info.plist @@ -5,13 +5,13 @@ CFBundleDevelopmentRegion English CFBundleExecutable - GrowlITTSW + ITTSW CFBundleIdentifier com.ithinksw.growl-ittsw CFBundleInfoDictionaryVersion 6.0 CFBundleName - GrowlITTSW + ITTSW CFBundlePackageType DISP CFBundleSignature