diff --git a/Makefile b/Makefile index 2a6a0c3..9f7eba0 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ NC=\033[0m coffees= src/core/core.coffee\ src/core/api.coffee\ - src/core/handlers/TestHandler.coffee\ + src/core/handlers/RemoteHandler.coffee\ src/core/gui.coffee\ src/core/BaseModel.coffee\ src/core/BaseApplication.coffee\ @@ -22,7 +22,7 @@ coffees= src/core/core.coffee\ packages = NotePad wTerm ActivityMonitor DummyApp Files services = PushNotification Spotlight Calendar -main: clean build_coffees build_tags build_themes schemes libs build_services build_packages +main: build_coffees build_tags build_themes schemes libs build_services build_packages - cp src/index.html $(BUILDDIR)/ lite: build_coffee build_tag build_theme schemes build_services build_packages @@ -67,7 +67,7 @@ antos_themes_build: for f in src/themes/antos/*.css; do (cat "$${f}"; echo) >> $(BUILDDIR)/resources/themes/antos/antos.css;done -mkdir -p $(BUILDDIR)/resources/themes/antos/fonts cp -rf src/themes/antos/fonts/* $(BUILDDIR)/resources/themes/antos/fonts - cp src/themes/antos/wallpaper.jpg $(BUILDDIR)/resources/themes/antos/ + cp src/themes/antos/wp.png $(BUILDDIR)/resources/themes/antos/ build_services: diff --git a/src/antos.coffee b/src/antos.coffee index acceb26..c996067 100644 --- a/src/antos.coffee +++ b/src/antos.coffee @@ -1,7 +1,7 @@ _GUI = self.OS.GUI _API = self.OS.API -_APP = self.OS.APP _PM = self.OS.PM +_OS = self.OS _courrier = self.OS.courrier this.onload = () -> console.log "Booting the os" diff --git a/src/core/BaseApplication.coffee b/src/core/BaseApplication.coffee index 906cfaf..ff54a23 100644 --- a/src/core/BaseApplication.coffee +++ b/src/core/BaseApplication.coffee @@ -1,7 +1,7 @@ self = this class BaseApplication extends this.OS.GUI.BaseModel - constructor: (name) -> - super name + constructor: (name, args) -> + super name, args init: -> me = @ @@ -44,11 +44,11 @@ class BaseApplication extends this.OS.GUI.BaseModel if not evt.prevent @.appmenu.set "items", [] if @.pid == @.appmenu.pid ($ @scheme).remove() - meta: () -> _APP[@name].meta + meta: () -> _OS.APP[@name].meta baseMenu: -> mn = [{ - text: _APP[@name].meta.name, + text: _OS.APP[@name].meta.name, child: [ { text: "About", dataid: "#{@name}-about" }, { text: "Exit", dataid: "#{@name}-exit" } diff --git a/src/core/BaseDialog.coffee b/src/core/BaseDialog.coffee index 30a87dc..1cfd133 100644 --- a/src/core/BaseDialog.coffee +++ b/src/core/BaseDialog.coffee @@ -1,6 +1,6 @@ class BaseDialog extends this.OS.GUI.BaseModel constructor: (name) -> - super name + super name, null @parent = undefined @modal = false @handler = undefined @@ -47,8 +47,8 @@ class BasicDialog extends BaseDialog html = " " html += "<#{@conf.tag} data-id = 'content'>" - html += "
" - html += "" for k,v of @conf.buttons + html += "
" + html += "" for k,v of @conf.buttons html += "
" #render the html _GUI.htmlToScheme html, @, @host @@ -60,6 +60,7 @@ class BasicDialog extends BaseDialog f = (_v) -> () -> _v.onclick me # bind action to button ( (me.find "bt#{k}").set "onbtclick", f(v) ) for k, v of @conf.buttons + @conf.filldata @ if @conf.filldata this.OS.GUI.BasicDialog = BasicDialog @@ -115,6 +116,22 @@ class ColorPickerDialog extends BasicDialog } this.OS.register "ColorPickerDialog", ColorPickerDialog +class InfoDialog extends BasicDialog + constructor: () -> + super "InfoDialog", { + tag: 'afx-grid-view', + width: 250, + height: 300, + resizable: true, + buttons: [ { label: 'Cancel', onclick: (d) -> d.quit() } ], + filldata: (d) -> + return unless d.data + rows = [] + rows.push [ { value: k }, { value: v } ] for k, v of d.data + (d.find "content").set "rows", rows + } +this.OS.register "InfoDialog", InfoDialog + class AboutDialog extends BaseDialog constructor: () -> super "AboutDialog" diff --git a/src/core/BaseModel.coffee b/src/core/BaseModel.coffee index 9025d4a..dd142f2 100644 --- a/src/core/BaseModel.coffee +++ b/src/core/BaseModel.coffee @@ -1,10 +1,12 @@ class BaseModel - constructor: (@name) -> + constructor: (@name, @args) -> @observable = riot.observable() @_api = self.OS.API me = @ @on "exit", () -> me.quit() @host = "#desktop" + _OS.setting.applications[@name] = {} if not _OS.setting.applications[@name] + @setting = _OS.setting.applications[@name] @dialog = undefined render: (p) -> @@ -29,7 +31,7 @@ class BaseModel subscribe: (e, f) -> _courrier.on e, f, @ - openDialog: (d, f) -> + openDialog: (d, f, data) -> if @dialog @dialog.show() return @@ -40,6 +42,7 @@ class BaseModel @dialog.parent = @ @dialog.handler = f @dialog.pid = @pid + @dialog.data = data @dialog.init() publish: (t, m) -> diff --git a/src/core/BaseService.coffee b/src/core/BaseService.coffee index 7b7b453..fbee401 100644 --- a/src/core/BaseService.coffee +++ b/src/core/BaseService.coffee @@ -1,6 +1,6 @@ class BaseService extends this.OS.GUI.BaseModel - constructor: (name) -> - super name + constructor: (name, args) -> + super name, args @icon = undefined @iconclass = "fa-paper-plane-o" @text = "" diff --git a/src/core/api.coffee b/src/core/api.coffee index d3d0226..9b5f6a2 100644 --- a/src/core/api.coffee +++ b/src/core/api.coffee @@ -3,20 +3,20 @@ self.OS.API = # fetch user data, used by the API to make requests # handlers are defined in /src/handlers handler: {} - VFS: - scandir: (p, c, f) -> - _API.handler.request "scandir", { path: p }, c, f #request a user data post: (p, d, c, f) -> q = _courrier.getMID() _API.loading q, p + $.ajax { - type: "POST", + type: 'POST', url: p, - data: d, - success: null, - dataType: 'json' + contentType: 'application/json', + data: JSON.stringify d, + dataType: 'json', + success: null } + #$.getJSON p, d .done (data) -> _API.loaded q, p, "OK" c(data) @@ -51,7 +51,7 @@ self.OS.API = .fail (e, s) -> _API.loaded q, p, "FAIL" f(e, s) - resource: (resource, callback) -> - path = "resources/#{resource}" - _API.get path, callback + resource: (r, c, f) -> + path = "resources/#{r}" + _API.get path, c, f diff --git a/src/core/core.coffee b/src/core/core.coffee index 955c373..ac28d9d 100644 --- a/src/core/core.coffee +++ b/src/core/core.coffee @@ -2,10 +2,13 @@ self = this self.OS or= - API: new Object() - GUI: new Object() - APP: new Object() - + API: {} + GUI: {} + APP: {} + setting: + user: {} + applications: {} + appearance: {} courrier: observable: riot.observable() quota: 0 @@ -15,6 +18,12 @@ self.OS or= _courrier.listeners[a.pid].push { e: e, f: f } _courrier.observable.on e, f trigger: (e, d) -> _courrier.observable.trigger e, d + osfail: (m, e, s) -> + _courrier.ostrigger "fail", { m: m, e: e, s: s } + oserror: (m, e, s) -> + _courrier.ostrigger "error", { m: m, e: e, s: s } + ostrigger: (e, d) -> + _courrier.trigger e, { id: 0, data: d, name: "OS" } unregister: (app) -> 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] @@ -24,12 +33,12 @@ self.OS or= _courrier.quota += 1 _courrier.quota register: (name, x) -> - if x.type is 3 then self.OS.GUI.dialog[name] = x else _APP[name] = x + if x.type is 3 then self.OS.GUI.dialog[name] = x else _OS.APP[name] = x PM: pidalloc: 0 - processes: new Object - createProcess: (app, cls) -> + processes: {} + createProcess: (app, cls, args) -> #if it is single ton # and a process is existing # just return it @@ -37,7 +46,7 @@ self.OS or= _PM.processes[app][0].show() else _PM.processes[app] = [] if not _PM.processes[app] - obj = new cls + obj = new cls(args) obj.birth = (new Date).getTime() _PM.pidalloc++ obj.pid = _PM.pidalloc @@ -55,20 +64,28 @@ self.OS or= app kill: (app) -> - return if not _PM.processes[app.name] + return if not app.name or not _PM.processes[app.name] i = _PM.processes[app.name].indexOf app if i >= 0 - if _APP[app.name].type == 1 then _GUI.undock app else _GUI.detachservice app + if _OS.APP[app.name].type == 1 then _GUI.undock app else _GUI.detachservice app _courrier.unregister app delete _PM.processes[app.name][i] _PM.processes[app.name].splice i, 1 + + killAll: (app) -> + return unless _PM.processes[app] + tmp = [] + tmp.push a for a in _PM.processes[app] + a.quit() for a in tmp boot: -> - #first load the configuration - #then load the theme - _GUI = self.OS.GUI - _GUI.loadTheme "antos" - _GUI.initDM() - _courrier.observable.one "syspanelloaded", () -> - _GUI.pushServices ["PushNotification", "Spotlight", "Calendar"] \ No newline at end of file + #first login + _API.handler.auth (d) -> + # in case someone call it more than once :) + if d.error + # show login screen + _GUI.login() + else + # startX :) + _GUI.startAntOS d.result \ No newline at end of file diff --git a/src/core/gui.coffee b/src/core/gui.coffee index 6350fed..db49532 100644 --- a/src/core/gui.coffee +++ b/src/core/gui.coffee @@ -18,11 +18,11 @@ self.OS.GUI = return null unless x _GUI.htmlToScheme x, app, parent , (e, s) -> - _courrier.trigger "fail", - {id: 0, data: { - m: "Cannot load scheme file: #{path} for #{app.name} (#{app.pid})",e: e, s: s }, - name:"OS" - } + _courrier.osfail "Cannot load scheme file: #{path} for #{app.name} (#{app.pid})",e,s + + clearTheme: () -> + $ "head link#ostheme" + .attr "href", "" loadTheme: (name) -> path = "resources/themes/#{name}/#{name}.css" @@ -37,19 +37,23 @@ self.OS.GUI = f i for i in srvs pushService: (srv) -> - return _PM.createProcess srv, _APP[srv] if _APP[srv] + return _PM.createProcess srv, _OS.APP[srv] if _OS.APP[srv] path = "services/#{srv}.js" _API.script path, (d) -> - _PM.createProcess srv, _APP[srv] + _PM.createProcess srv, _OS.APP[srv] , (e, s) -> _courrier.trigger "srvroutineready", srv - _courrier.trigger "fail", - { id:0,data:{m: "Cannot read service script: #{srv} ", e: e, s: s }, - name:"0S"} + _courrier.osfail "Cannot read service script: #{srv} ", e, s - launch: (app) -> - if not _APP[app] + 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 + + launch: (app, args) -> + if not _OS.APP[app] # first load it path = "packages/#{app}/" _API.script path + "main.js", @@ -61,26 +65,23 @@ self.OS.GUI = .appendTo 'head' , () -> #launch - if _APP[app] + if _OS.APP[app] # load app meta data _API.get "#{path}package.json", (data) -> - _APP[app].meta = data - _PM.createProcess app, _APP[app] + _OS.APP[app].meta = data + _PM.createProcess app, _OS.APP[app], args , (e, s) -> - _courrier.trigger "fail", - {id:0, data:{ m: "Cannot read application metadata: #{app} ",e: e, s: s }, name:"OS"} + _courrier.osfail "Cannot read application metadata: #{app}", e, s alert "cannot read application, meta-data" , (e, s) -> #BUG report here - _courrier.trigger "fail", - {id :0, data:{m: "Cannot load application script: #{app}", - e: e, s:s }, name:"OS"} + _courrier.osfail "Cannot load application script: #{app}", e, s console.log "bug report", e, s, path else # now launch it - if _APP[app] - _PM.createProcess app, _APP[app] + if _OS.APP[app] + _PM.createProcess app, _OS.APP[app], args dock: (app, meta) -> # dock an application to a dock # create a data object @@ -118,6 +119,7 @@ self.OS.GUI = handler event.target event.preventDefault() initDM: -> + # check login first _API.resource "schemes/dm.html", (x) -> return null unless x scheme = $.parseHTML x @@ -134,4 +136,42 @@ self.OS.GUI = console.log "context menu handler for desktop" # system menu riot.mount ($ "#syspanel", $ "#wrapper") - riot.mount ($ "#sysdock", $ "#wrapper"), { items: [] } \ No newline at end of file + riot.mount ($ "#sysdock", $ "#wrapper"), { items: [] } + , (e, s) -> + alert "System fall: Cannot init desktop manager" + + login: () -> + ($ "#wrapper").empty() + _GUI.clearTheme() + _API.resource "schemes/login.html", (x) -> + return null unless x + scheme = $.parseHTML x + ($ "#wrapper").append scheme + ($ "#btlogin").click () -> + data = + username: ($ "#txtuser").val(), + password: ($ "#txtpass").val() + _API.handler.login data, (d) -> + console.log d + if d.error then ($ "#login_error").html d.error else _GUI.startAntOS d.result + , (e, s) -> + alert "System fall: Cannot init login screen" + + startAntOS: (conf) -> + ($ "#wrapper").empty() + _GUI.clearTheme() + _courrier.observable = riot.observable() + _OS.APP = {} + _PM.processes = {} + _PM.pidalloc = 0 + _OS.setting.applications = conf.applications if conf.applications + _OS.setting.appearance = conf.appearance if conf.appearance + _OS.setting.user = conf.user + # get setting from conf + # load packages list + # load theme + # initDM + _GUI.loadTheme "antos" + _GUI.initDM() + _courrier.observable.one "syspanelloaded", () -> + _GUI.pushServices ["PushNotification", "Spotlight", "Calendar"] \ No newline at end of file diff --git a/src/core/handlers/RemoteHandler.coffee b/src/core/handlers/RemoteHandler.coffee new file mode 100644 index 0000000..9404c83 --- /dev/null +++ b/src/core/handlers/RemoteHandler.coffee @@ -0,0 +1,26 @@ +self.OS.API.handler = + scandir: (p, c ) -> + path = "lua-api/fs/scandir" + _API.post path, { path: p }, c, (e, s) -> + _courrier.osfail "Fail to make request: #{path}", e, s + + auth: (c) -> + p = "lua-api/system/auth" + _API.post p, {}, c, () -> + alert "Resource not found: #{p}" + login: (d, c) -> + p = "lua-api/system/login" + _API.post p, d, c, () -> + alert "Resource not found: #{p}" + logout: () -> + p = "lua-api/system/logout" + _API.post p, {}, (d) -> + _OS.boot() + , () -> + alert "Resource not found #{p}" + setting: () -> + p = "lua-api/system/settings" + _API.post p, _OS.setting, (d) -> + _courrier.oserror "Cannot save system setting", d.error if d.error + , (e, s) -> + _courrier.osfail "Fail to make request: #{p}", e, s \ No newline at end of file diff --git a/src/core/handlers/TestHandler.coffee b/src/core/handlers/TestHandler.coffee index b8bd5c7..54a1c37 100644 --- a/src/core/handlers/TestHandler.coffee +++ b/src/core/handlers/TestHandler.coffee @@ -1,8 +1,6 @@ self.OS.API.handler = - request: ( p, d, c, f) -> - path = switch p - when 'scandir' then 'resources/jsons/scandir.json' - else undefined - return unless path - _API.get path, c, f - \ No newline at end of file + scandir: (p, c ) -> + path = 'resources/jsons/scandir.json' + _API.get path , c, (e, s) -> + _courrier.osfail "System fall: Cannot read #{path}", e, s + \ No newline at end of file diff --git a/src/core/schemes/login.html b/src/core/schemes/login.html new file mode 100644 index 0000000..37fde20 --- /dev/null +++ b/src/core/schemes/login.html @@ -0,0 +1,78 @@ + + +
+

Welcome to AntOS, plese identify

+ + + + +
\ No newline at end of file diff --git a/src/core/tags/afx-app-window.js b/src/core/tags/afx-app-window.js index eef7224..ddef264 100644 --- a/src/core/tags/afx-app-window.js +++ b/src/core/tags/afx-app-window.js @@ -77,7 +77,15 @@ $(self.refs.content).children().each(function(e){ this.observable = self.root.observable }) - + var fn = function() + { + var ch = $(self.refs.content).height()/ $(self.refs.content).children().length + $(self.refs.content).children().each(function(e){ + $(this).css("height",ch+"px") + }) + } + fn() + self.root.observable.on("resize", function(){ fn()}) self.root.observable.on("focus",function(){ window._zindex++ $(self.refs.window) diff --git a/src/core/tags/afx-button.js b/src/core/tags/afx-button.js index ce41c71..01d9690 100644 --- a/src/core/tags/afx-button.js +++ b/src/core/tags/afx-button.js @@ -1,11 +1,12 @@
- +
\ No newline at end of file diff --git a/src/core/tags/afx-menu.js b/src/core/tags/afx-menu.js index cc5ad9e..82aed7a 100644 --- a/src/core/tags/afx-menu.js +++ b/src/core/tags/afx-menu.js @@ -4,7 +4,7 @@
  • - + @@ -22,7 +22,7 @@ } else { - this.rid = $(this.root).attr("data-id") + this.rid = $(this.root).attr("data-id") || Math.floor(Math.random() * 100000) + 1 isRoot = true } var self = this @@ -94,7 +94,6 @@ { this.root.observable = riot.observable() this.root.observable.on('menuselect',function(data){ - //console.log("From root",self.root) if(self.onmenuselect) self.onmenuselect(data) diff --git a/src/core/tags/afx-sys-panel.js b/src/core/tags/afx-sys-panel.js index 91b8dd7..49f58c9 100644 --- a/src/core/tags/afx-sys-panel.js +++ b/src/core/tags/afx-sys-panel.js @@ -21,12 +21,17 @@ onmenuselect: function(d) { if(d.e.item.data.type == "app") - window.OS.GUI.launch(d.e.item.data.text) + window.OS.GUI.launch(d.e.item.data.text, null) } }, - {text:"Logout"} + {text:"Logout", dataid: "sys-logout"} ]} - ] + ], + onmenuselect: function(d) + { + if(d.e.item.data.dataid == "sys-logout") + window.OS.API.handler.logout() + } } this.appmenu = { child: [] } this.systray = { diff --git a/src/core/tags/afx-tree-view.js b/src/core/tags/afx-tree-view.js index a28e6dc..c3d9aba 100644 --- a/src/core/tags/afx-tree-view.js +++ b/src/core/tags/afx-tree-view.js @@ -1,17 +1,22 @@ -
    - - +
    +
      +
    • +
    • + + - - { name } + + { name } +
    • +
    • - " + i} treeroot= {parent.treeroot}> + " + i} treeroot= {parent.treeroot}>
    @@ -28,6 +33,8 @@ } this.rid = $(self.root).attr("data-id") || Math.floor(Math.random() * 100000) + 1 self.ontreeselect = opts.ontreeselect + self.ontreedbclick = opts.ontreedbclick + self.fetch = opts.fetch self.indent = opts.indent || 1 var istoggle = false if(opts.treeroot) @@ -66,7 +73,13 @@ } this.on("mount", function(){ - $(self.refs.namediv).css("padding-left", self.indent*15 + "px" ) + $(self.refs.padding) + .css("display", "inline-block") + .css("height","1px") + .css("padding",0) + .css("margin", 0) + .css("background-color","transparent") + .css("width", self.indent*15 + "px" ) }) isFolder() { @@ -77,6 +90,11 @@ self.open = !self.open e.preventDefault() istoggle = true + if(self.open && self.nodes.length == 0 && self.fetch) + self.fetch(e.item, function(d){ + self.nodes = d + self.update() + }) } select(event) @@ -99,5 +117,22 @@ self.treeroot.update() event.preventDefault() } + _dbclick(event) + { + if(istoggle) + { + istoggle = false + return + } + data = { + id:self.rid, + data:event.item, + path: self.path} + if(self.ontreedbclick) + { + self.ontreedbclick(data) + } + self.root.observable.trigger('treedbclick', data) + } \ No newline at end of file diff --git a/src/core/tags/afx-vbox.js b/src/core/tags/afx-vbox.js index bd2b6d4..4860e0c 100644 --- a/src/core/tags/afx-vbox.js +++ b/src/core/tags/afx-vbox.js @@ -1,4 +1,4 @@ - +
    @@ -23,8 +23,8 @@ { var auto_width = [] var csize, ocwidth = 0, avaiheight; - avaiheight = $(self.root).parent().height() - avaiWidth = $(self.root).parent().width() + avaiheight = $(self.root).height() + avaiWidth = $(self.root).width() $(self.refs.container).css("height",avaiheight + "px") $(self.refs.container) .children() diff --git a/src/packages/ActivityMonitor/main.coffee b/src/packages/ActivityMonitor/main.coffee index c9766a9..97cda4c 100644 --- a/src/packages/ActivityMonitor/main.coffee +++ b/src/packages/ActivityMonitor/main.coffee @@ -1,8 +1,8 @@ _PM = this.OS.PM _APP = this.OS.APP class ActivityMonitor extends this.OS.GUI.BaseApplication - constructor: () -> - super "ActivityMonitor" + constructor: (args) -> + super "ActivityMonitor", args main: () -> me = @ @scheme.set "apptitle", "Activity Monitor" diff --git a/src/packages/DummyApp/main.coffee b/src/packages/DummyApp/main.coffee index 351e7f5..86b5af2 100644 --- a/src/packages/DummyApp/main.coffee +++ b/src/packages/DummyApp/main.coffee @@ -1,7 +1,7 @@ _GUI = this.OS.GUI class DummyApp extends this.OS.GUI.BaseApplication - constructor: () -> - super "DummyApp" + constructor: (args) -> + super "DummyApp", args main: () -> self = @ @on "btclick", (e)-> @@ -83,7 +83,14 @@ class DummyApp extends this.OS.GUI.BaseApplication @scheme.set "apptitle", "AntOS feature showcase" @scheme.contextmenuHandler = (e, m) -> - mdata = [ { text: " Child 1" }, { text: "child2", child: [{text: "sub child", child:[{text:"sub sub child"}] }]}] + mdata = [ + { text: " Child 1" }, + { text: "child2", child: [ + {text: "sub child", child:[{text:"sub sub child"}] }, + {text: "sub child 1" } + ], onmenuselect: (e) -> console.log e + } + ] m.set "items", mdata m.show(e) diff --git a/src/packages/Files/main.coffee b/src/packages/Files/main.coffee index 05aa9c2..4e8dc9d 100644 --- a/src/packages/Files/main.coffee +++ b/src/packages/Files/main.coffee @@ -1,62 +1,146 @@ class Files extends this.OS.GUI.BaseApplication - constructor: () -> - super "Files" + constructor: (args) -> + super "Files", args main: () -> me = @ @scheme.set "apptitle", "Files manager" @view = @find "fileview" - @scheme.contextmenuHandler = (e, m) -> - mdata = [ { text: " Child 1" }, { text: "child2", child: [{text: "sub child", child:[{text:"sub sub child"}] }]}] - m.set "items", mdata + @navinput = @find "navinput" + @navbar = @find "nav-bar" + @prepaths = [] + @favo = @find "favouri" + @loadSetting() + + @view.contextmenuHandler = (e, m) -> + m.set "items", [ me.mnFile(), me.mnEdit() ] m.show(e) - @on "fileselect", (d) -> console.log d - #load home directory - p = 'home:///' - @_api.VFS.scandir p, + #@on "fileselect", (d) -> console.log d + @on "filedbclick", (e) -> + #if e.data.type is 'dir' then me.chdir e.data.path, true + @favo.set "onlistselect", (e) -> me.chdir e.data.path, true + + ($ @find "btback").click () -> + return if me.prepaths.length is 0 + p = me.prepaths.pop() + me.favo.set "selected", -1 + me.chdir p, false + + ($ @navinput).keyup (e) -> + me.chdir ($ me.navinput).val() if e.keyCode is 13 #enter + + @view.set "chdir", (p) -> me.chdir p, true + @view.set "fetch", (e, f) -> + return unless e.child + 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}, + { text: "OS", path: 'os:///', iconclass:"fa fa-inbox" }, + { 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 + @toggleNav @setting.nav + + chdir: (p, push) -> + me = @ + me._api.handler.scandir p, (d) -> + if(d.error) + return me.error "Resource not found #{p}" + v = ($ me.navinput).val() + me.prepaths.push v if push and v isnt "" + ($ me.navinput).val p me.view.set "path", p me.view.set "data", d.result , (e, s) -> - alert "cannot open dir" + me.error "Cannot chdir #{p}" + mnFile:() -> + { + text: "File", + child: [ + { text: "New file", dataid: "#{@name}-mkf" }, + { text: "New folder", dataid: "#{@name}-mkdir" }, + { text: "Upload", dataid: "#{@name}-upload" } + ] + } + mnEdit: () -> + me = @ + { + text: "Edit", + child: [ + { text: "Rename", dataid: "#{@name}-mv" }, + { text: "Delete", dataid: "#{@name}-rm" }, + { text: "Information", dataid: "#{@name}-info" }, + { text: "Open with", dataid: "#{@name}-open" }, + { text: "Download", dataid: "#{@name}-download" }, + ], onmenuselect: (e) -> me.actionEdit e + } menu: () -> me = @ menu = [ - { - text: "File", - child: [ - { text: "New file", dataid: "#{@name}-mkf" }, - { text: "New folder", dataid: "#{@name}-mkdir" }, - { text: "Upload", dataid: "#{@name}-upload" } - ] - }, - { - text: "Edit", - child: [ - { text: "Rename", dataid: "#{@name}-mv" }, - { text: "Delete", dataid: "#{@name}-rm" }, - { text: "Information", dataid: "#{@name}-info" }, - { text: "Open with", dataid: "#{@name}-open" }, - { text: "Download", dataid: "#{@name}-download" }, - ] - }, + @mnFile(), + @mnEdit(), { text: "View", child: [ { text: "Refresh", dataid: "#{@name}-refresh" }, - { text: "Sidebar", switch: true, dataid: "#{@name}-side" }, - { text: "Navigation bar", switch: true , dataid: "#{@name}-nav" }, - { text: "Hidden files", switch: true, dataid: "#{@name}-hidden" }, + { text: "Sidebar", switch: true, checked: @setting.sidebar, dataid: "#{@name}-side" }, + { text: "Navigation bar", switch: true, checked: @setting.nav, dataid: "#{@name}-nav" }, + { text: "Hidden files", switch: true, checked: @setting.showhidden, dataid: "#{@name}-hidden" }, { text: "Type", child: [ - { text: "Icon view", radio: true, dataid: "#{@name}-icon", type: 'icon' }, - { text: "List view", radio:true, checked: true, dataid: "#{@name}-list", type: 'list' }, - { text: "Tree view", radio:true, dataid: "#{@name}-tree", type: 'tree' } + { text: "Icon view", radio: true, checked: @setting.view is 'icon', dataid: "#{@name}-icon", type: 'icon' }, + { text: "List view", radio:true, checked: @setting.view is 'list' or not @setting.view, dataid: "#{@name}-list", type: 'list' }, + { text: "Tree view", radio:true, checked: @setting.view is 'tree', dataid: "#{@name}-tree", type: 'tree' } ], onmenuselect: (e) -> me.view.set 'view', e.item.data.type + me.setting.view = e.item.data.type }, - ] + ], onmenuselect: (e) -> me.actionView e }, ] menu -this.OS.register "Files",Files \ No newline at end of file + toggleSidebar: (b) -> + if b then ($ @favo).show() else ($ @favo).hide() + @trigger "resize" + + toggleNav: (b) -> + if b then ($ @navbar).show() else ($ @navbar).hide() + @trigger "resize" + + actionView: (e) -> + switch e.item.data.dataid + when "#{@name}-hidden" + @.view.set "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 + when "#{@name}-nav" + @setting.nav = e.item.data.checked + @toggleNav e.item.data.checked + + actionEdit: (e) -> + switch e.item.data.dataid + when "#{@.name}-info" + file = @view.get "selectedFile" + return unless file + @openDialog "InfoDialog", null, file + else + @_api.handler.setting() + +this.OS.register "Files", Files \ No newline at end of file diff --git a/src/packages/Files/main.css b/src/packages/Files/main.css index e69de29..eaeda08 100644 --- a/src/packages/Files/main.css +++ b/src/packages/Files/main.css @@ -0,0 +1,36 @@ +afx-app-window[data-id ='files-app-window'] afx-list-view{ + border-top:1px solid #A6A6A6; +} +afx-app-window[data-id ='files-app-window'] afx-list-view[data-id='favouri']{ + background-color: #f6F6F6; + border-right: 1px solid #cbcbcb; + border-top:1px solid #A6A6A6; + padding:0; +} + +afx-app-window[data-id ='files-app-window'] afx-list-view[data-id='favouri'] li{ + background-color: transparent; +} +afx-app-window[data-id ='files-app-window'] afx-list-view[data-id='favouri'] li.selected { + background-color: #cecece; + color:#414339; +} +afx-app-window[data-id ='files-app-window'] .afx-window-top{ + border-bottom: 0; +} +afx-app-window[data-id ='files-app-window'] afx-vbox[data-id = "nav-bar"]{ + background-color: #dfdfdf; +} +afx-app-window[data-id ='files-app-window'] afx-grid-view afx-grid-row.grid_row_header div{ + border-top:1px solid #A6A6A6; +} +afx-app-window[data-id ='files-app-window'] button{ + height: 23px; + border-radius: 3px; + padding-top:2px; + margin-left: 5px; +} + +afx-app-window[data-id ='files-app-window'] input{ + border-radius: 3px; +} diff --git a/src/packages/Files/scheme.html b/src/packages/Files/scheme.html index acc4773..5011dce 100644 --- a/src/packages/Files/scheme.html +++ b/src/packages/Files/scheme.html @@ -1,5 +1,14 @@ - - - - - \ No newline at end of file + + + + + +
    +
    + + + + + +
    +
    \ No newline at end of file diff --git a/src/packages/NotePad/main.coffee b/src/packages/NotePad/main.coffee index 0117d0e..711cba7 100644 --- a/src/packages/NotePad/main.coffee +++ b/src/packages/NotePad/main.coffee @@ -1,10 +1,12 @@ class NotePad extends this.OS.GUI.BaseApplication - constructor: () -> - super "NotePad" + constructor: (args) -> + super "NotePad", args main: () -> me = @ @scheme.set "apptitle", "NotePad" - + @sidebar = @find "sidebar" + @location = @find "location" + @fileview = @find "fileview" div = @find "datarea" ace.require "ace/ext/language_tools" @.editor = ace.edit div @@ -52,7 +54,32 @@ class NotePad extends this.OS.GUI.BaseApplication @on "resize", () -> me.editor.resize() @on "focus", () -> me.editor.focus() + + @fileview.set "chdir", (d) -> me.chdir d + @fileview.set "fetch", (e, f) -> + return unless e.child + me._api.handler.scandir e.child.path, + (d) -> f d.result + , (e, s) -> me.error "Cannot fetch child dir #{e.child.path}" + @location.set "onlistselect", (e) -> me.chdir e.data.path + @location.set "items", [ + { text: "Home", path: 'home:///', iconclass:"fa fa-home", selected:true}, + { text: "OS", path: 'os:///', iconclass:"fa fa-inbox" }, + { text: "Desktop", path: 'home:///.desktop', iconclass: "fa fa-desktop" }, + ] + + chdir: (p) -> + me = @ + me._api.handler.scandir p, + (d) -> + if(d.error) + return me.error "Resource not found #{p}" + me.fileview.set "path", p + me.fileview.set "data", d.result + , (e, s) -> + me.error "Cannot chdir #{p}" + menu: ()-> menu = [{ text:"File", diff --git a/src/packages/NotePad/main.css b/src/packages/NotePad/main.css index 823d9b3..48a80b7 100644 --- a/src/packages/NotePad/main.css +++ b/src/packages/NotePad/main.css @@ -13,4 +13,7 @@ afx-app-window[data-id="notepad"] span[data-id="editorstat"]{ } afx-app-window[data-id="notepad"] afx-vbox[data-id="bottom-vbox"]{ background-color: #dfdfdf; +} +afx-app-window[data-id="notepad"] .afx-window-content { + background-color: #f6F6F6; } \ No newline at end of file diff --git a/src/packages/NotePad/scheme.html b/src/packages/NotePad/scheme.html index 0fb36b7..a8b8fc7 100644 --- a/src/packages/NotePad/scheme.html +++ b/src/packages/NotePad/scheme.html @@ -1,25 +1,17 @@ - - - -
    - -
    - - - -
    -
    +
    + +
    + + + +
    + +
    \ No newline at end of file diff --git a/src/packages/wTerm/main.coffee b/src/packages/wTerm/main.coffee index bd37d83..5e21ac1 100644 --- a/src/packages/wTerm/main.coffee +++ b/src/packages/wTerm/main.coffee @@ -1,6 +1,6 @@ class wTerm extends this.OS.GUI.BaseApplication - constructor: () -> - super "wTerm" + constructor: (args) -> + super "wTerm", args main: () -> me = @ diff --git a/src/services/Calendar.coffee b/src/services/Calendar.coffee index 1abf788..8a6aabd 100644 --- a/src/services/Calendar.coffee +++ b/src/services/Calendar.coffee @@ -1,6 +1,6 @@ class Calendar extends this.OS.GUI.BaseService - constructor: () -> - super "Calendar" + constructor: (args) -> + super "Calendar", args #@iconclass = "fa fa-commenting" @text = "" @iconclass = "fa fa-calendar" diff --git a/src/services/PushNotification.coffee b/src/services/PushNotification.coffee index 73cc6d9..c45bf93 100644 --- a/src/services/PushNotification.coffee +++ b/src/services/PushNotification.coffee @@ -1,6 +1,6 @@ class PushNotification extends this.OS.GUI.BaseService - constructor: () -> - super "PushNotification" + constructor: (args) -> + super "PushNotification", args @iconclass = "fa fa-bars" @onmenuselect = (e) -> console.log e @cb = undefined @@ -13,9 +13,11 @@ class PushNotification extends this.OS.GUI.BaseService spin: (b) -> if b and @iconclass is "fa fa-bars" @iconclass = "fa fa-spinner fa-spin" + @color = "#f90e00" @update() else if not b and @iconclass is "fa fa-spinner fa-spin" @iconclass = "fa fa-bars" + @color = "#414339" @update() main: -> diff --git a/src/services/Spotlight.coffee b/src/services/Spotlight.coffee index 79d736c..4d2337c 100644 --- a/src/services/Spotlight.coffee +++ b/src/services/Spotlight.coffee @@ -1,6 +1,6 @@ class Spotlight extends this.OS.GUI.BaseService - constructor: () -> - super "Spotlight" + constructor: (args) -> + super "Spotlight", args @iconclass = "fa fa-search" init: -> @child = [ diff --git a/src/themes/antos/afx-button.css b/src/themes/antos/afx-button.css index eeeb91d..f5a035c 100644 --- a/src/themes/antos/afx-button.css +++ b/src/themes/antos/afx-button.css @@ -2,7 +2,7 @@ afx-button button{ outline: none; padding: 4px; border: 1px solid #a6a6a6; - background-color: white; + background-color: #f6F6F6; color: #414339; border-radius: 6px; font-family: "Ubuntu"; diff --git a/src/themes/antos/afx-file-view.css b/src/themes/antos/afx-file-view.css index 04e53a1..4586f9f 100644 --- a/src/themes/antos/afx-file-view.css +++ b/src/themes/antos/afx-file-view.css @@ -3,13 +3,13 @@ afx-file-view { } afx-file-view div.status{ position: absolute; - bottom: 0px; + bottom: 1px; left:0px; padding:3px; right: 0px; height: 15px; - background-color: #dfdfdf; - border-top: 1px solid #a6A6a6; + background-color: #f6F6F6; + border-top: 1px solid #cbcbcb; } afx-file-view afx-list-view li{ float:left; @@ -29,7 +29,7 @@ afx-file-view afx-list-view i.dir:before{ content: "\f07b"; font-family: "FontAwesome"; font-size: 32px; - color: #414339; + color: #76D2F9; font-weight: normal; font-style: normal; } @@ -55,7 +55,9 @@ afx-file-view afx-list-view li.selected, afx-file-view afx-list-view li.select color:white; border-radius: 6px; } - +afx-file-view afx-grid-view{ + padding:0; +} afx-file-view afx-grid-view i.file:before{ content: "\f016"; font-family: "FontAwesome"; @@ -68,7 +70,7 @@ afx-file-view afx-grid-view i.dir:before{ content: "\f07b"; font-family: "FontAwesome"; font-size: 16px; - color: #414339; + color: #76D2F9; font-style: normal; font-weight: normal; } @@ -83,21 +85,30 @@ afx-file-view afx-grid-view afx-grid-row.grid_row_header{ background-color: #dfdfdf; } afx-file-view afx-grid-view afx-grid-row.grid_row_header div{ - border: 1px solid #a6a6a6; + border-top: 1px solid #a6a6a6; + border-right: 1px solid #a6a6a6; } afx-file-view afx-tree-view .afx-tree-view-folder-close:before{ content: "\f07b"; font-family: "FontAwesome"; font-size: 16px; + color:#76D2F9; } afx-file-view afx-tree-view .afx-tree-view-folder-open:before{ content: "\f07c"; font-family: "FontAwesome"; + color:#76D2F9; font-size: 16px; } -afx-file-view afx-tree-view { +afx-file-view afx-tree-view{ margin:0; + overflow: hidden; + display: inline-block; + background-color: transparent; +} +afx-file-view afx-tree-view .afx_tree_item_odd{ + background-color: transparent; } afx-file-view afx-tree-view i.file:before{ content: "\f016"; @@ -107,8 +118,41 @@ afx-file-view afx-tree-view i.file:before{ font-style: normal; font-weight: normal; } +afx-file-view afx-tree-view div{ + overflow: hidden; + white-space: nowrap; + background-color: transparent; + padding:0; +} +afx-file-view div.treecontainer{ + display: block; + overflow: auto; + padding:0; + margin:0; +} +afx-file-view afx-tree-view div.afx_tree_item_selected, afx-file-view afx-tree-view div.afx_tree_item_selected:hover{ + background-color: transparent; + color:#414339; +} -afx-file-view afx-tree-view div.afx_tree_item_selected i.file:before{ +afx-file-view afx-tree-view li.itemname{ + padding:3px; + padding-right: 5px; +} +afx-file-view afx-tree-view div.afx_tree_item_selected .itemname{ background-color: #116cd6; color:white; -} \ No newline at end of file + border-radius: 3px; + +} +afx-file-view afx-tree-view div.afx_tree_item_selected i.file:before{ + color:white; +} + +afx-file-view afx-tree-view .afx_folder_item{ + font-weight: normal; +} + +afx-file-view afx-tree-view afx-tree-view{ + display: inline-block; +} diff --git a/src/themes/antos/afx-tree-view.css b/src/themes/antos/afx-tree-view.css index 6b4d283..ff7044a 100644 --- a/src/themes/antos/afx-tree-view.css +++ b/src/themes/antos/afx-tree-view.css @@ -7,6 +7,7 @@ afx-tree-view{ afx-tree-view afx-tree-view{ padding:0; overflow: hidden; + display: block; } afx-tree-view ul{ margin:0; diff --git a/src/themes/antos/antos.css b/src/themes/antos/antos.css index e378508..b93c2e2 100644 --- a/src/themes/antos/antos.css +++ b/src/themes/antos/antos.css @@ -5,8 +5,9 @@ html,body{ font-size: 13px; width: 100%; height: 100%; - background-image: url(wallpaper.jpg); - background-size: cover; + background-image: url(wp.png); + /*background-size: cover;*/ + background-repeat: repeat; overflow: hidden; } #wrapper{ @@ -46,7 +47,7 @@ input { padding: 2px; height:23px; border: 1px solid #a6a6a6; - background-color: white; + background-color: #f6F6F6; color: #414339; border-radius: 5px; box-sizing: border-box; diff --git a/src/themes/antos/wallpaper.jpg b/src/themes/antos/wallpaper.jpg deleted file mode 100644 index 1c0f0fc..0000000 Binary files a/src/themes/antos/wallpaper.jpg and /dev/null differ diff --git a/src/themes/antos/wp.png b/src/themes/antos/wp.png new file mode 100644 index 0000000..7199322 Binary files /dev/null and b/src/themes/antos/wp.png differ