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                         
44                     //leftmenu.el.set_screen(Gdk.Screen.get_default());
45                      
46                     leftmenu.popup(null, null, null,  ev.button, ev.time);
47         
48                       return true;
49                 } );
50
51
52                 var child_0 = new Xcls_MenuItem7();
53                 child_0.init(this);
54                 leftmenu.append (  child_0.el  );
55                 leftmenu.show_all();
56                 w.show_all();
57
58         }
59         public class Xcls_MenuItem7 : Object  
60         {
61                 public Gtk.MenuItem el;
62                 public Xcls_Window _this;
63         
64                 public void init(Xcls_Window _owner ) {
65                         _this = _owner;
66                         var el = new Gtk.MenuItem.with_label("Delete Element");
67                         this.el = el;
68                     print("add activate\n");
69                     this.el.activate.connect(   ( ) => {
70                         
71                         print("SELECT?");
72                         
73                                 return  ;
74                     } );
75                 }
76
77         }
78 }