diff --git a/README b/README
index b15dbf2..df95e35 100644
--- a/README
+++ b/README
@@ -1 +1,4 @@
+A version of Newt that uses the new Notification Center in Mountain Lion instead of Growl. (Growl is still an option though)
+
+Original:
http://stackapps.com/questions/1993/newt-realtime-new-question-notifications-for-os-x
\ No newline at end of file
diff --git a/newt.xcodeproj/project.pbxproj b/newt.xcodeproj/project.pbxproj
index 7886ab0..7282eda 100644
--- a/newt.xcodeproj/project.pbxproj
+++ b/newt.xcodeproj/project.pbxproj
@@ -547,13 +547,13 @@
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = "DEBUG=1";
GCC_PREPROCESSOR_DEFINITIONS_NOT_USED_IN_PRECOMPS = "";
- GCC_VERSION = coop.plausible.blocks.compilers.gcc.4_2;
+ GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
INFOPLIST_FILE = "resources/newt-Info.plist";
ONLY_ACTIVE_ARCH = YES;
PREBINDING = NO;
- SDKROOT = macosx10.5;
+ SDKROOT = macosx;
};
name = Debug;
};
@@ -564,12 +564,12 @@
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_PREPROCESSOR_DEFINITIONS = "DEBUG=0";
GCC_PREPROCESSOR_DEFINITIONS_NOT_USED_IN_PRECOMPS = "";
- GCC_VERSION = coop.plausible.blocks.compilers.gcc.4_2;
+ GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.5;
PREBINDING = NO;
- SDKROOT = macosx10.6;
+ SDKROOT = macosx;
};
name = Release;
};
diff --git a/newt.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/newt.xcodeproj/project.xcworkspace/contents.xcworkspacedata
new file mode 100644
index 0000000..f8e174e
--- /dev/null
+++ b/newt.xcodeproj/project.xcworkspace/contents.xcworkspacedata
@@ -0,0 +1,7 @@
+
+
+
+
+
diff --git a/resources/English.lproj/PrefPane.xib b/resources/English.lproj/PrefPane.xib
index b569482..d062d45 100644
--- a/resources/English.lproj/PrefPane.xib
+++ b/resources/English.lproj/PrefPane.xib
@@ -2,22 +2,43 @@
1050
- 10J567
- 823
- 1038.35
- 462.00
+ 12A269
+ 2818
+ 1187
+ 624.00
-
-
-
+
+ IBCustomCell
+ NSButton
+ NSButtonCell
+ NSCustomObject
+ NSImageCell
+ NSImageView
+ NSProgressIndicator
+ NSScrollView
+ NSScroller
+ NSSearchField
+ NSSearchFieldCell
+ NSTableColumn
+ NSTableHeaderView
+ NSTableView
+ NSTextField
+ NSTextFieldCell
+ NSTokenField
+ NSTokenFieldCell
+ NSView
+ NSWindowTemplate
com.apple.InterfaceBuilder.CocoaPlugin
-
+
{{32, 238}, {461, 228}}
-
- 2
- 562
+
+ 133682
-
QSAAAEEgAABCKAAAQigAAA
+ 0.25
+ 4
+ 1
265
{{330, 474}, {163, 22}}
- 2
+
1
YES
- 343014976
+ 342884416
268436480
@@ -274,20 +296,20 @@
- 130560
+ 0
0
search
_searchFieldSearch:
- 138690815
+ 138690560
0
400
75
- 130560
+ 0
0
clear
@@ -299,7 +321,7 @@
_searchFieldCancel:
- 138690815
+ 138690560
0
400
@@ -307,6 +329,7 @@
255
+ NO
@@ -316,10 +339,10 @@
{{32, 167}, {461, 63}}
- 2
+
YES
- 341966336
+ 341835776
0
@@ -330,6 +353,7 @@
0.0
2
+ NO
2
@@ -340,12 +364,37 @@
33
YES
- -2080244224
+ -2080374784
0
Launch on startup
- 1211912703
+ 1211912448
+ 2
+
+
+
+
+ 200
+ 25
+
+ NO
+
+
+
+ 293
+ {{219, 18}, {276, 18}}
+
+
+ 33
+ YES
+
+ -2080374784
+ 0
+ Use Notification Center instead of Growl
+
+
+ 1211912448
2
@@ -354,15 +403,17 @@
200
25
+ NO
300
{{17, 118}, {182, 17}}
+
YES
- 68288064
+ 68157504
272630784
Comments and answers for:
@@ -375,15 +426,17 @@
+ NO
268
{{17, 479}, {99, 17}}
+
YES
- 68288064
+ 68157504
272630784
Questions for:
@@ -391,6 +444,7 @@
+ NO
@@ -405,16 +459,17 @@
{{285, 77}, {208, 58}}
+
YES
- 67239424
+ 134217728
33554432
-
2
2
0
NO
+ NO
YES
@@ -422,28 +477,31 @@
268
{{26, 69}, {109, 32}}
+
YES
- 67239424
+ 67108864
134217728
Select User
- -2038284033
+ -2038284288
129
200
25
+ NO
{513, 516}
- 2
+
- {{0, 0}, {1440, 878}}
- {1.79769e+308, 1.79769e+308}
+ {{0, 0}, {2560, 1578}}
+ {10000000000000, 10000000000000}
+ YES
SitesTableController
@@ -456,9 +514,9 @@
Select User
NSWindow
- {1.79769e+308, 1.79769e+308}
+
-
+
256
@@ -468,7 +526,7 @@
YES
- -1804468671
+ -1804599231
272630784
@@ -483,6 +541,7 @@
+ NO
@@ -491,23 +550,23 @@
YES
- 67239424
+ 67108864
134217728
Find User
- -2038284033
+ -2038284288
129
200
25
+ NO
1292
-
{{462, 21}, {16, 16}}
28938
@@ -520,7 +579,7 @@
YES
- 68288064
+ 68157504
272630784
@@ -531,13 +590,14 @@
MCAwIDAAA
+ NO
{594, 60}
-
- {{0, 0}, {1440, 878}}
- {1.79769e+308, 1.79769e+308}
+ {{0, 0}, {2560, 1578}}
+ {10000000000000, 10000000000000}
+ YES
@@ -558,22 +618,6 @@
97
-
-
- table
-
-
-
- 102
-
-
-
- mainColumn
-
-
-
- 103
-
sitesTable
@@ -582,22 +626,6 @@
104
-
-
- delegate
-
-
-
- 105
-
-
-
- dataSource
-
-
-
- 106
-
updateFilterAction:
@@ -614,22 +642,6 @@
115
-
-
- preferencePane
-
-
-
- 116
-
-
-
- delegate
-
-
-
- 120
-
launchOnStartup
@@ -678,14 +690,6 @@
166
-
-
- delegate
-
-
-
- 168
-
confirmUserSelection:
@@ -718,6 +722,86 @@
184
+
+
+ notificationCenterCheck
+
+
+
+ 189
+
+
+
+ updateNotificationOption:
+
+
+
+ 190
+
+
+
+ useNotificationCenterCheck
+
+
+
+ 191
+
+
+
+ delegate
+
+
+
+ 105
+
+
+
+ dataSource
+
+
+
+ 106
+
+
+
+ table
+
+
+
+ 102
+
+
+
+ mainColumn
+
+
+
+ 103
+
+
+
+ preferencePane
+
+
+
+ 116
+
+
+
+ delegate
+
+
+
+ 120
+
+
+
+ delegate
+
+
+
+ 168
+
initialFirstResponder
@@ -773,6 +857,7 @@
+
@@ -1001,6 +1086,19 @@
+
+ 186
+
+
+
+
+
+
+
+ 187
+
+
+
@@ -1009,69 +1107,36 @@
com.apple.InterfaceBuilder.CocoaPlugin
com.apple.InterfaceBuilder.CocoaPlugin
com.apple.InterfaceBuilder.CocoaPlugin
-
- P4AAAL+AAABCAAAAw4AAAA
-
com.apple.InterfaceBuilder.CocoaPlugin
com.apple.InterfaceBuilder.CocoaPlugin
-
- P4AAAL+AAABBkAAAwhQAAA
-
com.apple.InterfaceBuilder.CocoaPlugin
com.apple.InterfaceBuilder.CocoaPlugin
-
- P4AAAL+AAABBiAAAwwcAAA
-
com.apple.InterfaceBuilder.CocoaPlugin
com.apple.InterfaceBuilder.CocoaPlugin
-
- P4AAAL+AAABBoAAAwtQAAA
-
com.apple.InterfaceBuilder.CocoaPlugin
com.apple.InterfaceBuilder.CocoaPlugin
-
- P4AAAL+AAABBiAAAxAKAAA
-
com.apple.InterfaceBuilder.CocoaPlugin
com.apple.InterfaceBuilder.CocoaPlugin
-
- AUOOgABCngAAA
-
com.apple.InterfaceBuilder.CocoaPlugin
- {{477, 114}, {594, 60}}
com.apple.InterfaceBuilder.CocoaPlugin
{{477, 114}, {594, 60}}
com.apple.InterfaceBuilder.CocoaPlugin
com.apple.InterfaceBuilder.CocoaPlugin
-
- P4AAAL+AAABB0AAAwsoAAA
-
com.apple.InterfaceBuilder.CocoaPlugin
com.apple.InterfaceBuilder.CocoaPlugin
-
- P4AAAL+AAABDRwAAwigAAA
-
com.apple.InterfaceBuilder.CocoaPlugin
com.apple.InterfaceBuilder.CocoaPlugin
-
- P4AAAL+AAABD5wAAwhAAAA
-
com.apple.InterfaceBuilder.CocoaPlugin
-
- P4AAAL+AAABBiAAAwnAAAA
-
com.apple.InterfaceBuilder.CocoaPlugin
- {{385, 337}, {513, 516}}
+ com.apple.InterfaceBuilder.CocoaPlugin
+ com.apple.InterfaceBuilder.CocoaPlugin
com.apple.InterfaceBuilder.CocoaPlugin
{{385, 337}, {513, 516}}
com.apple.InterfaceBuilder.CocoaPlugin
com.apple.InterfaceBuilder.CocoaPlugin
-
- P4AAAL+AAABCAAAAw/YAAA
-
com.apple.InterfaceBuilder.CocoaPlugin
com.apple.InterfaceBuilder.CocoaPlugin
com.apple.InterfaceBuilder.CocoaPlugin
@@ -1082,740 +1147,22 @@
SiteTableCell
com.apple.InterfaceBuilder.CocoaPlugin
com.apple.InterfaceBuilder.CocoaPlugin
-
- P4AAAL+AAABDpQAAxAKAAA
-
com.apple.InterfaceBuilder.CocoaPlugin
- 185
-
-
-
-
- NSObject
-
- IBProjectSource
- lib/JSON/NSObject+SBJSON.h
-
-
-
- NSObject
-
- IBProjectSource
- lib/JSON/SBJsonWriter.h
-
-
-
- NSPreferencePane
- NSObject
-
- IBUserSource
-
-
-
-
- PreferencePaneController
- NSPreferencePane
-
- id
- id
- id
- id
-
-
-
- confirmUserSelection:
- id
-
-
- selectUserButton:
- id
-
-
- updateFilterAction:
- id
-
-
- updateStartupLaunchAction:
- id
-
-
-
- NSButton
- NSImageView
- NSWindow
- NSProgressIndicator
- NSTextField
- NSTextField
- NSButton
- NSSearchField
- SitesTableController
- NSTokenField
-
-
-
- launchOnStartup
- NSButton
-
-
- profileImage
- NSImageView
-
-
- profileInputWindow
- NSWindow
-
-
- profileProgressIndicator
- NSProgressIndicator
-
-
- profileSearchError
- NSTextField
-
-
- profileURL
- NSTextField
-
-
- searchUserButton
- NSButton
-
-
- siteSearchField
- NSSearchField
-
-
- sitesTable
- SitesTableController
-
-
- tagsField
- NSTokenField
-
-
-
- IBProjectSource
- source/PreferencePaneController.h
-
-
-
- PreferencePaneController
- NSPreferencePane
-
- IBUserSource
-
-
-
-
- SiteTableCell
- NSCell
-
- IBProjectSource
- source/SiteTableCell.h
-
-
-
- SitesTableController
- NSObject
-
- NSTableColumn
- PreferencePaneController
- NSTableView
-
-
-
- mainColumn
- NSTableColumn
-
-
- preferencePane
- PreferencePaneController
-
-
- table
- NSTableView
-
-
-
- IBProjectSource
- source/SitesTableController.h
-
-
-
-
-
- NSActionCell
- NSCell
-
- IBFrameworkSource
- AppKit.framework/Headers/NSActionCell.h
-
-
-
- NSApplication
- NSResponder
-
- IBFrameworkSource
- AppKit.framework/Headers/NSApplication.h
-
-
-
- NSApplication
-
- IBFrameworkSource
- AppKit.framework/Headers/NSApplicationScripting.h
-
-
-
- NSApplication
-
- IBFrameworkSource
- AppKit.framework/Headers/NSColorPanel.h
-
-
-
- NSApplication
-
- IBFrameworkSource
- AppKit.framework/Headers/NSHelpManager.h
-
-
-
- NSApplication
-
- IBFrameworkSource
- AppKit.framework/Headers/NSPageLayout.h
-
-
-
- NSApplication
-
- IBFrameworkSource
- AppKit.framework/Headers/NSUserInterfaceItemSearching.h
-
-
-
- NSButton
- NSControl
-
- IBFrameworkSource
- AppKit.framework/Headers/NSButton.h
-
-
-
- NSButtonCell
- NSActionCell
-
- IBFrameworkSource
- AppKit.framework/Headers/NSButtonCell.h
-
-
-
- NSCell
- NSObject
-
- IBFrameworkSource
- AppKit.framework/Headers/NSCell.h
-
-
-
- NSControl
- NSView
-
- IBFrameworkSource
- AppKit.framework/Headers/NSControl.h
-
-
-
- NSFormatter
- NSObject
-
- IBFrameworkSource
- Foundation.framework/Headers/NSFormatter.h
-
-
-
- NSImageCell
- NSCell
-
- IBFrameworkSource
- AppKit.framework/Headers/NSImageCell.h
-
-
-
- NSImageView
- NSControl
-
- IBFrameworkSource
- AppKit.framework/Headers/NSImageView.h
-
-
-
- NSMenu
- NSObject
-
- IBFrameworkSource
- AppKit.framework/Headers/NSMenu.h
-
-
-
- NSObject
-
- IBFrameworkSource
- AppKit.framework/Headers/NSAccessibility.h
-
-
-
- NSObject
-
-
-
- NSObject
-
-
-
- NSObject
-
-
-
- NSObject
-
-
-
- NSObject
-
- IBFrameworkSource
- AppKit.framework/Headers/NSDictionaryController.h
-
-
-
- NSObject
-
- IBFrameworkSource
- AppKit.framework/Headers/NSDragging.h
-
-
-
- NSObject
-
- IBFrameworkSource
- AppKit.framework/Headers/NSFontManager.h
-
-
-
- NSObject
-
- IBFrameworkSource
- AppKit.framework/Headers/NSFontPanel.h
-
-
-
- NSObject
-
- IBFrameworkSource
- AppKit.framework/Headers/NSKeyValueBinding.h
-
-
-
- NSObject
-
-
-
- NSObject
-
- IBFrameworkSource
- AppKit.framework/Headers/NSNibLoading.h
-
-
-
- NSObject
-
- IBFrameworkSource
- AppKit.framework/Headers/NSOutlineView.h
-
-
-
- NSObject
-
- IBFrameworkSource
- AppKit.framework/Headers/NSPasteboard.h
-
-
-
- NSObject
-
- IBFrameworkSource
- AppKit.framework/Headers/NSSavePanel.h
-
-
-
- NSObject
-
- IBFrameworkSource
- AppKit.framework/Headers/NSTableView.h
-
-
-
- NSObject
-
- IBFrameworkSource
- AppKit.framework/Headers/NSToolbarItem.h
-
-
-
- NSObject
-
- IBFrameworkSource
- AppKit.framework/Headers/NSView.h
-
-
-
- NSObject
-
- IBFrameworkSource
- Foundation.framework/Headers/NSArchiver.h
-
-
-
- NSObject
-
- IBFrameworkSource
- Foundation.framework/Headers/NSClassDescription.h
-
-
-
- NSObject
-
- IBFrameworkSource
- Foundation.framework/Headers/NSError.h
-
-
-
- NSObject
-
- IBFrameworkSource
- Foundation.framework/Headers/NSFileManager.h
-
-
-
- NSObject
-
- IBFrameworkSource
- Foundation.framework/Headers/NSKeyValueCoding.h
-
-
-
- NSObject
-
- IBFrameworkSource
- Foundation.framework/Headers/NSKeyValueObserving.h
-
-
-
- NSObject
-
- IBFrameworkSource
- Foundation.framework/Headers/NSKeyedArchiver.h
-
-
-
- NSObject
-
- IBFrameworkSource
- Foundation.framework/Headers/NSObject.h
-
-
-
- NSObject
-
- IBFrameworkSource
- Foundation.framework/Headers/NSObjectScripting.h
-
-
-
- NSObject
-
- IBFrameworkSource
- Foundation.framework/Headers/NSPortCoder.h
-
-
-
- NSObject
-
- IBFrameworkSource
- Foundation.framework/Headers/NSRunLoop.h
-
-
-
- NSObject
-
- IBFrameworkSource
- Foundation.framework/Headers/NSScriptClassDescription.h
-
-
-
- NSObject
-
- IBFrameworkSource
- Foundation.framework/Headers/NSScriptKeyValueCoding.h
-
-
-
- NSObject
-
- IBFrameworkSource
- Foundation.framework/Headers/NSScriptObjectSpecifiers.h
-
-
-
- NSObject
-
- IBFrameworkSource
- Foundation.framework/Headers/NSScriptWhoseTests.h
-
-
-
- NSObject
-
- IBFrameworkSource
- Foundation.framework/Headers/NSThread.h
-
-
-
- NSObject
-
- IBFrameworkSource
- Foundation.framework/Headers/NSURL.h
-
-
-
- NSObject
-
- IBFrameworkSource
- Foundation.framework/Headers/NSURLConnection.h
-
-
-
- NSObject
-
- IBFrameworkSource
- Foundation.framework/Headers/NSURLDownload.h
-
-
-
- NSObject
-
- IBFrameworkSource
- Growl.framework/Headers/GrowlApplicationBridge.h
-
-
-
- NSPreferencePane
- NSObject
-
- NSView
- NSView
- NSView
- NSWindow
-
-
-
- _firstKeyView
- NSView
-
-
- _initialKeyView
- NSView
-
-
- _lastKeyView
- NSView
-
-
- _window
- NSWindow
-
-
-
- IBFrameworkSource
- PreferencePanes.framework/Headers/NSPreferencePane.h
-
-
-
- NSProgressIndicator
- NSView
-
- IBFrameworkSource
- AppKit.framework/Headers/NSProgressIndicator.h
-
-
-
- NSResponder
-
- IBFrameworkSource
- AppKit.framework/Headers/NSInterfaceStyle.h
-
-
-
- NSResponder
- NSObject
-
- IBFrameworkSource
- AppKit.framework/Headers/NSResponder.h
-
-
-
- NSScrollView
- NSView
-
- IBFrameworkSource
- AppKit.framework/Headers/NSScrollView.h
-
-
-
- NSScroller
- NSControl
-
- IBFrameworkSource
- AppKit.framework/Headers/NSScroller.h
-
-
-
- NSSearchField
- NSTextField
-
- IBFrameworkSource
- AppKit.framework/Headers/NSSearchField.h
-
-
-
- NSSearchFieldCell
- NSTextFieldCell
-
- IBFrameworkSource
- AppKit.framework/Headers/NSSearchFieldCell.h
-
-
-
- NSTableColumn
- NSObject
-
- IBFrameworkSource
- AppKit.framework/Headers/NSTableColumn.h
-
-
-
- NSTableHeaderView
- NSView
-
- IBFrameworkSource
- AppKit.framework/Headers/NSTableHeaderView.h
-
-
-
- NSTableView
- NSControl
-
-
-
- NSTextField
- NSControl
-
- IBFrameworkSource
- AppKit.framework/Headers/NSTextField.h
-
-
-
- NSTextFieldCell
- NSActionCell
-
- IBFrameworkSource
- AppKit.framework/Headers/NSTextFieldCell.h
-
-
-
- NSTokenField
- NSTextField
-
- IBFrameworkSource
- AppKit.framework/Headers/NSTokenField.h
-
-
-
- NSTokenFieldCell
- NSTextFieldCell
-
- IBFrameworkSource
- AppKit.framework/Headers/NSTokenFieldCell.h
-
-
-
- NSView
-
- IBFrameworkSource
- AppKit.framework/Headers/NSClipView.h
-
-
-
- NSView
-
- IBFrameworkSource
- AppKit.framework/Headers/NSMenuItem.h
-
-
-
- NSView
-
- IBFrameworkSource
- AppKit.framework/Headers/NSRulerView.h
-
-
-
- NSView
- NSResponder
-
-
-
- NSWindow
-
- IBFrameworkSource
- AppKit.framework/Headers/NSDrawer.h
-
-
-
- NSWindow
- NSResponder
-
- IBFrameworkSource
- AppKit.framework/Headers/NSWindow.h
-
-
-
- NSWindow
-
- IBFrameworkSource
- AppKit.framework/Headers/NSWindowScripting.h
-
-
-
+ 191
+
0
IBCocoaFramework
com.apple.InterfaceBuilder.CocoaPlugin.macosx
-
- com.apple.InterfaceBuilder.CocoaPlugin.macosx
-
-
YES
- ../../newt.xcodeproj
3
NSSwitch
diff --git a/source/NewtMenulet.h b/source/NewtMenulet.h
index f439801..c50b6fa 100644
--- a/source/NewtMenulet.h
+++ b/source/NewtMenulet.h
@@ -37,7 +37,7 @@
//- (id)initWithApp:(id *)mainObject;
//@end
-@interface NewtMenulet : NSObject {
+@interface NewtMenulet : NSObject {
IBOutlet NSMenu *theMenu;
IBOutlet NSMenuItem *disableButton;
IBOutlet NSMenuItem *silentButton;
diff --git a/source/NewtMenulet.m b/source/NewtMenulet.m
index 27eac8c..80f424c 100644
--- a/source/NewtMenulet.m
+++ b/source/NewtMenulet.m
@@ -126,8 +126,11 @@ - (void)awakeFromNib {
sitesDataTimer = [self startTimerWithMethod:@selector(loadStackExchangeNetworkSites) andInterval:60*24];
- // initialise Growl
- [GrowlApplicationBridge setGrowlDelegate:self];
+
+
+ [GrowlApplicationBridge setGrowlDelegate:self];
+ [[NSUserNotificationCenter defaultUserNotificationCenter] setDelegate:self];
+
// experimental
// [[[NSWorkspace sharedWorkspace] notificationCenter] addObserver: self
@@ -239,6 +242,7 @@ - (void)showReputation:(NSArray *)profiles {
title = [NSString stringWithFormat:@"%d", dif];
}
+ if ([[NSUserDefaults standardUserDefaults] boolForKey:@"UseGrowl"]) {
[GrowlApplicationBridge notifyWithTitle:title
description:@""
notificationName:@"Reputation Change"
@@ -246,6 +250,12 @@ - (void)showReputation:(NSArray *)profiles {
priority:0
isSticky:FALSE
clickContext:url];
+ } else {
+ NSUserNotification *notification = [[NSUserNotification alloc] init];
+ notification.title = title;
+ notification.userInfo = [NSDictionary dictionaryWithObject:url forKey:@"URL"];
+ [[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:notification];
+ }
}
}
@@ -288,21 +298,21 @@ - (void)showReputation:(NSArray *)profiles {
newSize.width = 22;
[image setSize:newSize];
- [item setTitle:title];
- [item setImage:image];
- [image release];
+ [item setTitle:title];
+ [item setImage:image];
+ [image release];
}
}
- (void)clickReputation:(id)sender {
- NSArray *sites = [persistence objectForKey:@"most_used_sites"];
- int index = [sender tag] - 110;
- NSString *siteUrl = [sites objectAtIndex:index];
- NSDictionary *site = [persistence siteForKey:siteUrl];
- NSObject *userId = [site objectForKey:@"user_id"];
-
- NSString *url = [NSString stringWithFormat:@"%@/users/%@?tab=reputation", siteUrl, userId];
- [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:url]];
+ NSArray *sites = [persistence objectForKey:@"most_used_sites"];
+ int index = [sender tag] - 110;
+ NSString *siteUrl = [sites objectAtIndex:index];
+ NSDictionary *site = [persistence siteForKey:siteUrl];
+ NSObject *userId = [site objectForKey:@"user_id"];
+
+ NSString *url = [NSString stringWithFormat:@"%@/users/%@?tab=reputation", siteUrl, userId];
+ [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:url]];
}
- (IBAction)retrieveQuestions:(id)sender {
@@ -382,6 +392,7 @@ - (void)processNewQuestions:(NSDictionary *)data
NSString *url = [NSString stringWithFormat:@"%@/questions/%@", [site objectForKey:@"site_url"], questionId];
NSString *title = [tags componentsJoinedByString:@", "];
+ if ([[NSUserDefaults standardUserDefaults] boolForKey:@"UseGrowl"]) {
[GrowlApplicationBridge notifyWithTitle:title
description:prepareHTML([question objectForKey:@"title"])
notificationName:@"New Question"
@@ -389,6 +400,13 @@ - (void)processNewQuestions:(NSDictionary *)data
priority:0
isSticky:FALSE
clickContext:url];
+ } else {
+ NSUserNotification *notification = [[NSUserNotification alloc] init];
+ notification.title = title;
+ notification.informativeText = prepareHTML([question objectForKey:@"title"]);
+ notification.userInfo = [NSDictionary dictionaryWithObject:url forKey:@"URL"];
+ [[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:notification];
+ }
}
}
@@ -439,7 +457,9 @@ - (void)growlNotificationWasClicked:(id)clickContext {
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:clickContext]];
}
-
+- (void)userNotificationCenter:(NSUserNotificationCenter *)center didActivateNotification:(NSUserNotification *)notification {
+ [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:[notification.userInfo objectForKey:@"URL"]]];
+}
- (NSTimer *)startTimerWithMethod:(SEL)selector
andInterval:(double)interval {
@@ -580,6 +600,7 @@ - (void)processCommentsToUser:(NSDictionary *)result
// you can go to the url /questions/{answer_id} and you'll be redirected to the correct question
NSString *url = [NSString stringWithFormat:@"%@/questions/%@", [site objectForKey:@"site_url"], [comment objectForKey:@"post_id"]];
+ if ([[NSUserDefaults standardUserDefaults] boolForKey:@"UseGrowl"]) {
[GrowlApplicationBridge notifyWithTitle:[NSString stringWithFormat:@"Comment from %@", from]
description:text
notificationName:@"New Comment"
@@ -587,6 +608,13 @@ - (void)processCommentsToUser:(NSDictionary *)result
priority:0
isSticky:TRUE
clickContext:url];
+ } else {
+ NSUserNotification *notification = [[NSUserNotification alloc] init];
+ notification.title = [NSString stringWithFormat:@"Comment from %@", from];
+ notification.informativeText = text;
+ notification.userInfo = [NSDictionary dictionaryWithObject:url forKey:@"URL"];
+ [[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:notification];
+ }
}
}
@@ -644,6 +672,7 @@ - (void)processAnswers:(NSDictionary *)result
// you can go to the url /questions/{answer_id} and you'll be redirected to the correct question
NSString *url = [NSString stringWithFormat:@"%@/questions/%@", [site objectForKey:@"site_url"], answerId];
+ if ([[NSUserDefaults standardUserDefaults] boolForKey:@"UseGrowl"]) {
[GrowlApplicationBridge notifyWithTitle:[NSString stringWithFormat:@"A new answer by %@", from]
description:@""
notificationName:@"New Answer"
@@ -651,7 +680,13 @@ - (void)processAnswers:(NSDictionary *)result
priority:0
isSticky:TRUE
clickContext:url];
- }
+ } else {
+ NSUserNotification *notification = [[NSUserNotification alloc] init];
+ notification.title = [NSString stringWithFormat:@"A new answer by %@", from];
+ notification.userInfo = [NSDictionary dictionaryWithObject:url forKey:@"URL"];
+ [[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:notification];
+ }
+ }
}
diff --git a/source/PreferencePaneController.h b/source/PreferencePaneController.h
index b0ac602..b93ec6d 100644
--- a/source/PreferencePaneController.h
+++ b/source/PreferencePaneController.h
@@ -48,6 +48,7 @@
IBOutlet NSProgressIndicator *profileProgressIndicator;
IBOutlet NSButton *searchUserButton;
IBOutlet NSTextField *profileSearchError;
+ IBOutlet NSButton *useNotificationCenterCheck;
int activity;
@@ -65,6 +66,7 @@
- (IBAction)updateStartupLaunchAction:(id)sender;
- (IBAction)selectUserButton:(id)sender;
- (IBAction)confirmUserSelection:(id)sender;
+- (IBAction)updateNotificationOption:(id)sender;
- (void)displayPreferences;
- (void)closePreferences;
diff --git a/source/PreferencePaneController.m b/source/PreferencePaneController.m
index cc1b2de..85acba3 100644
--- a/source/PreferencePaneController.m
+++ b/source/PreferencePaneController.m
@@ -77,6 +77,7 @@ - (void)willSelect {
[launchOnStartup setState:1];
}
+ useNotificationCenterCheck.state = ![[NSUserDefaults standardUserDefaults] boolForKey:@"UseGrowl"] ? NSOnState : NSOffState;
NSData *flair = [persistence objectForKey:@"user_flair"];
if (flair != nil) {
@@ -188,6 +189,10 @@ - (IBAction)updateStartupLaunchAction:(id)sender {
}
}
+- (IBAction)updateNotificationOption:(id)sender {
+ [[NSUserDefaults standardUserDefaults] setBool:(useNotificationCenterCheck.state == NSOffState) forKey:@"UseGrowl"];
+}
+
- (LSSharedFileListItemRef)findStartupItem:(NSString *)appPath {
LSSharedFileListRef loginItems = LSSharedFileListCreate(NULL, kLSSharedFileListSessionLoginItems, NULL);