fix core api bugs

This commit is contained in:
Xuan Sang LE 2018-03-27 18:47:27 +02:00
parent e72aaddf45
commit 59cde330da
6 changed files with 20 additions and 12 deletions

View File

@ -26,8 +26,6 @@ class BaseApplication extends this.OS.GUI.BaseModel
SHIFT: {}
META: {}
me = @
@subscribe "appregistry", ( m ) ->
me.applySetting m.data.m if (m.name is me.name)
init: ->
me = @
@off "*"
@ -121,8 +119,7 @@ class BaseApplication extends this.OS.GUI.BaseModel
data:->
#implement by subclasses
# to return app data
update:->
#implement by subclasses
cleanup: (e) ->
#implement by subclasses
# to handle the exit event

View File

@ -27,8 +27,6 @@ class BaseModel
@on "exit", () -> me.quit()
@host = "#desktop"
@dialog = undefined
@subscribe "systemlocalechange", (name) ->
me.scheme.update() if me.scheme
render: (p) ->
_GUI.loadScheme p, @, @host
@ -104,6 +102,9 @@ class BaseModel
throwe: () ->
@_api.throwe @name
update:->
@scheme.update() if @scheme
find: (id) -> ($ "[data-id='#{id}']", @scheme)[0] if @scheme
select: (sel) -> $ sel, @scheme if @scheme

View File

@ -34,7 +34,9 @@ class BaseService extends this.OS.GUI.BaseModel
attach: (h) ->
@holder = h
update: () -> @holder.update() if @holder
update: () ->
@holder.update() if @holder
@scheme.update() if @scheme
watch: ( t, f) ->
me = @

View File

@ -52,7 +52,7 @@ self.OS or=
return unless _courrier.listeners[app.pid] and _courrier.listeners[app.pid].length > 0
_courrier.observable.off i.e, i.f for i in _courrier.listeners[app.pid]
delete _courrier.listeners[app.pid]
_courrier.listeners[app.pid] = []
# _courrier.listeners[app.pid]
getMID: () ->
_courrier.quota += 1
_courrier.quota

View File

@ -196,6 +196,9 @@ self.OS.GUI =
dock.get(0).newapp data
app.sysdock = dock.get(0)
app.appmenu = ($ "[data-id = 'appmenu']", "#syspanel")[0]
app.subscribe "systemlocalechange", (name) -> app.update()
app.subscribe "appregistry", ( m ) ->
app.applySetting m.data.m if (m.name is app.name)
toggleFullscreen: () ->
el = ($ "body")[0]
@ -216,6 +219,7 @@ self.OS.GUI =
attachservice: (srv) ->
($ "#syspanel")[0].attachservice srv
srv.init()
srv.subscribe "systemlocalechange", (name) -> srv.update()
detachservice: (srv) ->
($ "#syspanel")[0].detachservice srv
bindContextMenu: (event) ->

View File

@ -82,6 +82,8 @@ class Files extends this.OS.GUI.BaseApplication
@favo.set "items", mntpoints
#@favo.set "selected", -1
@applySetting()
@view.set "view", @setting.view if @setting.view
@subscribe "VFS", (d) ->
me.chdir null if d.data.file.hash() is me.currdir.hash() or d.data.file.parent().hash() is me.currdir.hash()
@bindKey "CTRL-F", () -> me.actionFile "#{me.name}-mkf"
@ -106,10 +108,12 @@ class Files extends this.OS.GUI.BaseApplication
applySetting: (k) ->
# view setting
@view.set "view", @setting.view if @setting.view
@view.set "showhidden", @setting.showhidden
@toggleSidebar @setting.sidebar
@toggleNav @setting.nav
switch k
when "showhidden" then @view.set "showhidden", @setting.showhidden
when "nav" then @toggleNav @setting.nav
when "sidebar" then @toggleSidebar @setting.sidebar
#@view.set "view", @setting.view if @setting.view
chdir: (p) ->
me = @