Skip to content

Instantly share code, notes, and snippets.

@theirix
Created August 26, 2012 10:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save theirix/3476769 to your computer and use it in GitHub Desktop.
Save theirix/3476769 to your computer and use it in GitHub Desktop.
GrowlTunes without menu icon
diff -r 234c34a9d09b Extras/GrowlTunes/GrowlTunes/GrowlTunesController.m
--- a/Extras/GrowlTunes/GrowlTunes/GrowlTunesController.m Wed May 30 00:37:42 2012 -0500
+++ b/Extras/GrowlTunes/GrowlTunes/GrowlTunesController.m Sun Aug 26 14:02:14 2012 +0400
@@ -97,6 +97,11 @@
}
}
+- (BOOL)hideMenuIcon
+{
+ return [[NSUserDefaults standardUserDefaults] boolForKey:@"hideMenuIcon"];
+}
+
// NSMenuItem just doesn't seem to understand. bind title and suddenly no means yes. not cool, NSMenuItem.
- (BOOL)noMeansNo
{ return NO; }
@@ -175,17 +180,20 @@
-(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
if ([keyPath isEqualToString:@"currentTrack"]) {
- [_currentTrackMenuItem setView:nil];
+ if (![self hideMenuIcon])
+ [_currentTrackMenuItem setView:nil];
if (![self.conductor isPlaying]) return;
NSDictionary* formatted = [[[self conductor] currentTrack] formattedDescriptionDictionary];
- if (!_currentTrackController) {
- self.currentTrackController = AUTORELEASE([[FormattedItemViewController alloc] init]);
+ if (![self hideMenuIcon]) {
+ if (!_currentTrackController) {
+ self.currentTrackController = AUTORELEASE([[FormattedItemViewController alloc] init]);
+ }
+ [_currentTrackController setFormattedDescription:formatted];
+ [_currentTrackMenuItem setView:[_currentTrackController view]];
}
- [_currentTrackController setFormattedDescription:formatted];
- [_currentTrackMenuItem setView:[_currentTrackController view]];
NSString* title = [formatted valueForKey:@"title"];
NSString* description = [formatted valueForKey:@"description"];
@@ -275,10 +283,12 @@
{
[self.conductor removeObserver:self forKeyPath:@"currentTrack"];
RELEASE(_iTunesConductor);
- RELEASE(_statusItemMenu);
- RELEASE(_currentTrackMenuItem);
- RELEASE(_currentTrackController);
- RELEASE(_statusItem);
+ if (![self hideMenuIcon]) {
+ RELEASE(_statusItemMenu);
+ RELEASE(_currentTrackMenuItem);
+ RELEASE(_currentTrackController);
+ RELEASE(_statusItem);
+ }
RELEASE(_formatwc);
RELEASE(_formatter);
SUPER_DEALLOC;
@@ -399,16 +409,18 @@
- (void)createStatusItem
{
- if (!_statusItem) {
- NSStatusBar* statusBar = [NSStatusBar systemStatusBar];
- _statusItem = [statusBar statusItemWithLength:NSVariableStatusItemLength];
- if (_statusItem) {
- RETAIN(_statusItem);
- [_statusItem setImage:[NSImage imageNamed:@"GrowlTunes-Template.pdf"]];
- [_statusItem setHighlightMode:YES];
- [_statusItem setAction:@selector(openMenu:)];
- [_statusItem setTarget:self];
-// [_statusItem setMenu:self.statusItemMenu];
+ if (![self hideMenuIcon]) {
+ if (!_statusItem) {
+ NSStatusBar* statusBar = [NSStatusBar systemStatusBar];
+ _statusItem = [statusBar statusItemWithLength:NSVariableStatusItemLength];
+ if (_statusItem) {
+ RETAIN(_statusItem);
+ [_statusItem setImage:[NSImage imageNamed:@"GrowlTunes-Template.pdf"]];
+ [_statusItem setHighlightMode:YES];
+ [_statusItem setAction:@selector(openMenu:)];
+ [_statusItem setTarget:self];
+ // [_statusItem setMenu:self.statusItemMenu];
+ }
}
}
}
@@ -428,9 +440,11 @@
- (void)removeStatusItem
{
- if (_statusItem) {
- [[NSStatusBar systemStatusBar] removeStatusItem:_statusItem];
- RELEASE(_statusItem);
+ if (![self hideMenuIcon]) {
+ if (_statusItem) {
+ [[NSStatusBar systemStatusBar] removeStatusItem:_statusItem];
+ RELEASE(_statusItem);
+ }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment