40 lines
1.0 KiB
C#
40 lines
1.0 KiB
C#
|
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;
|
|||
|
}
|
|||
|
}
|