From 8a5d4808b94d0e3383e7ca5f5c9db04f60f53a8d Mon Sep 17 00:00:00 2001 From: Jim Norman Date: Mon, 21 Aug 2006 16:55:51 +0000 Subject: [PATCH] import/export changes --- CASA/gui/Common.cs | 6 ++ CASA/gui/ExportSecrets.cs | 16 +++-- CASA/gui/FileChooser.cs | 128 +++++++++++++++++++++---------------- CASA/gui/MiCasa.cs | 19 +++--- CASA/gui/images/folder.png | Bin 0 -> 6584 bytes 5 files changed, 102 insertions(+), 67 deletions(-) create mode 100644 CASA/gui/images/folder.png diff --git a/CASA/gui/Common.cs b/CASA/gui/Common.cs index 54574833..0a3e1c1d 100644 --- a/CASA/gui/Common.cs +++ b/CASA/gui/Common.cs @@ -124,6 +124,12 @@ public class Common public static string LINUX_HELP_PATH = "file:///usr/share/doc/packages/CASA/help/"; public static string WINDOWS_HELP_PATH = "..\\help\\"; + +#if W32 + public static string IMAGE_PATH = "..\\images\\"; +#else + public static string IMAGE_PATH = "/usr/share/doc/packages/CASA/images/"; +#endif ///############################################################## /// ARG CONSTANTS diff --git a/CASA/gui/ExportSecrets.cs b/CASA/gui/ExportSecrets.cs index 416b68cd..a7eecc92 100644 --- a/CASA/gui/ExportSecrets.cs +++ b/CASA/gui/ExportSecrets.cs @@ -95,7 +95,8 @@ namespace Novell.CASA.GUI if (iLastSlash > 0) { sHintFile = sFileName.Substring(iLastSlash + 1); - sHintDir = sFileName.Substring(8, sFileName.Length - sHintFile.Length - 8); } + sHintDir = sFileName.Substring(0, sFileName.Length - sHintFile.Length); + } // save for later use m_config.SetConfigSetting(CommonGUI.HINT_DIR, sHintDir); @@ -107,7 +108,9 @@ namespace Novell.CASA.GUI byte[] theSecrets = (byte[])Novell.CASA.MiCasa.Communication.MiCasaRequestReply.Send(MiCasaRequestReply.VERB_EXPORT_SECRETS, null, null, null, exportSecrets); // write em out. - FileStream fs = new FileStream(sFileName.Substring(8), FileMode.Create); + + + FileStream fs = new FileStream(sFileName, FileMode.Create); fs.Write(theSecrets, 0, theSecrets.Length); fs.Flush(); fs.Close(); @@ -133,13 +136,18 @@ namespace Novell.CASA.GUI private string GetStorageFileName(string sHintDir, string sHintFile) { -#if W32 + + FileChooser fc = new FileChooser(); + String sFileName = fc.GetFile(sHintDir, sHintFile); + +/* +#if W32 String sFileName = CommonGUI.FileChooser(FileChooserAction.Save, "Select filename and location for secrets", sHintDir, sHintFile); #else String sFileName = null; CommonGUI.DisplayMessage(Gtk.MessageType.Info, "Not implemented"); #endif - +*/ return sFileName; } diff --git a/CASA/gui/FileChooser.cs b/CASA/gui/FileChooser.cs index 5169487f..5b0bbe69 100644 --- a/CASA/gui/FileChooser.cs +++ b/CASA/gui/FileChooser.cs @@ -17,10 +17,11 @@ namespace Novell.CASA.GUI private bool m_bFileChoosing = true; private Gtk.TreeStore tsDrives = new TreeStore(typeof(string)); - private Gtk.TreeStore ts = new TreeStore(typeof(string), typeof(string)); + private Gtk.TreeStore ts = new TreeStore(typeof(Gdk.Pixbuf), typeof(string), typeof(string), typeof(string)); - Thread tChooserThread = null; - Thread tMainThread = null; + private string m_pathSeparator = "/"; + + Thread tChooserThread = null; #region Glade Widgets @@ -44,10 +45,26 @@ namespace Novell.CASA.GUI public FileChooser() { - // - // TODO: Add constructor logic here - // - m_currentDirectory = Common.GetUserHomeDir(); + + if (Common.IS_WINDOWS) + m_pathSeparator = "\\"; + + SetCurrentDirectory(Common.GetUserHomeDir()); + } + + private void SetCurrentDirectory(string dir) + { + // replace all instances of the path separator with correct one + if (Common.IS_WINDOWS) + m_currentDirectory = dir.Replace("/", "\\"); + else + m_currentDirectory = dir; + + + //if (m_currentDirectory.EndsWith(m_pathSeparator)) + // m_currentDirectory = m_currentDirectory.Substring(0, m_currentDirectory.Length - 1); + + DisplayDirectory(); } public string GetFile(string sHintDir, string sHintFile) @@ -55,7 +72,7 @@ namespace Novell.CASA.GUI if (sHintDir != null) { if (Directory.Exists(sHintDir)) - m_currentDirectory = sHintDir; + SetCurrentDirectory(sHintDir); } if (sHintFile != null) @@ -63,28 +80,8 @@ namespace Novell.CASA.GUI m_hintFile = sHintFile; } - - if (true) - { - DoWork(); - } - else - { - //start a FileChooser Thread, and suspend this one until a file is selected or user cancels - tChooserThread = new Thread(new ThreadStart(DoWork)); - tChooserThread.Start(); - - // wait for it to start - while (!tChooserThread.IsAlive); - - // allow filechooser to run - Thread.Sleep(1); - - // wait for FileChooserThread to complete - tChooserThread.Join(); - } - - return m_currentDirectory + m_sFileSelected; + DoWork(); + return m_currentDirectory + m_pathSeparator + m_sFileSelected; } @@ -110,7 +107,7 @@ namespace Novell.CASA.GUI if (sHintDir != null) { if (Directory.Exists(sHintDir)) - m_currentDirectory = sHintDir; + SetCurrentDirectory(sHintDir); } if (sHintFile != null) @@ -136,18 +133,21 @@ namespace Novell.CASA.GUI treeviewFavorites.AppendColumn("Drive", new CellRendererText(), "text", 0); treeviewFavorites.Model = tsDrives; - treeviewFavorites.RowActivated += new RowActivatedHandler(treeviewFavorites_RowActivated); - + treeviewFavorites.RowActivated += new RowActivatedHandler(treeviewFavorites_RowActivated); // FILE LISTING // hook up the model - treeviewListing.AppendColumn("Name",new CellRendererText(),"text",0); - treeviewListing.AppendColumn("Date Modified",new CellRendererText(),"text",1); + TreeViewColumn col1 = new TreeViewColumn("", new Gtk.CellRendererPixbuf(), "pixbuf", 0); + treeviewListing.AppendColumn(col1); + treeviewListing.AppendColumn("Name",new CellRendererText(),"text",1); + treeviewListing.AppendColumn("Size",new CellRendererText(),"text",2); + treeviewListing.AppendColumn("Date Modified",new CellRendererText(),"text",3); treeviewListing.Model = ts; // hook up the events treeviewListing.RowActivated +=new RowActivatedHandler(treeviewListing_RowActivated); + DisplayDirectory(); DisplayFileListing(); if (m_hintFile != null) @@ -161,27 +161,36 @@ namespace Novell.CASA.GUI private void DisplayDirectory() { - entryCurrentDir.Text = m_currentDirectory; + if (entryCurrentDir != null) + entryCurrentDir.Text = m_currentDirectory; } private void DisplayFileListing() { - DisplayDirectory(); - + ts.Clear(); + // add in the dirs and files DirectoryInfo dirInfo = new DirectoryInfo(m_currentDirectory); DirectoryInfo[] dirs = dirInfo.GetDirectories(); + for (int i=0; i 1) + { + // if windows drive letter, keep the slash + if ((Common.IS_WINDOWS) && (iSlashIndex == 2)) + SetCurrentDirectory(m_currentDirectory.Substring(0, iSlashIndex + 1)); + else + SetCurrentDirectory(m_currentDirectory.Substring(0, iSlashIndex)); + + DisplayFileListing(); + } } private void imageUp_ButtonPressEvent(object o, ButtonPressEventArgs args) { - + } } } diff --git a/CASA/gui/MiCasa.cs b/CASA/gui/MiCasa.cs index e4a51b2d..645b786f 100644 --- a/CASA/gui/MiCasa.cs +++ b/CASA/gui/MiCasa.cs @@ -520,10 +520,10 @@ public class MiCasa : Store label88.Hide(); entryMasterPassword4.Hide(); - //labelRememberFor.Visible = true; - //labelSeconds.Visible = true; - //spinbuttonRememberFor.Visible = true; - //spinbuttonRememberFor.Text = m_sRememberFor; + labelRememberFor.Visible = true; + labelSeconds.Visible = true; + spinbuttonRememberFor.Visible = true; + spinbuttonRememberFor.Text = m_sRememberFor; dialogLogin.Show(); } @@ -549,7 +549,7 @@ public class MiCasa : Store tvKeyValue.InsertColumn(tvCol, 1); // get seconds to remember - /* + m_sRememberFor = spinbuttonRememberFor.Text; if (m_sRememberFor != null) { @@ -557,11 +557,11 @@ public class MiCasa : Store m_iRememberSeconds = int.Parse(m_sRememberFor); m_dtRememberMPUntil = dtNow.AddSeconds(m_iRememberSeconds); } - */ + dialogLogin.Destroy(); - //if (m_iRememberSeconds > 0) - // StartRememberTimer(); + if (m_iRememberSeconds > 0) + StartRememberTimer(); } else { @@ -594,7 +594,8 @@ public class MiCasa : Store public void StartRememberTimer() { - //if (m_tRememberTimer == null) + // NOTE: USE A TIMER RATHER THAN A THREAD + if (m_tRememberTimer == null) { m_tRememberTimer = new Thread(new ThreadStart(ResetTimerThreadFn)); m_tRememberTimer.Start(); diff --git a/CASA/gui/images/folder.png b/CASA/gui/images/folder.png new file mode 100644 index 0000000000000000000000000000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