Class: RunnerManager::RunnerMangerItem

Inherits:
TkFrame
  • Object
show all
Defined in:
lib/a-core.rb

Instance Method Summary collapse

Constructor Details

#initialize(_parent = nil, _runner_hash = nil, *args) ⇒ RunnerMangerItem

Returns a new instance of RunnerMangerItem.



1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
# File 'lib/a-core.rb', line 1643

def initialize(_parent=nil, _runner_hash=nil, *args)
  super(_parent, Arcadia.style('panel'))
  @runner_hash = _runner_hash
  Tk::BWidget::Label.new(self, 
     'image'=> Arcadia.file_icon(_runner_hash[:file_exts]),
     'relief'=>'flat').pack('side' =>'left')
  Tk::BWidget::Label.new(self, 
     'text'=>_runner_hash[:title],
     'helptext'=>_runner_hash[:file],
     'compound'=>:left, 
     'relief'=>'flat').pack('fill'=>'x','side' =>'left')
  _close_command = proc{
    if (Arcadia.dialog(self, 'type'=>'yes_no',
                    'msg'=>"Do you want delete runner item '#{_runner_hash[:name]}'?",
                    'title' => '(Arcadia) Manage runners',
                    'level' => 'question')=='yes')
    
      Arcadia.unpersistent("runners.#{_runner_hash[:name]}")
      mr = Arcadia.menu_root('runcurr')
      index_to_delete = -1
      i_end = mr.index('end')
      if i_end
        0.upto(i_end){|j|
          type = mr.menutype(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
      self.destroy
    end
  }   
  Tk::BWidget::Button.new(self, 
     'command'=>_close_command,
     'helptext'=>@runner_hash[:file],
     'background'=>'white',
     'image'=> Arcadia.image_res(TRASH_GIF),
     'relief'=>'flat').pack('side' =>'right','padx'=>0)
  pack('side' =>'top','anchor'=>'nw','fill'=>'x','padx'=>5, 'pady'=>5)
end