melonvpn-original-cs/MelonVPNClient/PopupMenu.cs

40 lines
1.0 KiB
C#
Raw Normal View History

2020-10-06 10:54:25 +01:00
using Gtk;
namespace MelonVPNClient
{
public class PopupMenu
{
private Menu me;
private MenuItem openItem;
private MenuItem toggleItem;
private MenuItem quitItem;
public PopupMenu(System.Action open, System.Action toggle, System.Action quit)
{
me = new Menu();
openItem = new MenuItem("...");
me.Add(openItem);
openItem.Activated += delegate { open(); };
toggleItem = new MenuItem("...");
me.Add(toggleItem);
toggleItem.Activated += delegate { toggle(); };
quitItem = new MenuItem("Quit");
me.Add(quitItem);
quitItem.Activated += delegate { quit(); };
me.ShowAll();
}
public void Update(bool ConnectedToVPN, bool Visible)
{
openItem.Label = Visible ? "Hide" : "Show";
toggleItem.Label = ConnectedToVPN ? "Disconnect" : "Connect";
}
public Menu GetMenu() => me;
}
}