Test.GtkWriter.vala.c
[app.Builder.js] / Builder4 / EditProject.js
1 Gtk = imports.gi.Gtk;
2 Gdk = imports.gi.Gdk;
3 Pango = imports.gi.Pango;
4 GLib = imports.gi.GLib;
5 Gio = imports.gi.Gio;
6 GObject = imports.gi.GObject;
7 GtkSource = imports.gi.GtkSource;
8 WebKit = imports.gi.WebKit;
9 Vte = imports.gi.Vte;
10 console = imports.console;
11 XObject = imports.XObject.XObject;
12 EditProject=new XObject({
13     xtype: Gtk.Dialog,
14     listeners : {
15         destroy_event : (self, event) => {
16              this.el.hide();
17                         return false;
18         },
19         response : (self, id) => {
20              if (id < 1) {
21                     this.el.hide();
22                     return;
23             }
24             if (_this.xtype.getValue().length < 1) {
25                 StandardErrorDialog.show("You have to set Project type");             
26                 return;
27             }
28             if (_this.dir.el.get_filename().length < 1) {
29                 StandardErrorDialog.show("You have to select a folder");             
30                 return;
31             }
32         
33             this.el.hide();
34             
35             
36             var fn = _this.dir.el.get_filename();
37             
38             var project = Project.Project.factory(_this.xtype.getValue(), fn);
39             
40             
41             //var pr = imports.Builder.Provider.ProjectManager.ProjectManager.update(this.project);
42             
43             this.success(project);
44         
45         }
46     },
47     border_width : 3,
48     default_height : 500,
49     default_width : 600,
50     title : "Project Properties",
51     deletable : true,
52     modal : true,
53     'void:show' : () {
54           
55     
56         //[ 'xtype'  ].forEach(function(k) {
57         //    _this.get(k).setValue(typeof(c[k]) == 'undefined' ? '' : c[k]);
58         //});
59         // shouild set path..
60         _this.model.loadData();
61         this.el.show_all();
62         //this.success = c.success;
63     },
64     items : [
65         {
66             xtype: Gtk.VBox,
67             pack : get_content_area().add,
68             items : [
69                 {
70                     xtype: Gtk.HBox,
71                     pack : "pack_start,false,true,3",
72                     items : [
73                         {
74                             xtype: Gtk.Label,
75                             pack : "pack_start,false,true,3",
76                             label : "Project type :"
77                         },
78                         {
79                             xtype: Gtk.ComboBox,
80                             id : "xtype",
81                             pack : "pack_end,true,true,3",
82                             init : this.el.add_attribute(cellrender , "markup", 1 );,
83                             setValue : (v)    {
84                                     var el = this.el;
85                                     el.set_active(-1);
86                                     
87                                     for (var i =0;i < this.data.length; i++ ) {
88                                         if (v == this.data.nth_datA(i)) {
89                                             el.set_active(ix);
90                                             return false;
91                                         }
92                                     }
93                                 },
94                             'string:getValue' : () {
95                                  var ix = this.el.get_active();
96                                     if (ix < 0 ) {
97                                         return "";
98                                     }
99                                     switch(ix) {
100                                         case 0:
101                                             return "Roo";
102                                         case 1:
103                                             return "Gtk";
104                                     }
105                                     return "";
106                             },
107                             items : [
108                                 {
109                                     xtype: Gtk.CellRendererText,
110                                     id : "cellrender",
111                                     pack : "pack_start,true"
112                                 },
113                                 {
114                                     xtype: Gtk.ListStore,
115                                     columns : "typeof(string),typeof(string)",
116                                     id : "model",
117                                     n_columns : 3,
118                                     pack : "set_model",
119                                     'void:loadData' : ( ) {
120                                             this.el.clear();
121                                                           
122                                             Gtk.TreeIter iter;
123                                                     
124                                             el.append(out iter);
125                                             
126                                             el.set_value(iter, 0, "Roo");
127                                             el.set_value(iter, 1, "Roo Project");
128                                              el.append(out iter);
129                                             
130                                             el.set_value(iter, 0, "Gtk");
131                                             el.set_value(iter, 1, "Gtk Project");
132                                              
133                                                   
134                                                                          
135                                     }
136                                 }
137                             ]
138                         }
139                     ]
140                 },
141                 {
142                     xtype: Gtk.FileChooserWidget,
143                     pack : "pack_end,true,true,5",
144                     action : Gtk.FileChooserAction.SELECT_FOLDER,
145                     id : "dir",
146                     select_multiple : false
147                 }
148             ]
149         },
150         {
151             xtype: Gtk.Button,
152             pack : "add_action_widget,1",
153             label : "OK"
154         },
155         {
156             xtype: Gtk.Button,
157             pack : "add_action_widget,0",
158             label : "Cancel"
159         }
160     ]
161 });
162 EditProject.init();
163 XObject.cache['/EditProject'] = EditProject;