class Object

Constants

Gdk
Gtk
RealGdk

Hack Gdk

RealGtk

Hack Gtk

Public Class Methods

main() click to toggle source
# File lib/knj/ironruby-gtk2/tests/test_ironruby_window.rb, line 38
def self.main
  RealGtk::Application.run
end
main_quit() click to toggle source
# File lib/knj/ironruby-gtk2/tests/test_ironruby_window.rb, line 42
def self.main_quit
  RealGtk::Application.quit
end
new(*paras) click to toggle source
# File lib/knj/ironruby-gtk2/gtk2.rb, line 59
def initialize(*paras)
  if Gtk.takeob
    @ob = Gtk.takeob
    if !@ob
      raise "Gtk.takeob was not set correctly: " + @ob.class.to_s
    end
    
    print "Spawning '#{self.class.to_s}' from default takeob.\n"
    
    Gtk.takeob = nil
  else
    splitted = self.class.to_s.split("::")
    realclass = "Real#{splitted.first}"
    classob = Kernel.const_get(realclass).const_get(splitted.last)
    
    if !classob
      raise "Class does not exist: " + realclass + "::" + splitted.last
    end
    
    print "Spawning '#{self.class.to_s}' from default constructor.\n"
    
    @ob = classob.new(*paras)
    
    if !@ob
      raise "Object was not spawned: #{self.class.to_s}, #{@ob.class.to_s}, #{realclass}::#{splitted.last}"
    end
  end
end

Public Instance Methods

_(key) click to toggle source

This method is used to make gettext work.

# File lib/knj/rhodes/rhodes.rb, line 189
def _(key)
  return $rhodes._(key)
end
_db() click to toggle source
# File lib/knj/includes/appserver_cli.rb, line 26
def _db
  return $db
end
_kas() click to toggle source
# File lib/knj/includes/appserver_cli.rb, line 22
def _kas
  return Appserver_cli
end
_ob() click to toggle source
# File lib/knj/includes/appserver_cli.rb, line 30
def _ob
  return $ob
end
_session() click to toggle source

This method is used to emulate web-behavior and make Knj::Locales.number_out and friends work properly.

# File lib/knj/rhodes/rhodes.rb, line 184
def _session
  return {:locale => $rhodes.locale}
end
add(widget) click to toggle source
# File lib/knj/jruby-gtk2/gtk2.rb, line 192
def add(widget)
  return @ob.add(widget.ob)
end
method_missing(*paras) click to toggle source
# File lib/knj/ironruby-gtk2/gtk2.rb, line 112
def method_missing(*paras)
  newparas = []
  first = true
  paras.each do |para|
    if first
      first = false
    else
      splitted = para.class.to_s.split("::")
      
      if splitted.first == "Gtk"
        para = para.ob
      elsif splitted.first == "Gdk"
        para = para.ob
      end
      
      newparas << para
    end
  end
  
  #print "Respond to '#{@ob.class.to_s}' -> '#{paras[0].to_s}'\n"
  if @ob.respond_to?(paras[0].to_s)
    #print "Send '#{@ob.class.to_s}' -> '#{paras[0].to_s}'\n"
    return @ob.send(paras[0], *newparas)
  end
  
  #puts @ob.methods.sort
  raise "No such method on #{self.class.name}:  #{paras[0]}"
end
pack_start(widget, arg1 = false, arg2 = false) click to toggle source
# File lib/knj/jruby-gtk2/gtk2.rb, line 196
def pack_start(widget, arg1 = false, arg2 = false)
  return @ob.pack_start(widget.ob, arg1, arg2, 0)
end
require(path) click to toggle source
# File lib/knj/includes/require_info.rb, line 6
def require(path)
  stat = require_knj(path)
  
  if stat and !Knj::REQUIRE_INFO.key?(path)
    Knj::REQUIRE_INFO[path] = {:caller => caller}
  end
  
  return stat
end
Also aliased as: require_knj
require_knj(path)
Alias for: require
signal_connect(signal, &block) click to toggle source
# File lib/knj/ironruby-gtk2/gtk2.rb, line 88
def signal_connect(signal, &block)
  classname = self.class.to_s.split("::")
  
  if Gtk.events[classname[0]] and Gtk.events[classname[0]][classname[1]] and Gtk.events[classname[0]][classname[1]][signal]
    ironevent = Gtk.events[classname[0]][classname[1]][signal]
  end
  
  if !ironevent
    raise "No iron-event '#{signal}' for '#{self.class.to_s}'"
  end
  
  print "Connected signal '#{signal}' to '#{self.class.to_s}'\n"
  
  if !@ob.respond_to?(ironevent)
    #puts @ob.methods.sort
    raise "RealGtk::" + classname[1] + " does not respond to: #{ironevent}."
  end
  
  @ob.send(ironevent) do |*args|
    print "Called signal '#{signal}' on '#{self.class.to_s}'\n"
    block.call
  end
end