Skip to content

Commit

Permalink
gtk: move monkey patch to lib/rabbit/gtk.rb
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Sep 13, 2024
1 parent ae638a2 commit 42e5f58
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
20 changes: 0 additions & 20 deletions lib/rabbit/action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,6 @@

require "rabbit/gtk"

module Gtk
class Action
alias _activate activate
def activate(&block)
@block = block
_activate
ensure
@block = nil
end

def block_given?
not @block.nil?
end

def call(*args, &block)
@block.call(*args, &block)
end
end
end

require 'rabbit/rabbit'
require 'rabbit/stock'
require 'rabbit/utils'
Expand Down
20 changes: 20 additions & 0 deletions lib/rabbit/gtk.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,23 @@
require "gtk3"

Gtk.init if Gtk.respond_to?(:init)

module Gtk
class Action
alias _activate activate
def activate(&block)
@block = block
_activate
ensure
@block = nil
end

def block_given?
not @block.nil?
end

def call(*args, &block)
@block.call(*args, &block)
end
end
end

0 comments on commit 42e5f58

Please sign in to comment.