diff modules/State.lua @ 228:ad40cd3fc7e9

pull states config out of namespace
author Flick
date Mon, 21 Mar 2011 11:33:15 -0700
parents 2e2abdaad2e5
children b4c100011c75
line wrap: on
line diff
--- a/modules/State.lua	Mon Mar 21 11:10:23 2011 -0700
+++ b/modules/State.lua	Mon Mar 21 11:33:15 2011 -0700
@@ -58,11 +58,11 @@
 -- PRIVATE --
 do
   function GetProperty( bar, state, propname )
-    return tfetch(module.db.profile.bars, bar:GetName(), "states", state, propname)
+    return tfetch(bar:GetConfig(), "states", state, propname)
   end
 
   function SetProperty( bar, state, propname, value )
-    local s = tbuild(module.db.profile.bars, bar:GetName(), "states", state)
+    local s = tbuild(bar:GetConfig(), "states", state)
     s[propname] = value
     bar:SetSecureStateData(state, propname, value)
   end
@@ -84,7 +84,7 @@
   end
 
   function ApplyStates( bar )
-    local states = tfetch(module.db.profile.bars, bar:GetName(), "states")
+    local states = tfetch(bar:GetConfig(), "states")
     if states then
       bar:SetStateDriver(states)
     end
@@ -115,8 +115,6 @@
   ReAction.RegisterCallback(self, "OnCreateBar","OnRefreshBar")
   ReAction.RegisterCallback(self, "OnDestroyBar")
   ReAction.RegisterCallback(self, "OnRefreshBar")
-  ReAction.RegisterCallback(self, "OnEraseBar")
-  ReAction.RegisterCallback(self, "OnRenameBar")
 end
 
 function module:OnEnable()
@@ -134,24 +132,13 @@
 end
 
 function module:OnRefreshBar(event, bar, name)
-  local c = self.db.profile.bars[name]
-  if c then
-    ApplyStates(bar)
-  end
+  ApplyStates(bar)
 end
 
 function module:OnDestroyBar(event, bar, name)
   CleanupStates(bar)
 end
 
-function module:OnEraseBar(event, bar, name)
-  self.db.profile.bars[name] = nil
-end
-
-function module:OnRenameBar(event, bar, oldname, newname)
-  local bars = self.db.profile.bars
-  bars[newname], bars[oldname] = bars[oldname], nil
-end
 
 
 
@@ -525,7 +512,7 @@
 
     -- get reference to states table: even if the bar
     -- name changes the states table ref won't
-    self.states = tbuild(module.db.profile.bars, bar:GetName(), "states")
+    self.states = tbuild(bar:GetConfig(), "states")
     self.state  = tbuild(self.states, opts.name)
 
     opts.order = self:GetRuleField("order")
@@ -824,7 +811,7 @@
 
   function module:GetBarOptions(bar)
     local private = { }
-    local states = tbuild(module.db.profile.bars, bar:GetName(), "states")
+    local states = tbuild(bar:GetConfig(), "states")
     local options = {
       name = L["Dynamic State"],
       type = "group",