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