event log: report size and history size. Closes #379
This commit is contained in:
parent
3f70f08084
commit
a4d1e5d120
|
@ -59,6 +59,24 @@ namespace SparkleLib {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public override double Size {
|
||||||
|
get {
|
||||||
|
return CalculateSize (
|
||||||
|
new DirectoryInfo (LocalPath)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public override double HistorySize {
|
||||||
|
get {
|
||||||
|
return CalculateSize (
|
||||||
|
new DirectoryInfo (Path.Combine (LocalPath, ".git"))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public override string [] UnsyncedFilePaths {
|
public override string [] UnsyncedFilePaths {
|
||||||
get {
|
get {
|
||||||
List<string> file_paths = new List<string> ();
|
List<string> file_paths = new List<string> ();
|
||||||
|
@ -638,5 +656,38 @@ namespace SparkleLib {
|
||||||
base.CreateInitialChangeSet ();
|
base.CreateInitialChangeSet ();
|
||||||
SyncUp ();
|
SyncUp ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Recursively gets a folder's size in bytes
|
||||||
|
public override double CalculateSize (DirectoryInfo parent)
|
||||||
|
{
|
||||||
|
if (!Directory.Exists (parent.ToString ()))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
double size = 0;
|
||||||
|
|
||||||
|
// Ignore the temporary 'rebase-apply' and '.tmp' directories. This prevents potential
|
||||||
|
// crashes when files are being queried whilst the files have already been deleted.
|
||||||
|
if (parent.Name.Equals ("rebase-apply") ||
|
||||||
|
parent.Name.Equals (".tmp"))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
try {
|
||||||
|
foreach (FileInfo file in parent.GetFiles()) {
|
||||||
|
if (!file.Exists)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
size += file.Length;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (DirectoryInfo directory in parent.GetDirectories ())
|
||||||
|
size += CalculateSize (directory);
|
||||||
|
|
||||||
|
} catch (Exception) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return size;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,8 +64,12 @@ namespace SparkleLib {
|
||||||
public abstract string CurrentRevision { get; }
|
public abstract string CurrentRevision { get; }
|
||||||
public abstract bool SyncUp ();
|
public abstract bool SyncUp ();
|
||||||
public abstract bool SyncDown ();
|
public abstract bool SyncDown ();
|
||||||
|
public abstract double CalculateSize (DirectoryInfo parent);
|
||||||
public abstract bool HasUnsyncedChanges { get; set; }
|
public abstract bool HasUnsyncedChanges { get; set; }
|
||||||
|
|
||||||
|
public abstract double Size { get; }
|
||||||
|
public abstract double HistorySize { get; }
|
||||||
|
|
||||||
public delegate void SyncStatusChangedEventHandler (SyncStatus new_status);
|
public delegate void SyncStatusChangedEventHandler (SyncStatus new_status);
|
||||||
public event SyncStatusChangedEventHandler SyncStatusChanged;
|
public event SyncStatusChangedEventHandler SyncStatusChanged;
|
||||||
|
|
||||||
|
@ -309,7 +313,7 @@ namespace SparkleLib {
|
||||||
this.sizebuffer.RemoveAt (0);
|
this.sizebuffer.RemoveAt (0);
|
||||||
|
|
||||||
DirectoryInfo dir_info = new DirectoryInfo (LocalPath);
|
DirectoryInfo dir_info = new DirectoryInfo (LocalPath);
|
||||||
this.sizebuffer.Add (CalculateFolderSize (dir_info));
|
this.sizebuffer.Add (CalculateSize (dir_info));
|
||||||
|
|
||||||
if (this.sizebuffer.Count >= 4 &&
|
if (this.sizebuffer.Count >= 4 &&
|
||||||
this.sizebuffer [0].Equals (this.sizebuffer [1]) &&
|
this.sizebuffer [0].Equals (this.sizebuffer [1]) &&
|
||||||
|
@ -588,33 +592,6 @@ namespace SparkleLib {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Recursively gets a folder's size in bytes
|
|
||||||
private double CalculateFolderSize (DirectoryInfo parent)
|
|
||||||
{
|
|
||||||
if (!System.IO.Directory.Exists (parent.ToString ()))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
double size = 0;
|
|
||||||
|
|
||||||
// Ignore the temporary 'rebase-apply' directory. This prevents potential
|
|
||||||
// crashes when files are being queried whilst the files have already been deleted.
|
|
||||||
if (parent.Name.Equals ("rebase-apply"))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
foreach (FileInfo file in parent.GetFiles ()) {
|
|
||||||
if (!file.Exists)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
size += file.Length;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (DirectoryInfo directory in parent.GetDirectories())
|
|
||||||
size += CalculateFolderSize (directory);
|
|
||||||
|
|
||||||
return size;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Creates a SHA-1 hash of input
|
// Creates a SHA-1 hash of input
|
||||||
private string SHA1 (string s)
|
private string SHA1 (string s)
|
||||||
{
|
{
|
||||||
|
|
|
@ -35,14 +35,17 @@ namespace SparkleShare {
|
||||||
PolicyDelegate = new SparkleWebPolicyDelegate ()
|
PolicyDelegate = new SparkleWebPolicyDelegate ()
|
||||||
};
|
};
|
||||||
|
|
||||||
private NSBox Separator = new NSBox (new RectangleF (0, 579, 480, 1)) {
|
private NSBox separator = new NSBox (new RectangleF (0, 579, 480, 1)) {
|
||||||
BorderColor = NSColor.LightGray,
|
BorderColor = NSColor.LightGray,
|
||||||
BoxType = NSBoxType.NSBoxCustom
|
BoxType = NSBoxType.NSBoxCustom
|
||||||
};
|
};
|
||||||
|
|
||||||
private NSPopUpButton popup_button;
|
private NSPopUpButton popup_button;
|
||||||
private NSProgressIndicator progress_indicator;
|
private NSProgressIndicator progress_indicator;
|
||||||
|
private NSTextField size_label;
|
||||||
|
private NSTextField size_label_value;
|
||||||
|
private NSTextField history_label;
|
||||||
|
private NSTextField history_label_value;
|
||||||
|
|
||||||
public SparkleEventLog (IntPtr handle) : base (handle) { }
|
public SparkleEventLog (IntPtr handle) : base (handle) { }
|
||||||
|
|
||||||
|
@ -64,7 +67,54 @@ namespace SparkleShare {
|
||||||
HasShadow = true;
|
HasShadow = true;
|
||||||
BackingType = NSBackingStore.Buffered;
|
BackingType = NSBackingStore.Buffered;
|
||||||
|
|
||||||
ContentView.AddSubview (Separator);
|
|
||||||
|
this.size_label = new NSTextField () {
|
||||||
|
Alignment = NSTextAlignment.Right,
|
||||||
|
BackgroundColor = NSColor.WindowBackground,
|
||||||
|
Bordered = false,
|
||||||
|
Editable = false,
|
||||||
|
Frame = new RectangleF (0, 588, 60, 20),
|
||||||
|
StringValue = "Size:",
|
||||||
|
Font = SparkleUI.BoldFont
|
||||||
|
};
|
||||||
|
|
||||||
|
this.size_label_value = new NSTextField () {
|
||||||
|
Alignment = NSTextAlignment.Left,
|
||||||
|
BackgroundColor = NSColor.WindowBackground,
|
||||||
|
Bordered = false,
|
||||||
|
Editable = false,
|
||||||
|
Frame = new RectangleF (60, 588, 75, 20),
|
||||||
|
StringValue = Controller.Size,
|
||||||
|
Font = SparkleUI.Font
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
this.history_label = new NSTextField () {
|
||||||
|
Alignment = NSTextAlignment.Right,
|
||||||
|
BackgroundColor = NSColor.WindowBackground,
|
||||||
|
Bordered = false,
|
||||||
|
Editable = false,
|
||||||
|
Frame = new RectangleF (130, 588, 60, 20),
|
||||||
|
StringValue = "History:",
|
||||||
|
Font = SparkleUI.BoldFont
|
||||||
|
};
|
||||||
|
|
||||||
|
this.history_label_value = new NSTextField () {
|
||||||
|
Alignment = NSTextAlignment.Left,
|
||||||
|
BackgroundColor = NSColor.WindowBackground,
|
||||||
|
Bordered = false,
|
||||||
|
Editable = false,
|
||||||
|
Frame = new RectangleF (190, 588, 75, 20),
|
||||||
|
StringValue = Controller.HistorySize,
|
||||||
|
Font = SparkleUI.Font
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
ContentView.AddSubview (this.size_label);
|
||||||
|
ContentView.AddSubview (this.size_label_value);
|
||||||
|
ContentView.AddSubview (this.history_label);
|
||||||
|
ContentView.AddSubview (this.history_label_value);
|
||||||
|
ContentView.AddSubview (this.separator);
|
||||||
|
|
||||||
|
|
||||||
this.progress_indicator = new NSProgressIndicator () {
|
this.progress_indicator = new NSProgressIndicator () {
|
||||||
|
@ -102,6 +152,14 @@ namespace SparkleShare {
|
||||||
ContentView.AddSubview (this.progress_indicator);
|
ContentView.AddSubview (this.progress_indicator);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Controller.UpdateSizeInfoEvent += delegate (string size, string history_size) {
|
||||||
|
InvokeOnMainThread (delegate {
|
||||||
|
Console.WriteLine (size + " " + history_size);
|
||||||
|
this.size_label_value.StringValue = size;
|
||||||
|
this.history_label_value.StringValue = history_size;
|
||||||
|
});
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -122,7 +180,7 @@ namespace SparkleShare {
|
||||||
this.popup_button.Font = NSFontManager.SharedFontManager.FontWithFamily
|
this.popup_button.Font = NSFontManager.SharedFontManager.FontWithFamily
|
||||||
("Lucida Grande", NSFontTraitMask.Condensed, 0, NSFont.SmallSystemFontSize);
|
("Lucida Grande", NSFontTraitMask.Condensed, 0, NSFont.SmallSystemFontSize);
|
||||||
|
|
||||||
this.popup_button.AddItem ("All Folders");
|
this.popup_button.AddItem ("All Projects");
|
||||||
this.popup_button.Menu.AddItem (NSMenuItem.SeparatorItem);
|
this.popup_button.Menu.AddItem (NSMenuItem.SeparatorItem);
|
||||||
this.popup_button.AddItems (folders);
|
this.popup_button.AddItems (folders);
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,7 @@ namespace SparkleShare {
|
||||||
public static SparkleBubbles Bubbles;
|
public static SparkleBubbles Bubbles;
|
||||||
public static SparkleAbout About;
|
public static SparkleAbout About;
|
||||||
public static NSFont Font;
|
public static NSFont Font;
|
||||||
|
public static NSFont BoldFont;
|
||||||
|
|
||||||
|
|
||||||
public SparkleUI ()
|
public SparkleUI ()
|
||||||
|
@ -59,6 +60,9 @@ namespace SparkleShare {
|
||||||
Font = NSFontManager.SharedFontManager.FontWithFamily
|
Font = NSFontManager.SharedFontManager.FontWithFamily
|
||||||
("Lucida Grande", NSFontTraitMask.Condensed, 0, 13);
|
("Lucida Grande", NSFontTraitMask.Condensed, 0, 13);
|
||||||
|
|
||||||
|
BoldFont = NSFontManager.SharedFontManager.FontWithFamily
|
||||||
|
("Lucida Grande", NSFontTraitMask.Bold, 0, 13);
|
||||||
|
|
||||||
StatusIcon = new SparkleStatusIcon ();
|
StatusIcon = new SparkleStatusIcon ();
|
||||||
Bubbles = new SparkleBubbles ();
|
Bubbles = new SparkleBubbles ();
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,6 @@ namespace SparkleShare {
|
||||||
public abstract class SparkleControllerBase {
|
public abstract class SparkleControllerBase {
|
||||||
|
|
||||||
public List <SparkleRepoBase> Repositories;
|
public List <SparkleRepoBase> Repositories;
|
||||||
public string FolderSize;
|
|
||||||
public readonly string SparklePath = SparkleConfig.DefaultConfig.FoldersPath;
|
public readonly string SparklePath = SparkleConfig.DefaultConfig.FoldersPath;
|
||||||
|
|
||||||
public event OnQuitWhileSyncingHandler OnQuitWhileSyncing;
|
public event OnQuitWhileSyncingHandler OnQuitWhileSyncing;
|
||||||
|
@ -53,9 +52,6 @@ namespace SparkleShare {
|
||||||
public event FolderListChangedHandler FolderListChanged;
|
public event FolderListChangedHandler FolderListChanged;
|
||||||
public delegate void FolderListChangedHandler ();
|
public delegate void FolderListChangedHandler ();
|
||||||
|
|
||||||
public event FolderSizeChangedHandler FolderSizeChanged;
|
|
||||||
public delegate void FolderSizeChangedHandler (string folder_size);
|
|
||||||
|
|
||||||
public event AvatarFetchedHandler AvatarFetched;
|
public event AvatarFetchedHandler AvatarFetched;
|
||||||
public delegate void AvatarFetchedHandler ();
|
public delegate void AvatarFetchedHandler ();
|
||||||
|
|
||||||
|
@ -109,8 +105,6 @@ namespace SparkleShare {
|
||||||
if (CreateSparkleShareFolder ())
|
if (CreateSparkleShareFolder ())
|
||||||
AddToBookmarks ();
|
AddToBookmarks ();
|
||||||
|
|
||||||
FolderSize = GetFolderSize ();
|
|
||||||
|
|
||||||
if (FirstRun)
|
if (FirstRun)
|
||||||
SparkleConfig.DefaultConfig.SetConfigOption ("notifications", bool.TrueString);
|
SparkleConfig.DefaultConfig.SetConfigOption ("notifications", bool.TrueString);
|
||||||
else
|
else
|
||||||
|
@ -130,11 +124,6 @@ namespace SparkleShare {
|
||||||
|
|
||||||
if (FolderListChanged != null)
|
if (FolderListChanged != null)
|
||||||
FolderListChanged ();
|
FolderListChanged ();
|
||||||
|
|
||||||
FolderSize = GetFolderSize ();
|
|
||||||
|
|
||||||
if (FolderSizeChanged != null)
|
|
||||||
FolderSizeChanged (FolderSize);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -163,8 +152,8 @@ namespace SparkleShare {
|
||||||
public bool AcceptInvitation (string server, string folder, string token)
|
public bool AcceptInvitation (string server, string folder, string token)
|
||||||
{
|
{
|
||||||
// The location of the user's public key for SparkleShare
|
// The location of the user's public key for SparkleShare
|
||||||
string public_key_file_path = SparkleHelpers.CombineMore (SparkleConfig.DefaultConfig.HomePath, ".ssh",
|
string public_key_file_path = SparkleHelpers.CombineMore (SparkleConfig.DefaultConfig.HomePath,
|
||||||
"sparkleshare." + UserEmail + ".key.pub");
|
".ssh", "sparkleshare." + UserEmail + ".key.pub");
|
||||||
|
|
||||||
if (!File.Exists (public_key_file_path))
|
if (!File.Exists (public_key_file_path))
|
||||||
return false;
|
return false;
|
||||||
|
@ -561,11 +550,6 @@ namespace SparkleShare {
|
||||||
} else {
|
} else {
|
||||||
if (OnIdle != null)
|
if (OnIdle != null)
|
||||||
OnIdle ();
|
OnIdle ();
|
||||||
|
|
||||||
FolderSize = GetFolderSize ();
|
|
||||||
|
|
||||||
if (FolderSizeChanged != null)
|
|
||||||
FolderSizeChanged (FolderSize);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -660,11 +644,6 @@ namespace SparkleShare {
|
||||||
|
|
||||||
if (FolderListChanged != null)
|
if (FolderListChanged != null)
|
||||||
FolderListChanged ();
|
FolderListChanged ();
|
||||||
|
|
||||||
FolderSize = GetFolderSize ();
|
|
||||||
|
|
||||||
if (FolderSizeChanged != null)
|
|
||||||
FolderSizeChanged (FolderSize);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -696,51 +675,37 @@ namespace SparkleShare {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private string GetFolderSize ()
|
public string GetSize (string folder_name)
|
||||||
{
|
{
|
||||||
double folder_size = CalculateFolderSize (
|
double folder_size = 0;
|
||||||
new DirectoryInfo (SparkleConfig.DefaultConfig.FoldersPath));
|
/* TODO
|
||||||
|
foreach (SparkleRepoBase repo in
|
||||||
|
Repositories.GetRange (0, Repositories.Count)) {
|
||||||
|
|
||||||
|
folder_size += repo.Size + repo.HistorySize;
|
||||||
|
}
|
||||||
|
*/
|
||||||
return FormatFolderSize (folder_size);
|
return FormatFolderSize (folder_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Recursively gets a folder's size in bytes
|
public string GetHistorySize (string folder_name)
|
||||||
private double CalculateFolderSize (DirectoryInfo parent)
|
|
||||||
{
|
{
|
||||||
if (!Directory.Exists (parent.ToString ()))
|
double folder_size = 0;
|
||||||
return 0;
|
/* TODO
|
||||||
|
foreach (SparkleRepoBase repo in
|
||||||
|
Repositories.GetRange (0, Repositories.Count)) {
|
||||||
|
|
||||||
double size = 0;
|
folder_size += repo.Size + repo.HistorySize;
|
||||||
|
|
||||||
// Ignore the temporary 'rebase-apply' and '.tmp' directories. This prevents potential
|
|
||||||
// crashes when files are being queried whilst the files have already been deleted.
|
|
||||||
if (parent.Name.Equals ("rebase-apply") ||
|
|
||||||
parent.Name.Equals (".tmp"))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
try {
|
|
||||||
foreach (FileInfo file in parent.GetFiles()) {
|
|
||||||
if (!file.Exists)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
size += file.Length;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (DirectoryInfo directory in parent.GetDirectories())
|
|
||||||
size += CalculateFolderSize (directory);
|
|
||||||
|
|
||||||
} catch (Exception) {
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
return size;
|
return FormatFolderSize (folder_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Format a file size nicely with small caps.
|
// Format a file size nicely with small caps.
|
||||||
// Example: 1048576 becomes "1 ᴍʙ"
|
// Example: 1048576 becomes "1 ᴍʙ"
|
||||||
private string FormatFolderSize (double byte_count)
|
public string FormatFolderSize (double byte_count)
|
||||||
{
|
{
|
||||||
if (byte_count >= 1099511627776)
|
if (byte_count >= 1099511627776)
|
||||||
return String.Format ("{0:##.##} ᴛʙ", Math.Round (byte_count / 1099511627776, 1));
|
return String.Format ("{0:##.##} ᴛʙ", Math.Round (byte_count / 1099511627776, 1));
|
||||||
|
@ -1037,11 +1002,6 @@ namespace SparkleShare {
|
||||||
if (FolderFetched != null)
|
if (FolderFetched != null)
|
||||||
FolderFetched (warnings);
|
FolderFetched (warnings);
|
||||||
|
|
||||||
FolderSize = GetFolderSize ();
|
|
||||||
|
|
||||||
if (FolderSizeChanged != null)
|
|
||||||
FolderSizeChanged (FolderSize);
|
|
||||||
|
|
||||||
if (FolderListChanged != null)
|
if (FolderListChanged != null)
|
||||||
FolderListChanged ();
|
FolderListChanged ();
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@ namespace SparkleShare {
|
||||||
|
|
||||||
public SparkleEventLogController Controller = new SparkleEventLogController ();
|
public SparkleEventLogController Controller = new SparkleEventLogController ();
|
||||||
|
|
||||||
|
private Label size_label;
|
||||||
private HBox layout_horizontal;
|
private HBox layout_horizontal;
|
||||||
private ComboBox combo_box;
|
private ComboBox combo_box;
|
||||||
private EventBox content_wrapper;
|
private EventBox content_wrapper;
|
||||||
|
@ -58,6 +59,11 @@ namespace SparkleShare {
|
||||||
|
|
||||||
DeleteEvent += Close;
|
DeleteEvent += Close;
|
||||||
|
|
||||||
|
this.size_label = new Label () {
|
||||||
|
Markup = "<b>Size:</b> " + Controller.Size + " " +
|
||||||
|
"<b>History:</b> " + Controller.HistorySize;
|
||||||
|
};
|
||||||
|
|
||||||
VBox layout_vertical = new VBox (false, 0);
|
VBox layout_vertical = new VBox (false, 0);
|
||||||
this.spinner = new SparkleSpinner (22);
|
this.spinner = new SparkleSpinner (22);
|
||||||
this.content_wrapper = new EventBox ();
|
this.content_wrapper = new EventBox ();
|
||||||
|
@ -86,7 +92,7 @@ namespace SparkleShare {
|
||||||
this.spinner.Start ();
|
this.spinner.Start ();
|
||||||
|
|
||||||
this.layout_horizontal = new HBox (true, 0);
|
this.layout_horizontal = new HBox (true, 0);
|
||||||
this.layout_horizontal.PackStart (new Label (""), true, true, 0);
|
this.layout_horizontal.PackStart (this.size_label, true, true, 0);
|
||||||
this.layout_horizontal.PackStart (new Label (""), true, true, 0);
|
this.layout_horizontal.PackStart (new Label (""), true, true, 0);
|
||||||
|
|
||||||
layout_vertical.PackStart (this.layout_horizontal, false, false, 0);
|
layout_vertical.PackStart (this.layout_horizontal, false, false, 0);
|
||||||
|
@ -123,6 +129,13 @@ namespace SparkleShare {
|
||||||
this.content_wrapper.ShowAll ();
|
this.content_wrapper.ShowAll ();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Controller.UpdateSizeInfoEvent += delegate (string size, string history_size) {
|
||||||
|
Application.Invoke (delegate {
|
||||||
|
Markup = "<b>Size:</b> " + size + " " +
|
||||||
|
"<b>History:</b> " + history_size;
|
||||||
|
});
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -142,7 +155,7 @@ namespace SparkleShare {
|
||||||
|
|
||||||
ListStore store = new ListStore (typeof (string));
|
ListStore store = new ListStore (typeof (string));
|
||||||
|
|
||||||
store.AppendValues (_("All Folders"));
|
store.AppendValues (_("All Projects"));
|
||||||
store.AppendValues ("---");
|
store.AppendValues ("---");
|
||||||
|
|
||||||
foreach (string folder in folders)
|
foreach (string folder in folders)
|
||||||
|
|
|
@ -34,9 +34,14 @@ namespace SparkleShare {
|
||||||
public event UpdateChooserEventHandler UpdateChooserEvent;
|
public event UpdateChooserEventHandler UpdateChooserEvent;
|
||||||
public delegate void UpdateChooserEventHandler (string [] folders);
|
public delegate void UpdateChooserEventHandler (string [] folders);
|
||||||
|
|
||||||
|
public event UpdateSizeInfoEventHandler UpdateSizeInfoEvent;
|
||||||
|
public delegate void UpdateSizeInfoEventHandler (string size, string history_size);
|
||||||
|
|
||||||
public event ContentLoadingEventHandler ContentLoadingEvent;
|
public event ContentLoadingEventHandler ContentLoadingEvent;
|
||||||
public delegate void ContentLoadingEventHandler ();
|
public delegate void ContentLoadingEventHandler ();
|
||||||
|
|
||||||
|
private string selected_folder;
|
||||||
|
|
||||||
|
|
||||||
public string SelectedFolder {
|
public string SelectedFolder {
|
||||||
get {
|
get {
|
||||||
|
@ -63,6 +68,9 @@ namespace SparkleShare {
|
||||||
|
|
||||||
if (UpdateContentEvent != null)
|
if (UpdateContentEvent != null)
|
||||||
UpdateContentEvent (html);
|
UpdateContentEvent (html);
|
||||||
|
|
||||||
|
if (UpdateSizeInfoEvent != null)
|
||||||
|
UpdateSizeInfoEvent (Size, HistorySize);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
thread.Start ();
|
thread.Start ();
|
||||||
|
@ -82,8 +90,35 @@ namespace SparkleShare {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string Size {
|
||||||
|
get {
|
||||||
|
double size = 0;
|
||||||
|
|
||||||
private string selected_folder;
|
foreach (SparkleRepoBase repo in Program.Controller.Repositories) {
|
||||||
|
if (this.selected_folder == null)
|
||||||
|
size += repo.Size;
|
||||||
|
else if (this.selected_folder.Equals (repo.Name))
|
||||||
|
return Program.Controller.FormatFolderSize (repo.Size);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Program.Controller.FormatSize (size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string HistorySize {
|
||||||
|
get {
|
||||||
|
double size = 0;
|
||||||
|
|
||||||
|
foreach (SparkleRepoBase repo in Program.Controller.Repositories) {
|
||||||
|
if (this.selected_folder == null)
|
||||||
|
size += repo.HistorySize;
|
||||||
|
else if (this.selected_folder.Equals (repo.Name))
|
||||||
|
return Program.Controller.FormatFolderSize (repo.HistorySize);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Program.Controller.FormatSize (size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public SparkleEventLogController ()
|
public SparkleEventLogController ()
|
||||||
|
@ -96,6 +131,9 @@ namespace SparkleShare {
|
||||||
Program.Controller.OnIdle += delegate {
|
Program.Controller.OnIdle += delegate {
|
||||||
if (UpdateContentEvent != null)
|
if (UpdateContentEvent != null)
|
||||||
UpdateContentEvent (HTML);
|
UpdateContentEvent (HTML);
|
||||||
|
|
||||||
|
if (UpdateSizeInfoEvent != null)
|
||||||
|
UpdateSizeInfoEvent (Size, HistorySize);
|
||||||
};
|
};
|
||||||
|
|
||||||
Program.Controller.FolderListChanged += delegate {
|
Program.Controller.FolderListChanged += delegate {
|
||||||
|
@ -110,11 +148,9 @@ namespace SparkleShare {
|
||||||
|
|
||||||
if (UpdateContentEvent != null)
|
if (UpdateContentEvent != null)
|
||||||
UpdateContentEvent (HTML);
|
UpdateContentEvent (HTML);
|
||||||
};
|
|
||||||
|
|
||||||
Program.Controller.NotificationRaised += delegate {
|
if (UpdateSizeInfoEvent != null)
|
||||||
if (UpdateContentEvent != null)
|
UpdateSizeInfoEvent (Size, HistorySize);
|
||||||
UpdateContentEvent (HTML);
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,8 @@
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
|
||||||
|
using SparkleLib;
|
||||||
|
|
||||||
namespace SparkleShare {
|
namespace SparkleShare {
|
||||||
|
|
||||||
public enum IconState {
|
public enum IconState {
|
||||||
|
@ -46,17 +48,18 @@ namespace SparkleShare {
|
||||||
|
|
||||||
public string FolderSize {
|
public string FolderSize {
|
||||||
get {
|
get {
|
||||||
return Program.Controller.FolderSize;
|
double size = 0;
|
||||||
|
|
||||||
|
foreach (SparkleRepoBase repo in Program.Controller.Repositories)
|
||||||
|
size += repo.Size + repo.HistorySize;
|
||||||
|
|
||||||
|
return Program.Controller.FormatSize (size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public SparkleStatusIconController ()
|
public SparkleStatusIconController ()
|
||||||
{
|
{
|
||||||
Program.Controller.FolderSizeChanged += delegate {
|
|
||||||
if (UpdateMenuEvent != null)
|
|
||||||
UpdateMenuEvent (CurrentState);
|
|
||||||
};
|
|
||||||
|
|
||||||
Program.Controller.FolderListChanged += delegate {
|
Program.Controller.FolderListChanged += delegate {
|
||||||
if (UpdateMenuEvent != null)
|
if (UpdateMenuEvent != null)
|
||||||
UpdateMenuEvent (CurrentState);
|
UpdateMenuEvent (CurrentState);
|
||||||
|
|
Loading…
Reference in a new issue