mac window: fix coding style and whitespace
This commit is contained in:
parent
24e58b1e25
commit
de5f86b3a4
|
@ -28,142 +28,122 @@ using Mono.Unix;
|
||||||
|
|
||||||
namespace SparkleShare {
|
namespace SparkleShare {
|
||||||
|
|
||||||
public class SparkleWindow : NSWindow {
|
public class SparkleWindow : NSWindow {
|
||||||
|
|
||||||
private NSImage SideSplash;
|
public List <NSButton> Buttons;
|
||||||
private NSImageView SideSplashView;
|
public string Header;
|
||||||
|
public string Description;
|
||||||
|
|
||||||
public List <NSButton> Buttons;
|
private NSImage SideSplash;
|
||||||
public string Header;
|
private NSImageView SideSplashView;
|
||||||
public string Description;
|
private NSTextField HeaderTextField;
|
||||||
|
private NSTextField DescriptionTextField;
|
||||||
private NSTextField HeaderTextField;
|
|
||||||
private NSTextField DescriptionTextField;
|
|
||||||
|
|
||||||
|
|
||||||
public SparkleWindow () : base ()
|
public SparkleWindow () : base ()
|
||||||
{
|
{
|
||||||
|
SetFrame (new RectangleF (0, 0, 640, 380), true);
|
||||||
|
|
||||||
SetFrame (new RectangleF (0, 0, 640, 380), true);
|
StyleMask = NSWindowStyle.Titled;
|
||||||
|
MaxSize = new SizeF (640, 380);
|
||||||
|
MinSize = new SizeF (640, 380);
|
||||||
|
HasShadow = true;
|
||||||
|
BackingType = NSBackingStore.Buffered;
|
||||||
|
|
||||||
StyleMask = NSWindowStyle.Titled;
|
Center ();
|
||||||
MaxSize = new SizeF (640, 380);
|
|
||||||
MinSize = new SizeF (640, 380);
|
|
||||||
HasShadow = true;
|
|
||||||
BackingType = NSBackingStore.Buffered;
|
|
||||||
|
|
||||||
Center ();
|
string side_splash_path = Path.Combine (NSBundle.MainBundle.ResourcePath,
|
||||||
|
"Pixmaps", "side-splash.png");
|
||||||
|
|
||||||
string side_splash_path = Path.Combine (NSBundle.MainBundle.ResourcePath,
|
SideSplash = new NSImage (side_splash_path) {
|
||||||
"Pixmaps", "side-splash.png");
|
Size = new SizeF (150, 407)
|
||||||
|
};
|
||||||
|
|
||||||
SideSplash = new NSImage (side_splash_path) {
|
SideSplashView = new NSImageView () {
|
||||||
Size = new SizeF (150, 407)
|
Image = SideSplash,
|
||||||
};
|
Frame = new RectangleF (0, 0, 150, 407)
|
||||||
|
};
|
||||||
|
|
||||||
SideSplashView = new NSImageView () {
|
Buttons = new List <NSButton> ();
|
||||||
Image = SideSplash,
|
|
||||||
Frame = new RectangleF (0, 0, 150, 407)
|
HeaderTextField = new NSTextField () {
|
||||||
};
|
Frame = new RectangleF (190, Frame.Height - 100, Frame.Width, 48),
|
||||||
|
BackgroundColor = NSColor.WindowBackground,
|
||||||
|
Bordered = false,
|
||||||
|
Editable = false,
|
||||||
|
Font = NSFontManager.SharedFontManager.FontWithFamily
|
||||||
|
("Lucida Grande", NSFontTraitMask.Bold, 0, 15)
|
||||||
|
};
|
||||||
|
|
||||||
|
DescriptionTextField = new NSTextField () {
|
||||||
|
Frame = new RectangleF (190, Frame.Height - 155 , 640 - 240, 64),
|
||||||
|
BackgroundColor = NSColor.WindowBackground,
|
||||||
|
Bordered = false,
|
||||||
|
Editable = false,
|
||||||
|
Font = SparkleUI.Font
|
||||||
|
};
|
||||||
|
|
||||||
|
NSApplication.SharedApplication.ActivateIgnoringOtherApps (true);
|
||||||
|
MakeKeyAndOrderFront (this);
|
||||||
|
|
||||||
|
OrderFrontRegardless ();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Buttons = new List <NSButton> ();
|
public void Reset ()
|
||||||
|
{
|
||||||
|
ContentView.Subviews = new NSView [0];
|
||||||
|
Buttons = new List <NSButton> ();
|
||||||
|
Header = "";
|
||||||
|
Description = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
HeaderTextField = new NSTextField () {
|
public void ShowAll ()
|
||||||
Frame = new RectangleF (190, Frame.Height - 100, Frame.Width, 48),
|
{
|
||||||
BackgroundColor = NSColor.WindowBackground,
|
HeaderTextField.StringValue = Header;
|
||||||
Bordered = false,
|
DescriptionTextField.StringValue = Description;
|
||||||
Editable = false,
|
|
||||||
Font = NSFontManager.SharedFontManager.FontWithFamily
|
|
||||||
("Lucida Grande", NSFontTraitMask.Bold, 0, 15)
|
|
||||||
};
|
|
||||||
|
|
||||||
DescriptionTextField = new NSTextField () {
|
ContentView.AddSubview (HeaderTextField);
|
||||||
Frame = new RectangleF (190, Frame.Height - 155 , 640 - 240, 64),
|
|
||||||
BackgroundColor = NSColor.WindowBackground,
|
if (!Description.Equals (""))
|
||||||
Bordered = false,
|
ContentView.AddSubview (DescriptionTextField);
|
||||||
Editable = false,
|
|
||||||
Font = SparkleUI.Font
|
ContentView.AddSubview (SideSplashView);
|
||||||
};
|
|
||||||
|
int i = 1;
|
||||||
|
if (Buttons.Count > 0) {
|
||||||
|
DefaultButtonCell = Buttons [0].Cell;
|
||||||
|
|
||||||
|
foreach (NSButton button in Buttons) {
|
||||||
|
button.BezelStyle = NSBezelStyle.Rounded;
|
||||||
|
button.Frame = new RectangleF (Frame.Width - 15 - (105 * i), 12, 105, 32);
|
||||||
|
|
||||||
|
// Make the button a bit wider if the text is
|
||||||
|
// likely to be longer
|
||||||
|
if (button.Title.Contains (" "))
|
||||||
|
button.Frame = new RectangleF (Frame.Width - 30 - (105 * i), 12, 120, 32);
|
||||||
|
|
||||||
|
button.Font = SparkleUI.Font;
|
||||||
|
ContentView.AddSubview (button);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
NSApplication.SharedApplication.ActivateIgnoringOtherApps (true);
|
public override void OrderFrontRegardless ()
|
||||||
MakeKeyAndOrderFront (this);
|
{
|
||||||
|
NSApplication.SharedApplication.AddWindowsItem (this, "SparkleShare Setup", false);
|
||||||
OrderFrontRegardless ();
|
base.OrderFrontRegardless ();
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void Reset () {
|
public override void PerformClose (NSObject sender)
|
||||||
|
{
|
||||||
ContentView.Subviews = new NSView [0];
|
OrderOut (this);
|
||||||
Buttons = new List <NSButton> ();
|
NSApplication.SharedApplication.RemoveWindowsItem (this);
|
||||||
|
return;
|
||||||
Header = "";
|
}
|
||||||
Description = "";
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void ShowAll () {
|
|
||||||
|
|
||||||
HeaderTextField.StringValue = Header;
|
|
||||||
DescriptionTextField.StringValue = Description;
|
|
||||||
|
|
||||||
ContentView.AddSubview (HeaderTextField);
|
|
||||||
|
|
||||||
if (!Description.Equals (""))
|
|
||||||
ContentView.AddSubview (DescriptionTextField);
|
|
||||||
|
|
||||||
ContentView.AddSubview (SideSplashView);
|
|
||||||
|
|
||||||
int i = 1;
|
|
||||||
|
|
||||||
if (Buttons.Count > 0) {
|
|
||||||
|
|
||||||
DefaultButtonCell = Buttons [0].Cell;
|
|
||||||
|
|
||||||
foreach (NSButton button in Buttons) {
|
|
||||||
|
|
||||||
button.BezelStyle = NSBezelStyle.Rounded;
|
|
||||||
button.Frame = new RectangleF (Frame.Width - 15 - (105 * i) , 12, 105, 32);
|
|
||||||
|
|
||||||
if (button.Title.Contains (" "))
|
|
||||||
button.Frame = new RectangleF (Frame.Width - 30 - (105 * i) , 12, 120, 32);
|
|
||||||
|
|
||||||
button.Font = SparkleUI.Font;
|
|
||||||
|
|
||||||
ContentView.AddSubview (button);
|
|
||||||
|
|
||||||
i++;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public override void OrderFrontRegardless ()
|
|
||||||
{
|
|
||||||
|
|
||||||
NSApplication.SharedApplication.AddWindowsItem (this, "SparkleShare Setup", false);
|
|
||||||
base.OrderFrontRegardless ();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public override void PerformClose (NSObject sender)
|
|
||||||
{
|
|
||||||
|
|
||||||
OrderOut (this);
|
|
||||||
NSApplication.SharedApplication.RemoveWindowsItem (this);
|
|
||||||
return;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -182,7 +182,6 @@ namespace SparkleShare {
|
||||||
|
|
||||||
// TODO: remove this later
|
// TODO: remove this later
|
||||||
private void MigrateConfig () {
|
private void MigrateConfig () {
|
||||||
string global_config_file_path = Path.Combine (SparklePaths.SparkleConfigPath, "config.xml");
|
|
||||||
string old_global_config_file_path = Path.Combine (SparklePaths.SparkleConfigPath, "config");
|
string old_global_config_file_path = Path.Combine (SparklePaths.SparkleConfigPath, "config");
|
||||||
|
|
||||||
StreamReader reader = new StreamReader (old_global_config_file_path);
|
StreamReader reader = new StreamReader (old_global_config_file_path);
|
||||||
|
|
|
@ -145,7 +145,7 @@ namespace SparkleShare {
|
||||||
|
|
||||||
// Strange magic needed by SetProcessName ()
|
// Strange magic needed by SetProcessName ()
|
||||||
[DllImport ("libc")]
|
[DllImport ("libc")]
|
||||||
private static extern int prctl (int option, byte [] arg2, IntPtr arg3, IntPtr arg4, IntPtr arg5);
|
private static extern int prctl (int option, byte [] arg2, IntPtr arg3, IntPtr arg4, IntPtr arg5);
|
||||||
|
|
||||||
|
|
||||||
// Sets the Unix process name to 'sparkleshare' instead of 'mono'
|
// Sets the Unix process name to 'sparkleshare' instead of 'mono'
|
||||||
|
|
Loading…
Reference in a new issue