resources/RooUsage.txt
[app.Builder.js] / tests / status_icon.js
1 #!/usr/bin/env seed
2
3 // Import and initialize GTK+
4 Gtk = imports.gi.Gtk;
5 Gdk = imports.gi.Gdk;
6 Gtk.init(null, null);
7
8 // Create the window
9 var window = new Gtk.Window({title: "Hello World"});
10 window.set_default_size(600, 500);
11 window.signal.hide.connect(Gtk.main_quit);
12
13 // Create the GtkStatusIcon from a file
14 var icon = new Gtk.StatusIcon({stock : Gtk.STOCK_MEDIA_PLAY});
15
16 // Create the menu
17 var menu = new Gtk.Menu();
18
19 // Create an item
20 var item = new Gtk.MenuItem({label: "Hello"});
21 menu.append(item);
22
23 // Signal connecting the popup_menu event of the icon to the "activate" function
24 icon.signal.popup_menu.connect(active, menu);
25
26 function active(status_icon, button, time, data)
27 {
28     // GtkMenu.popup, calling the Gtk.StatusIcon.position_menu function
29     // 
30     var area = new Gdk.Rectangle();
31      
32     var ret = {}; 
33     status_icon.get_geometry(ret);
34     
35     print(ret.orientation);
36     print(ret.area.width);
37     print(ret.area.height);
38     print(ret.area.x);
39     print(ret.area.y);
40     menu.popup(null, null, Gtk.StatusIcon.position_menu, status_icon, button, time);
41 }
42
43 window.show_all();
44
45 Gtk.main();