Class: Arcadia

Inherits:
TkApplication show all
Includes:
Observable
Defined in:
lib/a-core.rb

Instance Attribute Summary collapse

Attributes inherited from TkApplication

#tcltk_info

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from TkApplication

#run, sys_info

Methods inherited from Application

#[], #[]=, conf, #conf, #create, del_conf, del_conf_group, instance, #load_local_config, #load_theme, #local_dir, #local_file_config, #objects, #publish, #run, sys_info, #update_local_config

Methods included from EventBus

#attach_listener, #broadcast_event, #detach_listener, #process_event

Methods included from Persistable

#append_persistent_property, #override_persistent

Methods included from Configurable

#make_value, #properties_file2hash, properties_group, #resolve_link, #resolve_properties_link

Constructor Details

#initializeArcadia

Returns a new instance of Arcadia.



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'lib/a-core.rb', line 21

def initialize
  super(
    ApplicationParams.new(
      'arcadia',
      '0.9.3',
      'conf/arcadia.conf',
      'conf/arcadia.pers'
    )
  ) 
  load_config
  if self['conf']['encoding']
    Tk.encoding=self['conf']['encoding']
  end
#    @use_splash = self['conf']['splash.show']=='yes'
#    @splash = ArcadiaAboutSplash.new if @use_splash
#    @splash.set_progress(50) if @splash
#    @splash.deiconify if @splash
#    Tk.update
  @wf = TkWidgetFactory.new
  ArcadiaDialogManager.new(self)
  ArcadiaActionDispatcher.new(self)
  ArcadiaGemsWizard.new(self)
  MonitorLastUsedDir.new
  FocusEventManager.new
  #self.load_local_config(false)
  ObjectSpace.define_finalizer($arcadia, self.class.method(:finalize).to_proc)
  publish('action.on_exit', proc{do_exit})
  #_title = "Arcadia Ruby ide :: [Platform = #{RUBY_PLATFORM}] [Ruby version = #{RUBY_VERSION}] [TclTk version = #{tcltk_info.level}]"
  _title = "Arcadia ide "
  @root = TkRoot.new(
    'background'=> self['conf']['background']
    ){
    title _title
    withdraw
    protocol( "WM_DELETE_WINDOW", $arcadia['action.on_exit'])
    iconphoto(TkPhotoImage.new('dat'=>ARCADIA_RING_GIF))
  }
  @on_event = Hash.new

  @main_menu_bar = TkMenubar.new(
    'background'=> self['conf']['background']
  ).pack('fill'=>'x')
  @mf_root = Tk::BWidget::MainFrame.new(@root,
   'background'=> self['conf']['background'],
   'height'=> 0
    ){
    menu @main_menu_bar
  }.pack(
    'anchor'=> 'center',
    'fill'=> 'both',
    'expand'=> 1
  )
  #.place('x'=>0,'y'=>0,'relwidth'=>1,'relheight'=>1)
  @mf_root.show_statusbar('none')
  #@toolbar = @mf_root.add_toolbar
  @main_toolbar = ArcadiaMainToolbar.new(self, @mf_root.add_toolbar)
  @is_toolbar_show=self['conf']['user_toolbar_show']=='yes'
  @mf_root.show_toolbar(0,@is_toolbar_show)
  @use_splash = self['conf']['splash.show']=='yes'
  @splash = ArcadiaAboutSplash.new if @use_splash
  @splash.set_progress(50) if @splash
  @splash.deiconify if @splash
  Tk.update
  @splash.next_step('..prepare')  if @splash
  prepare
  @splash.last_step('..load finish')  if @splash
  if self['conf']['geometry']
    geometry = self['conf']['geometry']
  else
    start_width = (TkWinfo.screenwidth(@root)-4)
    start_height = (TkWinfo.screenheight(@root)-20)
    if RUBY_PLATFORM =~ /mswin|mingw/ # on doze don't go below the start gar
      start_height -= 50
      start_width -= 20
    end
    geometry = start_width.to_s+'x'+start_height.to_s+'+0+0'
  end
  @root.deiconify
  @root.focus(true)
  @root.geometry(geometry)
  @root.raise
  Tk.update_idletasks
  if self['conf']['geometry.state'] == 'zoomed'
    if Arcadia.is_windows?
      @root.state('zoomed')
    else
      @root.wm_attributes('zoomed',1)
    end
  end
  #sleep(1)
  @splash.destroy  if @splash
  if @first_run # first ARCADIA ever
    Arcadia.process_event(OpenBufferEvent.new(self,'file'=>'README'))
  elsif ARGV.length > 0
    ARGV.each{|_f|
      if  $pwd != File.dirname(__FILE__) && !File.exist?(_f)
        _f = "#{$pwd}/#{_f}"
      end
      Arcadia.process_event(OpenBufferEvent.new(self,'file'=>_f)) if File.exist?(_f)
    }
  end
  Arcadia.attach_listener(self, QuitEvent)
  Arcadia.persistent("version", self['applicationParams'].version)
end

Instance Attribute Details

#layoutObject (readonly)

Returns the value of attribute layout.



19
20
21
# File 'lib/a-core.rb', line 19

def layout
  @layout
end

#wfObject (readonly)

Returns the value of attribute wf.



20
21
22
# File 'lib/a-core.rb', line 20

def wf
  @wf
end

Class Method Details

.conf_group(_path, _refresh = false) ⇒ Object



892
893
894
# File 'lib/a-core.rb', line 892

def Arcadia.conf_group(_path, _refresh=false)
  Configurable.properties_group(_path, Arcadia.instance['conf'], 'conf', _refresh)
end

.console(_sender, _args = Hash.new) ⇒ Object



854
855
856
857
# File 'lib/a-core.rb', line 854

def Arcadia.console(_sender, _args=Hash.new)
  _event = process_event(MsgEvent.new(_sender, _args))
  _event.mark
end

.dialog(_sender, _args = Hash.new) ⇒ Object



879
880
881
882
# File 'lib/a-core.rb', line 879

def Arcadia.dialog(_sender, _args=Hash.new)
  _event = process_event(DialogEvent.new(_sender, _args))  
  return _event.results[0].value if _event
end

.file_extension(_filename = nil) ⇒ Object



859
860
861
862
863
864
# File 'lib/a-core.rb', line 859

def Arcadia.file_extension(_filename=nil)
  if _filename
    _m = /(.*\.)(.*$)/.match(File.basename(_filename))
  end
  _ret = (_m && _m.length > 1)?_m[2]: nil
end

.file_icon(_file_name) ⇒ Object



967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
# File 'lib/a-core.rb', line 967

def Arcadia.file_icon(_file_name)
  _file_name = '' if _file_name.nil?
  if @@instance['file_icons'] == nil
    @@instance['file_icons'] = Hash.new 
    @@instance['file_icons']['default']= TkPhotoImage.new('dat' => FILE_ICON_DEFAULT)
  end
  _base_name= File.basename(_file_name)
  if _base_name.include?('.')
    file_dn = _base_name.split('.')[-1]
  else
    file_dn = "no_ext"
  end
  if @@instance['file_icons'][file_dn].nil?
    file_icon_name="FILE_ICON_#{file_dn.upcase}"
    begin
      if eval("defined?(#{file_icon_name})")
        @@instance['file_icons'][file_dn]= TkPhotoImage.new('dat' => eval(file_icon_name))
      else
        @@instance['file_icons'][file_dn]= @@instance['file_icons']['default']
      end
    rescue Exception
      @@instance['file_icons'][file_dn]= @@instance['file_icons']['default']
    end
  end
  @@instance['file_icons'][file_dn]
end

.finalize(id) ⇒ Object



147
148
149
# File 'lib/a-core.rb', line 147

def Arcadia.finalize(id)
  puts "\nArcadia #{id} dying at #{Time.new}"
end

.gem_available?(_gem) ⇒ Boolean

Returns:

  • (Boolean)


212
213
214
215
216
217
218
# File 'lib/a-core.rb', line 212

def Arcadia.gem_available?(_gem)
    if Gem.respond_to?(:available?)
        return Gem.available?(_gem)
    else
        return !Gem.source_index.find_name(_gem).empty?
    end
end

.is_windows?Boolean

Returns:

  • (Boolean)


939
940
941
# File 'lib/a-core.rb', line 939

def Arcadia.is_windows?
  RUBY_PLATFORM =~ /mingw|mswin/
end

.layoutObject



923
924
925
926
927
# File 'lib/a-core.rb', line 923

def Arcadia.layout
  if @@instance
      return @@instance.layout
 end
end


956
957
958
959
960
961
962
963
964
# File 'lib/a-core.rb', line 956

def Arcadia.menu_root(_menu_root_name, _menu_root=nil)
  if @@instance['menu_roots'] == nil
    @@instance['menu_roots'] = Hash.new
  end
  if _menu_root != nil
    @@instance['menu_roots'][_menu_root_name]= _menu_root
  end
  @@instance['menu_roots'][_menu_root_name]
end

.open_file_dialogObject



935
936
937
# File 'lib/a-core.rb', line 935

def Arcadia.open_file_dialog
   Tk.getOpenFile 'initialdir' => MonitorLastUsedDir.get_last_dir
end

.pers_group(_path, _refresh = false) ⇒ Object



888
889
890
# File 'lib/a-core.rb', line 888

def Arcadia.pers_group(_path, _refresh=false)
  Configurable.properties_group(_path, Arcadia.instance['pers'], 'pers', _refresh)
end

.persistent(_property, _value = nil, _immediate = false) ⇒ Object



901
902
903
904
905
906
907
908
909
910
911
912
# File 'lib/a-core.rb', line 901

def Arcadia.persistent(_property, _value=nil, _immediate=false)
  if @@instance
    if _value.nil?
      return @@instance['pers'][_property]
    else
     @@instance['pers'][_property] = _value 
   end
   if _immediate      
     @@instance.append_persistent_property(@@instance['applicationParams'].persistent_file,_property, _value )
    end
 end
end

.runner(_name) ⇒ Object



872
873
874
875
876
# File 'lib/a-core.rb', line 872

def  Arcadia.runner(_name=nil)
  if @@instance
    return @@instance['runners'][_name]  
  end
end

.runner_for_file(_filename = nil) ⇒ Object



866
867
868
869
870
# File 'lib/a-core.rb', line 866

def  Arcadia.runner_for_file(_filename=nil)
  if @@instance
    return @@instance['runners_by_ext'][Arcadia.file_extension(_filename)]  
  end
end

.style(_class) ⇒ Object



884
885
886
# File 'lib/a-core.rb', line 884

def Arcadia.style(_class)
  Configurable.properties_group(_class, Arcadia.instance['conf'])
end

.unpersistent(_property, _immediate = false) ⇒ Object



914
915
916
917
918
919
920
921
# File 'lib/a-core.rb', line 914

def Arcadia.unpersistent(_property, _immediate=false)
  if @@instance
    @@instance['pers'].delete(_property)
    if _immediate      
      # not yet supported
    end
 end
end

.wfObject



929
930
931
932
933
# File 'lib/a-core.rb', line 929

def Arcadia.wf
  if @@instance
      return @@instance.wf
 end
end

.which(_command = nil) ⇒ Object



943
944
945
946
947
948
949
950
951
952
953
954
# File 'lib/a-core.rb', line 943

def Arcadia.which(_command=nil)
  return nil if _command.nil?
  _ret = nil
  ENV['PATH'].split(File::PATH_SEPARATOR).each{|_path|
    _file = File.join(_path, _command)
    if FileTest.exist?(_file)
      _ret = _file
      break
    end
  }
  _ret
end

Instance Method Details

#can_exit?Boolean

Returns:

  • (Boolean)


731
732
733
734
# File 'lib/a-core.rb', line 731

def can_exit?
  _event = Arcadia.process_event(ExitQueryEvent.new(self, 'can_exit'=>true))
  _event.can_exit
end

#check_gems_dependences(_ext) ⇒ Object



220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
# File 'lib/a-core.rb', line 220

def check_gems_dependences(_ext)
  ret = true
  gems_property = self['conf']["#{_ext}.gems"]
  if gems_property
    gems = gems_property.split(',').collect{| g | g.strip }
    if gems && gems.length > 0
      gems.each{|gem|
        # consider gem only if it is not installed
        if !Arcadia.gem_available?(gem)
          repository_property =  self['conf']["#{_ext}.gems.#{gem}.repository"]
          events_property =  self['conf']["#{_ext}.gems.#{gem}.events"]
          args = Hash.new
          args['extension_name']=_ext
          args['gem_name']=gem
          args['gem_repository']=repository_property if repository_property
          args['gem_events']=events_property if events_property
          if events_property
            #EventWatcher.new
            events_str = events_property.split(',')
            events_str.each{|event_str|
              EventWatcherForGem.new(eval(event_str),args)
            }
          else
            @splash.withdraw  if @splash
            _event = Arcadia.process_event(NeedRubyGemWizardEvent.new(self, args))
            ret = ret &&  Arcadia.gem_available?(gem)
#              if _event && _event.results
#                ret = ret && _event.results[0].installed
#              end
            @splash.deiconify  if @splash
          end
          break if !ret
        end
      } 
    end 
  end 
  ret
end

#do_buildObject



259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
# File 'lib/a-core.rb', line 259

def do_build
  # create extensions
  Array.new.concat(@exts).each{|extension|
    if extension && ext_source_must_be_loaded?(extension)
      gems_installed = check_gems_dependences(extension)
      if !gems_installed || !ext_load(extension)
        @exts.delete(extension)
      elsif !ext_active?(extension)
        @exts.delete(extension)
      elsif ext_active?(extension)
        @splash.next_step('... creating '+extension)  if @splash
        @exts.delete(extension) unless 
          (((@exts_dip[extension] != nil && @exts_loaded.include?(@exts_dip[extension]))||@exts_dip[extension] == nil) && ext_create(extension)) 
      end
    end
  }
  begin
    _build_event = Arcadia.process_event(BuildEvent.new(self))
  rescue Exception
    ret = false
    msg = "During build event processing(#{$!.class.to_s}) : #{$!} at : #{$@.to_s}"
    ans = Tk.messageBox('icon' => 'error', 'type' => 'abortretryignore',
    'title' => "(Arcadia) Build face", 'parent' => @root,
    'message' => msg)
    if  ans == 'abort'
      raise
      exit
    elsif ans == 'retry'
      retry
    else
      Tk.update
    end
  end
end

#do_exitObject



716
717
718
719
720
721
722
723
724
725
726
727
728
729
# File 'lib/a-core.rb', line 716

def do_exit
  q1 = conf('confirm-on-exit')!='yes' || (Arcadia.dialog(self,
                      'type'=>'yes_no',
                      'msg'=>"Do you want exit?",
                      'title' => '(Arcadia) Exit',
                      'level' => 'question')=='yes')
  if q1 && can_exit?
    do_finalize
    @root.destroy
#      Tk.mainloop_exist?
#      Tk.destroy
    Tk.exit
  end
end

#do_finalizeObject



847
848
849
850
851
852
# File 'lib/a-core.rb', line 847

def do_finalize
  self.save_layout
  _event = Arcadia.process_event(FinalizeEvent.new(self))
  update_local_config
  self.override_persistent(self['applicationParams'].persistent_file, self['pers'])
end

#ext_active?(_name) ⇒ Boolean

Returns:

  • (Boolean)


151
152
153
154
# File 'lib/a-core.rb', line 151

def ext_active?(_name)
return (self['conf'][_name+'.active'] != nil && self['conf'][_name+'.active']=='yes')||
     	  (self['conf'][_name+'.active'] == nil)
end

#ext_create(_extension) ⇒ Object



339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
# File 'lib/a-core.rb', line 339

def ext_create(_extension)
  ret = true
  begin
    class_name = self['conf'][_extension+'.class']
    if class_name.strip.length > 0
      klass = nil
      begin
        klass = eval(class_name)
      rescue => e
        puts 'does an extension class have the wrong name associated with it, in its conf file?, or is not listing the right .rb file?'
        raise e
      end
      publish(_extension, klass.new(self, _extension))
    end
  rescue Exception,LoadError
    ret = false
    msg = "Loading \"#{_extension}\" (#{$!.class.to_s}) : #{$!} at : #{$@.to_s}"
    ans = Tk.messageBox('icon' => 'error', 'type' => 'abortretryignore',
    'title' => "(Arcadia) Extensions '#{_extension}'", 'parent' => @root,
    'message' => msg)
    if  ans == 'abort'
      raise
      exit
    elsif ans == 'retry'
      retry
    else
      Tk.update
    end
  end
  ret
end

#ext_load(_extension) ⇒ Object



313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
# File 'lib/a-core.rb', line 313

def ext_load(_extension)
  ret = true
  begin
    source = self['conf'][_extension+'.require']
    if source.strip.length > 0
     require "#{Dir.pwd}/#{source}" 
    end
    @exts_loaded << _extension
  rescue Exception,LoadError
    ret = false
    msg = "Loading \"#{_extension}\" (#{$!.class.to_s}) : #{$!} at : #{$@.to_s}"
    ans = Tk.messageBox('icon' => 'error', 'type' => 'abortretryignore',
    'title' => "(Arcadia) Extensions '#{_extension}'", 'parent' => @root,
    'message' => msg)
    if  ans == 'abort'
      raise
      exit
    elsif ans == 'retry'
      retry
    else
      Tk.update
    end
  end
  ret
end

#ext_method(_extension, _method) ⇒ Object



371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
# File 'lib/a-core.rb', line 371

def ext_method(_extension, _method)
  begin
    self[_extension].send(_method)
  rescue Exception
    msg = _method.to_s+' "'+_extension.to_s+'"'+" ("+$!.class.to_s+") "+" : "+$! + "\n at : "+$@.to_s
    ans = Tk.messageBox('icon' => 'warning', 'type' => 'abortretryignore',
    'title' => '(Arcadia) Extensions', 'parent' => @root,
    'message' => msg)
    if ans == 'abort'
      raise
      exit
    elsif ans == 'retry'
      retry
    else
      Tk.update
    end
  end
end

#ext_source_must_be_loaded?(_name) ⇒ Boolean

Returns:

  • (Boolean)


156
157
158
159
160
161
162
163
164
165
166
167
# File 'lib/a-core.rb', line 156

def ext_source_must_be_loaded?(_name)
  ret = ext_active?(_name)
  if !ret
  @exts_dip.each{|key,val|
    if val == _name
      ret = ret || ext_active?(key)
    end
    break if ret
  }
  end
  ret
end

#geometry_from_a(_a = nil) ⇒ Object



754
755
756
757
# File 'lib/a-core.rb', line 754

def geometry_from_a(_a=nil)
  return "0x0+0+0" if _a.nil? || _a.length < 4
  "#{_a[0]}x#{_a[1]}+#{_a[2]}+#{_a[3]}"
end

#geometry_refine(_geometry) ⇒ Object



736
737
738
739
740
741
742
743
744
745
# File 'lib/a-core.rb', line 736

def geometry_refine(_geometry)
  begin
    a = geometry_to_a(_geometry)
    toolbar_height = @root.winfo_height-@root.winfo_screenheight
    a[3] = (a[3].to_i - toolbar_height).to_s
    geometry_from_a(a)
  rescue
    return _geometry
  end
end

#geometry_to_a(_geometry = nil) ⇒ Object



747
748
749
750
751
752
# File 'lib/a-core.rb', line 747

def geometry_to_a(_geometry=nil)
  return if _geometry.nil?
  wh,x,y=_geometry.split('+')
  w,h=wh.split('x')
  [w,h,x,y]
end

#init_layoutObject



390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
# File 'lib/a-core.rb', line 390

def init_layout
  @layout = ArcadiaLayout.new(self, @mf_root.get_frame)
  suf = "layout.split"
  elems = self['conf'][suf]
  return if elems.nil?
  if elems.strip.length > 0
    groups = elems.split(',')
    groups.each{|group|
      if group
        suf1 = suf+'.'+group
        begin
          property = self['conf'][suf1]
          #next if property.nil?
          c = property.split('c')
          if c && c.length == 2
            pt = c[0].split('.')
            perc = c[1].include?('%')
            w = c[1].sub('%','')
            if perc 
              @layout.add_cols_perc(pt[0].to_i, pt[1].to_i, w.to_i)
            else
              @layout.add_cols(pt[0].to_i, pt[1].to_i, w.to_i)
            end
          else
            r = property.split('r')
            if r && r.length == 2
              pt = r[0].split('.')
              perc = r[1].include?('%')
              w = r[1].sub('%','')
              if perc 
                @layout.add_rows_perc(pt[0].to_i, pt[1].to_i, w.to_i)
              else
                @layout.add_rows(pt[0].to_i, pt[1].to_i, w.to_i)
              end
            end
          end
          
        rescue Exception
          msg = "Loading layout: (#{$!.class.to_s} : #{$!.to_s} at : #{$@.to_s})"
          if Arcadia.dialog(self, 'type'=>'ok_cancel', 'level'=>'error','title' => '(Arcadia) Layout', 'msg'=>msg)=='cancel'
            raise
            exit
          else
            Tk.update
          end
        end
      end
    }
  else
    @layout.add_mono_panel
  end
  @layout.add_headers
end

#load_configObject



444
445
446
447
448
449
450
451
452
453
# File 'lib/a-core.rb', line 444

def load_config
  self.load_local_config(false)
  # local config can contain loading conditions
  self.load_exts_conf
  self.load_local_config
  self.load_theme(self['conf']['theme'])
  self.resolve_properties_link(self['conf'],self['conf'])
  self.resolve_properties_link(self['conf_without_local'],self['conf_without_local'])
  self.load_sysdefaultproperty
end

#load_exts_confObject



169
170
171
172
173
174
175
# File 'lib/a-core.rb', line 169

def load_exts_conf
		@exts = Array.new
		@exts_i = Array.new
		@exts_dip = Hash.new
		@exts_loaded = Array.new
		load_exts_conf_from('ext')
end

#load_exts_conf_from(_dir = '', _ext_root = nil) ⇒ Object



177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
# File 'lib/a-core.rb', line 177

def load_exts_conf_from(_dir='',_ext_root=nil)
		dirs = Array.new
		files = Dir["#{_dir}/*"].concat(Dir[ENV["HOME"]+"/.arcadia/#{_dir}/*"]).sort
		files.each{|f|
			 dirs << f if File.stat(f).directory? && FileTest.exist?(f+'/'+File.basename(f)+'.conf')
		}
		dirs.each{|ext_dir|
	    conf_hash = self.properties_file2hash(ext_dir+'/'+File.basename(ext_dir)+'.conf') 
   	 conf_hash2 = Hash.new
   	 name = conf_hash['name']
     	 conf_hash.each{|key, value|
         var_plat = key.split(':')
         if var_plat.length > 1
           new_key = var_plat[0] + ':' + name + '.' + var_plat[1]
         else
           begin
            new_key = name+'.'+key
           rescue => e
            puts 'is an extension missing a name?'
            raise e
           end
         end	
     	   conf_hash2[new_key]= value
     	 }
     @exts << name
     if _ext_root
       @exts_dip[name] = _ext_root
     end	 	
  		 self['conf'].update(conf_hash2)	
  		 self['origin_conf'].update(conf_hash2)	
  		 self['conf_without_local'].update(conf_hash2)	
  		 load_exts_conf_from("#{ext_dir}/ext",name)
		}
end

#load_key_binding(_ext = '') ⇒ Object



623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
# File 'lib/a-core.rb', line 623

def load_key_binding(_ext='')
  return unless _ext && ext_active?(_ext)
  if _ext.length > 0 
    if self[_ext]
      _self_on_eval = self[_ext]
    else
      _self_on_eval = self
    end
    suf = "#{_ext}.keybinding"
  else
    _self_on_eval = self
    suf = "keybinding"
  end
  keybs=Arcadia.conf_group(suf)
  keybs.each{|k,v|
    value = v.strip
    key_dits = k.split('[')
    next if k.length == 0
    key_event=key_dits[0]
    if key_dits[1]
      key_sym=key_dits[1][0..-2]
    end
    @root.bind_append(key_event){|e|
      if key_sym == e.keysym
        Arcadia.process_event(_self_on_eval.instance_eval(value))
      end
    }
  }
end

#load_maximizedObject



294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
# File 'lib/a-core.rb', line 294

def load_maximized
  lm = self['conf']['layout.maximized']
  if lm    
    ext,index=lm.split(',')
    maxed = false
    if ext && index
      ext = ext.strip
      i=index.strip.to_i
      @exts_i.each{|e|
        if e.conf('name')==ext && !maxed
          e.maximize(i)
          maxed=true
          break
        end
      }    
    end
  end
end

#load_runnersObject



526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
# File 'lib/a-core.rb', line 526

def load_runners
  self['runners'] = Hash.new
  self['runners_by_ext'] = Hash.new
  mr = Arcadia.menu_root('runcurr')
  return if mr.nil?

  insert_runner_item = proc{|name, run|
    if run[:file_exts]
      run[:file_exts].split(',').each{|ext|
        self['runners_by_ext'][ext.strip.sub('.','')]=run
      }
    end
    if run[:runner] && self['runners'][run[:runner]]
      run = Hash.new.update(self['runners'][run[:runner]]).update(run)
      #self['runners'][name]=run
    end
    _run_title = run[:title]
    run[:title] = nil
    run[:runner_name] = name
    _command = proc{
        _event = Arcadia.process_event(
          RunCmdEvent.new(self, run)
        )
    }
    mr.insert('0', 
      :command ,{
        :image => Arcadia.file_icon(run[:file_exts]),
        :label => _run_title,
        :compound => 'left',
        :command => _command
      }
    )
  }

  insert_runner_instance_item = proc{|name, run|
    if run[:runner] && self['runners'][run[:runner]]
      run = Hash.new.update(self['runners'][run[:runner]]).update(run)
      #self['runners'][name]=run
    end
    _run_title = run[:title]
    run[:title] = nil
    run[:runner_name] = name
    _command = proc{
        _event = Arcadia.process_event(
          RunCmdEvent.new(self, run)
        )
    }
    mr.insert('0', 
      :command ,{
        :image => Arcadia.file_icon(run[:file_exts]),
        :label => _run_title,
        :compound => 'left',
        :command => _command
      }
    )
  }

  # conf runner
  runs=Arcadia.conf_group('runners')
  mr.insert('0', :separator) if runs && !runs.empty?

  runs.each{|name, hash_string|
    self['runners'][name]=eval hash_string
  }
  
  self['runners'].each{|name, run|
    insert_runner_item.call(name, run)
  }

  # pers runner instance
  runs=Arcadia.pers_group('runners')
  mr.insert('0', :separator) if runs && !runs.empty?
  pers_runner = Hash.new
  runs.each{|name, hash_string|
    begin
      pers_runner[name]=eval hash_string
    rescue Exception => e
      p  "Loading runners : probably bud runner conf '#{hash_string}' : #{e.message}"
      Arcadia.unpersistent("runners.#{name}")
    end
  }
  
  pers_runner.each{|name, run|
    insert_runner_instance_item.call(name, run)
  }
end

#load_sysdefaultpropertyObject



455
456
457
458
459
460
461
462
463
464
465
466
467
# File 'lib/a-core.rb', line 455

def load_sysdefaultproperty
#    colors = Hash.new
#    colors['background']=self['conf']['background']
#    colors['foreground']=self['conf']['foreground']
#    
#    TkPalette.set(colors)

  Tk.tk_call "eval","option add *background #{self['conf']['background']}"
  Tk.tk_call "eval","option add *foreground #{self['conf']['foreground']}"
  #Tk.tk_call "eval","option add *font #{self['conf']['font']}"
  Tk.tk_call "eval","option add *activebackground #{self['conf']['activebackground']}"
  Tk.tk_call "eval","option add *activeforeground #{self['conf']['activeforeground']}"
end

#load_user_control(_user_control, _ext = '', _pre = '') ⇒ Object



653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
# File 'lib/a-core.rb', line 653

def load_user_control(_user_control, _ext='', _pre='')
  return unless _ext && ext_active?(_ext)
  
  if _ext.length > 0 && self[_ext]
    _self_on_eval = self[_ext]
    suf = "#{_ext}.#{_user_control.class::SUF}"
  else
    _self_on_eval = self
    suf = "#{_user_control.class::SUF}"
  end
  if _pre.length > 0
    suf = "#{_pre}.#{suf}"
  end
  contexts = self['conf']["#{suf}.contexts"]
  contexts_caption = self['conf']["#{suf}.contexts.caption"]
  return if contexts.nil?
  groups = contexts.split(',')
  groups_caption = contexts_caption.split(',') if contexts_caption
  groups.each_with_index{|group, gi|
    if group
      suf1 = suf+'.'+group
      begin
        context_path = self['conf']["#{suf1}.context_path"]
        rif = self['conf']["#{suf1}.rif"] == nil ? 'main': self['conf']["#{suf1}.rif"]
        context_underline = self['conf']["#{suf1}.context_underline"]
        items = self['conf'][suf1].split(',')
        items.each{|item|
          suf2 = suf1+'.'+item
          disabled = !self['conf']["#{suf2}.disabled"].nil?
          iprops=Arcadia.conf_group(suf2)
          item_args = Hash.new
          
          iprops.each{|k,v|
            item_args[k]= make_value(_self_on_eval, v)
          }

          item_args['name'] = item if item_args['name'].nil?
          item_args['rif'] = rif
          item_args['context'] = group
          item_args['context_path'] = context_path
          item_args['context_caption'] = groups_caption[gi] if groups_caption
          item_args['context_underline'] = context_underline.strip.to_i if context_underline
          i = _user_control.new_item(_self_on_eval, item_args)
          i.enable=false if disabled
        }
      rescue Exception
        msg = "Loading #{groups} ->#{items} (#{$!.class.to_s} : #{$!.to_s} at : #{$@.to_s})"
        if Arcadia.dialog(self, 
          'type'=>'ok_cancel', 
          'title' => "(Arcadia) #{_user_control.class::SUF}", 
          'msg'=>msg,
          'level'=>'error')=='cancel'
          raise
          exit
        else
          Tk.update
        end
      end
    end
  }
  
end

#manage_runnersObject



613
614
615
616
617
618
619
620
621
# File 'lib/a-core.rb', line 613

def manage_runners
  if !@runm
    @runm = RunnerManager.new(Arcadia.layout.root)
    @runm.on_close=proc{@runm.hide}
  end
  @runm.show
  @runm.load_items 

end

#on_quit(_event) ⇒ Object



126
127
128
# File 'lib/a-core.rb', line 126

def on_quit(_event)
  self.do_exit
end

#prepareObject



469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
# File 'lib/a-core.rb', line 469

def prepare
  super
  @splash.next_step('...initialize')  if @splash
  @splash.next_step  if @splash
  #self.load_libs
  @splash.next_step  if @splash
  @splash.next_step('... load extensions')  if @splash
  #load_config
  init_layout
  publish('buffers.code.in_memory',Hash.new)
  publish('action.load_code_from_buffers', proc{TkBuffersChoise.new})
  publish('output.action.run_last', proc{$arcadia['output'].run_last})
  publish('main.action.open_file', proc{self['editor'].open_file(Arcadia.open_file_dialog)})
  @splash.next_step('... load obj controller')  if @splash
  @splash.next_step('... load editor')  if @splash
  publish('main.action.new_file',proc{$arcadia['editor'].open_buffer()})
  @splash.next_step('... load actions')  if @splash
  #provvisorio 
  @keytest = KeyTest.new
  @keytest.on_close=proc{@keytest.hide}
  @keytest.hide
  @keytest.title("Keys test")
  publish('action.test.keys', proc{@keytest.show})
  publish('action.get.font', proc{Tk::BWidget::SelectFont::Dialog.new.create})
  @splash.next_step  if @splash
  publish('action.show_about', proc{ArcadiaAboutSplash.new.deiconify})
#    publish('main.menu', @main_menu)
  @main_menu = ArcadiaMainMenu.new(@main_menu_bar)
  self.do_build
  #publish('main.menu', ArcadiaMainMenu.new(@main_menu))
  @splash.next_step  if @splash
  publish('objic.action.raise_active_obj',
  proc{
  		InspectorContract.instance.raise_active_toplevel(self)
  }
  )
  @splash.next_step('... toolbar buttons ')  if @splash
  #@main_toolbar.load_toolbar_buttons
  
  #load user controls
  #Arcadia control
  load_user_control(@main_toolbar)
  load_user_control(@main_menu)
  #Extension control
  load_key_binding
  @exts.each{|ext|
    @splash.next_step("... load #{ext} user controls ")  if @splash
    load_user_control(@main_menu, ext)
    load_user_control(@main_toolbar, ext)
    load_key_binding(ext)
  }
  load_user_control(@main_menu,"","e")
  load_user_control(@main_toolbar,"","e")
  load_runners
  #@layout.build_invert_menu
end

#register(_ext) ⇒ Object



130
131
132
# File 'lib/a-core.rb', line 130

def register(_ext)
  @exts_i << _ext
end

#save_layoutObject



759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
# File 'lib/a-core.rb', line 759

def save_layout
  self['conf']['geometry']= geometry_refine(TkWinfo.geometry(@root))
  begin
    if Arcadia.is_windows?
      self['conf']['geometry.state'] = @root.state.to_s
    else
      if @root.wm_attributes('zoomed') == '1'
        self['conf']['geometry.state']='zoomed'
      else
        self['conf']['geometry.state']='normal'
      end
    end
  rescue
    self['conf']['geometry.state']='not_supported'
  end
  Arcadia.del_conf_group(self['conf'],'layout')
  # resizing
  @exts_i.each{|e|
    found = false
    if e.conf('frames')
      frs = e.conf('frames').split(',') 
    else 
      frs = Array.new
    end
    frs.each_index{|i|
      if e.maximized?(i)
        self['conf']['layout.maximized']="#{e.conf('name')},#{i}"
        e.resize(i)
        found=true
        break
      end
    } 
    break if found
  }
  # layouts
  splits,doms,r,c = @layout.dump_geometry
  header = ""
  splits.each_index{|i|
    header << i.to_s
    header << ',' if i < splits.length-1
  }
  self['conf']['layout.split']= header
  splits.each_with_index{|sp,i|
    self['conf']["layout.split.#{i}"]=sp
  }
  # domains
  @exts_i.each{|e|
    if e.conf('frames')
      frs = e.conf('frames').split(',') 
    else 
      frs = Array.new
    end
    str_frames=''
    frs.each_index{|i|
      f = e.frame(i,false)
      if f
        ff = f.hinner_frame
        frame = ff.frame if ff
        if frame && TkWinfo.parent(frame).instance_of?(Tk::BWidget::NoteBook)
          frame=TkWinfo.parent(TkWinfo.parent(frame))
        elsif frame.nil?
          if str_frames.length > 0
            str_frames << ','
          end
          str_frames << '-1.-1'
        end
        if doms[frame]
          if str_frames.length > 0
            str_frames << ','
          end
          str_frames << doms[frame]
        end
      else
      end
    }
    if str_frames.length > 0
      self['conf']["#{e.conf('name')}.frames"]=str_frames
 #     p "#{e.conf('name')}.frames=#{str_frames}"
    end
  }
  # toolbar
  if @is_toolbar_show
    self['conf']['user_toolbar_show']='yes'
  else
    self['conf']['user_toolbar_show']='no'
  end
end

#show_hide_toolbarObject



134
135
136
137
138
139
140
141
142
143
144
# File 'lib/a-core.rb', line 134

def show_hide_toolbar
  if @is_toolbar_show
  		@mf_root.show_toolbar(0,false)
  		@is_toolbar_show = false
  else
  		@mf_root.show_toolbar(0,true)
  		Tk.update
  		@is_toolbar_show = true
  end
		
end