GUI merge changes

This commit is contained in:
Jim Norman 2005-10-13 19:56:58 +00:00
parent 922a33690b
commit c51cd6bebe
7 changed files with 278 additions and 70 deletions

View File

@ -19,6 +19,9 @@ using Novell.CASA;
using Novell.CASA.MiCasa.Common;
using Novell.CASA.MiCasa.Communication;
#if W32
using Microsoft.Win32;
#endif
public class CasaMain
{
@ -84,6 +87,8 @@ public class CasaMain
mmiEdit,
mmiOptions,
mmiDebug;
[Glade.Widget]
Gtk.CheckMenuItem mmiShowTaskIcon;
#endregion
@ -106,12 +111,24 @@ public class CasaMain
Application.Init();
if (Common.IsTrayAvailable() && Common.IsArgSet(args, Common.ARG_SHOW_TRAY_ICON))
if (args.Length > 0)
{
mCasaTray = new CasaTray();
if (Common.IsTrayAvailable() && Common.IsArgSet(args, Common.ARG_SHOW_TRAY_ICON))
{
mCasaTray = new CasaTray();
}
else
{
// launch both
if (Common.IsTrayAvailable())
mCasaTray = new CasaTray();
new CasaMain(args);
}
}
else
{
new CasaMain(args);
}
Application.Run();
@ -220,6 +237,9 @@ public class CasaMain
else
UnlockGUI();
if (mCasaTray != null)
mmiShowTaskIcon.Active = true;
windowMain.Show();
Logger.DbgLog("GUI:CasaMain.InitializeGUI() - END");
@ -727,13 +747,13 @@ public class CasaMain
public void OnDestroyMiCASASecrets(object sender, EventArgs args)
{
Logger.DbgLog("GUI:CasaMain.OnDestroyMiCASASecrets() - START");
CommonGUI.menuDestroyMiCasa_Activated(sender, args);
Logger.DbgLog("GUI:CasaMain.OnDestroyMiCASASecrets() - START");
CommonGUI temp = new CommonGUI();
temp.menuDestroyMiCasa_Activated(this, mCasaTray);
Logger.DbgLog("GUI:CasaMain.OnDestroyMiCASASecrets() - END");
}
internal void LockGUI()
{
mmiLockSecrets.Sensitive = false;
@ -1011,6 +1031,90 @@ public class CasaMain
dialogPreferences.Destroy();
}
public void on_show_tasktray_icon1_activate(object obj, EventArgs args)
{
if (mmiShowTaskIcon.Active)
{
if (mCasaTray == null)
{
if (IsTraySetForStartup() == false)
PromptUserForStartup();
mCasaTray = new CasaTray(this);
}
}
else
{
if (mCasaTray != null)
{
mCasaTray.Destroy();
mCasaTray = null;
}
}
}
private bool IsTraySetForStartup()
{
#if W32
string sStartup = CommonGUI.ReadRegKey(
Registry.CurrentUser,
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run",
"CASA Tray");
if (sStartup == null || sStartup.Length < 1)
return false;
else
return true;
#endif
#if LINUX
// TODO check startup script for the user.
return false;
#endif
}
private void PromptUserForStartup()
{
// prompt user
MessageDialog md=new MessageDialog(null,Gtk.DialogFlags.Modal,
Gtk.MessageType.Question,
Gtk.ButtonsType.YesNo,
"Show the Tray Icon at startup?");
md.SetPosition(Gtk.WindowPosition.Center);
md.Response +=new ResponseHandler(md_Response);
md.Modal = true;
md.SetIconFromFile(Common.CASAICONS);
md.Show();
}
private void md_Response(object o, ResponseArgs args)
{
if (args.ResponseId.Equals(Gtk.ResponseType.Yes))
{
#if W32
// get our program path
String sPath = "\"" +Environment.GetEnvironmentVariable("ProgramFiles")+
"\\Novell\\CASA\\bin\\CASAManager.exe\" -tray";
CommonGUI.WriteRegKey(Registry.CurrentUser,
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run",
"CASA Tray",
sPath);
#endif
// TODO: Set startup script for the user
}
MessageDialog md = (MessageDialog)o;
if (md != null)
{
md.Destroy();
}
}
///#######################################################################
/// DEBUG
@ -1119,7 +1223,7 @@ public class CasaMain
internal void Focus()
{
windowMain.Present();
}
}
}
}
///###########################################################################

View File

@ -15,13 +15,13 @@ namespace Novell.CASA.GUI
public class CasaTray
{
#if W32
private static System.Windows.Forms.NotifyIcon notifyIcon;
public static System.Drawing.Icon m_iconNormal;
public static System.Drawing.Icon m_iconLocked;
#endif
#if LINUX
Egg.TrayIcon icon;
EventBox eb;
private Gtk.Image m_imageLocked = new Image("images/CASA_16.png", IconSize.Menu);
private Gtk.Image m_imageUnlocked = new Image(Stock.Find, IconSize.Menu);
@ -30,9 +30,19 @@ namespace Novell.CASA.GUI
private static CasaMain mCasaMain = null;
public CasaTray(CasaMain casaInstance)
{
mCasaMain = casaInstance;
Setup();
}
public CasaTray()
{
Setup();
}
private void Setup()
{
#if W32
Stream s = null;
notifyIcon = new System.Windows.Forms.NotifyIcon();
@ -94,10 +104,11 @@ namespace Novell.CASA.GUI
// hooking event
eb.ButtonPressEvent += new ButtonPressEventHandler (this.OnImageClick);
Egg.TrayIcon icon = new Egg.TrayIcon("Test");
icon = new Egg.TrayIcon("Test");
icon.Add(eb);
// showing the trayicon
icon.ShowAll();
icon.ShowAll();
#endif
}
@ -179,7 +190,12 @@ namespace Novell.CASA.GUI
}
private void OnPopupClick(object o, EventArgs args)
{
Application.Quit(); // quits the application when the users clicks the popup menu
if (mCasaMain != null)
{
this.Destroy();
}
else
Application.Quit(); // quits the application when the users clicks the popup menu
}
#if W32
private void notifyIcon_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
@ -200,24 +216,7 @@ namespace Novell.CASA.GUI
if (mCasaMain == null)
mCasaMain = new CasaMain(null);
else
mCasaMain.Focus();
/*
// launch the GUI
Process myProcess = new Process();
#if W32
ProcessStartInfo myProcessStartInfo = new ProcessStartInfo("CASAManager.exe");
#else
ProcessStartInfo myProcessStartInfo = new ProcessStartInfo("mono");
myProcessStartInfo.Arguments = "/opt/novell/CASA/bin/CASAManager.exe";
#endif
myProcessStartInfo.UseShellExecute = false;
myProcessStartInfo.RedirectStandardOutput = true;
myProcess.StartInfo = myProcessStartInfo;
myProcess.Start();
*/
mCasaMain.Focus();
}
private void menuLockMiCasa_Activated(object sender, EventArgs e)
@ -259,7 +258,8 @@ namespace Novell.CASA.GUI
private void menuDestroyMiCasa_Activated(object sender, EventArgs e)
{
CommonGUI.menuDestroyMiCasa_Activated(sender, e);
CommonGUI temp = new CommonGUI();
temp.menuDestroyMiCasa_Activated(mCasaMain, this);
}
internal void UpdateTrayIcon(bool StoreIsLocked)
@ -278,5 +278,17 @@ namespace Novell.CASA.GUI
#endif
}
internal void Destroy()
{
#if W32
notifyIcon.Dispose();
#endif
#if LINUX
// Does not work
icon.Dispose();
#endif
}
}
}

View File

@ -84,7 +84,16 @@ public class Common
///##############################################################
/// ARG CONSTANTS
public static string ARG_SHOW_TRAY_ICON = "tray";
public static string ARG_SHOW_TRAY_ICON = "-tray";
///#############################################################
///CasaIcons path
#if W32
public static string CASAICONS = "../images/CASAIcons.ico";
#endif
#if LINUX
public static string CASAICONS = "opt/novell/CASA/images/CASAIcons.ico";
#endif
///##############################################################
/// ERROR CODES

View File

@ -6,6 +6,9 @@ using Novell.CASA;
using Novell.CASA.MiCasa.Common;
using Novell.CASA.MiCasa.Communication;
#if W32
using Microsoft.Win32;
#endif
namespace Novell.CASA.GUI
{
/// <summary>
@ -68,8 +71,11 @@ namespace Novell.CASA.GUI
dialogLogin.Show();
}
internal static void menuDestroyMiCasa_Activated(object sender, EventArgs e)
internal void menuDestroyMiCasa_Activated(CasaMain casaMain, CasaTray tray)
{
mCasaInstance = casaMain;
mTrayInstance = tray;
// prompt user
MessageDialog md=new MessageDialog(null,Gtk.DialogFlags.Modal,
Gtk.MessageType.Warning,
@ -79,15 +85,18 @@ namespace Novell.CASA.GUI
md.SetPosition(Gtk.WindowPosition.Center);
md.Response +=new ResponseHandler(md_Response);
md.Modal = true;
md.SetIconFromFile(Common.CASAICONS);
md.Show();
}
private static void md_Response(object o, ResponseArgs args)
private void md_Response(object o, ResponseArgs args)
{
if (args.ResponseId.Equals(Gtk.ResponseType.Ok))
{
MiCasaRequestReply.Send(MiCasaRequestReply.VERB_REMOVE_ALL_SECRETS);
MiCasaRequestReply.Send(MiCasaRequestReply.VERB_REMOVE_ALL_SECRETS);
if (mCasaInstance != null)
mCasaInstance.objMiCasa.AggregateStore();
}
MessageDialog md = (MessageDialog)o;
@ -119,20 +128,20 @@ namespace Novell.CASA.GUI
else
{
// prompt user
MessageDialog md=new MessageDialog(mainWindow,Gtk.DialogFlags.Modal,
MessageDialog md=new MessageDialog(
mainWindow,Gtk.DialogFlags.Modal,
Gtk.MessageType.Warning,
Gtk.ButtonsType.Ok,
"Master Password entered is incorrect");
md.Response +=new ResponseHandler(md_Response2);
md.SetPosition(Gtk.WindowPosition.CenterOnParent);
md.Modal = true;
md.Modal = true;
md.SetIconFromFile(Common.CASAICONS);
md.Show();
}
}
public void closebuttonLogin_clicked(object abj, EventArgs args)
{
dialogLogin.Destroy();
@ -176,5 +185,63 @@ namespace Novell.CASA.GUI
mTrayInstance.UpdateTrayIcon(false);
}
}
#if W32
internal static string ReadRegKey(RegistryKey rk, string sSubKey, string KeyName)
{
// Opening the registry key
// RegistryKey rk = Registry.Users;
// Open a subKey as read-only
RegistryKey sk1 = rk.OpenSubKey(sSubKey);
// If the RegistrySubKey doesn't exist -> (null)
if ( sk1 == null )
{
return null;
}
else
{
try
{
// If the RegistryKey exists I get its value
// or null is returned.
return (string)sk1.GetValue(KeyName.ToUpper());
}
catch (Exception e)
{
//ShowErrorMessage(e, "Reading registry " + KeyName.ToUpper());
return null;
}
}
}
internal static void WriteRegKey(RegistryKey rk, string sSubKey, string KeyName, string sKeyValue)
{
RegistryKey sk1 = rk.OpenSubKey(sSubKey, true);
// If the RegistrySubKey doesn't exist -> (null)
if ( sk1 == null )
{
//return null;
}
else
{
try
{
// If the RegistryKey exists I get its value
// or null is returned.
sk1.SetValue(KeyName, sKeyValue);
sk1.Close();
}
catch (Exception e)
{
sk1.Close();
//ShowErrorMessage(e, "Reading registry " + KeyName.ToUpper());
Console.Write(e.ToString());
//return null;
}
}
}
#endif
}
}

View File

@ -460,7 +460,7 @@ public class MiCasa : Store
gxmlTemp.Autoconnect (this);
dialogLogin.TransientFor = dialogManageSecret;
label86.Text = "Enter your Master Password to view passwords";
label86.Text = "Enter your Master Password to view values";
entryMasterPassword3.Text="";
entryMasterPassword3.HasFocus = true;
label88.Hide();

View File

@ -301,7 +301,6 @@ namespace Novell.CASA.GUI {
//Common.ShowErrorDialog(exp);
}
}
}
}

View File

@ -52,7 +52,7 @@
<property name="use_underline">True</property>
<child internal-child="image">
<widget class="GtkImage" id="image2446">
<widget class="GtkImage" id="image2536">
<property name="visible">True</property>
<property name="stock">gtk-new</property>
<property name="icon_size">1</property>
@ -74,7 +74,7 @@
<signal name="activate" handler="OnNewSecretActivated" last_modification_time="Tue, 27 Sep 2005 06:02:26 GMT"/>
<child internal-child="image">
<widget class="GtkImage" id="image2447">
<widget class="GtkImage" id="image2537">
<property name="visible">True</property>
<property name="stock">gtk-new</property>
<property name="icon_size">1</property>
@ -95,7 +95,7 @@
<signal name="activate" handler="OnNewKeyActivated" last_modification_time="Tue, 27 Sep 2005 06:02:36 GMT"/>
<child internal-child="image">
<widget class="GtkImage" id="image2448">
<widget class="GtkImage" id="image2538">
<property name="visible">True</property>
<property name="stock">gtk-new</property>
<property name="icon_size">1</property>
@ -121,7 +121,7 @@
<accelerator key="F5" modifiers="0" signal="activate"/>
<child internal-child="image">
<widget class="GtkImage" id="image2449">
<widget class="GtkImage" id="image2539">
<property name="visible">True</property>
<property name="stock">gtk-refresh</property>
<property name="icon_size">1</property>
@ -148,7 +148,7 @@
<signal name="activate" handler="OnLockMiCASASecrets" last_modification_time="Mon, 10 Oct 2005 19:51:54 GMT"/>
<child internal-child="image">
<widget class="GtkImage" id="image2450">
<widget class="GtkImage" id="image2540">
<property name="visible">True</property>
<property name="stock">gtk-dialog-authentication</property>
<property name="icon_size">1</property>
@ -169,7 +169,7 @@
<signal name="activate" handler="OnUnLockMiCASASecrets" last_modification_time="Tue, 11 Oct 2005 20:12:35 GMT"/>
<child internal-child="image">
<widget class="GtkImage" id="image2451">
<widget class="GtkImage" id="image2541">
<property name="visible">True</property>
<property name="stock">gtk-open</property>
<property name="icon_size">1</property>
@ -190,7 +190,7 @@
<signal name="activate" handler="OnDestroyMiCASASecrets" last_modification_time="Tue, 11 Oct 2005 20:12:35 GMT"/>
<child internal-child="image">
<widget class="GtkImage" id="image2452">
<widget class="GtkImage" id="image2542">
<property name="visible">True</property>
<property name="stock">gtk-delete</property>
<property name="icon_size">1</property>
@ -218,7 +218,7 @@
<accelerator key="Q" modifiers="GDK_CONTROL_MASK" signal="activate"/>
<child internal-child="image">
<widget class="GtkImage" id="image2453">
<widget class="GtkImage" id="image2543">
<property name="visible">True</property>
<property name="stock">gtk-quit</property>
<property name="icon_size">1</property>
@ -254,7 +254,7 @@
<accelerator key="F2" modifiers="0" signal="activate"/>
<child internal-child="image">
<widget class="GtkImage" id="image2454">
<widget class="GtkImage" id="image2544">
<property name="visible">True</property>
<property name="stock">gtk-zoom-fit</property>
<property name="icon_size">1</property>
@ -275,7 +275,7 @@
<signal name="activate" handler="LinkKeyValue" last_modification_time="Fri, 19 Aug 2005 06:23:15 GMT"/>
<child internal-child="image">
<widget class="GtkImage" id="image2455">
<widget class="GtkImage" id="image2545">
<property name="visible">True</property>
<property name="stock">gtk-jump-to</property>
<property name="icon_size">1</property>
@ -296,7 +296,7 @@
<signal name="activate" handler="CopyKeyValue" last_modification_time="Fri, 19 Aug 2005 06:23:15 GMT"/>
<child internal-child="image">
<widget class="GtkImage" id="image2456">
<widget class="GtkImage" id="image2546">
<property name="visible">True</property>
<property name="stock">gtk-copy</property>
<property name="icon_size">1</property>
@ -324,7 +324,7 @@
<accelerator key="Delete" modifiers="0" signal="activate"/>
<child internal-child="image">
<widget class="GtkImage" id="image2457">
<widget class="GtkImage" id="image2547">
<property name="visible">True</property>
<property name="stock">gtk-delete</property>
<property name="icon_size">1</property>
@ -358,7 +358,7 @@
<signal name="activate" handler="PersistentStorage" last_modification_time="Fri, 19 Aug 2005 06:40:17 GMT"/>
<child internal-child="image">
<widget class="GtkImage" id="image2458">
<widget class="GtkImage" id="image2548">
<property name="visible">True</property>
<property name="stock">gtk-revert-to-saved</property>
<property name="icon_size">1</property>
@ -379,7 +379,7 @@
<signal name="activate" handler="Preferences" last_modification_time="Fri, 19 Aug 2005 06:40:17 GMT"/>
<child internal-child="image">
<widget class="GtkImage" id="image2459">
<widget class="GtkImage" id="image2549">
<property name="visible">True</property>
<property name="stock">gtk-preferences</property>
<property name="icon_size">1</property>
@ -391,6 +391,22 @@
</child>
</widget>
</child>
<child>
<widget class="GtkSeparatorMenuItem" id="separator6">
<property name="visible">True</property>
</widget>
</child>
<child>
<widget class="GtkCheckMenuItem" id="mmiShowTaskIcon">
<property name="visible">True</property>
<property name="label" translatable="yes">Show Tasktray Icon</property>
<property name="use_underline">True</property>
<property name="active">False</property>
<signal name="activate" handler="on_show_tasktray_icon1_activate" last_modification_time="Thu, 13 Oct 2005 15:10:40 GMT"/>
</widget>
</child>
</widget>
</child>
</widget>
@ -413,7 +429,7 @@
<signal name="activate" handler="on_create_sample_secrets1_activate" last_modification_time="Fri, 30 Sep 2005 12:58:41 GMT"/>
<child internal-child="image">
<widget class="GtkImage" id="image2460">
<widget class="GtkImage" id="image2550">
<property name="visible">True</property>
<property name="stock">gtk-file</property>
<property name="icon_size">1</property>
@ -434,7 +450,7 @@
<signal name="activate" handler="on_remove_test_secrets1_activate" last_modification_time="Fri, 30 Sep 2005 12:59:05 GMT"/>
<child internal-child="image">
<widget class="GtkImage" id="image2461">
<widget class="GtkImage" id="image2551">
<property name="visible">True</property>
<property name="stock">gtk-missing-image</property>
<property name="icon_size">1</property>
@ -471,7 +487,7 @@
<signal name="activate" handler="on_view_log_file1_activate" last_modification_time="Fri, 30 Sep 2005 12:59:41 GMT"/>
<child internal-child="image">
<widget class="GtkImage" id="image2462">
<widget class="GtkImage" id="image2552">
<property name="visible">True</property>
<property name="stock">gtk-zoom-fit</property>
<property name="icon_size">1</property>
@ -505,7 +521,7 @@
<accelerator key="F1" modifiers="0" signal="activate"/>
<child internal-child="image">
<widget class="GtkImage" id="image2463">
<widget class="GtkImage" id="image2553">
<property name="visible">True</property>
<property name="stock">gtk-help</property>
<property name="icon_size">1</property>
@ -532,7 +548,7 @@
<signal name="activate" handler="About" last_modification_time="Thu, 01 Sep 2005 15:30:28 GMT"/>
<child internal-child="image">
<widget class="GtkImage" id="image2464">
<widget class="GtkImage" id="image2554">
<property name="visible">True</property>
<property name="stock">gtk-dialog-info</property>
<property name="icon_size">1</property>
@ -1330,7 +1346,7 @@
<property name="modal">True</property>
<property name="resizable">False</property>
<property name="destroy_with_parent">True</property>
<property name="icon">micasa-logo.png</property>
<property name="icon">CASAicons.ico</property>
<property name="decorated">True</property>
<property name="skip_taskbar_hint">False</property>
<property name="skip_pager_hint">False</property>
@ -1513,7 +1529,7 @@ their backend stores.</property>
<property name="default_height">500</property>
<property name="resizable">True</property>
<property name="destroy_with_parent">True</property>
<property name="icon">micasa-logo.png</property>
<property name="icon">CASAicons.ico</property>
<property name="decorated">True</property>
<property name="skip_taskbar_hint">False</property>
<property name="skip_pager_hint">False</property>
@ -3165,7 +3181,7 @@ their backend stores.</property>
<property name="modal">True</property>
<property name="resizable">False</property>
<property name="destroy_with_parent">True</property>
<property name="icon">micasa-logo.png</property>
<property name="icon">CASAicons.ico</property>
<property name="decorated">True</property>
<property name="skip_taskbar_hint">False</property>
<property name="skip_pager_hint">False</property>
@ -3399,7 +3415,7 @@ and all the key-value pairs.</property>
<property name="modal">True</property>
<property name="resizable">False</property>
<property name="destroy_with_parent">True</property>
<property name="icon">micasa-logo.png</property>
<property name="icon">CASAicons.ico</property>
<property name="decorated">True</property>
<property name="skip_taskbar_hint">False</property>
<property name="skip_pager_hint">False</property>
@ -3578,7 +3594,7 @@ Console.</property>
<property name="modal">True</property>
<property name="resizable">False</property>
<property name="destroy_with_parent">True</property>
<property name="icon">micasa-logo.png</property>
<property name="icon">CASAicons.ico</property>
<property name="decorated">True</property>
<property name="skip_taskbar_hint">False</property>
<property name="skip_pager_hint">False</property>
@ -3944,7 +3960,7 @@ prompted for the Master Password at startup.</property>
<property name="modal">True</property>
<property name="resizable">False</property>
<property name="destroy_with_parent">True</property>
<property name="icon">micasa-logo.png</property>
<property name="icon">CASAicons.ico</property>
<property name="decorated">True</property>
<property name="skip_taskbar_hint">False</property>
<property name="skip_pager_hint">False</property>
@ -4444,7 +4460,7 @@ prompted for the Master Password at startup.</property>
<property name="modal">True</property>
<property name="resizable">False</property>
<property name="destroy_with_parent">True</property>
<property name="icon">micasa-logo.png</property>
<property name="icon">CASAicons.ico</property>
<property name="decorated">True</property>
<property name="skip_taskbar_hint">False</property>
<property name="skip_pager_hint">False</property>
@ -4786,7 +4802,7 @@ CSL Manojna&lt;/b&gt;</property>
<property name="modal">True</property>
<property name="resizable">False</property>
<property name="destroy_with_parent">True</property>
<property name="icon">micasa-logo.png</property>
<property name="icon">CASAicons.ico</property>
<property name="decorated">True</property>
<property name="skip_taskbar_hint">False</property>
<property name="skip_pager_hint">False</property>
@ -5112,6 +5128,7 @@ prompted for the Master Password at startup.</property>
<property name="modal">False</property>
<property name="resizable">True</property>
<property name="destroy_with_parent">False</property>
<property name="icon">CASAicons.ico</property>
<property name="decorated">True</property>
<property name="skip_taskbar_hint">False</property>
<property name="skip_pager_hint">False</property>
@ -5227,7 +5244,7 @@ prompted for the Master Password at startup.</property>
<property name="default_height">500</property>
<property name="resizable">True</property>
<property name="destroy_with_parent">True</property>
<property name="icon">micasa-logo.png</property>
<property name="icon">CASAicons.ico</property>
<property name="decorated">True</property>
<property name="skip_taskbar_hint">False</property>
<property name="skip_pager_hint">False</property>
@ -5779,7 +5796,7 @@ prompted for the Master Password at startup.</property>
<property name="modal">False</property>
<property name="resizable">False</property>
<property name="destroy_with_parent">True</property>
<property name="icon">micasa-logo.png</property>
<property name="icon">CASAicons.ico</property>
<property name="decorated">True</property>
<property name="skip_taskbar_hint">False</property>
<property name="skip_pager_hint">False</property>
@ -5931,7 +5948,7 @@ instance is already running.&lt;/b&gt;</property>
<property name="modal">False</property>
<property name="resizable">False</property>
<property name="destroy_with_parent">True</property>
<property name="icon">micasa-logo.png</property>
<property name="icon">CASAicons.ico</property>
<property name="decorated">True</property>
<property name="skip_taskbar_hint">False</property>
<property name="skip_pager_hint">False</property>