Skip to content

Commit

Permalink
Show alert when you launch GitNub without the nub command from a dir …
Browse files Browse the repository at this point in the history
…that isn't a git repo
  • Loading branch information
Justin Palmer committed Oct 13, 2008
1 parent 2915656 commit a0f044d
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 16 deletions.
29 changes: 15 additions & 14 deletions English.lproj/MainMenu.xib
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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>
Expand Down Expand Up @@ -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"/>
Expand Down Expand Up @@ -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>
Expand Down Expand Up @@ -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>
Expand Down Expand Up @@ -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"/>
Expand All @@ -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>
Expand All @@ -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>
Expand Down Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion GNFileSystemItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@
- (BOOL)isLeafNode;
- (NSDictionary*)attributes;
- (BOOL)isHeading;
- (BOOL)ignoredByGit:(NSString *)fileItem;
// - (BOOL)ignoredByGit:(NSString *)fileItem;
@end
20 changes: 20 additions & 0 deletions controllers/ApplicationController.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -77,6 +78,8 @@ def awakeFromNib
end
end

else
warn_user_no_repository
end
end

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
17 changes: 16 additions & 1 deletion views/GitNubWebView.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
class GitNubWebView < WebView
def awakeFromNib
self.setUIDelegate(self)
self.setPolicyDelegate(self)
end

def webView_dragDestinationActionMaskForDraggingInfo(view, info)
Expand All @@ -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.