Merge pull request #156 from catap/hide_menubar_icon

Added setting 'hide menubar icon' to panel, and implemented support at menubar app
This commit is contained in:
Alter Step
2017-10-07 21:09:00 +02:00
committed by GitHub
10 changed files with 106 additions and 12 deletions
@@ -34,5 +34,6 @@ typedef enum {
- (IBAction)preferencesMenuItemPushed:(NSMenuItem *)sender;
- (IBAction)dnscryptMenuItemPushed:(NSMenuItem *)sender;
- (IBAction)hideMenubarIconMenuItemPushed:(NSMenuItem *)sender;
@end
@@ -101,6 +101,14 @@ BOOL appUpdated = FALSE;
}
[self updateLedStatus];
NSString *hideMenuBar = [self fromCommand: @"/bin/csh" withArguments: [NSArray arrayWithObjects: @"-c", @"cd '" kDNSCRIPT_SCRIPTS_BASE_DIR @"' && ./get-hide-menubar-icon-status.sh | ./get-upstream-resolvers.sh", nil]];
if ([hideMenuBar isEqualToString: @"yes"]) {
_statusItem.visible = FALSE;
} else if ([hideMenuBar isEqualToString: @"no"]) {
_statusItem.visible = TRUE;
}
NSString *currentResolvers = [self fromCommand: @"/bin/csh" withArguments: [NSArray arrayWithObjects: @"-c", @"cd '" kDNSCRIPT_SCRIPTS_BASE_DIR @"' && ./get-current-resolvers.sh | ./get-upstream-resolvers.sh", nil]];
_statusResolversMenuItem.title = currentResolvers;
@@ -213,4 +221,17 @@ BOOL appUpdated = FALSE;
}
}
- (BOOL) setHideMenubarIconOn {
[self showSpinners];
NSString *res = [self fromCommand: @"/bin/csh" withArguments: [NSArray arrayWithObjects: @"-c", @"cd '" kDNSCRIPT_SCRIPTS_BASE_DIR @"' && ./create-ticket.sh && ./switch-hide-menubar-icon-on.sh", nil]];
(void) res;
_statusItem.visible = FALSE;
return TRUE;
}
- (IBAction)hideMenubarIconMenuItemPushed:(NSMenuItem *)sender
{
[self setHideMenubarIconOn];
}
@end
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="5056" systemVersion="13D45a" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="13196" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
<dependencies>
<deployment defaultVersion="1060" identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="5056"/>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="13196"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="NSApplication">
@@ -11,7 +11,7 @@
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<customObject id="494" customClass="AppDelegate">
<connections>
<outlet property="dnscryptMenu" destination="539" id="543"/>
@@ -45,12 +45,18 @@
<modifierMask key="keyEquivalentModifierMask"/>
</menuItem>
<menuItem isSeparatorItem="YES" id="554"/>
<menuItem title="Hide from the menu bar" keyEquivalent="h" id="558">
<menuItem title="Hide from the menu bar" keyEquivalent="h" id="yYW-Ye-NGW">
<connections>
<action selector="hideMenubarIconMenuItemPushed:" target="494" id="QDi-0b-iiy"/>
</connections>
</menuItem>
<menuItem title="Quit" keyEquivalent="q" id="558">
<connections>
<action selector="terminate:" target="-1" id="560"/>
</connections>
</menuItem>
</items>
<point key="canvasLocation" x="139" y="175.5"/>
</menu>
</objects>
</document>
@@ -42,6 +42,7 @@ typedef enum {
NSTabViewItem *_releaseNotesTabViewItem;
NSButton *_dnscryptButton;
NSButton *_hideMenubarIcon;
NSButton *_disableIPv6Button;
NSTextField *_currentResolverTextField;
@@ -65,6 +66,7 @@ typedef enum {
@property (nonatomic, strong) IBOutlet NSTabViewItem *releaseNotesTabViewItem;
@property (nonatomic, strong) IBOutlet NSButton *dnscryptButton;
@property (nonatomic, strong) IBOutlet NSButton *hideMenubarIcon;
@property (nonatomic, strong) IBOutlet NSButton *disableIPv6Button;
@property (nonatomic, strong) IBOutlet NSTextField *currentResolverTextField;
@@ -90,6 +92,7 @@ typedef enum {
- (void) mainViewDidLoad;
- (IBAction)dnscryptButtonPressed:(NSButton *)sender;
- (IBAction)hideMenubarIcon:(NSButton *)sender;
- (IBAction)disableIPv6ButtonPressed:(NSButton *)sender;
- (IBAction)providerLinkPushed:(NSButton *)sender;
- (IBAction)uninstallPushed:(NSButton *)sender;
@@ -16,6 +16,7 @@
@synthesize blockedQueryLoggingButton = _blockedQueryLoggingButton;
@synthesize dnscryptButton = _dnscryptButton;
@synthesize disableIPv6Button = _disableIPv6Button;
@synthesize hideMenubarIcon = _hideMenubarIcon;
@synthesize statusImageView = _statusImageView;
@synthesize statusText = _statusText;
@synthesize currentResolverTextField = _currentResolverTextField;
@@ -31,6 +32,7 @@ BOOL exceptionsUpdated = FALSE;
- (void) setCheckBoxesEnabled: (BOOL) enabled
{
[_dnscryptButton setEnabled: enabled];
[_hideMenubarIcon setEnabled: enabled];
[_disableIPv6Button setEnabled: enabled];
[_resolverNamesButton setEnabled: enabled];
}
@@ -59,6 +61,7 @@ BOOL exceptionsUpdated = FALSE;
NSString *res;
_dnscryptButton.state = 0;
_hideMenubarIcon.state = 0;
_disableIPv6Button.state = 0;
[_blacklistIPsTextView setPlaceHolderText: @"IP addresses to block.\n\nExamples:\n\n203.0.113.7\n198.51.100.*"];
@@ -69,6 +72,10 @@ BOOL exceptionsUpdated = FALSE;
if ([res isEqualToString: @"yes"]) {
[_dnscryptButton setState: 1];
}
res = [self fromCommand: @"/bin/csh" withArguments: [NSArray arrayWithObjects: @"-f", @"-c", @"cd '" kDNSCRYPT_SCRIPTS_BASE_DIR @"' && exec ./get-hide-menubar-icon-status.sh", nil]];
if ([res isEqualToString: @"yes"]) {
[_hideMenubarIcon setState: 1];
}
res = [self fromCommand: @"/bin/csh" withArguments: [NSArray arrayWithObjects: @"-f", @"-c", @"cd '" kDNSCRYPT_SCRIPTS_BASE_DIR @"' && exec ./get-aaaa-blocking-status.sh", nil]];
if ([res isEqualToString: @"yes"]) {
[_disableIPv6Button setState: 1];
@@ -201,6 +208,20 @@ BOOL exceptionsUpdated = FALSE;
return TRUE;
}
- (BOOL) setHideMenubarIconOn {
[self showSpinners];
NSString *res = [self fromCommand: @"/bin/csh" withArguments: [NSArray arrayWithObjects: @"-f", @"-c", @"cd '" kDNSCRYPT_SCRIPTS_BASE_DIR @"' && ./create-ticket.sh && ./switch-hide-menubar-icon-on.sh", nil]];
(void) res;
return TRUE;
}
- (BOOL) setHideMenubarIconOff {
[self showSpinners];
NSString *res = [self fromCommand: @"/bin/csh" withArguments: [NSArray arrayWithObjects: @"-f", @"-c", @"cd '" kDNSCRYPT_SCRIPTS_BASE_DIR @"' && ./create-ticket.sh && ./switch-hide-menubar-icon-off.sh", nil]];
(void) res;
return TRUE;
}
- (BOOL) setDisableIPv6On {
[self showSpinners];
NSString *res = [self fromCommand: @"/bin/csh" withArguments: [NSArray arrayWithObjects: @"-f", @"-c", @"cd '" kDNSCRYPT_SCRIPTS_BASE_DIR @"' && ./create-ticket.sh && ./switch-aaaa-blocking-on.sh", nil]];
@@ -224,6 +245,15 @@ BOOL exceptionsUpdated = FALSE;
}
}
- (IBAction)hideMenubarIcon:(NSButton *)sender
{
if (sender.state != 0) {
[self setHideMenubarIconOn];
} else {
[self setHideMenubarIconOff];
}
}
- (IBAction)disableIPv6ButtonPressed:(NSButton *)sender
{
if (sender.state != 0) {
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="11542" systemVersion="16E144f" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="13196" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
<dependencies>
<deployment version="1070" identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="11542"/>
<plugIn identifier="com.apple.WebKitIBPlugin" version="11542"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="13196"/>
<plugIn identifier="com.apple.WebKitIBPlugin" version="13196"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
@@ -20,6 +20,7 @@
<outlet property="disableIPv6Button" destination="ESJ-Kf-yNj" id="xFL-L3-vLp"/>
<outlet property="dnscryptButton" destination="179" id="363"/>
<outlet property="exceptionsTextView" destination="YvE-Lo-YVl" id="9u8-Sn-Poo"/>
<outlet property="hideMenubarIcon" destination="Y6w-zv-NQr" id="t6p-SL-hiB"/>
<outlet property="locationText" destination="e9H-pq-zb6" id="Elc-qh-Z8b"/>
<outlet property="providerLink" destination="323" id="Riq-Cc-CLa"/>
<outlet property="queryLoggingButton" destination="398" id="458"/>
@@ -186,6 +187,18 @@
</textFieldCell>
<accessibility description="Current resolver IP addresses"/>
</textField>
<button toolTip="Use the DNSCrypt protocol" misplaced="YES" id="Y6w-zv-NQr">
<rect key="frame" x="15" y="205" width="204" height="22"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="check" title="Hide menubar icon" bezelStyle="regularSquare" imagePosition="left" alignment="left" inset="2" id="yaC-i9-RQL">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system" size="14"/>
</buttonCell>
<accessibility description="Enable DNSCrypt"/>
<connections>
<action selector="hideMenubarIcon:" target="-2" id="7kK-mO-czX"/>
</connections>
</button>
</subviews>
</view>
</tabViewItem>
@@ -292,7 +305,7 @@
<rect key="frame" x="1" y="1" width="171" height="139"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textView importsGraphics="NO" richText="NO" usesFontPanel="YES" selectionGranularity="word" findStyle="panel" incrementalSearchingEnabled="YES" allowsUndo="YES" usesRuler="YES" allowsNonContiguousLayout="YES" smartInsertDelete="YES" id="Jos-8C-r8h" customClass="NSPlaceHolderTextView">
<textView importsGraphics="NO" richText="NO" verticallyResizable="YES" usesFontPanel="YES" selectionGranularity="word" findStyle="panel" incrementalSearchingEnabled="YES" allowsUndo="YES" usesRuler="YES" allowsNonContiguousLayout="YES" smartInsertDelete="YES" id="Jos-8C-r8h" customClass="NSPlaceHolderTextView">
<rect key="frame" x="0.0" y="0.0" width="171" height="139"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
@@ -325,7 +338,7 @@
<rect key="frame" x="1" y="1" width="171" height="139"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textView importsGraphics="NO" richText="NO" usesFontPanel="YES" findStyle="panel" incrementalSearchingEnabled="YES" allowsUndo="YES" usesRuler="YES" allowsNonContiguousLayout="YES" spellingCorrection="YES" smartInsertDelete="YES" id="gRF-Cw-rp9" customClass="NSPlaceHolderTextView">
<textView importsGraphics="NO" richText="NO" verticallyResizable="YES" usesFontPanel="YES" findStyle="panel" incrementalSearchingEnabled="YES" allowsUndo="YES" usesRuler="YES" allowsNonContiguousLayout="YES" spellingCorrection="YES" smartInsertDelete="YES" id="gRF-Cw-rp9" customClass="NSPlaceHolderTextView">
<rect key="frame" x="0.0" y="0.0" width="171" height="139"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
@@ -358,7 +371,7 @@
<rect key="frame" x="1" y="1" width="171" height="139"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textView importsGraphics="NO" richText="NO" usesFontPanel="YES" findStyle="panel" incrementalSearchingEnabled="YES" allowsUndo="YES" usesRuler="YES" allowsNonContiguousLayout="YES" spellingCorrection="YES" smartInsertDelete="YES" id="YvE-Lo-YVl" customClass="NSPlaceHolderTextView">
<textView importsGraphics="NO" richText="NO" verticallyResizable="YES" usesFontPanel="YES" findStyle="panel" incrementalSearchingEnabled="YES" allowsUndo="YES" usesRuler="YES" allowsNonContiguousLayout="YES" spellingCorrection="YES" smartInsertDelete="YES" id="YvE-Lo-YVl" customClass="NSPlaceHolderTextView">
<rect key="frame" x="0.0" y="0.0" width="171" height="139"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
@@ -16,6 +16,7 @@ STATES_DIR="${DNSCRYPT_VAR_BASE_DIR}/states"
DNSCRYPT_RESOLVER_NAME_FILE="${CONTROL_DIR}/dnscrypt-resolver-name"
DNSCRYPT_FILE="${CONTROL_DIR}/dnscrypt"
HIDE_MENUBAR_ICON_FILE="${CONTROL_DIR}/hide-menubar-icon"
HANDLERS_LOCK_FILE="${DNSCRYPT_VAR_RUN_BASE_DIR}/dnscrypt-handlers.lock"
DNSCRYPT_PROXY_PLUGINS_BASE_FILE="${CONTROL_DIR}/plugin"
STATIC_RESOLVERS_FILE="${CONTROL_DIR}/static-resolvers"
@@ -0,0 +1,9 @@
#! /bin/sh
. ./common.inc
if [ -e "$HIDE_MENUBAR_ICON_FILE" ]; then
echo 'yes'
else
echo 'no'
fi
@@ -0,0 +1,5 @@
#! /bin/sh
. ./common.inc
rm -f "$HIDE_MENUBAR_ICON_FILE"
@@ -0,0 +1,5 @@
#! /bin/sh
. ./common.inc
echo "libdcplugin_example_ldns_hide_menubar_icon.la" > "$HIDE_MENUBAR_ICON_FILE"