3 Pango = imports.gi.Pango;
4 GLib = imports.gi.GLib;
6 GObject = imports.gi.GObject;
7 GtkSource = imports.gi.GtkSource;
8 WebKit = imports.gi.WebKit;
10 console = imports.console;
11 XObject = imports.XObject.XObject;
12 DialogNewComponent=new XObject({
16 title : "New Component",
17 id : "DialogNewComponent",
25 c = c || { name : '' , xtype : '' };
26 // check whic project we are adding to..
27 XObject.extend(this, c);
28 // causes problems.. get_screen?? not transfer ownership?
29 /// var Window = imports.Builder.Window.Window;
30 //this.el.set_screen(Window.el.get_screen());
33 //for (var i in this.project.paths) {
39 //console.log('load paths');
42 // this.get('directory_model').loadData(paths);
45 console.log('show all');
47 this.success = c.success;
49 var tm = this.get('template_model');
54 var dir = __script_path__ + '/templates/';
56 var f = Gio.file_new_for_path(dir);
57 f.enumerate_children_async ("*", Gio.FileQueryInfoFlags.NONE,
58 GLib.PRIORITY_DEFAULT, null, function(o,ar) {
60 var fe = f.enumerate_children_finish(ar);
62 while (ch = fe.next_file(null)) {
63 var add = dir + '/' + ch.get_name();
64 if (!add.match(/\.js$/)) {
67 tm.templates.push(add);
77 "delete_event":function (self, event) {
81 "response":function (self, response_id) {
82 if (response_id < 1) { // cancel!
91 if (!this.get('xnsid').el.get_text().length ) {
92 this.get('/StandardErrorDialog').show(
93 "You have to set Project name "
99 for (var i in this.project.paths) {
104 var xidns = DialogNewComponent.get('xnsid').el.get_text();
107 if (GLib.file_test (GLib.dir + '/' + xidns + '.bjs', GLib.FileTest.EXISTS)) {
108 StandardErrorDialog.show(
109 "That file already exists"
116 //var tmpl = this.project.loadFileOnly(DialogNewComponent.get('template').getValue());
119 var nf = _this.project.create(dir + '/' + xidns + '.bjs');
120 if (this.get('/DialogNewComponent').success) {
121 this.get('/DialogNewComponent').success(_this.project, nf);
124 "show":function (self) {
131 pack : function(p,e) {
132 p.el.get_content_area().add(e.el)
137 pack : "pack_start,false,true,0",
141 pack : "pack_start,false,true,0",
142 label : "Component Name",
147 pack : "pack_end,true,true,0",
156 pack : "add_action_widget,0",
161 pack : "add_action_widget,1",
166 DialogNewComponent.init();
167 XObject.cache['/DialogNewComponent'] = DialogNewComponent;