Created
August 6, 2009 00:25
-
-
Save duairc/163061 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Helper | |
# ... | |
class << self | |
def included(base) | |
base.class_eval do | |
(class << self; self; end).class_eval do | |
alias_method :__new, :new | |
private :__new | |
define_method(:new) do |*args| | |
base.class_eval do | |
unless instance_methods.include? :__initialize | |
alias_method :__initialize, :initialize | |
private :__initialize | |
def initialize(*args) | |
@icons = Gtk::IconFactory.new | |
@icons.add_default | |
@stocks = {} | |
Gtk::Stock.constants.each do |c| | |
begin | |
s = c.to_sym | |
id = Gtk::Stock.const_get(s) | |
@stocks[s], = Gtk::Stock.lookup(id) | |
rescue ArgumentError then end | |
end | |
@actions = Hash.new do |hash, key| | |
value = Gtk::ActionGroup.new(key.to_s) | |
hash[key] = value | |
value.instance_eval do | |
class << self | |
def add(*actions) | |
actions.each do |action| | |
add_action(action) | |
end | |
end | |
end | |
end | |
value | |
end | |
@accels = Gtk::AccelGroup.new | |
__initialize(*args) | |
add_accel_group(@accels) | |
end | |
end | |
end | |
__new(*args) | |
end | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment