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     new Xcls_Window();
22
23         Gtk.main();
24         return 0;
25 }
26
27 public class Xcls_Window : Object {
28
29
30         public Xcls_Window() {
31                 var w = new Gtk.Window(  );
32
33                 var b = new Gtk.Button.with_label ("Click me (0)");
34                 w.add(b);
35                 var leftmenu = new Gtk.Menu();
36         
37                 b.button_press_event.connect(   ( ev) => {
38                     
39                     if (ev.type != Gdk.EventType.BUTTON_PRESS  || ev.button != 3) {
40                         return false;
41                     }
42  
43                     leftmenu.popup(null, null, null,  ev.button, ev.time);
44         
45                       return true;
46                 } );
47
48
49                 var child_0 = new Xcls_MenuItem7();
50                 child_0.init(this);
51                 leftmenu.append (  child_0.el  );
52                 leftmenu.show_all();
53                 w.show_all();
54
55         }
56         public class Xcls_MenuItem7 : Object  
57         {
58                 public Gtk.MenuItem el;
59                 public Xcls_Window _this;
60         
61                 public void init(Xcls_Window _owner ) {
62                         //_this = _owner;
63                         this.el = new Gtk.MenuItem.with_label("Delete Element");
64                     print("add activate\n");
65                     this.el.activate.connect(   ( ) => {
66                         
67                         print("SELECT?");
68                         
69                                 return  ;
70                     } );
71                 }
72
73         }
74 }