# =========================================================================== # eXe # Copyright 2004-2006, University of Auckland # Copyright 2004-2007 eXe Project, New Zealand Tertiary Education Commission # # 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 # =========================================================================== """ The base class for all iDevices """ import copy import logging from copy import deepcopy from exe.engine.persist import Persistable from exe.engine.translate import lateTranslate from exe.engine.resource import Resource log = logging.getLogger(__name__) # =========================================================================== class Idevice(Persistable): """ The base class for all iDevices iDevices are mini templates which the user uses to create content in the package """ # Class attributes # see derieved classes for persistenceVersion nextId = 1 NoEmphasis, SomeEmphasis, StrongEmphasis = range(3) def __init__(self, title, author, purpose, tip, icon, parentNode=None): """Initialize a new iDevice, setting a unique id""" log.debug("Creating iDevice") self.edit = True self.lastIdevice = True self.emphasis = Idevice.NoEmphasis self.version = 0 self.id = unicode(Idevice.nextId) Idevice.nextId += 1 self.parentNode = parentNode self._title = title self._author = author self._purpose = purpose self._tip = tip self.icon = icon # userResources are copied into and stored in the package self.userResources = [] # systemResources are resources from whatever style dir we are using at render time if self.icon: self.systemResources = ["icon_"+self.icon+".gif"] else: self.systemResources = [] # Properties def get_title(self): """ Gives a nicely encoded and translated title that can be put inside xul labels (eg.