import/export changes

This commit is contained in:
Jim Norman 2006-08-21 16:55:51 +00:00
parent 52e89dd71a
commit 8a5d4808b9
5 changed files with 102 additions and 67 deletions

View File

@ -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

View File

@ -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;
}

View File

@ -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<dirs.Length; i++)
{
ts.AppendValues(dirs[i].Name, "Folder");
{
ts.AppendValues(new Gdk.Pixbuf (Common.IMAGE_PATH + "folder.png", 16, 16), dirs[i].Name, "", "File folder");
}
FileInfo[] files = dirInfo.GetFiles();
for (int i=0; i<files.Length; i++)
{
ts.AppendValues(files[i].Name, files[i].LastWriteTime.ToShortDateString() + " " + files[i].LastWriteTime.ToShortTimeString());
{
ts.AppendValues(new Gdk.Pixbuf (Common.IMAGE_PATH + "CASA_16.png"), files[i].Name, (files[i].Length/1000).ToString() + " KB", files[i].LastWriteTime.ToShortDateString() + " " + files[i].LastWriteTime.ToShortTimeString());
}
}
private int GetItemCount(string sDir)
{
DirectoryInfo dirInfo = new DirectoryInfo(sDir);
DirectoryInfo[] dirs = dirInfo.GetDirectories();
FileInfo[] files = dirInfo.GetFiles();
return dirs.Length + files.Length;
}
private void treeviewListing_RowActivated(object o, RowActivatedArgs args)
@ -190,19 +199,20 @@ namespace Novell.CASA.GUI
TreeIter iter;
string selected;
// trim any trailing \
if (m_currentDirectory.EndsWith("\\"))
m_currentDirectory = m_currentDirectory.Substring(0, m_currentDirectory.Length - 1);
try
{
if( treeviewListing.Selection.GetSelected (out model, out iter) )
{
selected = (string) model.GetValue(iter, 0);
if (selected.Equals(".."))
selected = (string) model.GetValue(iter, 1);
if (Directory.Exists(m_currentDirectory + "/" + selected))
{
// backup one directory
m_currentDirectory = m_currentDirectory.Substring(0, m_currentDirectory.LastIndexOf("/"));
}
else if (Directory.Exists(m_currentDirectory + "/" + selected))
{
m_currentDirectory = m_currentDirectory + "/" + selected;
SetCurrentDirectory(m_currentDirectory + "/" + selected);
// clear current view
ts.Clear();
@ -238,8 +248,7 @@ namespace Novell.CASA.GUI
if( treeviewFavorites.Selection.GetSelected (out model, out iter) )
{
selected = (string)model.GetValue(iter, 0);
m_currentDirectory = selected;
ts.Clear();
SetCurrentDirectory(selected);
DisplayFileListing();
}
}
@ -266,12 +275,23 @@ namespace Novell.CASA.GUI
public void on_buttonUP_clicked(object o, EventArgs args)
{
Console.WriteLine("Button clicked");
int iSlashIndex = m_currentDirectory.LastIndexOf(m_pathSeparator);
// back up one directory
if (iSlashIndex > 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)
{
}
}
}

View File

@ -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();

BIN
CASA/gui/images/folder.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB