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

View File

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

View File

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

View File

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

View File

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

View File

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