1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
|
# File 'lib/a-core.rb', line 1810
def initialize(_runner_manager, _parent=nil, _runner_hash=nil, _row=0, _state_array=nil, *args)
@runner_hash = _runner_hash
@readonly = _state_array && _state_array.include?(:disabled)
@enable_close_button = !@readonly || _runner_hash[:origin] == 'runtime'
@h_hash = {}
p_update_height = proc{|tktext|
index = tktext.index('end -1 chars')
r,c = index.split('.')
if tktext.cget('wrap') != 'none'
w = tktext.width
h = ((c.to_i-1)/w.to_i).round + 1
else
h = r.to_i
end
h_to_set = h
@h_hash.each{|k,v| h_to_set = v if k != tktext && v > h_to_set }
@h_hash[tktext] = h
if tktext.height != h_to_set
tktext.height(h_to_set)
@h_hash.each{|k,v|
p_update_height.call(k) if k != tktext
}
end
}
row_fill = false
@ttklicon = Arcadia.wf.label(_parent,
'image'=> _runner_hash[:image].nil? ? Arcadia.file_icon(_runner_hash[:file_exts]) : Arcadia.image_res(_runner_hash[:image]) ,
'relief'=>'flat').grid(:column => 0, :row => _row, :sticky => "W", :padx=>1, :pady=>1)
@ttklicon.state(:disabled) if @readonly
@ename_old = _runner_hash[:name]
@ttkename = Arcadia.wf.text(_parent, 'width' => _runner_manager.name_width,
"height" => 1).hint(_runner_hash[:file]).grid(:column => 1, :row => _row, :sticky => "WE", :padx=>1, :pady=>1)
@ttkename.insert('end', _runner_hash[:name])
@ttkename.state(:disabled) && @ttkename.fg('darkgray') if @readonly
row_fill = row_fill || @ttkename.value.strip.length > 0
@etitle_old = _runner_hash[:title]
@ttketitle = Arcadia.wf.text(_parent, 'width' => _runner_manager.title_width,
"height" => 1).hint(_runner_hash[:file]).grid(:column => 2, :row => _row, :sticky => "WE", :padx=>1, :pady=>1)
@ttketitle.insert('end', _runner_hash[:title])
@ttketitle.state(:disabled) && @ttketitle.fg('darkgray') if @readonly
row_fill = row_fill || @ttketitle.value.strip.length > 0
@ecmd_old = _runner_hash[:cmd]
@ttkecmd = Arcadia.wf.text(_parent, 'width' => _runner_manager.cmd_width, 'wrap'=>'word',
"height" => 1).grid(:column => 3, :row => _row, :sticky => "WE", :padx=>1, :pady=>1)
@ttkecmd.insert('end', _runner_hash[:cmd])
@ttkecmd.state(:disabled) && @ttkecmd.fg('darkgray') if @readonly
row_fill = row_fill || @ttkecmd.value.strip.length > 0
@eexts_old = _runner_hash[:file_exts]
@ttkeexts = Arcadia.wf.text(_parent, 'width' => _runner_manager.ext_width,
"height" => 1).grid(:column => 4, :row => _row, :sticky => "WE", :padx=>1, :pady=>1)
@ttkeexts.insert('end', _runner_hash[:file_exts])
@ttkeexts.state(:disabled) && @ttkeexts.fg('darkgray') if @readonly
row_fill = row_fill || @ttkeexts.value.strip.length > 0
copy_command = proc{ _runner_manager.do_add(self) }
@ttkbcopy = Arcadia.wf.toolbutton(_parent,
'command'=> copy_command,
'image'=> Arcadia.image_res(COPY_GIF)
).grid(:column => 5, :row => _row, :sticky => "W", :padx=>1, :pady=>1)
close_command = proc{
if (Arcadia.hinner_dialog(self, 'type'=>'yes_no',
'msg'=> Arcadia.text("main.d.confirm_delete_runner.msg", [_runner_hash[:name]]),
'title' => Arcadia.text("main.d.confirm_delete_runner.title"),
'level' => 'question')=='yes')
if _runner_hash[:origin] == 'runtime'
Arcadia.unpersistent("runners.#{_runner_hash[:name]}")
else
Arcadia.del_conf("runners.#{_runner_hash[:name]}")
end
mr = Arcadia.('runcurr')
index_to_delete = -1
i_end = mr.index('end')
if i_end
0.upto(i_end){|j|
type = mr.(j)
if type != 'separator'
l = mr.entrycget(j,'label')
if l == _runner_hash[:title]
index_to_delete = j
break
end
end
}
end
if index_to_delete > -1
mr.delete(index_to_delete)
end
_runner_manager.do_delete_item(self)
self.destroy
end
}
@ttkbclose = Arcadia.wf.toolbutton(_parent,
'command'=> close_command,
'image'=> Arcadia.image_res(CLOSE_FRAME_GIF)
).grid(:column => 6, :row => _row, :sticky => "W", :padx=>1, :pady=>1)
@ttkbclose.hint=@runner_hash[:file]
@ttkbclose.state(:disabled) if !@enable_close_button
[@ttkename, @ttketitle, @ttkecmd, @ttkeexts].each{|tktext|
p_update_height.call(tktext) if row_fill
tktext.bind_append("KeyRelease"){p_update_height.call(tktext)}
}
end
|