From 6e98c7c2dbe7542a5136da32997ceb9c73269ebd Mon Sep 17 00:00:00 2001 From: Alan Knowles Date: Fri, 17 Dec 2010 10:17:32 +0800 Subject: [PATCH] sync --- Builder/Provider/ProjectManager.js | 16 ++++++++++++---- Sample/Window.bjs | 24 ++++++++++++------------ Sample/Window.js | 29 +++++++++++++++-------------- 3 files changed, 39 insertions(+), 30 deletions(-) diff --git a/Builder/Provider/ProjectManager.js b/Builder/Provider/ProjectManager.js index ccba8c89b..c108fad21 100755 --- a/Builder/Provider/ProjectManager.js +++ b/Builder/Provider/ProjectManager.js @@ -43,9 +43,7 @@ ProjectManager = new Observable({ dir.make_directory(); return; } - - - + this.projects = []; var gdir = GLib.dir_open(this.dirname,0); while (true) { @@ -53,7 +51,7 @@ ProjectManager = new Observable({ var fn = gdir.read_name(); if (!fn) { gdir.close(); - return; + break; } if (!fn.match(/.json$/)) { continue; @@ -78,7 +76,17 @@ ProjectManager = new Observable({ } + this.projects.sort(function(a,b) { + if (a.getName() == b.getName()) { + return 0; + } + return a.getName() > b.getName() ? 1 : -1; + + + }); + + diff --git a/Sample/Window.bjs b/Sample/Window.bjs index 9876443e5..cb877e8eb 100644 --- a/Sample/Window.bjs +++ b/Sample/Window.bjs @@ -362,15 +362,15 @@ "pack": "pack_start,false,false", "items": [ { - "|xns": "Gtk", - "xtype": "ComboBox", - "id": "combo", - "|init": "function() {\n XObject.prototype.init.call(this);\n this.el.add_attribute(this.get('render').el , 'markup', 1 ); \n}\n", - "|getValue": "function() {\n var ix = this.el.get_active();\n if (ix < 0 ) {\n return false;\n }\n var data = imports.Builder.Provider.ProjectManager.ProjectManager.projects;\n if (typeof(data[ix]) == 'undefined') {\n \treturn false; \n }\n return data[ix].fn;\n}", - "|setValue": "function(fn)\n{\n var el = this.el;\n el.set_active(-1);\n var data = imports.Builder.Provider.ProjectManager.ProjectManager.projects;\n data.forEach(function(n, ix) {\n if (fn == n.fn) {\n el.set_active(ix);\n return false;\n }\n });\n}\n", "listeners": { "changed": "function (self) {\n\tvar fn = this.getValue();\n\tvar pm = imports.Builder.Provider.ProjectManager.ProjectManager;\n\tthis.get('/LeftProjectTree.model').loadProject(pm.getByFn(fn))\n}" }, + "id": "combo", + "xtype": "ComboBox", + "|getValue": "function() {\n var ix = this.el.get_active();\n if (ix < 0 ) {\n return false;\n }\n var data = imports.Builder.Provider.ProjectManager.ProjectManager.projects;\n if (typeof(data[ix]) == 'undefined') {\n \treturn false; \n }\n return data[ix].fn;\n}", + "|init": "function() {\n XObject.prototype.init.call(this);\n this.el.add_attribute(this.get('render').el , 'markup', 1 ); \n}\n", + "|setValue": "function(fn)\n{\n var el = this.el;\n el.set_active(-1);\n var data = imports.Builder.Provider.ProjectManager.ProjectManager.projects;\n data.forEach(function(n, ix) {\n if (fn == n.fn) {\n el.set_active(ix);\n return false;\n }\n });\n}\n", + "|xns": "Gtk", "items": [ { "|xns": "Gtk", @@ -379,12 +379,12 @@ "id": "render" }, { - "|xns": "Gtk", - "xtype": "ListStore", + "id": "combomodel", "pack": "set_model", - "|init": "function() {\n XObject.prototype.init.call(this);\n this.el.set_column_types ( 2, [\n GObject.TYPE_STRING, // real key\n GObject.TYPE_STRING // real type\n \n \n ] );\n var pm = imports.Builder.Provider.ProjectManager.ProjectManager;\n var _this = this;\n pm.on('changed', function() {\n print(\"caught changed hook on project manager - reloading data\");\n\t_this.loadData(pm.projects);\n\n });\n}\n", + "xtype": "ListStore", + "|init": "function() {\n XObject.prototype.init.call(this);\n this.el.set_column_types ( 2, [\n GObject.TYPE_STRING, // real key\n GObject.TYPE_STRING // real type\n \n \n ] );\n // this.el.set_sort_column_id(1,Gtk.SortType.ASCENDING);\n var pm = imports.Builder.Provider.ProjectManager.ProjectManager;\n var _this = this;\n pm.on('changed', function() {\n print(\"caught changed hook on project manager - reloading data\");\n\t_this.loadData(pm.projects);\n\n });\n}\n", "|loadData": "function(data) {\n var ov = this.get('/LeftProjectTree.combo').getValue();\n this.el.clear();\n var iter = new Gtk.TreeIter();\n var el = this.el;\n data.forEach(function(p) {\n \n el.append(iter);\n \n \n el.set_value(iter, 0, p.fn);\n el.set_value(iter, 1, p.name);\n \n });\n \n this.get('/LeftProjectTree.combo').setValue(ov);\n}\n", - "id": "combomodel" + "|xns": "Gtk" } ] } @@ -779,10 +779,10 @@ "|xns": "Gtk" }, { - "|xns": "Gtk", + "pack": false, "xtype": "TreeViewColumn", "|init": "function() {\n this.el = new Gtk.TreeViewColumn();\n this.parent.el.append_column(this.el);\n \n XObject.prototype.init.call(this);\n this.el.add_attribute(this.items[0].el , 'markup', 4 );\n}\n", - "pack": false, + "|xns": "Gtk", "items": [ { "|xns": "Gtk", diff --git a/Sample/Window.js b/Sample/Window.js index 4696e8193..04aaf2c7e 100644 --- a/Sample/Window.js +++ b/Sample/Window.js @@ -1468,11 +1468,14 @@ Window=new XObject({ items : [ { xtype: Gtk.ComboBox, - id : "combo", - init : function() { - XObject.prototype.init.call(this); - this.el.add_attribute(this.get('render').el , 'markup', 1 ); + listeners : { + changed : function (self) { + var fn = this.getValue(); + var pm = imports.Builder.Provider.ProjectManager.ProjectManager; + this.get('/LeftProjectTree.model').loadProject(pm.getByFn(fn)) + } }, + id : "combo", getValue : function() { var ix = this.el.get_active(); if (ix < 0 ) { @@ -1484,6 +1487,10 @@ Window=new XObject({ } return data[ix].fn; }, + init : function() { + XObject.prototype.init.call(this); + this.el.add_attribute(this.get('render').el , 'markup', 1 ); + }, setValue : function(fn) { var el = this.el; @@ -1496,13 +1503,6 @@ Window=new XObject({ } }); }, - listeners : { - changed : function (self) { - var fn = this.getValue(); - var pm = imports.Builder.Provider.ProjectManager.ProjectManager; - this.get('/LeftProjectTree.model').loadProject(pm.getByFn(fn)) - } - }, items : [ { xtype: Gtk.CellRendererText, @@ -1511,6 +1511,7 @@ Window=new XObject({ }, { xtype: Gtk.ListStore, + id : "combomodel", pack : "set_model", init : function() { XObject.prototype.init.call(this); @@ -1520,6 +1521,7 @@ Window=new XObject({ ] ); + // this.el.set_sort_column_id(1,Gtk.SortType.ASCENDING); var pm = imports.Builder.Provider.ProjectManager.ProjectManager; var _this = this; pm.on('changed', function() { @@ -1544,8 +1546,7 @@ Window=new XObject({ }); this.get('/LeftProjectTree.combo').setValue(ov); - }, - id : "combomodel" + } } ] } @@ -2739,6 +2740,7 @@ Window=new XObject({ }, { xtype: Gtk.TreeViewColumn, + pack : false, init : function() { this.el = new Gtk.TreeViewColumn(); this.parent.el.append_column(this.el); @@ -2746,7 +2748,6 @@ Window=new XObject({ XObject.prototype.init.call(this); this.el.add_attribute(this.items[0].el , 'markup', 4 ); }, - pack : false, items : [ { xtype: Gtk.CellRendererText, -- 2.39.2