X-Git-Url: http://git.roojs.org/?a=blobdiff_plain;f=Sample%2FEditProject.js;h=456e1e5f64611270ca2e5a3f70a14fd9692164b2;hb=048b010aaf3960fd73352f23d6884b2dad08e9e2;hp=bf8f093c9d7241148a746b1a971710ca2d3d6c2e;hpb=b52e9d72db45e252a32beb38acdf67e61b1159bb;p=app.Builder.js diff --git a/Sample/EditProject.js b/Sample/EditProject.js index bf8f093c9..456e1e5f6 100644 --- a/Sample/EditProject.js +++ b/Sample/EditProject.js @@ -11,11 +11,11 @@ console = imports.console; XObject = imports.XObject.XObject; EditProject=new XObject({ xtype: Gtk.Dialog, - default_height : 300, + default_height : 500, default_width : 600, deletable : true, modal : true, - border_width : 0, + border_width : 3, title : "Project Properties", show : function(c) { c = c || { name : '' , xtype : '' }; @@ -24,36 +24,42 @@ EditProject=new XObject({ this.init(); } var _this = this; - [ 'xtype' , 'name' ].forEach(function(k) { + [ 'xtype' ].forEach(function(k) { _this.get(k).setValue(typeof(c[k]) == 'undefined' ? '' : c[k]); }); + // shouild set path.. this.el.show_all(); this.success = c.success; }, listeners : { - "destroy_event":function (self, event) { + destroy_event : function (self, event) { this.el.hide(); - return true; + return false; }, - "response":function (self, response_id) { + response : function (self, id) { if (id < 1) { this.el.hide(); return; } if (!this.get('xtype').getValue().length) { - this.get('/StandardErrorDialog').show("You have to set Project type"); - + this.get('/StandardErrorDialog').show("You have to set Project type"); return; } + if (!this.get('dir').el.get_filename().length) { + this.get('/StandardErrorDialog').show("You have to select a folder"); + return; + } + this.el.hide(); + var fn = this.get('dir').el.get_filename(); - - this.project.name = this.get('name').getValue(); + this.project.name = GLib.basename(fn); this.project.xtype = this.get('xtype').getValue(); - + this.project.paths = {}; + this.project.paths[fn] = 'dir' ; var pr = imports.Builder.Provider.ProjectManager.ProjectManager.update(this.project); @@ -65,8 +71,8 @@ EditProject=new XObject({ { xtype: Gtk.VBox, pack : function(p,e) { - p.el.get_content_area().add(e.el) - }, + p.el.get_content_area().add(e.el) + }, items : [ { xtype: Gtk.HBox, @@ -75,34 +81,11 @@ EditProject=new XObject({ { xtype: Gtk.Label, pack : "pack_start,false,true,3", - label : "Project Name :" - }, - { - xtype: Gtk.Entry, - pack : "pack_end,true,true,0", - id : "name", - getValue : function() { - return this.el.get_text(); - }, - setValue : function(v) - { - this.el.set_text(v); - } - } - ] - }, - { - xtype: Gtk.HBox, - pack : "pack_start,false,true,3", - items : [ - { - xtype: Gtk.Label, - pack : "pack_start,false,true,0", label : "Project type :" }, { xtype: Gtk.ComboBox, - pack : "pack_end,true,true,0", + pack : "pack_end,true,true,3", id : "xtype", setValue : function(v) { @@ -122,10 +105,14 @@ EditProject=new XObject({ } return this.get('model').data[ix].xtype; }, + init : function() { + XObject.prototype.init.call(this); + this.el.add_attribute(this.items[0].el , 'markup', 1 ); + }, items : [ { xtype: Gtk.CellRendererText, - pack : false + pack : "pack_start" }, { xtype: Gtk.ListStore, @@ -162,9 +149,7 @@ EditProject=new XObject({ el.set_value(iter, 1, p.desc); }); - - - + }, id : "model" @@ -175,8 +160,10 @@ EditProject=new XObject({ }, { xtype: Gtk.FileChooserWidget, - pack : "pack_end,true,true,3", - action : Gtk.FileChooserAction.SELECT_FOLDER + pack : "pack_end,true,true,5", + action : Gtk.FileChooserAction.SELECT_FOLDER, + id : "dir", + select_multiple : false } ] },