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