Skip to content

Commit

Permalink
RAD-314: "Backup" option for single folders in inventory
Browse files Browse the repository at this point in the history
git-svn-id: https://radegast.googlecode.com/svn/trunk@1270 f7a694da-4d33-11de-9ad6-1127a62b9fcd
  • Loading branch information
lkalif committed Apr 20, 2012
1 parent 3eeb1db commit 7c7d764
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
13 changes: 10 additions & 3 deletions Radegast/GUI/Consoles/Inventory/InventoryBackup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,19 @@ public partial class InventoryBackup : Form
private int fetched = 0;
private TextWriter csvFile = null;
private int traversed = 0;
private InventoryNode rootNode;

public InventoryBackup(RadegastInstance instance)
public InventoryBackup(RadegastInstance instance, UUID rootFolder)
{
InitializeComponent();
Disposed += new System.EventHandler(InventoryBackup_Disposed);
this.instance = instance;
inv = client.Inventory.Store;
rootNode = inv.RootNode;
if (inv.Items.ContainsKey(rootFolder) && inv.Items[rootFolder].Data is InventoryFolder)
{
rootNode = inv.GetNodeFor(rootFolder);
}
}

void InventoryBackup_Disposed(object sender, System.EventArgs e)
Expand Down Expand Up @@ -123,7 +129,7 @@ private void btnFolder_Click(object sender, System.EventArgs e)

backupThread = new Thread(new ThreadStart(() =>
{
TraverseDir(inv.RootNode, Path.DirectorySeparatorChar.ToString());
TraverseDir(rootNode, Path.DirectorySeparatorChar.ToString());
if (csvFile != null)
{
try
Expand Down Expand Up @@ -153,7 +159,8 @@ private void btnFolder_Click(object sender, System.EventArgs e)

private void TraverseDir(InventoryNode node, string path)
{
foreach (InventoryNode n in node.Nodes.Values)
var nodes = new List<InventoryNode>(node.Nodes.Values);
foreach (InventoryNode n in nodes)
{
traversed++;
if (IsHandleCreated && (traversed % 13 == 0))
Expand Down
10 changes: 9 additions & 1 deletion Radegast/GUI/Consoles/Inventory/InventoryConsole.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1339,6 +1339,10 @@ private void ctxInv_Opening(object sender, CancelEventArgs e)
ctxItem.Name = "refresh";
ctxInv.Items.Add(ctxItem);

ctxItem = new ToolStripMenuItem("Backup...", null, OnInvContextClick);
ctxItem.Name = "backup";
ctxInv.Items.Add(ctxItem);

ctxInv.Items.Add(new ToolStripSeparator());

ctxItem = new ToolStripMenuItem("Expand", null, OnInvContextClick);
Expand Down Expand Up @@ -1648,6 +1652,10 @@ private void OnInvContextClick(object sender, EventArgs e)
fetchFolder(f.UUID, f.OwnerID, true);
break;

case "backup":
(new InventoryBackup(instance, f.UUID)).Show();
break;

case "expand":
invTree.SelectedNode.Expand();
break;
Expand Down Expand Up @@ -2275,7 +2283,7 @@ private void invTree_DragOver(object sender, DragEventArgs e)

private void saveAllTToolStripMenuItem_Click(object sender, EventArgs e)
{
(new InventoryBackup(instance)).Show();
(new InventoryBackup(instance, Inventory.RootFolder.UUID)).Show();
}

private void tbtnSystemFoldersFirst_Click(object sender, EventArgs e)
Expand Down

0 comments on commit 7c7d764

Please sign in to comment.