Permalink
Browse files

Show alert when you launch GitNub without the nub command from a dir …

…that isn't a git repo
  • Loading branch information...
1 parent 2915656 commit a0f044d7eba0ffe6a896274f38301086fb2564a9 @Caged committed Oct 13, 2008
Showing with 52 additions and 16 deletions.
  1. +15 −14 English.lproj/MainMenu.xib
  2. +1 −1 GNFileSystemItem.h
  3. +20 −0 controllers/ApplicationController.rb
  4. +16 −1 views/GitNubWebView.rb
View
@@ -8,8 +8,9 @@
<string key="IBDocument.HIToolboxVersion">352.00</string>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
- <integer value="589"/>
+ <integer value="29"/>
<integer value="344"/>
+ <integer value="589"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -34,7 +35,7 @@
<int key="NSWindowBacking">2</int>
<string key="NSWindowRect">{{246, 89}, {990, 682}}</string>
<int key="NSWTFlags">813170688</int>
- <string key="NSWindowTitle">GitNub</string>
+ <string key="NSWindowTitle">Gitnub</string>
<string key="NSWindowClass">TexturedWindow</string>
<nil key="NSViewClass"/>
<string key="NSWindowContentMaxSize">{3.40282e+38, 3.40282e+38}</string>
@@ -776,20 +777,20 @@
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSMenuItem" id="273211888">
<reference key="NSMenu" ref="613528524"/>
- <string key="NSTitle">GitNub</string>
+ <string key="NSTitle">Gitnub</string>
<string key="NSKeyEquiv"/>
<int key="NSKeyEquivModMask">1048576</int>
<int key="NSMnemonicLoc">2147483647</int>
<reference key="NSOnImage" ref="602984626"/>
<reference key="NSMixedImage" ref="414381303"/>
<string key="NSAction">submenuAction:</string>
<object class="NSMenu" key="NSSubmenu" id="514001054">
- <string key="NSTitle">GitNub</string>
+ <string key="NSTitle">Gitnub</string>
<object class="NSMutableArray" key="NSMenuItems">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSMenuItem" id="905696592">
<reference key="NSMenu" ref="514001054"/>
- <string key="NSTitle">About GitNub</string>
+ <string key="NSTitle">About Gitnub</string>
<string key="NSKeyEquiv"/>
<int key="NSMnemonicLoc">2147483647</int>
<reference key="NSOnImage" ref="602984626"/>
@@ -856,7 +857,7 @@
</object>
<object class="NSMenuItem" id="75149726">
<reference key="NSMenu" ref="514001054"/>
- <string key="NSTitle">Hide GitNub</string>
+ <string key="NSTitle">Hide Gitnub</string>
<string key="NSKeyEquiv">h</string>
<int key="NSKeyEquivModMask">1048576</int>
<int key="NSMnemonicLoc">2147483647</int>
@@ -894,7 +895,7 @@
</object>
<object class="NSMenuItem" id="826738325">
<reference key="NSMenu" ref="514001054"/>
- <string key="NSTitle">Quit GitNub</string>
+ <string key="NSTitle">Quit Gitnub</string>
<string key="NSKeyEquiv">q</string>
<int key="NSKeyEquivModMask">1048576</int>
<int key="NSMnemonicLoc">2147483647</int>
@@ -2762,8 +2763,8 @@
<reference ref="9"/>
<string>{{105, 155}, {990, 682}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="0" id="6"/>
- <reference ref="6"/>
+ <integer value="0" id="8"/>
+ <reference ref="8"/>
<string>{{105, 155}, {990, 682}}</string>
<reference ref="9"/>
<reference ref="9"/>
@@ -2784,12 +2785,12 @@
<string>{{736, 76}, {172, 63}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{98, 319}, {170, 63}}</string>
- <string>{{435, 829}, {186, 20}}</string>
+ <string>{{435, 829}, {185, 20}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<reference ref="9"/>
<string>{{70, 809}, {142, 20}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="0" id="8"/>
+ <reference ref="8"/>
<object class="NSColor">
<int key="NSColorSpace">1</int>
<bytes key="NSRGB">MC44MDAwMDAwMSAwLjgwMDAwMDAxIDAuODAwMDAwMDEAA</bytes>
@@ -2810,14 +2811,14 @@
<reference ref="8"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string>{{559, 736}, {194, 93}}</string>
+ <string>{{558, 736}, {194, 93}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{223, 784}, {194, 23}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string>{{556, 611}, {154, 223}}</string>
+ <string>{{514, 606}, {154, 223}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
@@ -2885,7 +2886,7 @@
<string>{{908, 93}, {64, 6}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string>{{488, 641}, {218, 193}}</string>
+ <string>{{447, 636}, {218, 193}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<reference ref="9"/>
<string>{{82, 616}, {218, 193}}</string>
View
@@ -25,5 +25,5 @@
- (BOOL)isLeafNode;
- (NSDictionary*)attributes;
- (BOOL)isHeading;
-- (BOOL)ignoredByGit:(NSString *)fileItem;
+// - (BOOL)ignoredByGit:(NSString *)fileItem;
@end
@@ -64,6 +64,7 @@ def awakeFromNib
@branch_field.cell.setBackgroundStyle(NSBackgroundStyleRaised)
@tab_panel.setDelegate(self)
+ set_window_title
setup_search_field
setup_refs_view_menu
@@ -77,6 +78,8 @@ def awakeFromNib
end
end
+ else
+ warn_user_no_repository
end
end
@@ -135,6 +138,11 @@ def active_branch
end
private
+ def set_window_title
+ name = File.basename(repository_location)
+ @window.title = name
+ end
+
def ignore_list
@ignore_list ||= lambda do
# Grit takes over ls-files so we have to run it this way
@@ -210,4 +218,16 @@ def setup_search_field
add_menu_item.call("Path", "Find commits based on a path", false)
@search_field.cell.setPlaceholderString("Search commits...")
end
+
+ def warn_user_no_repository
+ alert = NSAlert.alloc.init
+ alert.addButtonWithTitle("OK")
+ alert.setMessageText("Couldn't find a git repository")
+ alert.setInformativeText("Make sure you launch GitNub with the `nub` command line tool from a valid git repository.")
+ alert.setAlertStyle(NSCriticalAlertStyle)
+
+ if(alert.runModal == NSAlertFirstButtonReturn)
+ NSApp.terminate
+ end
+ end
end
View
@@ -1,6 +1,7 @@
class GitNubWebView < WebView
def awakeFromNib
self.setUIDelegate(self)
+ self.setPolicyDelegate(self)
end
def webView_dragDestinationActionMaskForDraggingInfo(view, info)
@@ -15,5 +16,19 @@ def performDragOperation(sender)
# str = sender.draggingPasteboard.stringForType("NSStringPboardType")
# puts NSURL.URLWithString(str).host
end
-
+
+ def webView_decidePolicyForNavigationAction_request_frame_decisionListener(webview, info, request, frame, listener)
+ puts info['WebActionNavigationTypeKey']
+
+ if info['WebActionNavigationTypeKey'].to_i == 0
+ if request.URL.to_s =~ /^file:\/\//
+ listener.use
+ else
+ listener.ignore
+ NSWorkspace.sharedWorkspace.openURL(request.URL)
+ end
+ else
+ listener.use
+ end
+ end
end

0 comments on commit a0f044d

Please sign in to comment.