From 46e50b191f8398504505ed95a12915acc349c122 Mon Sep 17 00:00:00 2001 From: Xuan Sang LE Date: Mon, 22 Jan 2018 19:59:08 +0100 Subject: [PATCH] global settting --- Makefile | 13 ++-- src/core/BaseModel.coffee | 11 ++- src/core/gui.coffee | 71 +++++++++++-------- src/packages/ActivityMonitor/Makefile | 26 +------ .../CoreServices}/Calendar.coffee | 0 src/packages/CoreServices/Makefile | 11 +++ .../CoreServices}/PushNotification.coffee | 0 .../CoreServices}/Spotlight.coffee | 0 src/packages/CoreServices/package.json | 14 ++++ src/packages/DummyApp/Makefile | 26 +------ src/packages/Files/Makefile | 26 +------ src/packages/Files/main.coffee | 33 +++++---- src/packages/NotePad/Makefile | 26 +------ src/packages/pkg.mk | 25 +++++++ src/packages/wTerm/Makefile | 27 +------ 15 files changed, 133 insertions(+), 176 deletions(-) rename src/{services => packages/CoreServices}/Calendar.coffee (100%) create mode 100644 src/packages/CoreServices/Makefile rename src/{services => packages/CoreServices}/PushNotification.coffee (100%) rename src/{services => packages/CoreServices}/Spotlight.coffee (100%) create mode 100644 src/packages/CoreServices/package.json create mode 100644 src/packages/pkg.mk diff --git a/Makefile b/Makefile index 9f7eba0..ae7cc75 100644 --- a/Makefile +++ b/Makefile @@ -19,13 +19,12 @@ coffees= src/core/core.coffee\ -packages = NotePad wTerm ActivityMonitor DummyApp Files -services = PushNotification Spotlight Calendar +packages = CoreServices NotePad wTerm ActivityMonitor DummyApp Files -main: build_coffees build_tags build_themes schemes libs build_services build_packages +main: build_coffees build_tags build_themes schemes libs build_packages - cp src/index.html $(BUILDDIR)/ -lite: build_coffee build_tag build_theme schemes build_services build_packages +lite: build_coffee build_tag build_theme schemes build_packages #%.js: %.coffee # coffee --compile $< @@ -33,6 +32,7 @@ build_coffees: @echo "$(BLUE)Building coffee files$(NC)" - mkdir $(BUILDDIR)/scripts - rm $(BUILDDIR)/scripts/antos.js + - rm $(BUILDDIR)/scripts/antos.coffee for f in $(coffees); do (cat "$${f}"; echo) >> $(BUILDDIR)/scripts/antos.coffee; done coffee --compile $(BUILDDIR)/scripts/antos.coffee - rm $(BUILDDIR)/scripts/antos.coffee @@ -70,11 +70,6 @@ antos_themes_build: cp src/themes/antos/wp.png $(BUILDDIR)/resources/themes/antos/ -build_services: - @echo "$(BLUE)Building services$(NC)" - -mkdir -p $(BUILDDIR)/services - -rm -rf $(BUILDDIR)/services/* - for f in $(services); do (coffee -cs < "src/services/$$f.coffee" >$(BUILDDIR)/services/"$$f.js");done build_packages: - mkdir $(BUILDDIR)/packages - for d in $(packages); do ( test -d $(BUILDDIR)/packages/$$d && rm -rf $(BUILDDIR)/packages/$$d/* ); done diff --git a/src/core/BaseModel.coffee b/src/core/BaseModel.coffee index dd142f2..9a01462 100644 --- a/src/core/BaseModel.coffee +++ b/src/core/BaseModel.coffee @@ -8,6 +8,13 @@ class BaseModel _OS.setting.applications[@name] = {} if not _OS.setting.applications[@name] @setting = _OS.setting.applications[@name] @dialog = undefined + @subscribe "appregistry" + ,(m)-> + me.applySetting m.data.m if (m.name is me.name) + + registry: (k,v) -> + @setting[k] = v + @publish "appregistry",k render: (p) -> _GUI.loadScheme p, @, @host @@ -24,12 +31,14 @@ class BaseModel #implement by sub class onexit: (e) -> #implement by subclass + applySetting: (k) -> one: (e, f) -> @observable.one e, f on: (e, f) -> @observable.on e, f trigger: (e, d) -> @observable.trigger e, d - subscribe: (e, f) -> _courrier.on e, f, @ + subscribe: (e, f) -> + _courrier.on e, f, @ openDialog: (d, f, data) -> if @dialog diff --git a/src/core/gui.coffee b/src/core/gui.coffee index 5babe75..a624c9e 100644 --- a/src/core/gui.coffee +++ b/src/core/gui.coffee @@ -36,48 +36,58 @@ self.OS.GUI = srvs.splice 0, 1 f i for i in srvs - pushService: (srv) -> + pushService: (ph) -> + arr = ph.split "/" + srv = arr[1] + app = arr[0] return _PM.createProcess srv, _OS.APP[srv] if _OS.APP[srv] - path = "services/#{srv}.js" - _API.script path, - (d) -> - _PM.createProcess srv, _OS.APP[srv] - , (e, s) -> + _GUI.loadApp app, + (a)-> + return _PM.createProcess srv, _OS.APP[srv] if _OS.APP[srv] + (e, s) -> _courrier.trigger "srvroutineready", srv _courrier.osfail "Cannot read service script: #{srv} ", e, s - + forceLaunch: (app, args) -> console.log "This method is used for developing only, please use the launch method instead" _PM.killAll app _OS.APP[app] = undefined _GUI.launch app, args + loadApp:(app, ok, err) -> + path = "packages/#{app}/" + _API.script path + "main.js", + (d) -> + #load css file + _API.get "#{path}main.css", + () -> + $ '', { rel: 'stylesheet', type: 'text/css', 'href': "#{path}main.css" } + .appendTo 'head' + , () -> + #launch + if _OS.APP[app] + # load app meta data + _API.get "#{path}package.json", + (data) -> + _OS.APP[app].meta = data + ok app + , (e, s) -> + _courrier.osfail "Cannot read application metadata: #{app}", e, s + err e, s + else + ok app + , (e, s) -> + #BUG report here + _courrier.osfail "Cannot load application script: #{app}", e, s + console.log "bug report", e, s, path + err e,s launch: (app, args) -> if not _OS.APP[app] # first load it - path = "packages/#{app}/" - _API.script path + "main.js", - (d) -> - #load css file - _API.get "#{path}main.css", - () -> - $ '', { rel: 'stylesheet', type: 'text/css', 'href': "#{path}main.css" } - .appendTo 'head' - , () -> - #launch - if _OS.APP[app] - # load app meta data - _API.get "#{path}package.json", - (data) -> - _OS.APP[app].meta = data - _PM.createProcess app, _OS.APP[app], args - , (e, s) -> - _courrier.osfail "Cannot read application metadata: #{app}", e, s - alert "cannot read application, meta-data" + _GUI.loadApp app, + (a)-> + _PM.createProcess a, _OS.APP[a], args , (e, s) -> - #BUG report here - _courrier.osfail "Cannot load application script: #{app}", e, s - console.log "bug report", e, s, path else # now launch it if _OS.APP[app] @@ -168,4 +178,5 @@ self.OS.GUI = _GUI.loadTheme "antos" _GUI.initDM() _courrier.observable.one "syspanelloaded", () -> - _GUI.pushServices ["PushNotification", "Spotlight", "Calendar"] \ No newline at end of file + #_GUI.loadApp "CoreServices", (a) -> + _GUI.pushServices ["CoreServices/PushNotification", "CoreServices/Spotlight", "CoreServices/Calendar"] \ No newline at end of file diff --git a/src/packages/ActivityMonitor/Makefile b/src/packages/ActivityMonitor/Makefile index 5bd288b..d0e0037 100644 --- a/src/packages/ActivityMonitor/Makefile +++ b/src/packages/ActivityMonitor/Makefile @@ -6,28 +6,6 @@ cssfiles = main.css copyfiles = scheme.html package.json +PKG_NAME=ActivityMonitor -BLUE=\033[1;34m -NC=\033[0m - -main: title clean js css copy - -title: - @echo "$(BLUE)======= Package ActivityMonitor =======$(NC)" - -coffee: - - mkdir build - for f in $(coffee_files); do (coffee -cs < $$f >build/"$$f.js");done - for f in build/*.coffee.js; do (cat "$${f}"; echo) >> build/main.js; done - - rm build/*.coffee.js - -js: coffee - for f in $(jsfiles); do (cat "$${f}"; echo) >> build/main.js; done - -css: - for f in $(cssfiles); do (cat "$${f}"; echo) >> build/main.css; done - -copy: - cp -rf $(copyfiles) build/ -clean: - - rm -rf build/* \ No newline at end of file +include ../pkg.mk \ No newline at end of file diff --git a/src/services/Calendar.coffee b/src/packages/CoreServices/Calendar.coffee similarity index 100% rename from src/services/Calendar.coffee rename to src/packages/CoreServices/Calendar.coffee diff --git a/src/packages/CoreServices/Makefile b/src/packages/CoreServices/Makefile new file mode 100644 index 0000000..ec6d4d7 --- /dev/null +++ b/src/packages/CoreServices/Makefile @@ -0,0 +1,11 @@ +coffee_files = Calendar.coffee PushNotification.coffee Spotlight.coffee + +jsfiles = + +cssfiles = + +copyfiles = package.json + + +PKG_NAME=CoreServices +include ../pkg.mk \ No newline at end of file diff --git a/src/services/PushNotification.coffee b/src/packages/CoreServices/PushNotification.coffee similarity index 100% rename from src/services/PushNotification.coffee rename to src/packages/CoreServices/PushNotification.coffee diff --git a/src/services/Spotlight.coffee b/src/packages/CoreServices/Spotlight.coffee similarity index 100% rename from src/services/Spotlight.coffee rename to src/packages/CoreServices/Spotlight.coffee diff --git a/src/packages/CoreServices/package.json b/src/packages/CoreServices/package.json new file mode 100644 index 0000000..a8c1003 --- /dev/null +++ b/src/packages/CoreServices/package.json @@ -0,0 +1,14 @@ +{ + "app":"CoreServices", + "name":"CoreServices", + "description":"This is the core services", + "info":{ + "author": "Xuan Sang LE", + "email": "xsang.le@gmail.com", + "credit": "dedicated to some one here", + "licences": "MIT" + }, + "version":"0.1a", + "category":"System", + "mimes":["*"] +} \ No newline at end of file diff --git a/src/packages/DummyApp/Makefile b/src/packages/DummyApp/Makefile index 249b97f..159e7bd 100644 --- a/src/packages/DummyApp/Makefile +++ b/src/packages/DummyApp/Makefile @@ -7,27 +7,5 @@ cssfiles = main.css copyfiles = scheme.html package.json -BLUE=\033[1;34m -NC=\033[0m - -main: title clean js css copy - -title: - @echo "$(BLUE)======= Package DummyApp =======$(NC)" - -coffee: - - mkdir build - for f in $(coffee_files); do (coffee -cs < $$f >build/"$$f.js");done - for f in build/*.coffee.js; do (cat "$${f}"; echo) >> build/main.js; done - - rm build/*.coffee.js - -js: coffee - for f in $(jsfiles); do (cat "$${f}"; echo) >> build/main.js; done - -css: - for f in $(cssfiles); do (cat "$${f}"; echo) >> build/main.css; done - -copy: - cp -rf $(copyfiles) build/ -clean: - - rm -rf build/* \ No newline at end of file +PKG_NAME=DummyApp +include ../pkg.mk \ No newline at end of file diff --git a/src/packages/Files/Makefile b/src/packages/Files/Makefile index 09641f6..bf5a0bc 100644 --- a/src/packages/Files/Makefile +++ b/src/packages/Files/Makefile @@ -7,27 +7,5 @@ cssfiles = main.css copyfiles = scheme.html package.json -BLUE=\033[1;34m -NC=\033[0m - -main: title clean js css copy - -title: - @echo "$(BLUE)======= Package Files =======$(NC)" - -coffee: - - mkdir build - for f in $(coffee_files); do (coffee -cs < $$f >build/"$$f.js");done - for f in build/*.coffee.js; do (cat "$${f}"; echo) >> build/main.js; done - - rm build/*.coffee.js - -js: coffee - for f in $(jsfiles); do (cat "$${f}"; echo) >> build/main.js; done - -css: - for f in $(cssfiles); do (cat "$${f}"; echo) >> build/main.css; done - -copy: - cp -rf $(copyfiles) build/ -clean: - - rm -rf build/* \ No newline at end of file +PKG_NAME=ActivityFile +include ../pkg.mk \ No newline at end of file diff --git a/src/packages/Files/main.coffee b/src/packages/Files/main.coffee index 4e8dc9d..8334b06 100644 --- a/src/packages/Files/main.coffee +++ b/src/packages/Files/main.coffee @@ -9,7 +9,6 @@ class Files extends this.OS.GUI.BaseApplication @navbar = @find "nav-bar" @prepaths = [] @favo = @find "favouri" - @loadSetting() @view.contextmenuHandler = (e, m) -> m.set "items", [ me.mnFile(), me.mnEdit() ] @@ -34,13 +33,7 @@ class Files extends this.OS.GUI.BaseApplication me._api.handler.scandir e.child.path, (d) -> f d.result , (e, s) -> me.error "Cannot fetch child dir #{e.child.path}" - - @favo.set "items", @setting.favorite - - loadSetting: () -> - # view setting - @view.set "view", @setting.view if @setting.view - @view.set "showhidden", @setting.showhidden if @setting.showhidden + @setting.favorite = [ { text: "Applications", path: 'apps:///', iconclass:"fa fa-adn"}, { text: "Home", path: 'home:///', iconclass:"fa fa-home", selected:true}, @@ -48,8 +41,15 @@ class Files extends this.OS.GUI.BaseApplication { text: "Desktop", path: 'home:///.desktop', iconclass: "fa fa-desktop" }, ] if not @setting.favorite @setting.sidebar = true if @setting.sidebar is undefined - @toggleSidebar @setting.sidebar @setting.nav = true if @setting.nav is undefined + @favo.set "items", @setting.favorite + @applySetting() + + applySetting: (k) -> + # view setting + @view.set "view", @setting.view if @setting.view + @view.set "showhidden", @setting.showhidden if @setting.showhidden + @toggleSidebar @setting.sidebar @toggleNav @setting.nav chdir: (p, push) -> @@ -123,16 +123,19 @@ class Files extends this.OS.GUI.BaseApplication actionView: (e) -> switch e.item.data.dataid when "#{@name}-hidden" - @.view.set "showhidden", e.item.data.checked - @.setting.showhidden = e.item.data.checked + #@.view.set "showhidden", e.item.data.checked + @registry "showhidden",e.item.data.checked + #@.setting.showhidden = e.item.data.checked when "#{@name}-refresh" @.chdir ($ @.navinput).val(), false when "#{@name}-side" - @setting.sidebar = e.item.data.checked - @toggleSidebar e.item.data.checked + @registry "sidebar",e.item.data.checked + #@setting.sidebar = e.item.data.checked + #@toggleSidebar e.item.data.checked when "#{@name}-nav" - @setting.nav = e.item.data.checked - @toggleNav e.item.data.checked + @registry "nav", e.item.data.checked + #@setting.nav = e.item.data.checked + #@toggleNav e.item.data.checked actionEdit: (e) -> switch e.item.data.dataid diff --git a/src/packages/NotePad/Makefile b/src/packages/NotePad/Makefile index c190611..0fb6fd4 100644 --- a/src/packages/NotePad/Makefile +++ b/src/packages/NotePad/Makefile @@ -7,27 +7,5 @@ cssfiles = main.css copyfiles = scheme.html package.json -BLUE=\033[1;34m -NC=\033[0m - -main: title clean js css copy - -title: - @echo "$(BLUE)======= Package NotePad =======$(NC)" - -coffee: - - mkdir build - for f in $(coffee_files); do (coffee -cs < $$f >build/"$$f.js");done - for f in build/*.coffee.js; do (cat "$${f}"; echo) >> build/main.js; done - - rm build/*.coffee.js - -js: coffee - for f in $(jsfiles); do (cat "$${f}"; echo) >> build/main.js; done - -css: - for f in $(cssfiles); do (cat "$${f}"; echo) >> build/main.css; done - -copy: - cp -rf $(copyfiles) build/ -clean: - - rm -rf build/* \ No newline at end of file +PKG_NAME=NotePad +include ../pkg.mk \ No newline at end of file diff --git a/src/packages/pkg.mk b/src/packages/pkg.mk new file mode 100644 index 0000000..ca20e9c --- /dev/null +++ b/src/packages/pkg.mk @@ -0,0 +1,25 @@ + +BLUE=\033[1;34m +NC=\033[0m + +main: title clean js css copy + +title: + @echo "$(BLUE)======= Package $(PKG_NAME) =======$(NC)" + +coffee: + - mkdir build + for f in $(coffee_files); do (coffee -cs < $$f >build/"$$f.js");done + for f in build/*.coffee.js; do (cat "$${f}"; echo) >> build/main.js; done + - rm build/*.coffee.js + +js: coffee + for f in $(jsfiles); do (cat "$${f}"; echo) >> build/main.js; done + +css: + for f in $(cssfiles); do (cat "$${f}"; echo) >> build/main.css; done + +copy: + cp -rf $(copyfiles) build/ +clean: + - rm -rf build/* \ No newline at end of file diff --git a/src/packages/wTerm/Makefile b/src/packages/wTerm/Makefile index b8c381e..08691d4 100644 --- a/src/packages/wTerm/Makefile +++ b/src/packages/wTerm/Makefile @@ -7,28 +7,5 @@ cssfiles = xterm.css main.css copyfiles = scheme.html package.json -BLUE=\033[1;34m -NC=\033[0m - -main: title clean js css copy - -title: - @echo "$(BLUE)======= Package wTerm =======$(NC)" - - rm -rf build/* - -coffee: - - mkdir build - for f in $(coffee_files); do (coffee -cs < $$f >build/"$$f.js");done - for f in build/*.coffee.js; do (cat "$${f}"; echo) >> build/main.js; done - - rm build/*.coffee.js - -js: coffee - for f in $(jsfiles); do (cat "$${f}"; echo) >> build/main.js; done - -css: - for f in $(cssfiles); do (cat "$${f}"; echo) >> build/main.css; done - -copy: - cp -rf $(copyfiles) build/ -clean: - - rm -rf build/* \ No newline at end of file +PKG_NAME=wTerm +include ../pkg.mk \ No newline at end of file