# program_clist.rb

# $Id: program_clist.rb,v 1.1.1.1 2002/04/30 04:15:45 kenji Exp $

# 2002/4/30  Takuro Ashie <ashie@homa.ne.jp>
# Copyright (C) 2002 Takuro Ashie <ashie@homa.ne.jp>
# This is free software with ABSOLUTELY NO WARRANTY.

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.


###############################################################################
#
#   ProgramCList Widget
#
###############################################################################
class ProgramCList < Gtk::CList
  include Gtk

  #
  # initialize ()
  #
  def initialize ()
    super (['開始日', '開始時刻', '終了日', '終了時刻',
	     'ch', '品質', 'ファイル名'])

    for i in 0..6
      set_column_auto_resize (i, true)
    end      
    set_column_justification (4, JUSTIFY_CENTER)
  end


  #
  # appendProgram () :
  #    Append a ProgramItem.
  #
  # aItem : The ProgramItem to add.
  #
  def appendProgram (aItem)
    start_day  = aItem.starttime.strftime ('%Y/%m/%d')
    start_time = aItem.starttime.strftime ('%H:%M:%S')
    end_day    = aItem.endtime.strftime ('%Y/%m/%d')
    end_time   = aItem.endtime.strftime ('%H:%M:%S')
    row = append [start_day, start_time, end_day, end_time,
                  aItem.channel, aItem.quality, aItem.filename]
    set_row_data (row, aItem)
  end


  #
  # setList () :
  #    Set list of ProgramItem.
  #    If a list is already exist, it will be cleared.
  # 
  # aList : Array which contain ProgramItem.
  #
  def setList (aList)
    clear
    aList.each do |item|
      appendProgram (item)
    end
  end
end
