Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 26 additions & 6 deletions FreenetTray/Base.lproj/FNSettingsWindow.xib
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<window title="Freenet Settings" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" restorable="NO" oneShot="NO" releasedWhenClosed="NO" showsToolbarButton="NO" visibleAtLaunch="NO" animationBehavior="default" id="F0z-JX-Cv5">
<windowStyleMask key="styleMask" titled="YES" closable="YES"/>
<rect key="contentRect" x="196" y="240" width="398" height="335"/>
<rect key="screenRect" x="0.0" y="0.0" width="1280" height="778"/>
<rect key="contentRect" x="196" y="240" width="398" height="368"/>
<rect key="screenRect" x="0.0" y="0.0" width="1920" height="1057"/>
<view key="contentView" wantsLayer="YES" id="se5-gp-TjO">
<rect key="frame" x="0.0" y="0.0" width="398" height="335"/>
<rect key="frame" x="0.0" y="0.0" width="398" height="368"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<button fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Nf3-Bh-Mxb">
<rect key="frame" x="44" y="299" width="336" height="18"/>
<rect key="frame" x="44" y="332" width="336" height="18"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="check" title="Start tray app when I log in" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="LpL-CZ-4IY">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
Expand Down Expand Up @@ -217,7 +217,7 @@
</connections>
</pathControl>
<button fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="mxV-EL-AaY">
<rect key="frame" x="44" y="265" width="336" height="18"/>
<rect key="frame" x="44" y="298" width="336" height="18"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="check" title="Start Freenet automatically" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="9kj-pP-3mQ">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
Expand All @@ -244,7 +244,7 @@
</connections>
</button>
<button fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="l9V-G2-CJc">
<rect key="frame" x="44" y="232" width="336" height="18"/>
<rect key="frame" x="44" y="265" width="336" height="18"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="check" title="Enable notifications" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="tU5-0T-jon">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
Expand Down Expand Up @@ -289,6 +289,26 @@
<binding destination="-2" name="enabled" keyPath="self.validNodeFound" id="YHi-0F-BaS"/>
</connections>
</button>
<button fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Nmx-YS-YIs">
<rect key="frame" x="44" y="232" width="336" height="18"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="check" title="Grayscale menu icon" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="qFU-9O-oeJ">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
<attributedString key="userComments">
<fragment content="Option title">
<attributes>
<font key="NSFont" metaFont="smallSystem"/>
<paragraphStyle key="NSParagraphStyle" alignment="natural" lineBreakMode="wordWrapping" baseWritingDirection="natural" tighteningFactorForTruncation="0.0"/>
</attributes>
</fragment>
</attributedString>
</buttonCell>
<connections>
<action selector="changeTrayIconColor:" target="-2" id="zux-Hi-ogo"/>
<binding destination="W3z-tc-WcL" name="value" keyPath="values.grayscaleIcon" id="Cbg-Yi-iQw"/>
</connections>
</button>
</subviews>
</view>
<attributedString key="userComments">
Expand Down
2 changes: 2 additions & 0 deletions FreenetTray/FNSettingsWindowController.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,6 @@

-(IBAction)uninstallFreenet:(id)sender;

-(IBAction)changeTrayIconColor:(id)sender;

@end
6 changes: 6 additions & 0 deletions FreenetTray/FNSettingsWindowController.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

#import "FNNodeController.h"

#import "TrayIcon.h"

@interface FNSettingsWindowController ()

@end
Expand Down Expand Up @@ -96,6 +98,10 @@ -(IBAction)selectNodeLocation:(id)sender {

}

-(IBAction)changeTrayIconColor:(id)sender {
[TrayIcon refreshColors];
}

-(IBAction)uninstallFreenet:(id)sender {
[FNHelpers displayUninstallAlert];
}
Expand Down
1 change: 1 addition & 0 deletions FreenetTray/TrayIcon.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
+ (void)drawRunningIcon;
+ (void)drawNotRunningIcon;
+ (void)drawHighlightedIcon;
+ (void)refreshColors;

// Generated Images
+ (NSImage*)imageOfRunningIcon;
Expand Down
58 changes: 55 additions & 3 deletions FreenetTray/TrayIcon.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@
#import "TrayIcon.h"


@interface TrayIcon ()

// color getter
+ (NSColor *)runningIconColor;
+ (NSColor *)notRunningIconColor;
+ (NSColor *)highlightedIconColor;

@end



@implementation TrayIcon

#pragma mark Cache
Expand All @@ -21,16 +32,57 @@ @implementation TrayIcon
static NSImage* _imageOfNotRunningIcon = nil;
static NSImage* _imageOfHighlightedIcon = nil;

static NSColor* _runningColor = nil;
static NSColor* _notRunningColor = nil;
static NSColor* _highlightedColor = nil;


#pragma mark Initialization

+ (void)initialize {
[TrayIcon refreshColors];
}

#pragma mark Tray colors

+ (void)refreshColors {

_imageOfRunningIcon = nil;
_imageOfNotRunningIcon = nil;
_imageOfHighlightedIcon = nil;

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];

_runningColor = [defaults boolForKey:@"grayscaleIcon"]
? [NSColor colorWithCalibratedRed: 1. green:1. blue: 1. alpha: 1.]
: [NSColor colorWithCalibratedRed: 0.161 green: 0.322 blue: 0.765 alpha: 1.];

_notRunningColor = [defaults boolForKey:@"grayscaleIcon"]
? [NSColor colorWithCalibratedRed: 0.337 green: 0.337 blue: 0.337 alpha: 1]
: [NSColor colorWithCalibratedRed: 1. green: 0. blue: 0. alpha: 1.];

_highlightedColor = [defaults boolForKey:@"grayscaleIcon"]
? [NSColor colorWithCalibratedRed: 0.663 green: 0.663 blue: 0.663 alpha: 1]
: [NSColor colorWithCalibratedRed: 1 green: 1 blue: 1 alpha: 1];
}

+ (NSColor *)runningIconColor {
return _runningColor;
}

+ (NSColor *)notRunningIconColor {
return _notRunningColor;
}

+ (NSColor *)highlightedIconColor {
return _highlightedColor;
}

#pragma mark Drawing Methods

+ (void)drawRunningIcon {
//// Color Declarations
NSColor* run = [NSColor colorWithCalibratedRed: 0.161 green: 0.322 blue: 0.765 alpha: 1];
NSColor* run = [TrayIcon runningIconColor];

//// Group
{
Expand Down Expand Up @@ -64,7 +116,7 @@ + (void)drawRunningIcon {

+ (void)drawNotRunningIcon {
//// Color Declarations
NSColor* stop = [NSColor colorWithCalibratedRed: 1 green: 0 blue: 0 alpha: 1];
NSColor* stop = [TrayIcon notRunningIconColor];

//// Group
{
Expand Down Expand Up @@ -98,7 +150,7 @@ + (void)drawNotRunningIcon {

+ (void)drawHighlightedIcon {
//// Color Declarations
NSColor* highlight = [NSColor colorWithCalibratedRed: 1 green: 1 blue: 1 alpha: 1];
NSColor* highlight = [TrayIcon highlightedIconColor];

//// Group
{
Expand Down
2 changes: 2 additions & 0 deletions FreenetTray/defaults.plist
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@
<true/>
<key>firstlaunch</key>
<true/>
<key>grayscaleIcon</key>
<false/>
</dict>
</plist>