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