Bug 141689. Prevent multiple menus.

This commit is contained in:
Jim Norman 2006-01-06 23:08:58 +00:00
parent ef80fd0ac5
commit 95544542e0
2 changed files with 309 additions and 295 deletions

View File

@ -1,3 +1,7 @@
-------------------------------------------------------------------
Fri Jan 6 16:06:03 MST 2006 - jnorman@novell.com
- Bug 141689. Prevent multiple menus.
-------------------------------------------------------------------
Fri Jan 6 17:44:03 IST 2006 - smanojna@novell.com

View File

@ -29,6 +29,7 @@ namespace Novell.CASA.GUI
#endif
private static CasaMain mCasaMain = null;
private Menu popupMenu = null;
public CasaTray(CasaMain casaInstance)
{
@ -114,75 +115,84 @@ namespace Novell.CASA.GUI
private void ShowContextMenu()
{
Menu popupMenu = new Menu(); // creates the menu
MenuItem miSep = new MenuItem();
MenuItem miSep2 = new MenuItem();
MenuItem miSep3 = new MenuItem();
ImageMenuItem menuLaunchGUI = new ImageMenuItem ("Manage Secrets");
Image appimg = new Image(Stock.New, IconSize.Menu);
menuLaunchGUI.Image = appimg; // sets the menu item's image
menuLaunchGUI.Activated +=new EventHandler(menuLaunchGUI_Activated);
popupMenu.Add(menuLaunchGUI);
popupMenu.Add(miSep);
ImageMenuItem menuLockMiCasa = new ImageMenuItem ("Lock Secrets");
//appimg = new Image(Stock.Close, IconSize.Menu);
appimg = new Image("gtk-dialog-authentication", IconSize.Menu);
menuLockMiCasa.Image = appimg; // sets the menu item's image
menuLockMiCasa.Activated +=new EventHandler(menuLockMiCasa_Activated);
ImageMenuItem menuUnLockMiCasa = new ImageMenuItem ("Unlock Secrets...");
appimg = new Image(Stock.Open, IconSize.Menu);
menuUnLockMiCasa.Image = appimg; // sets the menu item's image
menuUnLockMiCasa.Activated +=new EventHandler(menuLockMiCasa_Activated);
popupMenu.Add(menuLockMiCasa);
popupMenu.Add(menuUnLockMiCasa);
popupMenu.Add(miSep2);
ImageMenuItem menuDestroyMiCasa = new ImageMenuItem ("Destroy Secrets");
appimg = new Image(Stock.Delete, IconSize.Menu);
menuDestroyMiCasa.Image = appimg; // sets the menu item's image
menuDestroyMiCasa.Activated +=new EventHandler(menuDestroyMiCasa_Activated);
popupMenu.Add(menuDestroyMiCasa);
if (MiCASAStore.IsLocked())
if (popupMenu != null && popupMenu.Visible)
{
menuLockMiCasa.Sensitive = false;
menuDestroyMiCasa.Sensitive = false;
}
else
{
menuUnLockMiCasa.Sensitive = false;
menuDestroyMiCasa.Sensitive = true;
popupMenu.Destroy();
}
ImageMenuItem menuOptionsMiCasa = new ImageMenuItem ("Options ....");
menuOptionsMiCasa.Sensitive = false;
popupMenu.Add(menuOptionsMiCasa);
popupMenu.Add(miSep3);
if (popupMenu == null || !popupMenu.Visible)
{
popupMenu = new Menu(); // creates the menu
// creates a menu item with no image as default
ImageMenuItem menuPopup1 = new ImageMenuItem ("Exit");
appimg = new Image(Stock.Quit, IconSize.Menu);
menuPopup1.Image = appimg; // sets the menu item's image
popupMenu.Add(menuPopup1); // adds the menu item to the menu
MenuItem miSep = new MenuItem();
MenuItem miSep2 = new MenuItem();
MenuItem miSep3 = new MenuItem();
// hooks a event when the user clicks the icon
menuPopup1.Activated += new EventHandler(this.OnPopupClick);
popupMenu.ShowAll(); // shows everything
ImageMenuItem menuLaunchGUI = new ImageMenuItem ("Manage Secrets");
Image appimg = new Image(Stock.New, IconSize.Menu);
menuLaunchGUI.Image = appimg; // sets the menu item's image
menuLaunchGUI.Activated +=new EventHandler(menuLaunchGUI_Activated);
popupMenu.Add(menuLaunchGUI);
popupMenu.Add(miSep);
// pops up the actual menu when the user right clicks
//popupMenu.Popup(null, null, null, IntPtr.Zero, args.Event.Button, args.Event.Time);
ImageMenuItem menuLockMiCasa = new ImageMenuItem ("Lock Secrets");
popupMenu.Popup();
//appimg = new Image(Stock.Close, IconSize.Menu);
appimg = new Image("gtk-dialog-authentication", IconSize.Menu);
menuLockMiCasa.Image = appimg; // sets the menu item's image
menuLockMiCasa.Activated +=new EventHandler(menuLockMiCasa_Activated);
ImageMenuItem menuUnLockMiCasa = new ImageMenuItem ("Unlock Secrets...");
appimg = new Image(Stock.Open, IconSize.Menu);
menuUnLockMiCasa.Image = appimg; // sets the menu item's image
menuUnLockMiCasa.Activated +=new EventHandler(menuLockMiCasa_Activated);
popupMenu.Add(menuLockMiCasa);
popupMenu.Add(menuUnLockMiCasa);
popupMenu.Add(miSep2);
ImageMenuItem menuDestroyMiCasa = new ImageMenuItem ("Destroy Secrets");
appimg = new Image(Stock.Delete, IconSize.Menu);
menuDestroyMiCasa.Image = appimg; // sets the menu item's image
menuDestroyMiCasa.Activated +=new EventHandler(menuDestroyMiCasa_Activated);
popupMenu.Add(menuDestroyMiCasa);
if (MiCASAStore.IsLocked())
{
menuLockMiCasa.Sensitive = false;
menuDestroyMiCasa.Sensitive = false;
}
else
{
menuUnLockMiCasa.Sensitive = false;
menuDestroyMiCasa.Sensitive = true;
}
ImageMenuItem menuOptionsMiCasa = new ImageMenuItem ("Options ....");
menuOptionsMiCasa.Sensitive = false;
popupMenu.Add(menuOptionsMiCasa);
popupMenu.Add(miSep3);
// creates a menu item with no image as default
ImageMenuItem menuPopup1 = new ImageMenuItem ("Exit");
appimg = new Image(Stock.Quit, IconSize.Menu);
menuPopup1.Image = appimg; // sets the menu item's image
popupMenu.Add(menuPopup1); // adds the menu item to the menu
// hooks a event when the user clicks the icon
menuPopup1.Activated += new EventHandler(this.OnPopupClick);
popupMenu.ShowAll(); // shows everything
// pops up the actual menu when the user right clicks
//popupMenu.Popup(null, null, null, IntPtr.Zero, args.Event.Button, args.Event.Time);
popupMenu.Popup();
}
}
private void OnImageClick (object o, ButtonPressEventArgs args) // handler for mouse click