tests/menu.vala
[app.Builder.js] / tests / menu.vala
1 /* -- to compile
2 valac  --pkg gio-2.0  --pkg posix  --pkg gtk+-3.0 --pkg libnotify --pkg gtksourceview-3.0  --pkg  libwnck-3.0 \
3     /tmp/WindowLeftTree.vala  -o /tmp/WindowLeftTree
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
18 public static Xcls_WindowLeftTree  WindowLeftTree;
19
20 public class Xcls_WindowLeftTree : Object 
21 {
22     public Gtk.Window el;
23     private Xcls_WindowLeftTree  _this;
24
25     public Xcls_LeftTreeMenu LeftTreeMenu;
26
27         // ctor 
28     public Xcls_WindowLeftTree()
29     {
30         this.el = new Gtk.Window(  );
31         _this = this;
32         WindowLeftTree = this;
33
34         // my vars
35
36         // set gobject values
37         this.el.shadow_type = Gtk.ShadowType.IN;
38         var child_0 = new Xcls_button(_this);
39         this.el.add (  child_0.el  );
40         _this.LeftTreeMenu = new Xcls_LeftTreeMenu(_this);
41
42         // init method 
43          this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
44          
45     }
46  
47
48     // skip xvala_id - not pipe 
49     public class Xcls_button : Object 
50     {
51         public Gtk.Button el;
52         private Xcls_WindowLeftTree  _this;
53  
54             // ctor 
55         public Xcls_button(Xcls_WindowLeftTree _owner)
56         {
57             this.el = new Gtk.Button.with_label ("Click me (0)");
58             _this = _owner;
59             _this.button = this;
60
61              
62
63             // listeners 
64             this.el.button_press_event.connect(   ( ev) => {
65                 //console.log("button press?");
66             
67                 
68  
69                 if (ev.type != Gdk.EventType.BUTTON_PRESS  || ev.button != 3) {
70                     //print("click" + ev.type);
71                     return false;
72                 }
73  
74                     
75                  _this.LeftTreeMenu.el.set_screen(Gdk.Screen.get_default());
76                  _this.LeftTreeMenu.el.show_all();
77                  _this.LeftTreeMenu.el.popup(null, null, null,  ev.button, ev.time);
78                  //   print("click:" + res.path.to_string());
79                   return true;
80             } );
81             
82         }
83
84          
85     }
86
87
88
89         
90     public class Xcls_LeftTreeMenu : Object 
91     {
92         public Gtk.Menu el;
93         private Xcls_WindowLeftTree  _this;
94
95
96             // my vars
97
98             // ctor 
99         public Xcls_LeftTreeMenu(Xcls_WindowLeftTree _owner)
100         {
101             print("Xcls_LeftTreeMenu:Ctor called\n");
102             _this = _owner;
103                  
104                         
105                         this.el = new Gtk.Menu();
106             _this.LeftTreeMenu = this;
107
108             // my vars
109
110             // set gobject values
111             var child_0 = new Xcls_MenuItem7(_this);
112             this.el.add (  child_0.el  );
113             var child_1 = new Xcls_MenuItem8(_this);
114             this.el.add (  child_1.el  );
115         }
116
117         // userdefined functions 
118
119         // skip id - not pipe 
120
121         // skip pack - not pipe 
122
123         // skip xtype - not pipe 
124
125         // skip |xns - no return type
126
127         // skip items - not pipe 
128
129         // skip xvala_cls - not pipe 
130
131         // skip xvala_xcls - not pipe 
132
133         // skip xvala_id - not pipe 
134     }
135     public class Xcls_MenuItem7 : Object 
136     {
137         public Gtk.MenuItem el;
138         private Xcls_WindowLeftTree  _this;
139
140
141             // my vars
142
143             // ctor 
144         public Xcls_MenuItem7(Xcls_WindowLeftTree _owner)
145         {
146             
147             _this = _owner;
148                  
149                         this.el = new Gtk.MenuItem.with_label("Delete Element");
150             // my vars
151
152             // set gobject values
153             //this.el.label = "Delete Element";
154                         print("add activate\n");
155             // listeners 
156                         
157                         
158             this.el.select.connect(   ( ) => {
159                 
160                 print("SELECT?");
161                 
162                                 return  ;
163             } );
164         }
165
166         // userdefined functions 
167
168         // skip listeners - not pipe 
169
170         // skip label - already used 
171
172         // skip pack - not pipe 
173
174         // skip xtype - not pipe 
175
176         // skip |xns - no return type
177
178         // skip xvala_cls - not pipe 
179
180         // skip xvala_xcls - not pipe 
181
182         // skip xvala_id - not pipe 
183     }
184     public class Xcls_MenuItem8 : Object 
185     {
186         public Gtk.MenuItem el;
187         private Xcls_WindowLeftTree  _this;
188
189
190             // my vars
191
192             // ctor 
193         public Xcls_MenuItem8(Xcls_WindowLeftTree _owner)
194         {
195             this.el = new Gtk.MenuItem();
196             _this = _owner;
197
198             // my vars
199
200             // set gobject values
201             this.el.label = "Save as Template";
202
203             // listeners 
204             this.el.activate.connect(   () => {
205             
206                  DialogSaveTemplate.show(_this.model.file.palete(), _this.getActiveElement());
207                  
208                 
209             } );
210         }
211
212         // userdefined functions 
213
214         // skip listeners - not pipe 
215
216         // skip label - already used 
217
218         // skip pack - not pipe 
219
220         // skip xtype - not pipe 
221
222         // skip |xns - no return type
223
224         // skip xvala_cls - not pipe 
225
226         // skip xvala_xcls - not pipe 
227
228         // skip xvala_id - not pipe 
229     }
230 }