Class: Fugit::MainFrame
- Inherits:
-
Frame
- Object
- Frame
- Fugit::MainFrame
- Defined in:
- lib/fugit/main_frame.rb
Instance Method Summary collapse
-
#initialize(title, version) ⇒ MainFrame
constructor
A new instance of MainFrame.
- #setup_working_directory ⇒ Object
Constructor Details
#initialize(title, version) ⇒ MainFrame
Returns a new instance of MainFrame.
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 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/fugit/main_frame.rb', line 19 def initialize(title, version) pwd = setup_working_directory super(nil, :title => "#{pwd} - #{title}#{version == "Developer's alpha" ? " ~~ALPHA~~" : ""}", :size => [ 800, 600 ]) @app_verion = version self.repo = Grit::Repo.new(Dir.pwd) @notebook = Notebook.new(self, ID_ANY, :style => FULL_REPAINT_ON_RESIZE) @commit_panel = CommitTab.new(@notebook) @history_panel = HistroyTab.new(@notebook) @notebook.add_page(@commit_panel, "Commit", true) @notebook.add_page(@history_panel, "History") box = BoxSizer.new(VERTICAL) box.add(@notebook, 1, EXPAND) self.set_sizer(box) set_min_size(Size.new(400,300)) icon_file = File.(File.join(IconBasePath, "plus_minus.gif")) self.icon = Icon.new(icon_file, BITMAP_TYPE_GIF) evt_notebook_page_changed(@notebook) {|event| (:tab_switch)} = MenuBar.new # The "file" menu = Menu.new # Using ID_EXIT standard id means the menu item will be given the right label for the platform and language, and placed in the correct platform-specific menu - eg on OS X, in the Application's menu .append(ID_SAVE, "&Save commit\tCtrl-S", "Save commit") push = .append(ID_ANY, "&Push\tCtrl-P", "Push commits to a remote repo") refresh = .append(ID_ANY, "&Refresh\tCtrl-R", "Refresh the index list") .append(ID_EXIT, "E&xit", "Quit this program") .append(, "&File") # The "help" menu = Menu.new .append(ID_ABOUT, "&About...\tF1", "Show about dialog") .append(, "&Help") # Assign the menubar to this frame self. = (ID_SAVE) {|event| (:save_clicked)} (push) {|event| (:push_clicked)} (refresh) {|event| (:refresh)} (ID_EXIT) {|event| close} # End the application; it should finish automatically when the last window is closed. (ID_ABOUT) do |event| Wx::about_box(:name => self.title, :version => @app_verion, :description => "WxRuby-based git GUI", :developers => ['tekkub - http://tekkub.github.com']) end evt_close() do |event| (:exiting) # Notify listeners that we're closing up shop destroy exit end end |
Instance Method Details
#setup_working_directory ⇒ Object
77 78 79 80 81 82 83 84 85 86 |
# File 'lib/fugit/main_frame.rb', line 77 def setup_working_directory orig = Dir.pwd last_dir = nil while !File.exist?(".git") && last_dir != Dir.pwd last_dir = Dir.pwd Dir.chdir("..") end Dir.chdir(orig) unless File.exist?(".git") # We got to the top level without finding a git directory File.basename(Dir.pwd) end |