resources/RooUsage.txt
[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.ref();
51                 child_0.init(this);
52                 leftmenu.append (  child_0.el  );
53                 leftmenu.show_all();
54                 w.show_all();
55
56         }
57         public class Xcls_MenuItem7 : Object  
58         {
59                 public Gtk.MenuItem el;
60                 public Xcls_Window _this;
61         
62                 public void init(Xcls_Window _owner ) {
63                         //_this = _owner;
64                         this.el = new Gtk.MenuItem.with_label("Delete Element");
65                         this.el.ref();
66                     print("add activate\n");
67                     this.el.activate.connect(   ( ) => {
68                         
69                         print("SELECT?");
70                         
71                                 return  ;
72                     } );
73                 }
74
75         }
76 }