Module: VimMate::Plugin::SubversionMenu::InstanceMethods

Defined in:
lib/vim_mate/plugins/subversion/lib/menu.rb

Instance Method Summary collapse

Instance Method Details

#initialize_with_svn(*args) ⇒ Object



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
# File 'lib/vim_mate/plugins/subversion/lib/menu.rb', line 12

def initialize_with_svn(*args)
  initialize_without_svn(*args)
  svn_sub_menu = Gtk::Menu.new

  svn_sub_menu.append(svn_add = Gtk::ImageMenuItem.new(Gtk::Stock::ADD))
  svn_add.signal_connect("activate") do
    menu_svn_add
  end

  svn_sub_menu.append(svn_rename = Gtk::MenuItem.new("R_ename"))
  svn_rename.signal_connect("activate") do
    menu_svn_rename
  end

  svn_sub_menu.append(svn_delete = Gtk::ImageMenuItem.new(Gtk::Stock::DELETE))
  svn_delete.signal_connect("activate") do
    menu_svn_delete
  end

  svn_sub_menu.append(svn_revert = Gtk::ImageMenuItem.new(Gtk::Stock::REVERT_TO_SAVED))
  svn_revert.signal_connect("activate") do
    menu_svn_revert
  end

  @gtk_menu.append(subversion = Gtk::MenuItem.new("S_ubversion"))
  subversion.submenu = svn_sub_menu
  @gtk_menu.show_all
end

Add the selected file to subversion



41
42
43
44
# File 'lib/vim_mate/plugins/subversion/lib/menu.rb', line 41

def menu_svn_add
  Subversion.add(@last_path)
  menu_refresh
end

Delete the selected file from subversion



79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/vim_mate/plugins/subversion/lib/menu.rb', line 79

def menu_svn_delete
  dialog = Gtk::MessageDialog.new(@parent_window.gtk_window,
                                  Gtk::MessageDialog::Flags::MODAL,
                                  Gtk::MessageDialog::Type::QUESTION,
                                  Gtk::MessageDialog::ButtonsType::YES_NO,
                                  "Do a Subversion Delete on #{File.basename(@last_path)} ?")
  dialog.set_icon_list(Icons.window_icons)
  if dialog.run == Gtk::Dialog::RESPONSE_YES
    Subversion.remove(@last_path)
  end
  dialog.destroy
  menu_refresh
end

Rename the selected file with subversion



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/vim_mate/plugins/subversion/lib/menu.rb', line 47

def menu_svn_rename
  dialog = Gtk::FileChooserDialog.new("Rename #{File.basename(@last_path)}",
                                      @parent_window.gtk_window,
                                      Gtk::FileChooser::ACTION_SAVE,
                                      nil,
                                      [Gtk::Stock::CANCEL, Gtk::Dialog::RESPONSE_CANCEL],
                                      [Gtk::Stock::SAVE, Gtk::Dialog::RESPONSE_ACCEPT])
  dialog.set_icon_list(Icons.window_icons)
  dialog.current_folder = File.dirname(@last_path)
  if dialog.run == Gtk::Dialog::RESPONSE_ACCEPT
    Subversion.move(@last_path, dialog.filename)
  end
  dialog.destroy
  menu_refresh
end

Revert the selected file in subversion



64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/vim_mate/plugins/subversion/lib/menu.rb', line 64

def menu_svn_revert
  dialog = Gtk::MessageDialog.new(@parent_window.gtk_window,
                                  Gtk::MessageDialog::Flags::MODAL,
                                  Gtk::MessageDialog::Type::QUESTION,
                                  Gtk::MessageDialog::ButtonsType::YES_NO,
                                  "Do a Subversion Revert on #{File.basename(@last_path)} ?")
  dialog.set_icon_list(Icons.window_icons)
  if dialog.run == Gtk::Dialog::RESPONSE_YES
    Subversion.revert(@last_path)
  end
  dialog.destroy
  menu_refresh
end