Delegate for Preferences Panel is added
Change-Id: I1c2d1821626d9344e116d57b4867fe5166bb0d70
diff --git a/osx/MainMenu.xib b/osx/MainMenu.xib
index 8ee537e..e19bfba 100644
--- a/osx/MainMenu.xib
+++ b/osx/MainMenu.xib
@@ -22,6 +22,7 @@
<outlet property="forwardingSettingsView" destination="lQz-E7-PRx" id="8MT-1G-PZi"/>
<outlet property="generalSettingsView" destination="A7D-GN-X5W" id="Apc-XD-aOH"/>
<outlet property="ndnPreferences" destination="c5x-Oa-5tb" id="5qP-ZT-G5y"/>
+ <outlet property="preferencesDelegate" destination="0yn-TQ-4SC" id="OUx-zN-9bt"/>
<outlet property="preferencesPanel" destination="coQ-VU-5RU" id="Jb0-qB-W2K"/>
<outlet property="routingStatus" destination="Vc8-fu-RAY" id="GVC-zB-uSO"/>
<outlet property="securitySettingsView" destination="o3g-Q4-BEo" id="a3X-aK-fOB"/>
@@ -30,6 +31,14 @@
<outlet property="trafficMap" destination="6tC-sG-tLM" id="rxz-Jt-3au"/>
</connections>
</customObject>
+ <customObject id="0yn-TQ-4SC" userLabel="Preference Delegate" customClass="PreferenceDelegate">
+ <connections>
+ <outlet property="forwardingSettingsView" destination="lQz-E7-PRx" id="d1y-fe-mMm"/>
+ <outlet property="generalSettingsView" destination="A7D-GN-X5W" id="paQ-iM-qEx"/>
+ <outlet property="preferencesPanel" destination="coQ-VU-5RU" id="tZs-5C-1La"/>
+ <outlet property="securitySettingsView" destination="o3g-Q4-BEo" id="UDh-Kj-DYk"/>
+ </connections>
+ </customObject>
<menu id="ovl-jc-kIR">
<items>
<menuItem title="NDN disconnected" id="yhj-L6-nZL">
@@ -66,7 +75,7 @@
<menuItem title="Preferences" id="c5x-Oa-5tb">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
- <action selector="openNDNDPreferences:" target="494" id="VWY-2X-g0b"/>
+ <action selector="showPreferencesPanel:" target="0yn-TQ-4SC" id="fSq-Mk-9Hv"/>
</connections>
</menuItem>
</items>
@@ -156,17 +165,17 @@
<toolbarItem implicitItemIdentifier="NSToolbarFlexibleSpaceItem" id="NVu-QV-Pc4"/>
<toolbarItem implicitItemIdentifier="3648465F-1236-436C-88D7-002134AB1299" label="General" paletteLabel="General" tag="-1" image="NSPreferencesGeneral" id="Ppn-Fc-Ncg">
<connections>
- <action selector="openGeneralSettings:" target="494" id="iib-ep-d7d"/>
+ <action selector="openGeneralSettings:" target="0yn-TQ-4SC" id="8op-rr-lR0"/>
</connections>
</toolbarItem>
<toolbarItem implicitItemIdentifier="0FA8D11D-6C2C-43BD-94B8-3A7A8F16C193" label="Forwarding" paletteLabel="Forwarding" tag="-1" image="NSNetwork" id="wWT-fR-d9Z">
<connections>
- <action selector="openForwardingSettings:" target="494" id="0Sb-lQ-Fsd"/>
+ <action selector="openForwardingSettings:" target="0yn-TQ-4SC" id="nv8-xH-jyM"/>
</connections>
</toolbarItem>
<toolbarItem implicitItemIdentifier="40F41351-5D87-4CD1-81BF-EB61A224433D" label="Security" paletteLabel="Security" tag="-1" image="NSAdvanced" id="JtM-k1-dOw">
<connections>
- <action selector="openSecuritySettings:" target="494" id="MLk-ah-hpM"/>
+ <action selector="openSecuritySettings:" target="0yn-TQ-4SC" id="fB4-d2-txt"/>
</connections>
</toolbarItem>
</allowedToolbarItems>
@@ -192,7 +201,7 @@
<font key="font" size="14" name="LucidaGrande"/>
</buttonCell>
<connections>
- <action selector="switchSoftwareUpdates:" target="494" id="wmO-D9-xT5"/>
+ <action selector="switchSoftwareUpdates:" target="0yn-TQ-4SC" id="Gh4-nv-8N8"/>
</connections>
</button>
<button fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="pK9-GZ-bQL">
@@ -203,7 +212,7 @@
<font key="font" size="14" name="LucidaGrande"/>
</buttonCell>
<connections>
- <action selector="switchHubDiscovery:" target="494" id="I9B-EQ-nOm"/>
+ <action selector="switchHubDiscovery:" target="0yn-TQ-4SC" id="by5-Mt-5bD"/>
</connections>
</button>
</subviews>
@@ -267,10 +276,10 @@
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
</clipView>
<scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" id="l9T-JI-kUJ">
- <rect key="frame" x="1" y="118" width="419" height="16"/>
+ <rect key="frame" x="1" y="1" width="0.0" height="16"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
- <scroller key="verticalScroller" hidden="YES" verticalHuggingPriority="750" doubleValue="37" id="Ohc-CY-k3U">
+ <scroller key="verticalScroller" hidden="YES" verticalHuggingPriority="750" doubleValue="1" id="Ohc-CY-k3U">
<rect key="frame" x="-15" y="17" width="16" height="0.0"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
diff --git a/osx/menu-delegate.h b/osx/menu-delegate.h
index 485a98d..e3054e6 100644
--- a/osx/menu-delegate.h
+++ b/osx/menu-delegate.h
@@ -7,6 +7,7 @@
*/
#import <Cocoa/Cocoa.h>
+#import "preference-delegate.h"
@interface MenuDelegate : NSObject <NSApplicationDelegate>
{
@@ -33,10 +34,7 @@
IBOutlet NSView *connectionStatusView;
IBOutlet NSTextField *connectionStatusText;
- IBOutlet NSWindow *preferencesPanel;
- IBOutlet NSView *generalSettingsView;
- IBOutlet NSView *forwardingSettingsView;
- IBOutlet NSView *securitySettingsView;
+ IBOutlet PreferenceDelegate *preferencesDelegate;
}
-(void)menu:(NSMenu *)menu willHighlightItem:(NSMenuItem *)item;
@@ -44,12 +42,5 @@
-(IBAction)openDaemonStatus:(id)sender;
-(IBAction)openRoutingStatusPage:(id)sender;
-(IBAction)openTrafficMapPage:(id)sender;
--(IBAction)openNDNDPreferences:(id)sender;
--(IBAction)openGeneralSettings:(id)sender;
--(IBAction)openForwardingSettings:(id)sender;
--(IBAction)openSecuritySettings:(id)sender;
-
--(IBAction)switchSoftwareUpdates:(id)sender;
--(IBAction)switchHubDiscovery:(id)sender;
@end
diff --git a/osx/menu-delegate.mm b/osx/menu-delegate.mm
index 8660108..d92a474 100644
--- a/osx/menu-delegate.mm
+++ b/osx/menu-delegate.mm
@@ -118,52 +118,6 @@
}
}
--(IBAction)openNDNDPreferences:(id)sender
-{
- [preferencesPanel setContentView:generalSettingsView];
- [preferencesPanel makeKeyAndOrderFront:sender];
- [preferencesPanel setLevel: NSStatusWindowLevel];
-}
-
--(IBAction)openGeneralSettings:(id)sender
-{
- [preferencesPanel setContentView:generalSettingsView];
-}
-
--(IBAction)openForwardingSettings:(id)sender
-{
- [preferencesPanel setContentView:forwardingSettingsView];
-}
-
--(IBAction)openSecuritySettings:(id)sender
-{
- [preferencesPanel setContentView:securitySettingsView];
-}
-
--(IBAction)switchSoftwareUpdates:(id)sender
-{
- if ([(NSButton*)sender state] == NSOnState)
- {
- allowSoftwareUpdates = true;
- }
- else
- {
- allowSoftwareUpdates = false;
- }
-}
-
--(IBAction)switchHubDiscovery:(id)sender
-{
- if ([(NSButton*)sender state] == NSOnState)
- {
- enableHubDiscovery = true;
- }
- else
- {
- enableHubDiscovery = false;
- }
-}
-
-(void)onTick:(NSTimer *)timer
{
if (daemonStarted)
diff --git a/osx/preference-delegate.h b/osx/preference-delegate.h
new file mode 100644
index 0000000..c5efb60
--- /dev/null
+++ b/osx/preference-delegate.h
@@ -0,0 +1,29 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * @copyright See LICENCE for copyright and license information.
+ *
+ * @author Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ * @author Ilya Moiseenko <iliamo@ucla.edu>
+ */
+
+#import <Cocoa/Cocoa.h>
+
+@interface PreferenceDelegate : NSObject
+{
+ IBOutlet NSWindow *preferencesPanel;
+ IBOutlet NSView *generalSettingsView;
+ IBOutlet NSView *forwardingSettingsView;
+ IBOutlet NSView *securitySettingsView;
+}
+
+@property BOOL allowSoftwareUpdates;
+@property BOOL enableHubDiscovery;
+
+-(IBAction)showPreferencesPanel:(id)sender;
+-(IBAction)openGeneralSettings:(id)sender;
+-(IBAction)openForwardingSettings:(id)sender;
+-(IBAction)openSecuritySettings:(id)sender;
+
+-(IBAction)switchSoftwareUpdates:(id)sender;
+-(IBAction)switchHubDiscovery:(id)sender;
+@end
diff --git a/osx/preference-delegate.mm b/osx/preference-delegate.mm
new file mode 100644
index 0000000..b9495c5
--- /dev/null
+++ b/osx/preference-delegate.mm
@@ -0,0 +1,60 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * @copyright See LICENCE for copyright and license information.
+ *
+ * @author Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ * @author Ilya Moiseenko <iliamo@ucla.edu>
+ */
+
+#import "preference-delegate.h"
+
+@implementation PreferenceDelegate
+
+-(IBAction)showPreferencesPanel:(id)sender
+{
+ [preferencesPanel setContentView:generalSettingsView];
+ [preferencesPanel makeKeyAndOrderFront:sender];
+ [preferencesPanel setLevel: NSStatusWindowLevel];
+}
+
+-(IBAction)openGeneralSettings:(id)sender
+{
+ [preferencesPanel setContentView:generalSettingsView];
+}
+
+-(IBAction)openForwardingSettings:(id)sender
+{
+ [preferencesPanel setContentView:forwardingSettingsView];
+}
+
+-(IBAction)openSecuritySettings:(id)sender
+{
+ [preferencesPanel setContentView:securitySettingsView];
+}
+
+-(IBAction)switchSoftwareUpdates:(id)sender
+{
+ if ([(NSButton*)sender state] == NSOnState)
+ {
+ _allowSoftwareUpdates = true;
+ }
+ else
+ {
+ _allowSoftwareUpdates = false;
+ }
+}
+
+-(IBAction)switchHubDiscovery:(id)sender
+{
+ if ([(NSButton*)sender state] == NSOnState)
+ {
+ _enableHubDiscovery = true;
+ }
+ else
+ {
+ _enableHubDiscovery = false;
+ }
+}
+
+
+@end