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