tests/menu.vala
[app.Builder.js] / tests / menu.vala
1 /* -- to compile
2 valac  --pkg gio-2.0  --pkg posix  --pkg gtk+-3.0  \
3     /tmp/WindowLeftTree.vala  -o /tmp/WindowLeftTree
4 */
5
6
7 /* -- to test class
8 static int main (string[] args) {
9     Gtk.init (ref args);
10     new Xcls_WindowLeftTree();
11     WindowLeftTree.show_all();
12      Gtk.main ();
13     return 0;
14 }
15 */
16         
17 int main (string[] args) {
18     Gtk.init (ref args);
19     new JsRender.Lang_Class();
20         GLib.Log.set_always_fatal(LogLevelFlags.LEVEL_ERROR | LogLevelFlags.LEVEL_CRITICAL); 
21         //print ("Drop points for Gtk.ScrolledWindow are : " + 
22         //      string.joinv(", " , Palete.factory("Gtk").getDropList("Gtk.ScrolledWindow"))
23         //);
24
25         //testBuilderFile("Editor", "JSON");
26         //testBuilderFile("Editor", "JS");
27         //testBuilderFile("Editor", "VALA");
28         var a  = new Xcls_WindowLeftTree();
29         a.el.show_all();
30         
31         Gtk.main();
32
33     
34         
35         return 0;
36 }
37
38 public static Xcls_WindowLeftTree  WindowLeftTree;
39
40 public class Xcls_WindowLeftTree : Object 
41 {
42     public Gtk.Window el;
43     private Xcls_WindowLeftTree  _this;
44
45     public Xcls_LeftTreeMenu LeftTreeMenu;
46
47         // ctor 
48     public Xcls_WindowLeftTree()
49     {
50         this.el = new Gtk.Window(  );
51         _this = this;
52         WindowLeftTree = this;
53
54         // my vars
55
56         // set gobject values
57         this.el.shadow_type = Gtk.ShadowType.IN;
58         var child_0 = new Xcls_button(_this);
59         this.el.add (  child_0.el  );
60         _this.LeftTreeMenu = new Xcls_LeftTreeMenu(_this);
61
62         // init method 
63          this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
64          
65     }
66  
67
68     // skip xvala_id - not pipe 
69     public class Xcls_button : Object 
70     {
71         public Gtk.Button el;
72         private Xcls_WindowLeftTree  _this;
73  
74             // ctor 
75         public Xcls_button(Xcls_WindowLeftTree _owner)
76         {
77             this.el = new Gtk.Button.with_label ("Click me (0)");
78             _this = _owner;
79             _this.button = this;
80
81              
82
83             // listeners 
84             this.el.button_press_event.connect(   ( ev) => {
85                 //console.log("button press?");
86             
87                 
88  
89                 if (ev.type != Gdk.EventType.BUTTON_PRESS  || ev.button != 3) {
90                     //print("click" + ev.type);
91                     return false;
92                 }
93  
94                     
95                  _this.LeftTreeMenu.el.set_screen(Gdk.Screen.get_default());
96                  _this.LeftTreeMenu.el.show_all();
97                  _this.LeftTreeMenu.el.popup(null, null, null,  ev.button, ev.time);
98                  //   print("click:" + res.path.to_string());
99                   return true;
100             } );
101             
102         }
103
104          
105     }
106
107
108
109         
110     public class Xcls_LeftTreeMenu : Object 
111     {
112         public Gtk.Menu el;
113         private Xcls_WindowLeftTree  _this;
114
115
116             // my vars
117
118             // ctor 
119         public Xcls_LeftTreeMenu(Xcls_WindowLeftTree _owner)
120         {
121             print("Xcls_LeftTreeMenu:Ctor called\n");
122             _this = _owner;
123                  
124                         
125                         this.el = new Gtk.Menu();
126             _this.LeftTreeMenu = this;
127
128             // my vars
129
130             // set gobject values
131             var child_0 = new Xcls_MenuItem7(_this);
132             this.el.add (  child_0.el  );
133             var child_1 = new Xcls_MenuItem8(_this);
134             this.el.add (  child_1.el  );
135         }
136
137         // userdefined functions 
138
139         // skip id - not pipe 
140
141         // skip pack - not pipe 
142
143         // skip xtype - not pipe 
144
145         // skip |xns - no return type
146
147         // skip items - not pipe 
148
149         // skip xvala_cls - not pipe 
150
151         // skip xvala_xcls - not pipe 
152
153         // skip xvala_id - not pipe 
154     }
155     public class Xcls_MenuItem7 : Object 
156     {
157         public Gtk.MenuItem el;
158         private Xcls_WindowLeftTree  _this;
159
160
161             // my vars
162
163             // ctor 
164         public Xcls_MenuItem7(Xcls_WindowLeftTree _owner)
165         {
166             
167             _this = _owner;
168                  
169                         this.el = new Gtk.MenuItem.with_label("Delete Element");
170             // my vars
171
172             // set gobject values
173             //this.el.label = "Delete Element";
174                         print("add activate\n");
175             // listeners 
176                         
177                         
178             this.el.select.connect(   ( ) => {
179                 
180                 print("SELECT?");
181                 
182                                 return  ;
183             } );
184         }
185
186         // userdefined functions 
187
188         // skip listeners - not pipe 
189
190         // skip label - already used 
191
192         // skip pack - not pipe 
193
194         // skip xtype - not pipe 
195
196         // skip |xns - no return type
197
198         // skip xvala_cls - not pipe 
199
200         // skip xvala_xcls - not pipe 
201
202         // skip xvala_id - not pipe 
203     }
204     public class Xcls_MenuItem8 : Object 
205     {
206         public Gtk.MenuItem el;
207         private Xcls_WindowLeftTree  _this;
208
209
210             // my vars
211
212             // ctor 
213         public Xcls_MenuItem8(Xcls_WindowLeftTree _owner)
214         {
215             this.el = new Gtk.MenuItem();
216             _this = _owner;
217
218             // my vars
219
220             // set gobject values
221             this.el.label = "Save as Template";
222
223             // listeners 
224             this.el.activate.connect(   () => {
225             
226                 print("connect");  
227                 
228             } );
229         }
230
231         // userdefined functions 
232
233         // skip listeners - not pipe 
234
235         // skip label - already used 
236
237         // skip pack - not pipe 
238
239         // skip xtype - not pipe 
240
241         // skip |xns - no return type
242
243         // skip xvala_cls - not pipe 
244
245         // skip xvala_xcls - not pipe 
246
247         // skip xvala_id - not pipe 
248     }
249 }