public
Fork of Caged/gitnub
Description: A Gitk-like application written in RubyCocoa that looks like it belongs on a Mac. See the wiki for downloads and screenshots.
Homepage: http://alternateidea.com
Clone URL: git://github.com/benstiglitz/gitnub.git
Search Repo:
commit  c9db2c13ce5beff291191d14a6130072560a5fc0
tree    62fb5efd05816825b32cd47edc0be94e6bc4dde2
parent  dbe195471fd7fe6441325d1ebcb6a64b51878828
gitnub / ApplicationController.rb
100644 63 lines (53 sloc) 1.545 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#
# ApplicationController.rb
# GitNub
#
# Created by Justin Palmer on 3/1/08.
# Copyright (c) 2008 Active Reload, LLC. All rights reserved.
#
$VERBOSE = nil
require 'rubygems'
require 'osx/cocoa'
require 'mime-types/lib/mime/types'
require 'grit/lib/grit'
require 'InfoWindowController'
 
OSX.ns_import 'ImageTextCell'
include OSX
 
REPOSITORY_LOCATION = ENV['PWD'].nil? ? '' : ENV['PWD']
 
class ApplicationController < OSX::NSObject
  ib_outlet :commits_table
  ib_outlet :commits_controller
  ib_outlet :window
  ib_outlet :main_canvas
  ib_outlet :main_view
  ib_outlet :info_button
  ib_outlet :branch_field
  
  def applicationDidFinishLaunching(sender)
    @window.makeKeyAndOrderFront(self)
  end
  
  def applicationShouldTerminateAfterLastWindowClosed(notification)
    return true
  end
  
  def awakeFromNib
    begin
      @repo = Grit::Repo.new(REPOSITORY_LOCATION)
    rescue Grit::InvalidGitRepositoryError
      return false
    end
    
    @window.delegate = self
    column = @commits_table.tableColumns[0]
    cell = ImageTextCell.alloc.init
    column.dataCell = cell
    cell.dataDelegate = @commits_controller
    
    @main_view.setFrameSize(@main_canvas.frame.size)
    @main_canvas.addSubview(@main_view)
    
    @branch_field.cell.setBackgroundStyle(NSBackgroundStyleRaised)
  end
  
  ib_action :show_info_panel
  def show_info_panel(sender)
    if @info_controller.nil?
      @info_controller = InfoWindowController.alloc.init_with_repository(@repo)
    end
    @info_controller.showWindow(self)
  end
end