Skip to content

Commit

Permalink
Refactor the UI and general clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
Hadi Michel Salem committed Mar 23, 2014
1 parent 9d9aaba commit 44832dd
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 61 deletions.
11 changes: 7 additions & 4 deletions Spotify Notifications/AppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,25 @@
@property (strong, nonatomic) IBOutlet NSMenuItem *openLastFMArtist;
@property (strong, nonatomic) IBOutlet NSMenuItem *openLastFMAlbum;
@property (strong, nonatomic) IBOutlet NSMenuItem *openLastFMTrack;
@property (strong, nonatomic) IBOutlet NSPopUpButton *showNotificationsToggle;
@property (strong, nonatomic) IBOutlet NSPopUpButton *showPlayPauseNotifToggle;
@property (strong, nonatomic) IBOutlet NSPopUpButton *soundToggle;
@property (strong, nonatomic) IBOutlet NSPopUpButton *iconToggle;
@property (strong, nonatomic) IBOutlet NSPopUpButton *startupToggle;
@property (strong, nonatomic) IBOutlet NSPopUpButton *showTracksToggle;
@property (strong, nonatomic) IBOutlet NSPopUpButton *albumArtToggle;
@property (weak, nonatomic) IBOutlet MASShortcutView *shortcutView;

- (IBAction)showAuthor:(id)sender;
- (IBAction)showSource:(id)sender;
- (IBAction)showContributors:(id)sender;

- (IBAction)showLastFM:(id)sender;
- (IBAction)showPreferences:(id)sender;

- (IBAction)toggleIcons:(id)sender;
- (IBAction)toggleNotifications:(id)sender;
- (IBAction)togglePlayPauseNotif:(id)sender;
- (IBAction)toggleSound:(id)sender;
- (IBAction)toggleIcons:(id)sender;
- (IBAction)toggleStartup:(id)sender;
- (IBAction)toggleShowTracks:(id)sender;
- (IBAction)toggleAlbumArt:(id)sender;

@end
57 changes: 33 additions & 24 deletions Spotify Notifications/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,22 @@

@implementation AppDelegate

@synthesize window;
@synthesize statusBar;
@synthesize statusMenu;
@synthesize openPreferences;
@synthesize openLastFMMenu;
@synthesize openLastFMArtist;
@synthesize openLastFMAlbum;
@synthesize openLastFMTrack;

@synthesize showNotificationsToggle;
@synthesize showPlayPauseNotifToggle;
@synthesize soundToggle;
@synthesize window;
@synthesize iconToggle;
@synthesize startupToggle;
@synthesize showTracksToggle;
@synthesize shortcutView;
@synthesize albumArtToggle;
@synthesize shortcutView;

BOOL UserNotificationContentImagePropertyAvailable;

Expand Down Expand Up @@ -91,10 +93,11 @@ - (void)applicationDidFinishLaunching:(NSNotification *)notification {
[self setIcon];
[self setupGlobalShortcutForNotifications];

[showNotificationsToggle selectItemAtIndex:[self getProperty:@"notifications"]];
[showPlayPauseNotifToggle selectItemAtIndex:[self getProperty:@"playpausenotifs"]];
[soundToggle selectItemAtIndex:[self getProperty:@"notificationSound"]];
[iconToggle selectItemAtIndex:[self getProperty:@"iconSelection"]];
[startupToggle selectItemAtIndex:[self getProperty:@"startupSelection"]];
[showTracksToggle selectItemAtIndex:[self getProperty:@"showTracks"]];
[albumArtToggle selectItemAtIndex:[self getProperty:@"includeAlbumArt"]];

if (!(UserNotificationContentImagePropertyAvailable)) {
Expand Down Expand Up @@ -171,7 +174,7 @@ - (IBAction)showSource:(id)sender {

}

- (IBAction)showAuthor:(id)sender {
- (IBAction)showContributors:(id)sender {

[[NSWorkspace sharedWorkspace] openURL: [NSURL URLWithString:@"https://github.com/citruspi/Spotify-Notifications/graphs/contributors"]];

Expand Down Expand Up @@ -232,7 +235,7 @@ - (void)eventOccured:(NSNotification *)notification {
[openLastFMMenu setEnabled:YES];
}

if (![previousTrack isEqualToString:track.trackID] && [self getProperty:@"showTracks"] == 0) {
if ( [self getProperty:@"notifications"] == 0 && (![previousTrack isEqualToString:track.trackID] || [self getProperty:@"playpausenotifs"] == 0) ) {

previousTrack = track.trackID;
track.albumArt = nil;
Expand Down Expand Up @@ -263,34 +266,22 @@ - (void)eventOccured:(NSNotification *)notification {

}

- (IBAction)toggleSound:(id)sender {
- (IBAction)toggleNotifications:(id)sender {

[self saveProperty:@"notificationSound" value:(int)[soundToggle indexOfSelectedItem]];
[self saveProperty:@"notifications" value:(int)[showNotificationsToggle indexOfSelectedItem]];

}

- (IBAction)toggleShowTracks:(id)sender {
- (IBAction)togglePlayPauseNotif:(id)sender {

[self saveProperty:@"showTracks" value:(int)[showTracksToggle indexOfSelectedItem]];
[self saveProperty:@"playpausenotifs" value:(int)[showPlayPauseNotifToggle indexOfSelectedItem]];

}

- (IBAction)toggleStartup:(id)sender {

[self saveProperty:@"startupSelection" value:(int)[startupToggle indexOfSelectedItem]];
- (IBAction)toggleSound:(id)sender {

if ([self getProperty:@"startupSelection"] == 0) {

[GBLaunchAtLogin addAppAsLoginItem];

}
[self saveProperty:@"notificationSound" value:(int)[soundToggle indexOfSelectedItem]];

if ([self getProperty:@"startupSelection"] == 1) {

[GBLaunchAtLogin removeAppFromLoginItems];

}

}

- (void)setIcon {
Expand Down Expand Up @@ -330,6 +321,24 @@ - (IBAction)toggleIcons:(id)sender {

}

- (IBAction)toggleStartup:(id)sender {

[self saveProperty:@"startupSelection" value:(int)[startupToggle indexOfSelectedItem]];

if ([self getProperty:@"startupSelection"] == 0) {

[GBLaunchAtLogin addAppAsLoginItem];

}

if ([self getProperty:@"startupSelection"] == 1) {

[GBLaunchAtLogin removeAppFromLoginItems];

}

}

- (IBAction)toggleAlbumArt:(id)sender {

[self saveProperty:@"includeAlbumArt" value:(int)[albumArtToggle indexOfSelectedItem]];
Expand Down
66 changes: 33 additions & 33 deletions Spotify Notifications/en.lproj/MainMenu.xib
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,8 @@
<outlet property="openPrefences" destination="61H-gV-eIG" id="GBH-Wk-wmZ"/>
<outlet property="openPreferences" destination="61H-gV-eIG" id="6Ub-JI-ndP"/>
<outlet property="shortcutView" destination="zbi-2N-Pgf" id="H7h-c9-67G"/>
<outlet property="showTracksToggle" destination="ayC-ZL-bmW" id="pg9-8B-2yn"/>
<outlet property="showNotificationsToggle" destination="RJH-ok-8hR" id="LWi-2B-mAL"/>
<outlet property="showPlayPauseNotifToggle" destination="dKE-qO-891" id="a2L-G2-XPE"/>
<outlet property="soundToggle" destination="jB5-XW-fCl" id="Q6q-bI-u2H"/>
<outlet property="startupToggle" destination="rMI-2V-W99" id="Oc9-Ow-nwg"/>
<outlet property="statusMenu" destination="536" id="541"/>
Expand All @@ -677,7 +678,6 @@
</connections>
</menuItem>
<menuItem title="Lookup on Last.FM" enabled="NO" id="SZW-Od-Gwx">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Lookup on Last.FM" id="a8M-Lg-29f">
<items>
<menuItem title="Artist" enabled="NO" id="0cf-J0-9nm">
Expand Down Expand Up @@ -739,7 +739,7 @@
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="showAuthor:" target="494" id="MjA-8T-a8A"/>
<action selector="showContributors:" target="494" id="hXO-Ta-a3q"/>
</connections>
</button>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="nr8-cn-xxJ">
Expand Down Expand Up @@ -823,12 +823,12 @@
<popUpButton verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="jB5-XW-fCl">
<rect key="frame" x="167" y="164" width="170" height="26"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<popUpButtonCell key="cell" type="push" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="Jhk-RF-RQ5">
<popUpButtonCell key="cell" type="push" title="Enabled" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="border" tag="1" imageScaling="proportionallyDown" inset="2" selectedItem="KbY-H6-Sda" id="Jhk-RF-RQ5">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="menu"/>
<menu key="menu" title="OtherViews" id="Y57-tp-Va4">
<items>
<menuItem title="Enabled" tag="1" id="KbY-H6-Sda">
<menuItem title="Enabled" state="on" tag="1" id="KbY-H6-Sda">
<modifierMask key="keyEquivalentModifierMask"/>
</menuItem>
<menuItem title="Disabled" tag="2" id="MbK-Pk-wgP">
Expand All @@ -844,12 +844,12 @@
<popUpButton verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="rMI-2V-W99">
<rect key="frame" x="167" y="110" width="170" height="26"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<popUpButtonCell key="cell" type="push" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="8XQ-a4-UIa">
<popUpButtonCell key="cell" type="push" title="Enabled" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="border" tag="1" imageScaling="proportionallyDown" inset="2" selectedItem="ov9-Kg-xJq" id="8XQ-a4-UIa">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="menu"/>
<menu key="menu" title="OtherViews" id="nOl-F5-prg">
<items>
<menuItem title="Enabled" tag="1" id="ov9-Kg-xJq">
<menuItem title="Enabled" state="on" tag="1" id="ov9-Kg-xJq">
<modifierMask key="keyEquivalentModifierMask"/>
</menuItem>
<menuItem title="Disabled" tag="2" id="svf-mj-ToE">
Expand All @@ -874,12 +874,12 @@
<popUpButton verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="keF-Aq-QVQ">
<rect key="frame" x="167" y="83" width="170" height="26"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<popUpButtonCell key="cell" type="push" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="8EN-nE-3Wy">
<popUpButtonCell key="cell" type="push" title="Enabled" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="border" tag="1" imageScaling="proportionallyDown" inset="2" selectedItem="p4b-IH-z0r" id="8EN-nE-3Wy">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="menu"/>
<menu key="menu" title="OtherViews" id="GY0-J5-AmB">
<items>
<menuItem title="Enabled" tag="1" id="p4b-IH-z0r">
<menuItem title="Enabled" state="on" tag="1" id="p4b-IH-z0r">
<modifierMask key="keyEquivalentModifierMask"/>
</menuItem>
<menuItem title="Disabled" tag="2" id="NZc-Rd-lf5">
Expand All @@ -901,27 +901,6 @@
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<popUpButton verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="ayC-ZL-bmW">
<rect key="frame" x="167" y="191" width="170" height="26"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<popUpButtonCell key="cell" type="push" title="Disabled" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="border" tag="2" imageScaling="proportionallyDown" inset="2" selectedItem="Epx-s3-85T" id="ARj-pb-YK5">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="menu"/>
<menu key="menu" title="OtherViews" id="A27-al-LxM">
<items>
<menuItem title="Enabled" tag="1" id="J4l-ac-GAs">
<modifierMask key="keyEquivalentModifierMask"/>
</menuItem>
<menuItem title="Disabled" state="on" tag="2" id="Epx-s3-85T">
<modifierMask key="keyEquivalentModifierMask"/>
</menuItem>
</items>
</menu>
</popUpButtonCell>
<connections>
<action selector="toggleShowTracks:" target="494" id="Lq9-71-hkk"/>
</connections>
</popUpButton>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="rkW-He-mVK">
<rect key="frame" x="10" y="223" width="145" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
Expand All @@ -934,12 +913,12 @@
<popUpButton verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="RJH-ok-8hR">
<rect key="frame" x="167" y="218" width="170" height="26"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<popUpButtonCell key="cell" type="push" title="Enabled" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="border" tag="1" imageScaling="proportionallyDown" inset="2" selectedItem="eqe-Am-8Oq" id="R1J-bu-Swu">
<popUpButtonCell key="cell" type="push" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="R1J-bu-Swu">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="menu"/>
<menu key="menu" title="OtherViews" id="8g6-eQ-Xt4">
<items>
<menuItem title="Enabled" state="on" tag="1" id="eqe-Am-8Oq">
<menuItem title="Enabled" tag="1" id="eqe-Am-8Oq">
<modifierMask key="keyEquivalentModifierMask"/>
</menuItem>
<menuItem title="Disabled" tag="2" id="P6z-FO-2LM">
Expand All @@ -949,13 +928,34 @@
</menu>
</popUpButtonCell>
<connections>
<action selector="toggleShowTracks:" target="494" id="w53-Q7-0AJ"/>
<action selector="toggleNotifications:" target="494" id="N8l-IB-0X7"/>
</connections>
</popUpButton>
<customView fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="zbi-2N-Pgf" customClass="MASShortcutView">
<rect key="frame" x="169" y="61" width="165" height="19"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
</customView>
<popUpButton verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="dKE-qO-891">
<rect key="frame" x="167" y="191" width="170" height="26"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<popUpButtonCell key="cell" type="push" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" id="QNd-Gx-4yw">
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
<menu key="menu" title="OtherViews" id="QAf-HP-KO3">
<items>
<menuItem title="Enabled" id="2Ls-Uz-fDf">
<modifierMask key="keyEquivalentModifierMask"/>
</menuItem>
<menuItem title="Disabled" state="on" id="AMf-hz-DON">
<modifierMask key="keyEquivalentModifierMask"/>
</menuItem>
</items>
</menu>
</popUpButtonCell>
<connections>
<action selector="togglePlayPauseNotif:" target="494" id="Lq7-ST-cJP"/>
</connections>
</popUpButton>
</subviews>
</view>
</window>
Expand Down

0 comments on commit 44832dd

Please sign in to comment.