00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 from ost import gui
00022 from ost import gfx
00023 from ost import info
00024 from PyQt4 import QtCore, QtGui
00025 from immutable_gradient_info_handler import ImmutableGradientInfoHandler
00026
00027
00028 class GradientInfoHandler(ImmutableGradientInfoHandler):
00029 def __init__(self, fileName):
00030 ImmutableGradientInfoHandler.__init__(self, fileName)
00031
00032 def StoreQGradient(self,gradient,name):
00033 group = self.gradients_.CreateGroup(self.GRADIENT_GROUP_NAME)
00034 group.SetAttribute(self.NAME_ATTRIBUTE_NAME, name)
00035 gfx_gradient = self.ConvertToGfxGradient(gradient)
00036
00037 gfx_gradient.GradientToInfo(group)
00038 self.handle_.Export(self.FILE_NAME)
00039
00040 def RemoveGradient(self, name):
00041 group_list = self.gradients_.GetGroups(self.GRADIENT_GROUP_NAME)
00042 for group in group_list:
00043 if group.HasAttribute(self.NAME_ATTRIBUTE_NAME):
00044 groupname = group.GetAttribute(self.NAME_ATTRIBUTE_NAME)
00045 if name == groupname:
00046 groupToDel = group
00047 break
00048
00049 if groupToDel != None:
00050 self.gradients_.Remove(groupToDel)
00051 self.handle_.Export(self.FILE_NAME)
00052
00053 def RenameGradient(self, old, new):
00054 group_list = self.gradients_.GetGroups(self.GRADIENT_GROUP_NAME)
00055 for group in group_list:
00056 if group.HasAttribute(self.NAME_ATTRIBUTE_NAME):
00057 groupname = group.GetAttribute(self.NAME_ATTRIBUTE_NAME)
00058 if old == groupname:
00059 group.SetAttribute(self.NAME_ATTRIBUTE_NAME, new)
00060 self.handle_.Export(self.FILE_NAME)