From b18f1b99a2757bcd3653e829977774c5855058d6 Mon Sep 17 00:00:00 2001 From: Alan Knowles Date: Mon, 12 Jul 2010 17:34:19 +0800 Subject: [PATCH] tests/status_icon.js --- tests/status_icon.js | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/tests/status_icon.js b/tests/status_icon.js index e69de29bb..b2f6f9ee1 100644 --- a/tests/status_icon.js +++ b/tests/status_icon.js @@ -0,0 +1,39 @@ +#!/usr/bin/env seed + +// Import and initialize GTK+ +Gtk = imports.gi.Gtk; +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({file : "/home/marin/Bureau/Bric_a_brac/notify/icon.png"}); + +// 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 orient = new Gtk.Orientation(); + var ret = {}; + status_icon.get_geometry(ret, area, orient); + + menu.popup(null, null, Gtk.StatusIcon.position_menu, status_icon, button, time); +} + +window.show_all(); + +Gtk.main(); -- 2.39.2