Process commandline args one time.

This commit is contained in:
Jim Norman 2007-03-30 21:00:57 +00:00
parent 137e56f7cf
commit f4a696d991
2 changed files with 60 additions and 31 deletions

View File

@ -46,9 +46,8 @@ namespace Novell.CASA.GUI
public GnomeKeyring objGnomeKeyring = null; public GnomeKeyring objGnomeKeyring = null;
public static Glade.XML gxmlMain = null; public static Glade.XML gxmlMain = null;
public static CasaTray mCasaTray = null; public static CasaTray mCasaTray = null;
public static bool m_bShowDebug = false;
public static bool m_bshowDialogStillRunning = true; public static bool m_bshowDialogStillRunning = true;
public static bool m_bGuiLocked = false; public static bool m_bGuiLocked = false;
@ -165,6 +164,7 @@ namespace Novell.CASA.GUI
{ {
Logger.DbgLog("GUI:CasaMain.Main() - BEGIN"); Logger.DbgLog("GUI:CasaMain.Main() - BEGIN");
Common.ParseArgs(args);
Common.ReadPlatform(); Common.ReadPlatform();
#if W32 #if W32
@ -176,8 +176,7 @@ namespace Novell.CASA.GUI
try try
{ {
if (Common.IsArgSet(args, Common.ARG_DEBUG))
m_bShowDebug = true;
// ping micasad // ping micasad
Ping ping = new Ping(); Ping ping = new Ping();
@ -194,7 +193,7 @@ namespace Novell.CASA.GUI
string message; string message;
Gtk.ButtonsType buttonType = Gtk.ButtonsType.Close; Gtk.ButtonsType buttonType = Gtk.ButtonsType.Close;
if (m_bShowDebug) if (Common.bArgDebug)
{ {
message = e.ToString(); message = e.ToString();
Console.WriteLine(e.StackTrace); Console.WriteLine(e.StackTrace);
@ -252,12 +251,17 @@ namespace Novell.CASA.GUI
{ {
try try
{ {
if (!Common.IsArgSet(args, Common.ARG_NO_TRAY_ICON)) if (Common.bArgShowTrayIcon)
{ {
if (config.GetConfigSetting(Common.CONFIG_RUN_IN_TRAY, true)) if (config.GetConfigSetting(Common.CONFIG_RUN_IN_TRAY, true))
{ {
if (mCasaTray == null) if (mCasaTray == null)
mCasaTray = new CasaTray(this, config); {
mCasaTray = new CasaTray(this, config);
if (Common.bArgStartMinimized)
mCasaTray.CasaManagerQuit();
}
} }
} }
} }
@ -297,7 +301,7 @@ namespace Novell.CASA.GUI
windowMain.DeleteEvent += new DeleteEventHandler(OnWindowMainDeleted); windowMain.DeleteEvent += new DeleteEventHandler(OnWindowMainDeleted);
// DEBUG // DEBUG
if (!m_bShowDebug) if (!Common.bArgDebug)
mmiDebug.Hide(); mmiDebug.Hide();
/// PLATFORM SPECIFIC GUI CHANGES /// PLATFORM SPECIFIC GUI CHANGES

View File

@ -137,9 +137,14 @@ public class Common
///############################################################## ///##############################################################
/// ARG CONSTANTS /// ARG CONSTANTS
/// ///
public static string ARG_NO_TRAY_ICON = "-notray"; public const string ARG_NO_TRAY_ICON = "-notray";
public static string ARG_SHOW_TRAY_ICON = "-tray"; public const string ARG_DEBUG = "-debug";
public static string ARG_DEBUG = "-debug"; public const string ARG_MINIMIZE_ON_START = "-min";
public const string ARG_HELP = "-help";
public static bool bArgShowTrayIcon = true;
public static bool bArgDebug = false;
public static bool bArgStartMinimized = false;
// config settings // config settings
// NOTE: some of these are used in micasad // NOTE: some of these are used in micasad
@ -332,19 +337,39 @@ public class Common
return false; return false;
} }
public static bool IsArgSet(string[] args, string argToCheck) public static void ParseArgs(string[] args)
{ {
if (args != null) foreach (string arg in args)
{ {
for (int i=0; i<args.Length; i++)
{
if (argToCheck.Equals(args[i].ToLower()))
return true;
}
}
return false; switch (arg)
} {
case Common.ARG_NO_TRAY_ICON:
bArgShowTrayIcon = false;
break;
case Common.ARG_DEBUG:
bArgDebug = true;
break;
case Common.ARG_MINIMIZE_ON_START:
bArgStartMinimized = true;
break;
case Common.ARG_HELP:
Console.WriteLine("Usage options");
Console.WriteLine(Common.ARG_NO_TRAY_ICON + " do not show tray icon");
Console.WriteLine(Common.ARG_MINIMIZE_ON_START + " start minimized");
Console.WriteLine(Common.ARG_HELP + " show help options");
Application.Quit();
break;
//default:
Console.WriteLine("Unsupported argument {0}", arg);
}
}
}
private static string GetLocale() private static string GetLocale()
{ {