mac: Fix memory warnings in event log
This commit is contained in:
parent
c8204870d5
commit
bc749a31f5
|
@ -31,15 +31,8 @@ namespace SparkleShare {
|
||||||
|
|
||||||
public SparkleEventLogController Controller = new SparkleEventLogController ();
|
public SparkleEventLogController Controller = new SparkleEventLogController ();
|
||||||
|
|
||||||
private WebView web_view = new WebView (new RectangleF (0, 0, 480, 579), "", "") {
|
private WebView web_view;
|
||||||
PolicyDelegate = new SparkleWebPolicyDelegate ()
|
private NSBox separator;
|
||||||
};
|
|
||||||
|
|
||||||
private NSBox separator = new NSBox (new RectangleF (0, 579, 480, 1)) {
|
|
||||||
BorderColor = NSColor.LightGray,
|
|
||||||
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;
|
||||||
|
@ -49,188 +42,225 @@ namespace SparkleShare {
|
||||||
private NSButton hidden_close_button;
|
private NSButton hidden_close_button;
|
||||||
|
|
||||||
|
|
||||||
public SparkleEventLog (IntPtr handle) : base (handle) { }
|
public SparkleEventLog (IntPtr handle) : base (handle)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// TODO: Window needs to be made resizable
|
|
||||||
public SparkleEventLog () : base ()
|
public SparkleEventLog () : base ()
|
||||||
{
|
{
|
||||||
Title = "Recent Changes";
|
using (var a = new NSAutoreleasePool ())
|
||||||
|
{
|
||||||
|
Title = "Recent Changes";
|
||||||
|
Delegate = new SparkleEventsDelegate ();
|
||||||
|
// TODO: Window needs to be made resizable
|
||||||
|
|
||||||
Delegate = new SparkleEventsDelegate ();
|
SetFrame (new RectangleF (0, 0, 480, 640), true);
|
||||||
|
Center ();
|
||||||
|
|
||||||
SetFrame (new RectangleF (0, 0, 480, 640), true);
|
StyleMask = (NSWindowStyle.Closable |
|
||||||
Center ();
|
NSWindowStyle.Miniaturizable |
|
||||||
|
NSWindowStyle.Titled);
|
||||||
|
|
||||||
StyleMask = (NSWindowStyle.Closable |
|
MaxSize = new SizeF (480, 640);
|
||||||
NSWindowStyle.Miniaturizable |
|
MinSize = new SizeF (480, 640);
|
||||||
NSWindowStyle.Titled);
|
HasShadow = true;
|
||||||
|
BackingType = NSBackingStore.Buffered;
|
||||||
MaxSize = new SizeF (480, 640);
|
|
||||||
MinSize = new SizeF (480, 640);
|
|
||||||
HasShadow = true;
|
|
||||||
BackingType = NSBackingStore.Buffered;
|
|
||||||
|
|
||||||
|
|
||||||
this.hidden_close_button = new NSButton () {
|
this.web_view = new WebView (new RectangleF (0, 0, 480, 579), "", "") {
|
||||||
Frame = new RectangleF (0, 0, 0, 0),
|
PolicyDelegate = new SparkleWebPolicyDelegate ()
|
||||||
KeyEquivalentModifierMask = NSEventModifierMask.CommandKeyMask,
|
|
||||||
KeyEquivalent = "w"
|
|
||||||
};
|
|
||||||
|
|
||||||
this.hidden_close_button.Activated += delegate {
|
|
||||||
Controller.WindowClosed ();
|
|
||||||
};
|
|
||||||
|
|
||||||
ContentView.AddSubview (this.hidden_close_button);
|
|
||||||
|
|
||||||
|
|
||||||
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 = "…",
|
|
||||||
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 = "…",
|
|
||||||
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 () {
|
|
||||||
Style = NSProgressIndicatorStyle.Spinning,
|
|
||||||
Frame = new RectangleF (this.web_view.Frame.Width / 2 - 10,
|
|
||||||
this.web_view.Frame.Height / 2 + 10, 20, 20)
|
|
||||||
};
|
|
||||||
|
|
||||||
this.progress_indicator.StartAnimation (this);
|
|
||||||
ContentView.AddSubview (this.progress_indicator);
|
|
||||||
|
|
||||||
|
|
||||||
(this.web_view.PolicyDelegate as SparkleWebPolicyDelegate)
|
|
||||||
.LinkClicked += delegate (string href) {
|
|
||||||
Controller.LinkClicked (href);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
this.hidden_close_button = new NSButton () {
|
||||||
|
Frame = new RectangleF (0, 0, 0, 0),
|
||||||
|
KeyEquivalentModifierMask = NSEventModifierMask.CommandKeyMask,
|
||||||
|
KeyEquivalent = "w"
|
||||||
|
};
|
||||||
|
|
||||||
|
this.hidden_close_button.Activated += delegate {
|
||||||
|
Controller.WindowClosed ();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
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 = "…",
|
||||||
|
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 = "…",
|
||||||
|
Font = SparkleUI.Font
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
this.separator = new NSBox (new RectangleF (0, 579, 480, 1)) {
|
||||||
|
BorderColor = NSColor.LightGray,
|
||||||
|
BoxType = NSBoxType.NSBoxCustom
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
this.progress_indicator = new NSProgressIndicator () {
|
||||||
|
Style = NSProgressIndicatorStyle.Spinning,
|
||||||
|
Frame = new RectangleF (this.web_view.Frame.Width / 2 - 10,
|
||||||
|
this.web_view.Frame.Height / 2 + 10, 20, 20)
|
||||||
|
};
|
||||||
|
|
||||||
|
this.progress_indicator.StartAnimation (this);
|
||||||
|
|
||||||
|
|
||||||
|
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);
|
||||||
|
ContentView.AddSubview (this.progress_indicator);
|
||||||
|
ContentView.AddSubview (this.hidden_close_button);
|
||||||
|
|
||||||
|
|
||||||
|
(this.web_view.PolicyDelegate as
|
||||||
|
SparkleWebPolicyDelegate).LinkClicked += delegate (string href) {
|
||||||
|
Controller.LinkClicked (href);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Hook up the controller events
|
// Hook up the controller events
|
||||||
Controller.HideWindowEvent += delegate {
|
Controller.HideWindowEvent += delegate {
|
||||||
InvokeOnMainThread (delegate {
|
using (var a = new NSAutoreleasePool ())
|
||||||
PerformClose (this);
|
{
|
||||||
});
|
InvokeOnMainThread (delegate {
|
||||||
|
PerformClose (this);
|
||||||
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Controller.ShowWindowEvent += delegate {
|
Controller.ShowWindowEvent += delegate {
|
||||||
InvokeOnMainThread (delegate {
|
using (var a = new NSAutoreleasePool ())
|
||||||
OrderFrontRegardless ();
|
{
|
||||||
|
InvokeOnMainThread (delegate {
|
||||||
|
OrderFrontRegardless ();
|
||||||
|
|
||||||
UpdateContent (null);
|
UpdateContent (null);
|
||||||
UpdateChooser (null);
|
UpdateChooser (null);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Controller.UpdateChooserEvent += delegate (string [] folders) {
|
Controller.UpdateChooserEvent += delegate (string [] folders) {
|
||||||
InvokeOnMainThread (delegate {
|
using (var a = new NSAutoreleasePool ())
|
||||||
UpdateChooser (folders);
|
{
|
||||||
});
|
InvokeOnMainThread (delegate {
|
||||||
|
UpdateChooser (folders);
|
||||||
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Controller.UpdateContentEvent += delegate (string html) {
|
Controller.UpdateContentEvent += delegate (string html) {
|
||||||
InvokeOnMainThread (delegate {
|
using (var a = new NSAutoreleasePool ())
|
||||||
UpdateContent (html);
|
{
|
||||||
});
|
InvokeOnMainThread (delegate {
|
||||||
|
UpdateContent (html);
|
||||||
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Controller.ContentLoadingEvent += delegate {
|
Controller.ContentLoadingEvent += delegate {
|
||||||
InvokeOnMainThread (delegate {
|
using (var a = new NSAutoreleasePool ())
|
||||||
if (this.web_view.Superview == ContentView)
|
{
|
||||||
this.web_view.RemoveFromSuperview ();
|
InvokeOnMainThread (delegate {
|
||||||
|
if (this.web_view.Superview == ContentView)
|
||||||
|
this.web_view.RemoveFromSuperview ();
|
||||||
|
|
||||||
ContentView.AddSubview (this.progress_indicator);
|
ContentView.AddSubview (this.progress_indicator);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Controller.UpdateSizeInfoEvent += delegate (string size, string history_size) {
|
Controller.UpdateSizeInfoEvent += delegate (string size, string history_size) {
|
||||||
InvokeOnMainThread (delegate {
|
using (var a = new NSAutoreleasePool ())
|
||||||
this.size_label_value.StringValue = size;
|
{
|
||||||
this.history_label_value.StringValue = history_size;
|
InvokeOnMainThread (delegate {
|
||||||
});
|
this.size_label_value.StringValue = size;
|
||||||
|
this.history_label_value.StringValue = history_size;
|
||||||
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void UpdateChooser (string [] folders)
|
public void UpdateChooser (string [] folders)
|
||||||
{
|
{
|
||||||
if (folders == null)
|
using (var a = new NSAutoreleasePool ())
|
||||||
folders = Controller.Folders;
|
{
|
||||||
|
if (folders == null)
|
||||||
|
folders = Controller.Folders;
|
||||||
|
|
||||||
if (this.popup_button != null)
|
if (this.popup_button != null)
|
||||||
this.popup_button.RemoveFromSuperview ();
|
this.popup_button.RemoveFromSuperview ();
|
||||||
|
|
||||||
this.popup_button = new NSPopUpButton () {
|
this.popup_button = new NSPopUpButton () {
|
||||||
Frame = new RectangleF (480 - 156 - 8, 640 - 31 - 24, 156, 26),
|
Frame = new RectangleF (480 - 156 - 8, 640 - 31 - 24, 156, 26),
|
||||||
PullsDown = false
|
PullsDown = false
|
||||||
};
|
};
|
||||||
|
|
||||||
this.popup_button.Cell.ControlSize = NSControlSize.Small;
|
this.popup_button.Cell.ControlSize = NSControlSize.Small;
|
||||||
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 Projects");
|
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);
|
||||||
|
|
||||||
this.popup_button.Activated += delegate {
|
this.popup_button.Activated += delegate {
|
||||||
if (this.popup_button.IndexOfSelectedItem == 0)
|
if (this.popup_button.IndexOfSelectedItem == 0)
|
||||||
Controller.SelectedFolder = null;
|
Controller.SelectedFolder = null;
|
||||||
else
|
else
|
||||||
Controller.SelectedFolder = this.popup_button.SelectedItem.Title;
|
Controller.SelectedFolder = this.popup_button.SelectedItem.Title;
|
||||||
};
|
};
|
||||||
|
|
||||||
ContentView.AddSubview (this.popup_button);
|
ContentView.AddSubview (this.popup_button);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void UpdateContent (string html)
|
public void UpdateContent (string html)
|
||||||
{
|
{
|
||||||
using (NSAutoreleasePool pool = new NSAutoreleasePool ()) {
|
Thread thread = new Thread (new ThreadStart (delegate {
|
||||||
Thread thread = new Thread (new ThreadStart (delegate {
|
using (var a = new NSAutoreleasePool ())
|
||||||
|
{
|
||||||
if (html == null)
|
if (html == null)
|
||||||
html = Controller.HTML;
|
html = Controller.HTML;
|
||||||
|
|
||||||
|
@ -262,7 +292,6 @@ namespace SparkleShare {
|
||||||
"file://" + Path.Combine (NSBundle.MainBundle.ResourcePath,
|
"file://" + Path.Combine (NSBundle.MainBundle.ResourcePath,
|
||||||
"Pixmaps", "document-moved-12.png"));
|
"Pixmaps", "document-moved-12.png"));
|
||||||
|
|
||||||
|
|
||||||
InvokeOnMainThread (delegate {
|
InvokeOnMainThread (delegate {
|
||||||
if (this.progress_indicator.Superview == ContentView)
|
if (this.progress_indicator.Superview == ContentView)
|
||||||
this.progress_indicator.RemoveFromSuperview ();
|
this.progress_indicator.RemoveFromSuperview ();
|
||||||
|
@ -270,10 +299,10 @@ namespace SparkleShare {
|
||||||
this.web_view.MainFrame.LoadHtmlString (html, new NSUrl (""));
|
this.web_view.MainFrame.LoadHtmlString (html, new NSUrl (""));
|
||||||
ContentView.AddSubview (this.web_view);
|
ContentView.AddSubview (this.web_view);
|
||||||
});
|
});
|
||||||
}));
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
thread.Start ();
|
thread.Start ();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue