using Panel; using GLib; using Gtk; public class Test.ValaApplet : Panel.Applet { private string right_click_menu_xml = "\n \n \n \n"; private BonoboUI.Verb[] verbs = null; construct { } public ValaApplet() { } private void create() { verbs = new BonoboUI.Verb[3]; var image = new Gtk.Image.from_icon_name ("gtk-about", Gtk.IconSize.SMALL_TOOLBAR); var verb = new BonoboUI.Verb(); verb.cname = "Properties"; verb.cb = this.on_context_menu_item_clicked; verb.user_data = null; verbs[0] = verb; verb = new BonoboUI.Verb(); verb.cname = "About"; verb.cb = this.on_context_menu_item_clicked; verb.user_data = null; verbs[1] = verb; verb = new BonoboUI.Verb(); verb.cname = null; verb.cb = null; verb.user_data = null; verbs[2] = verb; this.add (image); this.setup_menu (right_click_menu_xml, verbs, this); this.delete_event += this.on_applet_deleted; this.button_press_event += this.on_button_press; this.show_all (); } static bool factory (ValaApplet applet, string iid, pointer data) { debug ("applet factory called. iid=%s", iid); applet.create (); return true; } private bool on_button_press (Widget sender, Gdk.EventButton eventButton) { if (eventButton.type == Gdk.EventType.BUTTON_PRESS && eventButton.button == 1) { debug ("applet icon click"); return true; } return false; } private static void on_context_menu_item_clicked (BonoboUI.Component component, pointer user_data, string cname) { debug ("context menu item selected: %s", cname); } private void on_applet_deleted () { debug ("applet deleted"); } public static int main(string[] args) { var program = Gnome.Program.init ("GNOME_ValaApplet", "0", Gnome.libgnomeui_module, args.length, args, "sm-connect", false); var ret = Panel.Applet.factory_main ("OAFIID:GNOME_ValaApplet_Factory", typeof(Test.ValaApplet), factory, null); return ret; } }