# Copyright (c) 2001 LOGILAB S.A. (Paris, FRANCE).
# http://www.logilab.fr/ -- mailto:contact@logilab.fr
#
# 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.

"""
Property Window : properties of recipe
"""

__revision__ = "$Id: PropertyWindow.py,v 1.7 2001/12/06 10:45:17 syt Exp $"

from DialogWindow import DialogWindow,unicode_to_gtk
from gtk import *
from narval.lib import *

class PropertyWindow(DialogWindow):

    def __init__(self, model):
        recipe = model._recipe
        r_name = recipe.getAttributeNS(NO_NS,'name')
        DialogWindow.__init__(self,unicode_to_gtk(_("Properties of %s")%r_name))
        self.connect("delete_event",self._exit)
                   
        hbox = GtkHBox()
        hbox.pack_start(GtkLabel(unicode_to_gtk(_("Name : "))),expand=FALSE)
        self.name_entry = GtkEntry()
        self.name_entry.set_text(name)
        hbox.pack_end(self.name_entry)
        hbox.show_all()
        self.append_dialog(hbox,expand=FALSE)

        hbox = GtkHBox()
        hbox.pack_start(GtkLabel(unicode_to_gtk(_("Restart mode : "))),expand=FALSE)
        self.autorestart = GtkCheckButton(unicode_to_gtk(_("autorestart")))
        if recipe.getAttributeNS(NO_NS, 'restart')=='yes':
            test = TRUE
        else:
            test = FALSE
        self.autorestart.set_active(test)
        hbox.pack_end(self.autorestart)
        hbox.show_all()
        self.append_dialog(hbox,expand=FALSE)

        hbox = GtkHBox()
        hbox.pack_start(GtkLabel(unicode_to_gtk(_("Decay : "))),expand=FALSE)
        self.decay_entry = GtkEntry()
        self.decay_entry.set_text(recipe.getAttributeNS(AL_NS,'timestamp'))
        hbox.pack_end(self.decay_entry)
        hbox.show_all()
        self.append_dialog(hbox)
        
        self.ok_button.show()
        self.ok_button.set_flags(CAN_DEFAULT|HAS_DEFAULT)

        self.cancel_button.show()
        self.cancel_button.connect_object("clicked",lambda x:x.destroy(),self)

    ### PRIVATE ###

    def _exit(self,*args):
        self.destroy()
