diff options
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 46 |
1 files changed, 40 insertions, 6 deletions
@@ -101,13 +101,13 @@ settype(GuiElement *g, int type) for(int i = 0; i < nbaseprops; i++){ int tag = baseprops[i]; props[i].tag = tag; - props[i].val = propspecs[tag].def(); + props[i].val = propspecs[tag].def(type, tag); props[i].qid = mkpropqid(tag); } for(int i = 0; i < spec.nprops; i++){ int tag = spec.proptags[i]; props[i+nbaseprops].tag = tag; - props[i+nbaseprops].val = propspecs[tag].def(); + props[i+nbaseprops].val = propspecs[tag].def(type, tag); props[i+nbaseprops].qid = mkpropqid(tag); } @@ -195,9 +195,14 @@ fswalk1(Fid *fid, char *name, Qid *qid) fid->aux = g->parent; *qid = g->parent->qid; } - }else if(strcmp(name, "clone") == 0) - *qid = g->qclone; - else if(strcmp(name, "event") == 0) + }else if(strcmp(name, "clone") == 0){ + rlock(&g->lock); + if(guispecs[g->type].leafnode) + err = Eexist; + else + *qid = g->qclone; + runlock(&g->lock); + }else if(strcmp(name, "event") == 0) *qid = g->qevent; else if(strcmp(name, "type") == 0) *qid = g->qtype; @@ -304,6 +309,11 @@ dirtreegen(int n, Dir *d, void *aux) d->gid = estrdup9p(username); d->muid = estrdup9p(username); + rlock(&g->lock); + if(guispecs[g->type].leafnode) + n++; + runlock(&g->lock); + if(n < Fmax){ d->length = 0; @@ -427,7 +437,31 @@ fswrite(Req *r) switch(QID_TYPE(r->fid->qid)){ case Qtype: - err = "Can't switch type"; + { + char *buf = emalloc(r->ifcall.count + 1); + buf[r->ifcall.count] = 0; + memcpy(buf, r->ifcall.data, r->ifcall.count); + + int type; + for(type = 0; type < Gmax; type++){ + char *name = guispecs[type].name; + int len = strlen(name); + if(strncmp(buf, name, len) == 0 && allspace(buf+len)){ + rlock(&g->lock); + int canswitch = (g->nchildren == 0 || guispecs[type].leafnode == 0); + runlock(&g->lock); + + if(canswitch) + settype(g, type); + else + err = "old node has children, and new node type can't"; + break; + } + } + if(type == Gmax) + err = "no such gui element type"; + free(buf); + } break; case Qprop: { |