Class: KeepYourHead::Action
- Inherits:
-
Object
- Object
- KeepYourHead::Action
- Defined in:
- lib/Keepyourhead/gui/Action.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#object ⇒ Object
readonly
Returns the value of attribute object.
-
#procExecuteable ⇒ Object
Returns the value of attribute procExecuteable.
Instance Method Summary collapse
- #activate(*args) ⇒ Object
- #addActivator(widget) ⇒ Object
- #disable ⇒ Object
- #enable ⇒ Object
- #executeable? ⇒ Boolean
-
#initialize(object, name) ⇒ Action
constructor
A new instance of Action.
- #removeActivator(widget) ⇒ Object
- #updateEnable ⇒ Object
- #widgets ⇒ Object
Constructor Details
#initialize(object, name) ⇒ Action
Returns a new instance of Action.
26 27 28 29 30 31 |
# File 'lib/Keepyourhead/gui/Action.rb', line 26 def initialize(object, name) @widgets = [] @handler_id = {} @object = object @name = name end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
24 25 26 |
# File 'lib/Keepyourhead/gui/Action.rb', line 24 def name @name end |
#object ⇒ Object (readonly)
Returns the value of attribute object.
23 24 25 |
# File 'lib/Keepyourhead/gui/Action.rb', line 23 def object @object end |
#procExecuteable ⇒ Object
Returns the value of attribute procExecuteable.
22 23 24 |
# File 'lib/Keepyourhead/gui/Action.rb', line 22 def procExecuteable @procExecuteable end |
Instance Method Details
#activate(*args) ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/Keepyourhead/gui/Action.rb', line 77 def activate(*args) if self.executeable? then object.actionBefore ret = object.send("onAction#{name}", *args) object.actionAfter else ret = nil end ret end |
#addActivator(widget) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/Keepyourhead/gui/Action.rb', line 37 def addActivator() assert( @handler_id[] == nil ) @handler_id[] = case when Gtk::MenuItem .signal_connect("activate") { self.activate } when Gtk::ToolButton .signal_connect("clicked") { self.activate } else throw ExceptionNotImplemented end end |
#disable ⇒ Object
62 63 64 |
# File 'lib/Keepyourhead/gui/Action.rb', line 62 def disable .each{ |w| w.sensitive = false } end |
#enable ⇒ Object
59 60 61 |
# File 'lib/Keepyourhead/gui/Action.rb', line 59 def enable .each{ |w| w.sensitive = true } end |
#executeable? ⇒ Boolean
66 67 68 |
# File 'lib/Keepyourhead/gui/Action.rb', line 66 def executeable? (not self.procExecuteable) || self.procExecuteable.call(object) end |
#removeActivator(widget) ⇒ Object
53 54 55 56 57 |
# File 'lib/Keepyourhead/gui/Action.rb', line 53 def removeActivator() assert( @handler_id[] ) .signal_handler_disconnect @handler_id[] @handler_id.delete end |
#updateEnable ⇒ Object
69 70 71 72 73 74 75 |
# File 'lib/Keepyourhead/gui/Action.rb', line 69 def updateEnable if executeable? then enable else disable end end |
#widgets ⇒ Object
33 34 35 |
# File 'lib/Keepyourhead/gui/Action.rb', line 33 def @handler_id.keys end |