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