X-Git-Url: http://git.roojs.org/?a=blobdiff_plain;f=tests%2Fstatus_icon.js;h=07658044ce03ee38f20ebabd5fc5bdc3d20c5083;hb=df1bc552d9ddc36cd32e7408ea1bd4082f08a5fd;hp=e69de29bb2d1d6434b8b29ae775ad8c2e48c5391;hpb=eead6678496a6afdd28257bf8c2c5232db582324;p=app.Builder.js diff --git a/tests/status_icon.js b/tests/status_icon.js index e69de29bb..07658044c 100644 --- a/tests/status_icon.js +++ b/tests/status_icon.js @@ -0,0 +1,45 @@ +#!/usr/bin/env seed + +// Import and initialize GTK+ +Gtk = imports.gi.Gtk; +Gdk = imports.gi.Gdk; +Gtk.init(null, null); + +// Create the window +var window = new Gtk.Window({title: "Hello World"}); +window.set_default_size(600, 500); +window.signal.hide.connect(Gtk.main_quit); + +// Create the GtkStatusIcon from a file +var icon = new Gtk.StatusIcon({stock : Gtk.STOCK_MEDIA_PLAY}); + +// Create the menu +var menu = new Gtk.Menu(); + +// Create an item +var item = new Gtk.MenuItem({label: "Hello"}); +menu.append(item); + +// Signal connecting the popup_menu event of the icon to the "activate" function +icon.signal.popup_menu.connect(active, menu); + +function active(status_icon, button, time, data) +{ + // GtkMenu.popup, calling the Gtk.StatusIcon.position_menu function + // + var area = new Gdk.Rectangle(); + + var ret = {}; + status_icon.get_geometry(ret); + + print(ret.orientation); + print(ret.area.width); + print(ret.area.height); + print(ret.area.x); + print(ret.area.y); + menu.popup(null, null, Gtk.StatusIcon.position_menu, status_icon, button, time); +} + +window.show_all(); + +Gtk.main();