add setting package

This commit is contained in:
Xuan Sang LE 2018-03-11 21:31:40 +01:00
parent 10015d99b0
commit 8fef0c5e96
23 changed files with 231 additions and 24 deletions

View File

@ -240,7 +240,7 @@ class AboutDialog extends BaseDialog
super "AboutDialog"
init: () ->
@render "os:///resources/schemes/about.html"
@render "os://resources/schemes/about.html"
main: () ->
mt = @meta()
@ -260,7 +260,7 @@ class FileDiaLog extends BaseDialog
super "FileDiaLog"
init: () ->
@render "os:///resources/schemes/filedialog.html"
@render "os://resources/schemes/filedialog.html"
main: () ->
fileview = @find "fileview"

View File

@ -242,7 +242,7 @@ self.OS.API =
, (e, s) ->
_courrier.oserror __("Cannot load 3rd library at: {0}", l), e, r
else
path = "os:///scripts/"
path = "os://scripts/"
js = "#{path}#{l}.js"
js.asFileHandler().onready (d) ->
_API.shared[l] = true

View File

@ -118,7 +118,7 @@ self.OS.GUI =
_GUI.launch app, args
loadApp: (app, ok, err) ->
path = "os:///packages/#{app}"
path = "os://packages/#{app}"
path = _OS.setting.system.packages[app].path if _OS.setting.system.packages[app].path
js = path + "/main.js"
@ -210,7 +210,15 @@ self.OS.GUI =
c = arr[1].toUpperCase()
return unless _GUI.shortcut[fnk]
_GUI.shortcut[fnk][c] = f
wallpaper: (obj) ->
if obj
_OS.setting.appearance.wp = obj
wp = _OS.setting.appearance.wp
$("body").css("background-image", "url(#{_API.handler.get}/#{wp.url})" )
.css("background-size", wp.size)
.css("ackground-repeat", wp.repeat)
initDM: ->
($ document).on 'webkitfullscreenchange mozfullscreenchange fullscreenchange MSFullscreenChange', ()->
_GUI.fullscreen = not _GUI.fullscreen
@ -388,6 +396,7 @@ self.OS.GUI =
#console.log _OS.setting
# load theme
_GUI.loadTheme _OS.setting.appearance.theme
_GUI.wallpaper()
_courrier.observable.one "syspanelloaded", () ->
# TODO load packages list then build system menu
_courrier.observable.on "systemlocalechange", (name) ->

View File

@ -2,18 +2,23 @@
_OS.setting.desktop = conf.desktop if conf.desktop
_OS.setting.applications = conf.applications if conf.applications
_OS.setting.appearance = conf.appearance if conf.appearance
_OS.setting.appearance.wp = {
url: "os://resources/themes/system/wp/wp2.png",
size: "cover",
repeat: "repeat"
} unless _OS.setting.appearance.wp
_OS.setting.user = conf.user
_OS.setting.VFS = conf.VFS if conf.VFS
_OS.setting.desktop.path = "home:///.desktop" unless _OS.setting.desktop.path
_OS.setting.desktop.path = "home://.desktop" unless _OS.setting.desktop.path
_OS.setting.desktop.menu = {} unless _OS.setting.desktop.menu
_OS.setting.VFS.mountpoints = [
#TODO: multi app try to write to this object, it neet to be cloned
{ text: __("Applications"), path: 'app:///', iconclass: "fa fa-adn", type: "app" },
{ text: __("Home"), path: 'home:///', iconclass: "fa fa-home", type: "fs" },
{ text: __("Applications"), path: 'app://', iconclass: "fa fa-adn", type: "app" },
{ text: __("Home"), path: 'home://', iconclass: "fa fa-home", type: "fs" },
{ text: __("Desktop"), path: _OS.setting.desktop.path , iconclass: "fa fa-desktop", type: "fs" },
{ text: __("OS"), path: 'os:///', iconclass: "fa fa-inbox", type: "fs" },
{ text: __("Google Drive"), path: 'gdv:///', iconclass: "fa fa-inbox", type: "fs" },
{ text: __("Shared"), path: 'shared:///' , iconclass: "fa fa-share-square", type: "fs" }
{ text: __("OS"), path: 'os://', iconclass: "fa fa-inbox", type: "fs" },
{ text: __("Google Drive"), path: 'gdv://', iconclass: "fa fa-inbox", type: "fs" },
{ text: __("Shared"), path: 'shared://' , iconclass: "fa fa-share-square", type: "fs" }
] if not _OS.setting.VFS.mountpoints
_OS.setting.system = conf.system if conf.system
@ -28,8 +33,8 @@
} if not _OS.setting.system.startup
_OS.setting.system.pkgpaths = {
user: "home:///.packages",
system: "os:///packages"
user: "home://.packages",
system: "os://packages"
} unless _OS.setting.system.pkgpaths
_OS.setting.system.locale = "en_GB" unless _OS.setting.system.locale
_OS.setting.system.menu = {} unless _OS.setting.system.menu

View File

@ -20,7 +20,7 @@
return self[k]
}
this.on("mount", function (e) {
this.on("mount", function (e) {
self.refs.grid.root.observable = self.root.observable
calendar(null)
self.root.observable.on("gridcellselect", function(d){

View File

@ -6,6 +6,7 @@
var self = this
this.rid = $(self.root).attr("data-id") || Math.floor(Math.random() * 100000) + 1
this.on('mount', function(){
self.root.observable = (self.parent && self.parent.root && self.parent.root.observable) || opts.observable || riot.observable()
$(self.refs.container)
.css("display","flex")
.css("flex-direction","row")
@ -29,6 +30,16 @@
var csize, ocwidth = 0, avaiheight;
avaiheight = $(self.root).height()
avaiWidth = $(self.root).width()
/*if(avaiheight == 0)
{
avaiheight = $(self.parent.root).height()
$(self.root).css("height", avaiheight+"px")
}
if(avaiWidth == 0)
{
avaiWidth = $(self.parent.root).width()
$(self.root).css("height", avaiWidth+"px")
}*/
$(self.refs.container).css("height",avaiheight + "px")
$(self.refs.container)
.children()

View File

@ -112,6 +112,7 @@
}
this.on("mount", function(){
self.root.observable = opts.observable || (self.parent && self.parent.root && self.parent.root.observable) || riot.observable()
if(opts.dropdown == "true")
{
$(document).click(function(event) {

View File

@ -6,7 +6,7 @@
else
this.swon = false
var self = this
this.root.observable = opts.observable
//this.root.observable = opts.observable
if(opts.enable != undefined)
this.enable = opts.enable
else
@ -31,6 +31,9 @@
opts.swon = !self.swon
self.update()
}
/*this.on("mount", function(){
self.root.observable = (self.parent && self.parent.root && self.parent.root.observable) || opts.observable || riot.observable()
})*/
this.on("update", function(e){
self.swon = opts.swon
self.onchange = opts.onchange

View File

@ -3,7 +3,6 @@
<script>
var self = this
this.closable = opts.closable || false
self.root.observable = opts.observable || riot.observable()
self.ontabselect = opts.ontabselect
get_observable(){
return self.root.observable
@ -17,6 +16,7 @@
self.update(true)
}
self.on("mount", function(){
self.root.observable = opts.observable || (self.parent && self.parent.root && self.parent.root.observable) || riot.observable()
self.refs.list.root.observable = self.root.observable
/*self.root.observable.on("listselect", function(){
console.log("list select")

View File

@ -0,0 +1,84 @@
<afx-tab-container>
<afx-hbox ref = "mybox" if = {bar == "left"}>
<afx-tab-bar data-ref="tabbar" ></afx-tab-bar>
<div data-ref="container"></div>
</afx-hbox>
<afx-vbox ref = "mybox" if = { bar == "top"}>
<afx-tab-bar data-ref="tabbar" ></afx-tab-bar>
<div data-ref="container"></div>
</afx-vbox>
<script>
this.bar = opts.bar || "top"
this.barwidth = opts.barwidth
this.barheight = opts.barheight
var schemes = []
var self = this
var calibrate = function()
{
$(self.refs.mybox.root).css("width", $(self.root).width()+"px")
$(self.refs.mybox.root).css("height", $(self.root).height()+"px")
self.root.observable.trigger("calibrate")
}
self.on("mount", function () {
self.tabbar = $("[data-ref='tabbar']", self.root)[0]
self.container = $("[data-ref='container']", self.root)[0]
if(self.barwidth)
$(self.tabbar).attr("data-width", self.barwidth)
if(self.barheight)
$(self.tabbar).attr("data-height", self.barheight)
self.root.observable = (self.parent && self.parent.root && self.parent.root.observable) || opts.observable || riot.observable()
self.tabbar.set("ontabselect", function(e){
$(self.container).children().each(function(el){
$(this).hide()
})
$(e.data.scheme).show()
e.data.f()
calibrate()
})
self.root.observable.on("resize", function(){
calibrate()
})
})
var render = function(el)
{
var sch = $.parseHTML(el.scheme)
$(self.container).append(sch)
el.scheme = sch
riot.mount(sch, {observable: self.root.observable})
$(sch).hide()
el.f()
self.root.observable.trigger("tabrendered")
//self.root.observable.trigger("calibrate")
}
var addTab = function(el)
{
if(!el.f)
el.f = (function(){})
self.tabbar.push(el)
if(el.url)
{
el.url.asFileHandler().read(function(d){
el.scheme = d
render(el)
})
}
else
{
render(el)
}
}
self.root.setTabs = function(arr)
{
if(arr.length <= 0)
{
self.tabbar.set("selected", 0)
return
}
self.root.observable.one("tabrendered", function(){
arr.splice(0,1)
self.root.setTabs(arr)
})
addTab(arr[0])
}
</script>
</afx-tab-container>

View File

@ -6,6 +6,7 @@
var self = this
this.rid = $(self.root).attr("data-id") || Math.floor(Math.random() * 100000) + 1
this.on('mount', function(){
self.root.observable = (self.parent && self.parent.root && self.parent.root.observable) || opts.observable || riot.observable()
$(self.refs.container)
.css("display","flex")
.css("flex-direction","column")
@ -32,6 +33,16 @@
var csize, ocheight = 0, avaiheight;
avaiheight = $(self.root).height()
avaiwidth = $(self.root).width()
/*if(avaiheight == 0)
{
avaiheight = $(self.parent.root).height()
$(self.root).css("height", avaiheight+"px")
}
if(avaiwidth == 0)
{
avaiwidth = $(self.parent.root).width()
$(self.root).css("height", avaiwidth+"px")
}*/
$(self.refs.container).css("height",avaiheight + "px")
$(self.refs.container)
.children()

View File

@ -1,5 +1,5 @@
String.prototype.asFileHandler = () ->
list = @split ":///"
list = @split "://"
handlers = _API.VFS.findHandlers list[0]
if not handlers or handlers.length is 0
_courrier.osfail __("VFS unknown handler: {0}", @), (_API.throwe "OS.VFS"), @
@ -25,7 +25,7 @@ class BaseFileHandler
@ready = false
return unless p
@path = p.toString()
list = @path.split ":///"
list = @path.split "://"
@protocol = list[0]
return unless list.length > 1
re = list[1].replace(/^\/+|\/+$/g, '')
@ -67,7 +67,7 @@ class BaseFileHandler
return _courrier.osfail __("VFS Cannot encode file: {0}", me.path), (_API.throwe "OS.VFS"), e
parent: () ->
return @ if @isRoot()
return (@protocol + ":///" + (@genealogy.slice 0 , @genealogy.length - 1).join "/")
return (@protocol + "://" + (@genealogy.slice 0 , @genealogy.length - 1).join "/")
onready: (f, err) ->
# read meta data

View File

@ -1,6 +1,6 @@
# GoogleDrive File Handler
G_CACHE = {"gdv:///":{ id: "root", mime: 'dir' } }
G_CACHE = {"gdv://":{ id: "root", mime: 'dir' } }
class GoogleDriveHandler extends this.OS.API.VFS.BaseFileHandler
constructor: (path) ->
@ -17,7 +17,7 @@ class GoogleDriveHandler extends this.OS.API.VFS.BaseFileHandler
fn = (r) ->
return f() if r
# perform the login
G_CACHE = {"gdv:///":{ id: "root", mime: 'dir' } }
G_CACHE = {"gdv://":{ id: "root", mime: 'dir' } }
gapi.auth2.getAuthInstance().signIn()
if _API.libready @setting.apilink
@ -316,7 +316,7 @@ self.OS.API.onsearch "Google Drive", (t) ->
return arr
self.OS.onexit "cleanUpGoogleDrive", () ->
G_CACHE = { "gdv:///": { id: "root", mime: 'dir' } }
G_CACHE = { "gdv://": { id: "root", mime: 'dir' } }
return unless _OS.setting.VFS.gdrive and _API.libready _OS.setting.VFS.gdrive.apilink
auth2 = gapi.auth2.getAuthInstance()
return unless auth2

View File

@ -80,7 +80,7 @@ class CodeBlock extends this.OS.GUI.BaseApplication
@socket.onopen = () ->
console.log "socket open"
enc = new TextEncoder "utf-8"
me.socket.send enc.encode me.blen + "os:///packages/packages.json"
me.socket.send enc.encode me.blen + "os://packages/packages.json"
@socket.onmessage = (e) ->
console.log e.data

View File

@ -8,7 +8,7 @@ class Files extends this.OS.GUI.BaseApplication
@view = @find "fileview"
@navinput = @find "navinput"
@navbar = @find "nav-bar"
@currdir = if @args and @args.length > 0 then @args[0].asFileHandler() else "home:///".asFileHandler()
@currdir = if @args and @args.length > 0 then @args[0].asFileHandler() else "home://".asFileHandler()
@favo = @find "favouri"
@clipboard = undefined

View File

@ -0,0 +1,11 @@
coffee_files = main.coffee
jsfiles =
cssfiles = main.css
copyfiles = scheme.html package.json schemes
PKG_NAME=Setting
include ../pkg.mk

View File

@ -0,0 +1,25 @@
class Setting extends this.OS.GUI.BaseApplication
constructor: (args) ->
super "Setting", args
main: () ->
me = @
@container = @find "container"
@container.setTabs [
{
text: "Appearance",
iconclass: "fa fa-paint-brush",
url: "#{@path()}/schemes/appearance.html",
f: () ->
console.log "finish init appearance"
},
{
text: "VFS",
iconclass: "fa fa-inbox" ,
url: "#{@path()}/schemes/vfs.html" ,
f: () ->
console.log "finish init VFS"
}
]
Setting.singleton = true
this.OS.register "Setting", Setting

View File

@ -0,0 +1,11 @@
afx-app-window[data-id = "setting-window"] afx-tab-container afx-tab-bar afx-list-view > div > ul > li{
float:none;
border-radius: 0;
font-weight: bold;
padding-top:3px;
padding-bottom: 3px;
border:0;
}
afx-app-window[data-id = "setting-window"] afx-tab-container div[data-ref="container"]{
border-left: 1px solid #cbcbcb;
}

View File

@ -0,0 +1,13 @@
{
"app":"Setting",
"name":"System setting",
"description":"System setting",
"info":{
"author": "Xuan Sang LE",
"email": "xsang.le@gmail.com"
},
"version":"0.1a",
"category":"System",
"iconclass":"fa fa-wrench",
"mimes":["none"]
}

View File

@ -0,0 +1,5 @@
<afx-app-window data-id = "setting-window" apptitle="Setting" width="600" height="400">
<afx-vbox>
<afx-tab-container data-id = "container" barwidth="120" bar="left"></afx-tab-container>
</afx-vbox>
</afx-app-window>

View File

@ -0,0 +1,14 @@
<afx-vbox>
<afx-label text = "__(Wallpaper)" class = "header" data-height="30"></afx-label>
<afx-hbox>
<afx-list-view data-width="120"></afx-list-view>
<div>
</div>
</afx-hbox>
<afx-label text = "__(Theme)" class = "header" data-height="30"></afx-label>
<afx-list-view data-height="50" dropdown="true"></afx-list-view>
<afx-hbox data-height="30" >
<div></div>
<afx-button text="__(Save)" iconclass="fa fa-save" data-width="50"></afx-button>
</afx-hbox>
</afx-vbox>

View File

@ -0,0 +1 @@
<afx-label text = "example2" ></afx-label>

View File

@ -0,0 +1,3 @@
afx-tab-container{
display: block;
}