module GerminalActions
Copyright 2016 Cédric LE MOIGNE, cedlemo@gmx.com This file is part of Germinal.
Germinal is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version.
Germinal is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with Germinal. If not, see <www.gnu.org/licenses/>.
Public Class Methods
add_action_to(name, application)
click to toggle source
# File lib/actions.rb, line 26 def self.add_action_to(name, application) method_name = "generate_#{name}_action".to_sym return false unless methods.include?(method_name) action = method(method_name).call(application) application.add_action(action) end
add_actions_to(application)
click to toggle source
# File lib/actions.rb, line 68 def self.add_actions_to(application) %w(about preferences quit term_copy term_paste).each do |name| add_action_to(name, application) end end
generate_about_action(application)
click to toggle source
# File lib/actions.rb, line 33 def self.generate_about_action(application) action = generate_action("about") do |_act, _param| application.windows[0].display_about end action end
generate_action(name) { |act, param| ... }
click to toggle source
# File lib/actions.rb, line 18 def self.generate_action(name) action = Gio::SimpleAction.new(name) action.signal_connect("activate") do |act, param| yield(act, param) if block_given? end action end
generate_preferences_action(application)
click to toggle source
# File lib/actions.rb, line 40 def self.generate_preferences_action(application) action = generate_action("preferences") do |_act, _param| puts "TODO" end action end
generate_quit_action(application)
click to toggle source
# File lib/actions.rb, line 47 def self.generate_quit_action(application) action = generate_action("quit") do |_act, _param| application.quit end action end
generate_term_copy_action(application)
click to toggle source
# File lib/actions.rb, line 54 def self.generate_term_copy_action(application) action = generate_action("term_copy") do |_act, _param| application.windows[0].notebook.current.copy_clipboard end action end
generate_term_paste_action(application)
click to toggle source
# File lib/actions.rb, line 61 def self.generate_term_paste_action(application) action = generate_action("term_paste") do |_act, _param| application.windows[0].notebook.current.paste_clipboard end action end