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.



1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
# File 'lib/a-core.rb', line 1448

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'=> TkPhotoImage.new('data' => TRASH_GIF),
     'relief'=>'flat').pack('side' =>'right','padx'=>0)
  pack('side' =>'top','anchor'=>'nw','fill'=>'x','padx'=>5, 'pady'=>5)
end