43
43
#import " TagEditingManager.h"
44
44
#import " NotesTableHeaderCell.h"
45
45
#import " DFView.h"
46
- #import " StatusItemView.h"
47
46
#import " ETContentView.h"
48
47
#import " PreviewController.h"
49
48
#import " ETClipView.h"
@@ -143,8 +142,6 @@ - (id)init {
143
142
144
143
NSNotificationCenter *nc=[NSNotificationCenter defaultCenter ];
145
144
[nc addObserver: previewController selector: @selector (requestPreviewUpdate: ) name: @" TextViewHasChangedContents" object: self ];
146
- [nc addObserver: self selector: @selector (toggleAttachedWindow: ) name: @" NVShouldActivate" object: nil ];
147
- [nc addObserver: self selector: @selector (toggleAttachedMenu: ) name: @" StatusItemMenuShouldDrop" object: nil ];
148
145
[nc addObserver: self selector: @selector (togDockIcon: ) name: @" AppShouldToggleDockIcon" object: nil ];
149
146
[nc addObserver: self selector: @selector (toggleStatusItem: ) name: @" AppShouldToggleStatusItem" object: nil ];
150
147
@@ -344,65 +341,54 @@ - (void)runDelayedUIActionsAfterLaunch {
344
341
[[prefsController bookmarksController ] setAppController: self ];
345
342
[[prefsController bookmarksController ] restoreWindowFromSave ];
346
343
[[prefsController bookmarksController ] updateBookmarksUI ];
347
- [self updateNoteMenus ];
348
- [textView setupFontMenu ];
349
- [prefsController registerAppActivationKeystrokeWithTarget: self selector: @selector (toggleNVActivation: )];
350
- [notationController updateLabelConnectionsAfterDecoding ];
351
- [notationController checkIfNotationIsTrashed ];
352
- [[SecureTextEntryManager sharedInstance ] checkForIncompatibleApps ];
353
-
354
- // connect sparkle programmatically to avoid loading its framework at nib awake;
355
-
356
- if (!NSClassFromString (@" SUUpdater" )) {
357
- NSString *frameworkPath = [[[NSBundle bundleForClass: [self class ]] privateFrameworksPath ] stringByAppendingPathComponent: @" Sparkle.framework" ];
358
- if ([[NSBundle bundleWithPath: frameworkPath] load ]) {
359
- SUUpdater *updater =[NSClassFromString (@" SUUpdater" ) performSelector: @selector (sharedUpdater )];
360
- if (IsLionOrLater) {
361
- [updater setFeedURL: [NSURL URLWithString: kSparkleUpdateFeedForLions ]];
362
- }else {
363
- [updater setFeedURL: [NSURL URLWithString: kSparkleUpdateFeedForSnowLeopard ]];
364
- }
365
- [sparkleUpdateItem setTarget: updater];
366
- [sparkleUpdateItem setAction: @selector (checkForUpdates: )];
367
- NSMenuItem *siSparkle = [statBarMenu itemWithTag: 902 ];
368
- [siSparkle setTarget: updater];
369
- [siSparkle setAction: @selector (checkForUpdates: )];
370
- if (![[prefsController notationPrefs ] firstTimeUsed ]) {
371
- // don't do anything automatically on the first launch; afterwards, check every 4 days, as specified in Info.plist
372
- // SEL checksSEL = @selector(setAutomaticallyChecksForUpdates:);
373
- [updater setAutomaticallyChecksForUpdates: YES ];
374
- // [updater methodForSelector:checksSEL](updater, checksSEL, YES);
375
- }
376
- } else {
377
- NSLog (@" Could not load %@ !" , frameworkPath);
378
- }
379
- }else {
380
- NSLog (@" su" );
381
- }
382
- // add elasticthreads' menuitems
383
- NSMenuItem *theMenuItem = [[[NSMenuItem alloc ] init ] autorelease ];
384
- [theMenuItem setTarget: self ];
385
- // NSMenu *notesMenu = [[[NSApp mainMenu] itemWithTag:NOTES_MENU_ID] submenu];
386
- theMenuItem = [theMenuItem copy ];
387
- // [statBarMenu insertItem:theMenuItem atIndex:4];
388
- [theMenuItem release ];
389
- // theMenuItem = [[viewMenu itemWithTag:801] copy];
390
- // [statBarMenu insertItem:theMenuItem atIndex:11];
391
- // [theMenuItem release];
344
+ [self updateNoteMenus ];
345
+ [textView setupFontMenu ];
346
+ [prefsController registerAppActivationKeystrokeWithTarget: self selector: @selector (toggleNVActivation: )];
347
+ [notationController updateLabelConnectionsAfterDecoding ];
348
+ [notationController checkIfNotationIsTrashed ];
349
+ [[SecureTextEntryManager sharedInstance ] checkForIncompatibleApps ];
350
+
351
+ // connect sparkle programmatically to avoid loading its framework at nib awake;
352
+ // if (!NSClassFromString(@"SUUpdater")) {
353
+ // NSLog(@"su:%@ SEL:%@",sparkleUpdateItem.target,sparkleUpdateItem.action);
354
+ // }else{
355
+ NSString *frameworkPath = [[[NSBundle bundleForClass: [self class ]] privateFrameworksPath ] stringByAppendingPathComponent: @" Sparkle.framework" ];
356
+ if ([[NSBundle bundleWithPath: frameworkPath] load ]) {
357
+ SUUpdater *updater =[SUUpdater sharedUpdater ];
358
+ if (IsLionOrLater) {
359
+ [updater setFeedURL: [NSURL URLWithString: kSparkleUpdateFeedForLions ]];
360
+ }else {
361
+ [updater setFeedURL: [NSURL URLWithString: kSparkleUpdateFeedForSnowLeopard ]];
362
+ }
363
+ [sparkleUpdateItem setTarget: updater];
364
+ [sparkleUpdateItem setAction: @selector (checkForUpdates: )];
365
+ NSMenuItem *siSparkle = [statBarMenu itemWithTag: 902 ];
366
+ [siSparkle setTarget: updater];
367
+ [siSparkle setAction: @selector (checkForUpdates: )];
368
+ if (![[prefsController notationPrefs ] firstTimeUsed ]) {
369
+ // don't do anything automatically on the first launch; afterwards, check every 4 days, as specified in Info.plist
370
+ // SEL checksSEL = @selector(setAutomaticallyChecksForUpdates:);
371
+ [updater setAutomaticallyChecksForUpdates: YES ];
372
+ // [updater methodForSelector:checksSEL](updater, checksSEL, YES);
373
+ }
374
+ } else {
375
+ NSLog (@" Could not load %@ !" , frameworkPath);
376
+ }
377
+ // }
378
+ // add elasticthreads' menuitems
392
379
if (IsLeopardOrLater){
393
- // theMenuItem =[viewMenu itemWithTag:314];
394
380
[fsMenuItem setEnabled: YES ];
395
381
[fsMenuItem setHidden: NO ];
396
-
382
+
397
383
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
398
384
if (IsLionOrLater) {
399
385
// [window setCollectionBehavior:NSWindowCollectionBehaviorTransient|NSWindowCollectionBehaviorMoveToActiveSpace];
400
386
//
401
387
[window setCollectionBehavior: NSWindowCollectionBehaviorFullScreenPrimary];
402
388
// [window setCollectionBehavior:NSWindowCollectionBehaviorFullScreenAuxiliary];
403
- // [NSApp setPresentationOptions:[NSApp currentSystemPresentationOptions]|NSApplicationPresentationFullScreen];
404
-
405
-
389
+ // [NSApp setPresentationOptions:[NSApp currentSystemPresentationOptions]|NSApplicationPresentationFullScreen];
390
+
391
+
406
392
}else {
407
393
#endif
408
394
[fsMenuItem setTarget: self ];
@@ -411,7 +397,8 @@ - (void)runDelayedUIActionsAfterLaunch {
411
397
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
412
398
}
413
399
#endif
414
- theMenuItem = [fsMenuItem copy ];
400
+
401
+ NSMenuItem *theMenuItem = [fsMenuItem copy ];
415
402
[statBarMenu insertItem: theMenuItem atIndex: 14 ];
416
403
[theMenuItem release ];
417
404
}
@@ -2228,7 +2215,6 @@ - (void)dealloc {
2228
2215
[dividerShader release ];
2229
2216
[[NSStatusBar systemStatusBar ] removeStatusItem: statusItem];
2230
2217
[statusItem release ];
2231
- [cView release ];
2232
2218
[statBarMenu release ];
2233
2219
[self postTextUpdate ];
2234
2220
@@ -2467,15 +2453,7 @@ - (NSMenu *)statBarMenu{
2467
2453
return statBarMenu;
2468
2454
}
2469
2455
2470
- - (void )toggleAttachedWindow: (NSNotification *)aNotification
2471
- {
2472
- [self toggleNVActivation: [aNotification object ]];
2473
- }
2474
2456
2475
- - (void )toggleAttachedMenu: (NSNotification *)aNotification
2476
- {
2477
- [statusItem popUpStatusItemMenu: statBarMenu];
2478
- }
2479
2457
2480
2458
#pragma mark multitagging
2481
2459
@@ -2807,7 +2785,7 @@ - (IBAction)switchFullScreen:(id)sender
2807
2785
NSResponder *currentResponder = [window firstResponder ];
2808
2786
NSDictionary * options;
2809
2787
if (([[NSUserDefaults standardUserDefaults ] boolForKey: @" ShowDockIcon" ])&&(IsSnowLeopardOrLater)) {
2810
- options = [ NSDictionary dictionaryWithObjectsAndKeys: [ NSNumber numberWithInt: (NSApplicationPresentationAutoHideMenuBar | NSApplicationPresentationHideDock)], @" NSFullScreenModeApplicationPresentationOptions " , nil ] ;
2788
+ options = @{ @" NSFullScreenModeApplicationPresentationOptions " :@ (NSApplicationPresentationAutoHideMenuBar | NSApplicationPresentationHideDock)} ;
2811
2789
}else {
2812
2790
options = nil ;
2813
2791
}
@@ -3377,22 +3355,49 @@ - (void)hideDockIconAfterDelay{
3377
3355
3378
3356
[self performSelector: @selector (hideDockIcon ) withObject: nil afterDelay: 0.22 ];
3379
3357
}
3380
-
3358
+
3359
+
3360
+
3361
+ - (IBAction )statusItemAction: (id )sender{
3362
+
3363
+ NSEvent *curEv=[NSApp currentEvent ];
3364
+ if ((curEv.type ==NSEventTypeRightMouseUp)||((NSEventModifierFlagControl&curEv.modifierFlags )!=0 )) {
3365
+ [statusItem popUpStatusItemMenu: statBarMenu];
3366
+ // NSPoint og=NSMakePoint(statusItem.button.frame.origin.x, 27.f);//NSMaxY(statusItem.button.frame));
3367
+ // [self.statusMenu popUpMenuPositioningItem:nil atLocation:og inView:statusItem.button];
3368
+ }else {
3369
+ [self toggleNVActivation: sender];
3370
+ }
3371
+ }
3372
+
3373
+
3381
3374
- (void )setUpStatusBarItem{
3382
- NSRect viewFrame = NSMakeRect (0 .0f , 0 .0f , 24 .0f ,[[NSStatusBar systemStatusBar ] thickness ]);
3383
- statusItem = [[[NSStatusBar systemStatusBar ] statusItemWithLength: 24 .0f ] retain ];
3384
- cView = [[[StatusItemView alloc ] initWithFrame: viewFrame] autorelease ];
3385
- [statusItem setView: cView];
3386
-
3387
- [[NSNotificationCenter defaultCenter ]postNotificationName:@" StatusBarMenuIsAwake" object: statBarMenu];
3375
+
3376
+ NSImage *statusIcon=[NSImage imageNamed: @" nvMenuDark" ];
3377
+ [statusIcon setSize: NSMakeSize (16.0 , 16.0 )];
3378
+ [statusIcon setTemplate: YES ];
3379
+ statusItem =[[NSStatusBar systemStatusBar ] statusItemWithLength: 24 .f];
3380
+ if (!IsYosemiteOrLater) {
3381
+ statusItem.button .image =statusIcon;
3382
+ statusItem.button .target =self;
3383
+ statusItem.button .action =@selector (statusItemAction: );
3384
+ [statusItem.button sendActionOn: NSEventMaskLeftMouseUp|NSEventMaskRightMouseUp];
3385
+ }else {
3386
+ statusItem.image =statusIcon;
3387
+ statusItem.target =self;
3388
+ statusItem.action =@selector (statusItemAction: );
3389
+ [statusItem sendActionOn: NSEventMaskLeftMouseUp|NSEventMaskRightMouseUp];
3390
+ statusItem.highlightMode =YES ;
3391
+ }
3392
+ [statusItem retain ];
3393
+
3388
3394
}
3389
3395
3390
3396
- (void )toggleStatusItem: (NSNotification *)notification{
3391
3397
if (!statusItem) {
3392
3398
[self setUpStatusBarItem ];
3393
3399
}else {
3394
3400
[[NSStatusBar systemStatusBar ]removeStatusItem:statusItem];
3395
- cView=nil ;
3396
3401
statusItem=nil ;
3397
3402
}
3398
3403
}
0 commit comments