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         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                         
93                                 //   print("click:" + res.path.to_string());
94                   return true;
95             } );
96             
97         }
98
99          
100     }
101
102
103
104         
105     public class Xcls_LeftTreeMenu : Object 
106     {
107         public Gtk.Menu el;
108         private Xcls_WindowLeftTree  _this;
109
110
111             // my vars
112
113             // ctor 
114         public Xcls_LeftTreeMenu(Xcls_WindowLeftTree _owner)
115         {
116             print("Xcls_LeftTreeMenu:Ctor called\n");
117             _this = _owner;
118                  
119                         
120                         this.el = new Gtk.Menu();
121             _this.LeftTreeMenu = this;
122
123             // my vars
124
125             // set gobject values
126             var child_0 = new Xcls_MenuItem7(_this);
127             this.el.add (  child_0.el  );
128                         child_0.initListeners();
129             var child_1 = new Xcls_MenuItem8(_this);
130             this.el.add (  child_1.el  );
131                         this.el.show_all();
132         }
133
134         // userdefined functions 
135
136         // skip id - not pipe 
137
138         // skip pack - not pipe 
139
140         // skip xtype - not pipe 
141
142         // skip |xns - no return type
143
144         // skip items - not pipe 
145
146         // skip xvala_cls - not pipe 
147
148         // skip xvala_xcls - not pipe 
149
150         // skip xvala_id - not pipe 
151     }
152     public class Xcls_MenuItem7 : Object 
153     {
154         public Gtk.MenuItem el;
155         private Xcls_WindowLeftTree  _this;
156
157
158             // my vars
159
160             // ctor 
161         public Xcls_MenuItem7(Xcls_WindowLeftTree _owner)
162         {
163             
164             _this = _owner;
165                  
166                         this.el = new Gtk.MenuItem.with_label("Delete Element");
167             // my vars
168
169             // set gobject values
170             //this.el.label = "Delete Element";
171                         
172             // listeners 
173                 }
174                 public void initListeners() {
175                         print("add activate\n");
176             this.el.activate.connect(   ( ) => {
177                 
178                 print("SELECT?");
179                 
180                                 return  ;
181             } );
182         }
183
184         // userdefined functions 
185
186         // skip listeners - not pipe 
187
188         // skip label - already used 
189
190         // skip pack - not pipe 
191
192         // skip xtype - not pipe 
193
194         // skip |xns - no return type
195
196         // skip xvala_cls - not pipe 
197
198         // skip xvala_xcls - not pipe 
199
200         // skip xvala_id - not pipe 
201     }
202     public class Xcls_MenuItem8 : Object 
203     {
204         public Gtk.MenuItem el;
205         private Xcls_WindowLeftTree  _this;
206
207
208             // my vars
209
210             // ctor 
211         public Xcls_MenuItem8(Xcls_WindowLeftTree _owner)
212         {
213             this.el = new Gtk.MenuItem();
214             _this = _owner;
215
216             // my vars
217
218             // set gobject values
219             this.el.label = "Save as Template";
220
221             // listeners 
222             this.el.activate.connect(   () => {
223             
224                 print("connect");  
225                 
226             } );
227         }
228
229         // userdefined functions 
230
231         // skip listeners - not pipe 
232
233         // skip label - already used 
234
235         // skip pack - not pipe 
236
237         // skip xtype - not pipe 
238
239         // skip |xns - no return type
240
241         // skip xvala_cls - not pipe 
242
243         // skip xvala_xcls - not pipe 
244
245         // skip xvala_id - not pipe 
246     }
247 }