Top Level Namespace

Defined Under Namespace

Modules: Gtk, Kernel, Ruiby, Ruiby_default_dialog, Ruiby_dsl, Ruiby_threader Classes: AbstractComposant, DynVar, Editor, Exemple, Message, Object, PopupForm, PopupTable, Ruiby_dialog, Ruiby_gtk, Terminal

Instance Method Summary collapse

Instance Method Details

#gui_async_pending_sizeObject

return the number of traitment waiting to be executed by main window



148
# File 'lib/ruiby_gtk/ruiby_threader.rb', line 148

def gui_async_pending_size() defined?($__queue__) ? $__queue__.size : 0 end

#gui_async_wait_size(size = 0) ⇒ Object

wait that number of traitment waiting to be inferior or equal a a reference



151
152
153
154
155
156
157
158
# File 'lib/ruiby_gtk/ruiby_threader.rb', line 151

def gui_async_wait_size(size=0) 
  if ! defined?($__mainwindow__)
    puts("\n\ngui_invoke_wait() : initialize() of main windows not done!\n\n") 
    return
  end
  sleep(0.07) while $__queue__.size>size 
  sleep(0.07)
end

#gui_invoke(&blk) ⇒ Object

if threader() is done by almost one window, evaluate (instance_eval) the bloc in the context of this window async: bloc will be evaluate after the return!



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/ruiby_gtk/ruiby_threader.rb', line 94

def gui_invoke(&blk) 
  if ! defined?($__mainwindow__)
    puts("\n\ngui_invoke() : initialize() of main windows not done!\n\n") 
    return
  end
  if $__mainthread__ != Thread.current
    if defined?($__queue__)
      $__queue__.push( blk ) 
    else
      puts("\n\nThreaded invoker not initilized! : please call threader(ms) on window constructor!\n\n") 
    end
  else
    $__mainwindow__.instance_eval( &blk )
  end
end

#gui_invoke_in_window(w, &blk) ⇒ Object



109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# File 'lib/ruiby_gtk/ruiby_threader.rb', line 109

def gui_invoke_in_window(w,&blk) 
  if ! defined?($__mainwindow__)
    puts("\n\ngui_invoke() : initialize() of main windows not done!\n\n") 
    return
  end
  if $__mainthread__ != Thread.current
    if defined?($__queue__)
      $__queue__.push( [w,blk] ) 
    else
      puts("\n\nThreaded invoker not initilized! : please call threader(ms) on window constructor!\n\n") 
    end
  else
    w.instance_eval( &blk )
  end
end

#gui_invoke_wait(&blk) ⇒ Object

if threader() is done by almost one window, evaluate (instance_eval) the bloc in the context of this window sync: bloc will be evaluate before the return. Warining! : imlementation is stupid



128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# File 'lib/ruiby_gtk/ruiby_threader.rb', line 128

def gui_invoke_wait(&blk) 
  if ! defined?($__mainwindow__)
    puts("\n\ngui_invoke_wait() : initialize() of main windows not done!\n\n") 
    return
  end
  if $__mainthread__ != Thread.current
    if defined?($__queue__)
      $__queue__.push( blk ) 
      $__queue__.push( proc {} )  # dummy bloc, empty stack mean blk is done!
      n=0
      (sleep(0.05);n+=1) while $__queue__.size>0 && n<5000 # 25 secondes max!
    else
      puts("\n\nThreaded invoker not initilized! : please call threader(ms) on window constructor!\n\n") 
    end
  else
    $__mainwindow__.instance_eval( &blk )
  end
end

#make_DynClass(h = {"dummy"=>"?"}) ⇒ Object

Object binding As Struct, but data member are all DynVar see samples/dyn.rb



105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/ruiby_gtk/dyn_var.rb', line 105

def make_DynClass(h={"dummy"=>"?"})
  Class.new() do
    def initialize(x={})
      @values=self.def_init().merge(x).each_with_object({}){ |(name,v),h|  h[name]=DynVar.new(v) }
    end
    define_method(:def_init) { h.dup } 
    define_method(:keys) {  h.keys }
    define_method(:to_h) {  @values.each_with_object({}) { |(k,v),h1| h1[k]=v.value} }
    h.each do |key,value|
      define_method(key) { @values[key] }
    end
  end
end

#make_StockDynClass(h = {"dummy"=>"?"}) ⇒ Object

make_DynClass, but data are saved at exit time. see samples/dyn.rb



121
122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/ruiby_gtk/dyn_var.rb', line 121

def make_StockDynClass(h={"dummy"=>"?"})
  Class.new() do
    def initialize(oname="",x={})
      @values=self.def_init().merge(x).each_with_object({}){ |(name,v),h| h[name]=DynVar.stock(oname+"/"+name,v)}
    end
    define_method(:def_init) { h.dup } 
    define_method(:keys) {  h.keys }
    define_method(:to_h) {  @values.each_with_object({}) { |(k,v),h1| h1[k]=v.value} }
    h.each do |key,value|
      define_method(key) { @values[key] }
    end
  end
end

#make_StockDynObject(oname, h) ⇒ Object



134
# File 'lib/ruiby_gtk/dyn_var.rb', line 134

def make_StockDynObject(oname,h) make_StockDynClass(h).new(oname) end