hs: modules/apps clean up
This commit is contained in:
parent
3b54b17d69
commit
8e8708a1c8
|
@ -7,22 +7,17 @@ App.new = function(name)
|
||||||
self.name = name
|
self.name = name
|
||||||
self.bindings = {}
|
self.bindings = {}
|
||||||
|
|
||||||
self.onInitFn = nil
|
|
||||||
self.onActivateFn = nil
|
self.onActivateFn = nil
|
||||||
self.onDeactivateFn = nil
|
self.onDeactivateFn = nil
|
||||||
self.onLaunchedFn = nil
|
self.onLaunchedFn = nil
|
||||||
self.onTerminatedFn = nil
|
self.onTerminatedFn = nil
|
||||||
|
|
||||||
self.bind = function(mods, key, action, predicate)
|
self.bind = function(mods, key, action, predicate)
|
||||||
table.insert(self.bindings,
|
table.insert(self.bindings, {key = hs.hotkey.new(mods, key, action),
|
||||||
{key = hs.hotkey.new(mods, key, action), predicate = predicate})
|
predicate = predicate})
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
self.onInit = function(fn)
|
|
||||||
fn(self)
|
|
||||||
return self
|
|
||||||
end
|
|
||||||
self.onActivate = function(fn)
|
self.onActivate = function(fn)
|
||||||
self.onActivateFn = fn
|
self.onActivateFn = fn
|
||||||
return self
|
return self
|
||||||
|
@ -66,11 +61,11 @@ App.new = function(name)
|
||||||
|
|
||||||
self.enableBinds = function(self)
|
self.enableBinds = function(self)
|
||||||
hs.fnutils.each(self.bindings, function(b)
|
hs.fnutils.each(self.bindings, function(b)
|
||||||
if b.predicate and not b.predicate() then
|
if b.predicate and not b.predicate() then
|
||||||
b.key:disable()
|
b.key:disable()
|
||||||
else
|
else
|
||||||
b.key:enable()
|
b.key:enable()
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -79,7 +74,7 @@ App.new = function(name)
|
||||||
end
|
end
|
||||||
|
|
||||||
self.clearBinds = function(self)
|
self.clearBinds = function(self)
|
||||||
hs.fnutils.each(self.bindings, function(b) b.key:delete() end)
|
self:disableBinds()
|
||||||
self.bindings = {}
|
self.bindings = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue