/* vim: set noexpandtab tabstop=4 shiftwidth=4 nowrap textwidth=100
*
* Echo Media Player
* Copyright (C) 2008 Shane O'Connell
*
* [ The original file includes a copyright header in this location describing
* the file as being released under the terms of the GNU General Public
* License. It has been removed in order to display the file as part of the
* archive. ]
*/
public class Echo.UI.ContextMenu : GLib.Object
{
private Gtk.ActionGroup _action_group;
private Gtk.Menu _menu;
private GLib.Object _context_object;
public signal void pre_popup(GLib.Object context_object);
public ContextMenu(GLib.Object context_object)
{
_action_group = new Gtk.ActionGroup("context-menu");
_menu = new Gtk.Menu();
_context_object = context_object;
}
public void add_item(string name, string? label, string? stock_id = null)
{
var action = new Gtk.Action(name, label, null, stock_id);
_action_group.add_action(action);
_menu.append((Gtk.MenuItem)action.create_menu_item());
}
public void add_separator()
{
var separator = new Gtk.SeparatorMenuItem();
separator.show();
_menu.append(separator);
}
public weak Gtk.Action? get_action(string name)
{
return _action_group.get_action(name);
}
public void popup(uint button, uint time)
{
pre_popup(_context_object);
_menu.popup(null, null, null, button, time);
}
}