OSDN Git Service

汎用ブラウザにURLロック機能を付けた
authormasakih <masakih@users.sourceforge.jp>
Wed, 17 Jun 2015 15:45:27 +0000 (00:45 +0900)
committermasakih <masakih@users.sourceforge.jp>
Wed, 17 Jun 2015 15:45:27 +0000 (00:45 +0900)
KCD/HMAppDelegate.h
KCD/HMExternalBrowserWindowController.h
KCD/HMExternalBrowserWindowController.m
KCD/ja.lproj/HMExternalBrowserWindowController.xib

index 669cfe9..0f4a4eb 100644 (file)
@@ -11,6 +11,7 @@
 #import "HMJSONViewWindowController.h"
 
 @class HMFleetInformation;
+@class HMExternalBrowserWindowController;
 
 typedef NS_ENUM(NSUInteger, HMShipType) {
     kHMAllType,
@@ -54,6 +55,8 @@ typedef NS_ENUM(NSUInteger, HMShipType) {
 
 - (IBAction)openNewBrowser:(id)sender;
 
+- (HMExternalBrowserWindowController *)createNewBrowser;
+
 #if ENABLE_JSON_LOG
 @property (strong) HMJSONViewWindowController *jsonViewWindowController;
 #endif
index 4ba6db3..9c927d0 100644 (file)
@@ -22,6 +22,7 @@
 @property (readonly) NSRect contentVisibleRect;
 @property BOOL canResize;
 @property BOOL canScroll;
+@property BOOL canMovePage;
 
 - (IBAction)clickGoBackSegment:(id)sender;
 
index 14baf98..3742a0e 100644 (file)
@@ -59,6 +59,7 @@
        
        self.canResize = YES;
        self.canScroll = YES;
+       self.canMovePage = YES;
 }
 
 - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
@@ -164,6 +165,12 @@ static BOOL sameState(BOOL a, BOOL b) {
 
 - (void)setBookmark:(HMBookmarkItem *)bookmark
 {
+       if(!self.canMovePage) {
+               HMAppDelegate *appDelegate = [[NSApplication sharedApplication] delegate];
+               HMExternalBrowserWindowController *newController = [appDelegate createNewBrowser];
+               [newController setBookmark:bookmark];
+               return;
+       }
        self.webView.mainFrameURL = bookmark.urlString;
        self.windowContentSize = bookmark.windowContentSize;
        self.canResize = bookmark.canResize;
index 801d20e..3a5abb9 100644 (file)
@@ -48,6 +48,8 @@
                                 <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
                             </textFieldCell>
                             <connections>
+                                <binding destination="-2" name="editable" keyPath="canMovePage" id="XNO-ln-Wxl"/>
+                                <binding destination="-2" name="enabled" keyPath="canMovePage" previousBinding="XNO-ln-Wxl" id="610-oc-a1H"/>
                                 <binding destination="Bwc-hB-eRh" name="value" keyPath="selection.mainFrameURL" id="vuh-9N-P9x"/>
                             </connections>
                         </textField>
@@ -86,6 +88,9 @@
                                 <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
                                 <font key="font" metaFont="system"/>
                             </buttonCell>
+                            <connections>
+                                <binding destination="-2" name="enabled" keyPath="canMovePage" id="oTe-BE-JvZ"/>
+                            </connections>
                         </button>
                         <connections>
                             <action selector="goHome:" target="-2" id="7WE-aZ-0yM"/>
                             </connections>
                         </button>
                     </toolbarItem>
+                    <toolbarItem implicitItemIdentifier="B26F6547-1AFA-461E-8849-7049CEB3CCD5" label="URL Lock" paletteLabel="URL Lock" id="3km-dZ-tV1">
+                        <nil key="toolTip"/>
+                        <size key="minSize" width="34" height="25"/>
+                        <size key="maxSize" width="34" height="32"/>
+                        <button key="view" verticalHuggingPriority="750" id="oIU-UU-oyi">
+                            <rect key="frame" x="0.0" y="14" width="34" height="25"/>
+                            <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
+                            <buttonCell key="cell" type="roundTextured" title="UR" bezelStyle="texturedRounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="EsD-AX-Gm6">
+                                <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES" changeBackground="YES" changeGray="YES"/>
+                                <font key="font" metaFont="system"/>
+                            </buttonCell>
+                            <connections>
+                                <binding destination="-2" name="value" keyPath="canMovePage" id="NNX-Bh-NfK">
+                                    <dictionary key="options">
+                                        <string key="NSValueTransformerName">NSNegateBoolean</string>
+                                    </dictionary>
+                                </binding>
+                            </connections>
+                        </button>
+                    </toolbarItem>
                 </allowedToolbarItems>
                 <defaultToolbarItems>
                     <toolbarItem reference="yBb-7R-Qfc"/>
                     <toolbarItem reference="QwU-Py-Vzr"/>
                     <toolbarItem reference="DmT-Fb-EfY"/>
+                    <toolbarItem reference="3km-dZ-tV1"/>
                     <toolbarItem reference="fQm-0j-yZH"/>
                     <toolbarItem reference="dk4-x0-fn2"/>
                 </defaultToolbarItems>