public StatusIconTray(GtkApplicationBase application) : base(application) { tray = new StatusIcon(Utilities.GetIcon(IconName, 24)); tray.Visible = true; tray.Activate += delegate { ToggleTaskWindowAction.Activate(); }; tray.PopupMenu += (sender, e) => { var popupMenu = Menu; popupMenu.ShowAll(); // shows everything tray.PresentMenu(popupMenu, (uint)e.Args [0], (uint)e.Args [1]); }; }
void IconPopupHandler(object o, PopupMenuArgs args) { Menu popup = new Menu(); MenuItem item = new MenuItem("About"); item.Activated += new EventHandler(OnMenuAbout); popup.Append(item); item = new MenuItem("Quit"); item.Activated += new EventHandler(OnCloseButtonClicked); popup.Append(item); popup.ShowAll(); statusIcon.PresentMenu(popup, 3, Gtk.Global.CurrentEventTime); // popup.Popup (); }
void OnStatusIconPopupMenu() { var contextMenu = ContextMenu; if (contextMenu == null) { return; } var popupMenu = new Menu(); foreach (var entry in contextMenu) { var item = new MenuItem(entry.Key); item.Activated += entry.Value; popupMenu.Add(item); } popupMenu.ShowAll(); statusIcon.PresentMenu(popupMenu, 0, Global.CurrentEventTime); }
public ConsoleWindow(Instance inst) : base("MultiMC Console") { // Build the GUI XML gxml = new XML(null, "MultiMC.GTKGUI.ConsoleWindow.glade", "vboxConsole", null); gxml.Autoconnect(this); this.Add(vboxConsole); vboxConsole.ShowAll(); this.Deletable = false; this.WidthRequest = 600; this.HeightRequest = 300; DeleteEvent += (o, args) => OnDeleteEvent(this, EventArgs.Empty); // If the user has show console on, show the window this.Visible = AppSettings.Main.ShowConsole; // Add a listener for when the instance quits Inst = inst; Inst.InstQuit += OnInstQuit; // Add formatting tags to the text buffer // Base tag using (TextTag baseTag = new TextTag("base")) { baseTag.Font = "Courier New"; consoleView.Buffer.TagTable.Add(baseTag); } // Standard output tag using (TextTag stdoutTag = new TextTag("std")) { consoleView.Buffer.TagTable.Add(stdoutTag); } // Error message tag using (TextTag errorTag = new TextTag("err")) { errorTag.ForegroundGdk = new Gdk.Color(255, 0, 0); consoleView.Buffer.TagTable.Add(errorTag); } // Misc message tag using (TextTag miscTag = new TextTag("etc")) { miscTag.ForegroundGdk = new Gdk.Color(0, 0, 255); consoleView.Buffer.TagTable.Add(miscTag); } // Listen for output from the instance if (Inst.Running) { AttachOutputListeners(); } else { Inst.InstLaunch += (sender, e) => { AttachOutputListeners(); Message("Instance started"); }; } // Add the tray icon statusIcon = new StatusIcon( Gdk.Pixbuf.LoadFromResource("MultiMC.Resources.MultiMC32.png")); statusIcon.Tooltip = "MultiMC Console"; statusIcon.Activate += (sender, e) => ShowConsole = !ShowConsole; // Make a context menu for the icon Menu trayMenu = new Menu(); // Show / hide console MenuItem showMenuItem = new MenuItem((ShowConsole ? "Hide Console" : "Show Console")); showMenuItem.Activated += (sender, e) => { ShowConsole = !ShowConsole; (showMenuItem.Child as Label).Text = (ShowConsole ? "Hide Console" : "Show Console"); }; trayMenu.Add(showMenuItem); // Kill Minecraft using (MenuItem killMenuItem = new MenuItem("Kill Minecraft")) { killMenuItem.Activated += (sender, e) => { Gtk.MessageDialog confirmDlg = new Gtk.MessageDialog(this, DialogFlags.Modal, MessageType.Warning, ButtonsType.OkCancel, "Killing Minecraft can " + "cause you to lose saves " + "and other things. " + "Are you sure?"); confirmDlg.Title = "Warning"; confirmDlg.Response += (object o, ResponseArgs args) => { if (args.ResponseId == ResponseType.Ok) { Inst.InstProcess.Kill(); } confirmDlg.Destroy(); }; confirmDlg.Run(); }; trayMenu.Add(killMenuItem); } trayMenu.ShowAll(); statusIcon.PopupMenu += (object o, PopupMenuArgs args) => statusIcon.PresentMenu(trayMenu, (uint)args.Args[0], (uint)args.Args[1]); if (inst.InstProcess != null && inst.InstProcess.StartInfo != null) { Message("Instance started with command: " + inst.InstProcess.StartInfo.FileName + " " + inst.InstProcess.StartInfo.Arguments.ToString()); } else { Message("Instance started"); } }