Attribute changed old-javascript
[app.Builder.js] / old-javascript / Builder4 / DialogTemplateSelect.vala
1 static DialogTemplateSelect  _DialogTemplateSelect;
2
3 public class DialogTemplateSelect : Object 
4 {
5     public Gtk.Dialog el;
6     private DialogTemplateSelect  _this;
7
8     public static DialogTemplateSelect singleton()
9     {
10         if (_DialogTemplateSelect == null) {
11             _DialogTemplateSelect= new DialogTemplateSelect();
12         }
13         return _DialogTemplateSelect;
14     }
15     public Xcls_combo combo;
16     public Xcls_cellrenderer cellrenderer;
17     public Xcls_model model;
18
19         // my vars (def)
20
21     // ctor 
22     public DialogTemplateSelect()
23     {
24         _this = this;
25         this.el = new Gtk.Dialog();
26
27         // my vars (dec)
28
29         // set gobject values
30         this.el.title = "Add an Object";
31         this.el.default_height = 200;
32         this.el.default_width = 400;
33         this.el.modal = true;
34         var child_0 = new Xcls_VBox2( _this );
35         child_0.ref();
36         this.el.get_content_area().add (  child_0.el  );
37         var child_1 = new Xcls_Button8( _this );
38         child_1.ref();
39         this.el.add_action_widget (  child_1.el , 0 );
40
41         // listeners 
42         this.el.delete_event.connect( (self, event)  =>{
43             this.el.hide();
44             return true;
45         });
46     }
47
48     // user defined functions 
49     public JsRender.Node? show (Gtk.Window pwindow, Palete.Palete pal, JsRender.Node node) {
50         
51         this.el.show_all();
52         var opts = pal.listTemplates(node);
53         if (opts.length() < 1) {
54             this.el.hide();
55             return node;
56         }
57         this.el.set_attached_to( pwindow);
58          this.el.set_transient_for( pwindow);
59         
60         //opts.unshift({ path: '' , name :'Just add Element' });
61          _this.model.loadData(opts);
62          _this.combo.el.set_active(0);
63          
64        
65         this.el.run();
66         this.el.hide();    
67         //var ix = _this.combo.el.get_active();
68         //if (ix < 1 ) {
69         //    return node;
70        // }
71        Gtk.TreeIter iter;
72         _this.combo.el.get_active_iter (out iter);
73         Value vfname;
74         this.model.el.get_value (iter, 0, out vfname);
75         
76         if (((string)vfname).length < 1) {
77             return node;
78         }
79         return pal.loadTemplate((string)vfname);
80     
81     }
82     public class Xcls_VBox2 : Object 
83     {
84         public Gtk.VBox el;
85         private DialogTemplateSelect  _this;
86
87
88             // my vars (def)
89
90         // ctor 
91         public Xcls_VBox2(DialogTemplateSelect _owner )
92         {
93             _this = _owner;
94             this.el = new Gtk.VBox( true, 0 );
95
96             // my vars (dec)
97
98             // set gobject values
99             var child_0 = new Xcls_HBox3( _this );
100             child_0.ref();
101             this.el.pack_start (  child_0.el , false,false,0 );
102         }
103
104         // user defined functions 
105     }
106     public class Xcls_HBox3 : Object 
107     {
108         public Gtk.HBox el;
109         private DialogTemplateSelect  _this;
110
111
112             // my vars (def)
113
114         // ctor 
115         public Xcls_HBox3(DialogTemplateSelect _owner )
116         {
117             _this = _owner;
118             this.el = new Gtk.HBox( true, 0 );
119
120             // my vars (dec)
121
122             // set gobject values
123             var child_0 = new Xcls_Label4( _this );
124             child_0.ref();
125             this.el.pack_start (  child_0.el , false,false );
126             var child_1 = new Xcls_combo( _this );
127             child_1.ref();
128             this.el.add (  child_1.el  );
129         }
130
131         // user defined functions 
132     }
133     public class Xcls_Label4 : Object 
134     {
135         public Gtk.Label el;
136         private DialogTemplateSelect  _this;
137
138
139             // my vars (def)
140
141         // ctor 
142         public Xcls_Label4(DialogTemplateSelect _owner )
143         {
144             _this = _owner;
145             this.el = new Gtk.Label( "Select Template : " );
146
147             // my vars (dec)
148
149             // set gobject values
150         }
151
152         // user defined functions 
153     }
154     public class Xcls_combo : Object 
155     {
156         public Gtk.ComboBox el;
157         private DialogTemplateSelect  _this;
158
159
160             // my vars (def)
161
162         // ctor 
163         public Xcls_combo(DialogTemplateSelect _owner )
164         {
165             _this = _owner;
166             _this.combo = this;
167             this.el = new Gtk.ComboBox();
168
169             // my vars (dec)
170
171             // set gobject values
172             var child_0 = new Xcls_cellrenderer( _this );
173             child_0.ref();
174             this.el.pack_start (  child_0.el , true );
175             var child_1 = new Xcls_model( _this );
176             child_1.ref();
177             this.el.set_model (  child_1.el  );
178
179             // init method 
180
181             this.el.add_attribute(_this.cellrenderer.el , "markup", 1 );        }
182
183         // user defined functions 
184     }
185     public class Xcls_cellrenderer : Object 
186     {
187         public Gtk.CellRendererText el;
188         private DialogTemplateSelect  _this;
189
190
191             // my vars (def)
192
193         // ctor 
194         public Xcls_cellrenderer(DialogTemplateSelect _owner )
195         {
196             _this = _owner;
197             _this.cellrenderer = this;
198             this.el = new Gtk.CellRendererText();
199
200             // my vars (dec)
201
202             // set gobject values
203         }
204
205         // user defined functions 
206     }
207     public class Xcls_model : Object 
208     {
209         public Gtk.ListStore el;
210         private DialogTemplateSelect  _this;
211
212
213             // my vars (def)
214
215         // ctor 
216         public Xcls_model(DialogTemplateSelect _owner )
217         {
218             _this = _owner;
219             _this.model = this;
220             this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
221
222             // my vars (dec)
223
224             // set gobject values
225         }
226
227         // user defined functions 
228         public void loadData (GLib.List<string> data) {
229             this.el.clear();                                    
230             Gtk.TreeIter iter;
231             var el = this.el;
232             
233             el.append(out iter);
234             
235              
236             el.set_value(iter, 0, "");
237             el.set_value(iter, 1, "Just add Element");
238             
239             for (var i = 0; i < data.length();i++) {
240             
241         
242                 el.append(out iter);
243                 var str = data.nth_data(i);
244                 var fn = Path.get_basename (str);
245                 fn.replace(".json", "");
246                 
247                 el.set_value(iter, 0, str);
248                 el.set_value(iter, 1, fn);
249                 
250             }
251             this.el.set_sort_column_id(1, Gtk.SortType.ASCENDING);          
252                                              
253         }
254     }
255     public class Xcls_Button8 : Object 
256     {
257         public Gtk.Button el;
258         private DialogTemplateSelect  _this;
259
260
261             // my vars (def)
262
263         // ctor 
264         public Xcls_Button8(DialogTemplateSelect _owner )
265         {
266             _this = _owner;
267             this.el = new Gtk.Button();
268
269             // my vars (dec)
270
271             // set gobject values
272             this.el.label = "OK";
273         }
274
275         // user defined functions 
276     }
277 }