Palete/Gtk.js
[app.Builder.js] / Builder4 / DialogNewComponent.vala
1 /* -- to compile
2 valac  --pkg gio-2.0  --pkg posix  --pkg gtk+-3.0 --pkg libnotify --pkg gtksourceview-3.0  --pkg  libwnck-3.0 \
3     /tmp/DialogNewComponent.vala  -o /tmp/DialogNewComponent
4 */
5
6
7 /* -- to test class
8 static int main (string[] args) {
9     Gtk.init (ref args);
10     new Xcls_DialogNewComponent();
11     DialogNewComponent.show_all();
12      Gtk.main ();
13     return 0;
14 }
15 */
16
17
18 public static Xcls_DialogNewComponent  DialogNewComponent;
19
20 public class Xcls_DialogNewComponent
21 {
22     public Gtk.Dialog el;
23     private static Xcls_DialogNewComponent  _this;
24
25     public Xcls_name name;
26     public Xcls_title title;
27     public Xcls_region region;
28     public Xcls_parent parent;
29     public Xcls_permname permname;
30     public Xcls_modOrder modOrder;
31
32         // my vars
33     public JsRender.JsRender file;
34     public Project.Project project;
35     public signal void success(Project.Project pr, JsRender.JsRender file);
36
37         // ctor 
38     public Xcls_DialogNewComponent()
39     {
40         this.el = new Gtk.Dialog();
41         _this = this;
42         DialogNewComponent = this;
43
44         // my vars
45
46         // set gobject values
47         this.el.default_height = 200;
48         this.el.default_width = 500;
49         this.el.deletable = false;
50         this.el.modal = true;
51         this.el.title = "New Component";
52         var child_0 = new Xcls_VBox2();
53         this.el.add (  child_0.el  );
54         var child_1 = new Xcls_Button16();
55         this.el.add_action_widget (  child_1.el , 0 );
56         var child_2 = new Xcls_Button17();
57         this.el.add_action_widget (  child_2.el , 1 );
58
59         // listeners 
60         this.el.delete_event.connect( (self, event) => {
61             this.el.hide();
62             return true;   
63         }
64         
65         
66          );
67         this.el.response.connect(   (self, response_id) =>  {
68           
69                 if (response_id < 1) { // cancel!
70                     this.el.hide();
71                     return;
72                 }
73         
74                 if (_this.name.el.get_text().length  < 1) {
75                     StandardErrorDialog.show(
76                         "You have to set Project name "
77                     );
78                      
79                     return;
80                 }
81                 // what does this do?
82                 
83                 var isNew = _this.file.name.length  > 0 ? false : true;
84                 
85                 if (_this.file.name.length > 0 && this.file.name != _this.name.el.get_text()) {
86                     StandardErrorDialog.show(
87                         "Sorry changing names does not work yet. "
88                     );
89                      
90                     return;
91                 }
92         
93                 // FIXME - this may be more complicated...
94                 //for (var i in this.def) {
95                 //    this.file[i] =  this.get(i).el.get_text();
96                 //}
97         
98                 if (!isNew) {
99                     _this.file.save();
100                     this.el.hide();
101                     return;
102                 }
103         
104             
105                 var dir = _this.project.firstPath();
106                 //FIXME...
107                 //for (var i in this.project.paths) {
108                 //      dir = i;
109                 //      break;
110                 //}
111         
112          
113                 
114                 // what about .js ?
115                 if (GLib.FileUtil.test(_this.file.name + ".bjs", GLib.FileTest.EXISTS)) {
116                     StandardErrorDialog.show(
117                         "That file already exists"
118                     ); 
119                     return;
120                 }
121                 this.el.hide();
122                 
123                 
124                 //var tmpl = this.project.loadFileOnly(DialogNewComponent.get('template').getValue());
125                  
126                 var nf = _this.project.create(dir + "/" + _this.file.name + ".bjs");
127                 //for (var i in this.file) {
128                 //    nf[i] = this.file[i];
129                 //}
130                 _this.success(_this.project, nf);
131                 /*
132         
133                 -- fixme -- needs to be a signal..
134                 if (DialogNewComponent.success != null) {
135                     DialogNewComponent.success(_this.project, nf);
136                 }
137                 */
138         } );
139         this.el.show.connect( (self)  => {
140           this.el.show_all();
141           
142         } );
143     }
144
145     // userdefined functions 
146
147     // skip listeners - not pipe 
148
149     // skip .JsRender.JsRender:file - already used 
150
151     // skip .Project.Project:project - already used 
152
153     // skip .signal:void:success - already used 
154
155     // skip default_height - already used 
156
157     // skip default_width - already used 
158
159     // skip id - not pipe 
160
161     // skip title - already used 
162
163     // skip xtype - not pipe 
164
165     // skip |deletable - already used 
166
167     // skip |modal - already used 
168     public void show(JsRender.JsRender c) 
169         {
170             this.project = c.project;
171             
172             if (!this.el) {
173                 //this.init();
174             }
175             
176             this.def =  { 
177                 name : '' , 
178                 title : '' ,
179                 region : '' ,
180                 parent: '',
181               //  disable: '',
182                 modOrder : '0',
183                 permname : ''
184             };
185             _this.name.el.set_text(c.name);
186             _this.title.el.set_text(c.title);
187             _this.parent.el.set_text(c.parent);    
188             _this.region.el.set_text(c.region);
189             _this.modOrder.el.set_text(c.modOrder);
190              _this.permname.el.set_text(c.permname);
191             
192             if (c.path.length > 0) {
193                 this.el.set_title("Edit File Details - " + c.name);
194             } else {
195                 this.el.set_title("Create New File");
196             }
197              
198             _this.file = c;
199             //console.log('show all');
200             this.el.show_all();
201             
202             //this.success = c.success;
203             
204             
205         }
206
207     // skip |xns - no return type
208
209     // skip items - not pipe 
210
211     // skip xvala_cls - not pipe 
212
213     // skip xvala_xcls - not pipe 
214
215     // skip xvala_id - not pipe 
216     public class Xcls_VBox2
217     {
218         public Gtk.VBox el;
219
220             // my vars
221
222             // ctor 
223         public Xcls_VBox2()
224         {
225             this.el = new Gtk.VBox( true, 0 );
226
227             // my vars
228
229             // set gobject values
230             var child_0 = new Xcls_Table3();
231             this.el.pack_start (  child_0.el , false,false,0 );
232         }
233
234         // userdefined functions 
235
236         // skip |xns - no return type
237
238         // skip xtype - not pipe 
239
240         // skip |pack - already used 
241
242         // skip items - not pipe 
243
244         // skip xvala_cls - not pipe 
245
246         // skip xvala_xcls - not pipe 
247
248         // skip xvala_id - not pipe 
249     }
250     public class Xcls_Table3
251     {
252         public Gtk.Table el;
253
254             // my vars
255
256             // ctor 
257         public Xcls_Table3()
258         {
259             this.el = new Gtk.Table();
260
261             // my vars
262
263             // set gobject values
264             this.el.homogeneous = false;
265             this.el.n_columns = 2;
266             this.el.n_rows = 3;
267             var child_0 = new Xcls_Label4();
268             this.el.add (  child_0.el  );
269             var child_1 = new Xcls_name();
270             this.el.add (  child_1.el  );
271             var child_2 = new Xcls_Label6();
272             this.el.add (  child_2.el  );
273             var child_3 = new Xcls_title();
274             this.el.add (  child_3.el  );
275             var child_4 = new Xcls_Label8();
276             this.el.add (  child_4.el  );
277             var child_5 = new Xcls_region();
278             this.el.add (  child_5.el  );
279             var child_6 = new Xcls_Label10();
280             this.el.add (  child_6.el  );
281             var child_7 = new Xcls_parent();
282             this.el.add (  child_7.el  );
283             var child_8 = new Xcls_Label12();
284             this.el.add (  child_8.el  );
285             var child_9 = new Xcls_permname();
286             this.el.add (  child_9.el  );
287             var child_10 = new Xcls_Label14();
288             this.el.add (  child_10.el  );
289             var child_11 = new Xcls_modOrder();
290             this.el.add (  child_11.el  );
291         }
292
293         // userdefined functions 
294
295         // skip n_columns - already used 
296
297         // skip n_rows - already used 
298
299         // skip pack - not pipe 
300
301         // skip xtype - not pipe 
302
303         // skip |homogeneous - already used 
304
305         // skip |xns - no return type
306
307         // skip items - not pipe 
308
309         // skip xvala_cls - not pipe 
310
311         // skip xvala_xcls - not pipe 
312
313         // skip xvala_id - not pipe 
314     }
315     public class Xcls_Label4
316     {
317         public Gtk.Label el;
318
319             // my vars
320
321             // ctor 
322         public Xcls_Label4()
323         {
324             this.el = new Gtk.Label();
325
326             // my vars
327
328             // set gobject values
329             this.el.justify = Gtk.Justification.RIGHT;
330             this.el.label = "Component Name";
331             this.el.xalign = 0.9;
332         }
333
334         // userdefined functions 
335
336         // skip label - already used 
337
338         // skip pack - not pipe 
339
340         // skip x_options - not pipe 
341
342         // skip xalign - already used 
343
344         // skip xtype - not pipe 
345
346         // skip |justify - already used 
347
348         // skip |xns - no return type
349
350         // skip xvala_cls - not pipe 
351
352         // skip xvala_xcls - not pipe 
353
354         // skip xvala_id - not pipe 
355     }
356     public class Xcls_name
357     {
358         public Gtk.Entry el;
359
360             // my vars
361
362             // ctor 
363         public Xcls_name()
364         {
365             this.el = new Gtk.Entry();
366             _this.name = this;
367
368             // my vars
369
370             // set gobject values
371             this.el.visible = true;
372         }
373
374         // userdefined functions 
375
376         // skip id - not pipe 
377
378         // skip pack - not pipe 
379
380         // skip xtype - not pipe 
381
382         // skip |visible - already used 
383
384         // skip |xns - no return type
385
386         // skip xvala_cls - not pipe 
387
388         // skip xvala_xcls - not pipe 
389
390         // skip xvala_id - not pipe 
391     }
392     public class Xcls_Label6
393     {
394         public Gtk.Label el;
395
396             // my vars
397
398             // ctor 
399         public Xcls_Label6()
400         {
401             this.el = new Gtk.Label();
402
403             // my vars
404
405             // set gobject values
406             this.el.justify = Gtk.Justification.RIGHT;
407             this.el.label = "Title";
408             this.el.visible = true;
409             this.el.xalign = 0.9;
410         }
411
412         // userdefined functions 
413
414         // skip label - already used 
415
416         // skip pack - not pipe 
417
418         // skip x_options - not pipe 
419
420         // skip xalign - already used 
421
422         // skip xtype - not pipe 
423
424         // skip |justify - already used 
425
426         // skip |visible - already used 
427
428         // skip |xns - no return type
429
430         // skip xvala_cls - not pipe 
431
432         // skip xvala_xcls - not pipe 
433
434         // skip xvala_id - not pipe 
435     }
436     public class Xcls_title
437     {
438         public Gtk.Entry el;
439
440             // my vars
441
442             // ctor 
443         public Xcls_title()
444         {
445             this.el = new Gtk.Entry();
446             _this.title = this;
447
448             // my vars
449
450             // set gobject values
451             this.el.visible = true;
452         }
453
454         // userdefined functions 
455
456         // skip id - not pipe 
457
458         // skip pack - not pipe 
459
460         // skip xtype - not pipe 
461
462         // skip |visible - already used 
463
464         // skip |xns - no return type
465
466         // skip xvala_cls - not pipe 
467
468         // skip xvala_xcls - not pipe 
469
470         // skip xvala_id - not pipe 
471     }
472     public class Xcls_Label8
473     {
474         public Gtk.Label el;
475
476             // my vars
477
478             // ctor 
479         public Xcls_Label8()
480         {
481             this.el = new Gtk.Label();
482
483             // my vars
484
485             // set gobject values
486             this.el.justify = Gtk.Justification.RIGHT;
487             this.el.label = "Region";
488             this.el.tooltip_text = "center, north, south, east, west";
489             this.el.visible = true;
490             this.el.xalign = 0.9;
491         }
492
493         // userdefined functions 
494
495         // skip label - already used 
496
497         // skip pack - not pipe 
498
499         // skip tooltip_text - already used 
500
501         // skip x_options - not pipe 
502
503         // skip xalign - already used 
504
505         // skip xtype - not pipe 
506
507         // skip |justify - already used 
508
509         // skip |visible - already used 
510
511         // skip |xns - no return type
512
513         // skip xvala_cls - not pipe 
514
515         // skip xvala_xcls - not pipe 
516
517         // skip xvala_id - not pipe 
518     }
519     public class Xcls_region
520     {
521         public Gtk.Entry el;
522
523             // my vars
524
525             // ctor 
526         public Xcls_region()
527         {
528             this.el = new Gtk.Entry();
529             _this.region = this;
530
531             // my vars
532
533             // set gobject values
534             this.el.visible = true;
535         }
536
537         // userdefined functions 
538
539         // skip id - not pipe 
540
541         // skip pack - not pipe 
542
543         // skip xtype - not pipe 
544
545         // skip |visible - already used 
546
547         // skip |xns - no return type
548
549         // skip xvala_cls - not pipe 
550
551         // skip xvala_xcls - not pipe 
552
553         // skip xvala_id - not pipe 
554     }
555     public class Xcls_Label10
556     {
557         public Gtk.Label el;
558
559             // my vars
560
561             // ctor 
562         public Xcls_Label10()
563         {
564             this.el = new Gtk.Label();
565
566             // my vars
567
568             // set gobject values
569             this.el.justify = Gtk.Justification.RIGHT;
570             this.el.label = "Parent Name";
571             this.el.visible = true;
572             this.el.xalign = 0.9;
573         }
574
575         // userdefined functions 
576
577         // skip label - already used 
578
579         // skip pack - not pipe 
580
581         // skip x_options - not pipe 
582
583         // skip xalign - already used 
584
585         // skip xtype - not pipe 
586
587         // skip |justify - already used 
588
589         // skip |visible - already used 
590
591         // skip |xns - no return type
592
593         // skip xvala_cls - not pipe 
594
595         // skip xvala_xcls - not pipe 
596
597         // skip xvala_id - not pipe 
598     }
599     public class Xcls_parent
600     {
601         public Gtk.Entry el;
602
603             // my vars
604
605             // ctor 
606         public Xcls_parent()
607         {
608             this.el = new Gtk.Entry();
609             _this.parent = this;
610
611             // my vars
612
613             // set gobject values
614             this.el.visible = true;
615         }
616
617         // userdefined functions 
618
619         // skip id - not pipe 
620
621         // skip pack - not pipe 
622
623         // skip xtype - not pipe 
624
625         // skip |visible - already used 
626
627         // skip |xns - no return type
628
629         // skip xvala_cls - not pipe 
630
631         // skip xvala_xcls - not pipe 
632
633         // skip xvala_id - not pipe 
634     }
635     public class Xcls_Label12
636     {
637         public Gtk.Label el;
638
639             // my vars
640
641             // ctor 
642         public Xcls_Label12()
643         {
644             this.el = new Gtk.Label();
645
646             // my vars
647
648             // set gobject values
649             this.el.justify = Gtk.Justification.RIGHT;
650             this.el.label = "Permission Name";
651             this.el.visible = true;
652             this.el.xalign = 0.9;
653         }
654
655         // userdefined functions 
656
657         // skip label - already used 
658
659         // skip pack - not pipe 
660
661         // skip x_options - not pipe 
662
663         // skip xalign - already used 
664
665         // skip xtype - not pipe 
666
667         // skip |justify - already used 
668
669         // skip |visible - already used 
670
671         // skip |xns - no return type
672
673         // skip xvala_cls - not pipe 
674
675         // skip xvala_xcls - not pipe 
676
677         // skip xvala_id - not pipe 
678     }
679     public class Xcls_permname
680     {
681         public Gtk.Entry el;
682
683             // my vars
684
685             // ctor 
686         public Xcls_permname()
687         {
688             this.el = new Gtk.Entry();
689             _this.permname = this;
690
691             // my vars
692
693             // set gobject values
694             this.el.visible = true;
695         }
696
697         // userdefined functions 
698
699         // skip id - not pipe 
700
701         // skip pack - not pipe 
702
703         // skip xtype - not pipe 
704
705         // skip |visible - already used 
706
707         // skip |xns - no return type
708
709         // skip xvala_cls - not pipe 
710
711         // skip xvala_xcls - not pipe 
712
713         // skip xvala_id - not pipe 
714     }
715     public class Xcls_Label14
716     {
717         public Gtk.Label el;
718
719             // my vars
720
721             // ctor 
722         public Xcls_Label14()
723         {
724             this.el = new Gtk.Label();
725
726             // my vars
727
728             // set gobject values
729             this.el.justify = Gtk.Justification.RIGHT;
730             this.el.label = "Order (for tabs)";
731             this.el.visible = true;
732             this.el.xalign = 0.9;
733         }
734
735         // userdefined functions 
736
737         // skip label - already used 
738
739         // skip pack - not pipe 
740
741         // skip x_options - not pipe 
742
743         // skip xalign - already used 
744
745         // skip xtype - not pipe 
746
747         // skip |justify - already used 
748
749         // skip |visible - already used 
750
751         // skip |xns - no return type
752
753         // skip xvala_cls - not pipe 
754
755         // skip xvala_xcls - not pipe 
756
757         // skip xvala_id - not pipe 
758     }
759     public class Xcls_modOrder
760     {
761         public Gtk.Entry el;
762
763             // my vars
764
765             // ctor 
766         public Xcls_modOrder()
767         {
768             this.el = new Gtk.Entry();
769             _this.modOrder = this;
770
771             // my vars
772
773             // set gobject values
774             this.el.visible = true;
775         }
776
777         // userdefined functions 
778
779         // skip id - not pipe 
780
781         // skip pack - not pipe 
782
783         // skip xtype - not pipe 
784
785         // skip |visible - already used 
786
787         // skip |xns - no return type
788
789         // skip xvala_cls - not pipe 
790
791         // skip xvala_xcls - not pipe 
792
793         // skip xvala_id - not pipe 
794     }
795     public class Xcls_Button16
796     {
797         public Gtk.Button el;
798
799             // my vars
800
801             // ctor 
802         public Xcls_Button16()
803         {
804             this.el = new Gtk.Button();
805
806             // my vars
807
808             // set gobject values
809             this.el.label = "Cancel";
810         }
811
812         // userdefined functions 
813
814         // skip |xns - no return type
815
816         // skip xtype - not pipe 
817
818         // skip pack - not pipe 
819
820         // skip label - already used 
821
822         // skip xvala_cls - not pipe 
823
824         // skip xvala_xcls - not pipe 
825
826         // skip xvala_id - not pipe 
827     }
828     public class Xcls_Button17
829     {
830         public Gtk.Button el;
831
832             // my vars
833
834             // ctor 
835         public Xcls_Button17()
836         {
837             this.el = new Gtk.Button();
838
839             // my vars
840
841             // set gobject values
842             this.el.label = "OK";
843         }
844
845         // userdefined functions 
846
847         // skip |xns - no return type
848
849         // skip xtype - not pipe 
850
851         // skip pack - not pipe 
852
853         // skip label - already used 
854
855         // skip xvala_cls - not pipe 
856
857         // skip xvala_xcls - not pipe 
858
859         // skip xvala_id - not pipe 
860     }
861 }