mac: clean up

This commit is contained in:
Hylke Bons 2012-11-26 10:24:48 +00:00
parent 2b1fa6a57c
commit 8cdaebc142
9 changed files with 85 additions and 833 deletions

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 2.5 MiB

After

Width:  |  Height:  |  Size: 1.8 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 70 KiB

After

Width:  |  Height:  |  Size: 93 KiB

View file

@ -21,7 +21,6 @@ using System.IO;
using MonoMac.AppKit;
using MonoMac.Foundation;
using MonoMac.ObjCRuntime;
namespace SparkleShare {
@ -29,11 +28,11 @@ namespace SparkleShare {
public SparkleAboutController Controller = new SparkleAboutController ();
private NSTextField version_text_field, updates_text_field, credits_text_field;
private SparkleLink website_link, credits_link, report_problem_link, debug_log_link;
private NSImage about_image;
private NSImageView about_image_view;
private NSTextField version_text_field, updates_text_field, credits_text_field;
private NSButton hidden_close_button;
private SparkleLink website_link, credits_link, report_problem_link, debug_log_link;
public SparkleAbout (IntPtr handle) : base (handle) { }
@ -51,44 +50,8 @@ namespace SparkleShare {
HasShadow = true;
BackingType = NSBackingStore.Buffered;
this.website_link = new SparkleLink ("Website", Controller.WebsiteLinkAddress);
this.website_link.Frame = new RectangleF (new PointF (295, 25), this.website_link.Frame.Size);
this.credits_link = new SparkleLink ("Credits", Controller.CreditsLinkAddress);
this.credits_link.Frame = new RectangleF (
new PointF (this.website_link.Frame.X + this.website_link.Frame.Width + 10, 25),
this.credits_link.Frame.Size);
this.report_problem_link = new SparkleLink ("Report a problem", Controller.ReportProblemLinkAddress);
this.report_problem_link.Frame = new RectangleF (
new PointF (this.credits_link.Frame.X + this.credits_link.Frame.Width + 10, 25),
this.report_problem_link.Frame.Size);
this.debug_log_link = new SparkleLink ("Debug log", Controller.DebugLogLinkAddress);
this.debug_log_link.Frame = new RectangleF (
new PointF (this.report_problem_link.Frame.X + this.report_problem_link.Frame.Width + 10, 25),
this.debug_log_link.Frame.Size);
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 ();
};
ContentView.AddSubview (this.hidden_close_button);
CreateAbout ();
ContentView.AddSubview (this.website_link);
ContentView.AddSubview (this.credits_link);
ContentView.AddSubview (this.report_problem_link);
ContentView.AddSubview (this.debug_log_link);
Controller.HideWindowEvent += delegate {
Program.Controller.Invoke (() => PerformClose (this));
};
@ -120,16 +83,13 @@ namespace SparkleShare {
private void CreateAbout ()
{
string about_image_path = Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "about.png");
this.about_image = new NSImage (about_image_path);
this.about_image.Size = new SizeF (640, 260);
this.about_image = new NSImage (about_image_path) { Size = new SizeF (640, 260) };
this.about_image_view = new NSImageView () {
Image = this.about_image,
Frame = new RectangleF (0, 0, 640, 260)
};
this.version_text_field = new NSTextField () {
StringValue = "version " + Controller.RunningVersion,
Frame = new RectangleF (295, 140, 318, 22),
@ -138,8 +98,8 @@ namespace SparkleShare {
Editable = false,
DrawsBackground = false,
TextColor = NSColor.White,
Font = NSFontManager.SharedFontManager.FontWithFamily
("Lucida Grande", NSFontTraitMask.Unbold, 0, 11)
Font = NSFontManager.SharedFontManager.FontWithFamily (
"Lucida Grande", NSFontTraitMask.Unbold, 0, 11)
};
this.updates_text_field = new NSTextField () {
@ -148,9 +108,9 @@ namespace SparkleShare {
Bordered = false,
Editable = false,
DrawsBackground = false,
Font = NSFontManager.SharedFontManager.FontWithFamily
("Lucida Grande", NSFontTraitMask.Unbold, 0, 11),
TextColor = NSColor.FromCalibratedRgba (0.45f, 0.62f, 0.81f, 1.0f) // Tango Sky Blue #1
TextColor = NSColor.FromCalibratedRgba (1.0f, 1.0f, 1.0f, 0.5f),
Font = NSFontManager.SharedFontManager.FontWithFamily (
"Lucida Grande", NSFontTraitMask.Unbold, 0, 11)
};
this.credits_text_field = new NSTextField () {
@ -168,10 +128,45 @@ namespace SparkleShare {
"Lucida Grande", NSFontTraitMask.Unbold, 0, 11),
};
this.website_link = new SparkleLink ("Website", Controller.WebsiteLinkAddress);
this.website_link.Frame = new RectangleF (new PointF (295, 25), this.website_link.Frame.Size);
this.credits_link = new SparkleLink ("Credits", Controller.CreditsLinkAddress);
this.credits_link.Frame = new RectangleF (
new PointF (this.website_link.Frame.X + this.website_link.Frame.Width + 10, 25),
this.credits_link.Frame.Size);
this.report_problem_link = new SparkleLink ("Report a problem", Controller.ReportProblemLinkAddress);
this.report_problem_link.Frame = new RectangleF (
new PointF (this.credits_link.Frame.X + this.credits_link.Frame.Width + 10, 25),
this.report_problem_link.Frame.Size);
this.debug_log_link = new SparkleLink ("Debug log", Controller.DebugLogLinkAddress);
this.debug_log_link.Frame = new RectangleF (
new PointF (this.report_problem_link.Frame.X + this.report_problem_link.Frame.Width + 10, 25),
this.debug_log_link.Frame.Size);
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 ();
};
ContentView.AddSubview (this.hidden_close_button);
ContentView.AddSubview (this.about_image_view);
ContentView.AddSubview (this.version_text_field);
ContentView.AddSubview (this.updates_text_field);
ContentView.AddSubview (this.credits_text_field);
ContentView.AddSubview (this.website_link);
ContentView.AddSubview (this.credits_link);
ContentView.AddSubview (this.report_problem_link);
ContentView.AddSubview (this.debug_log_link);
}
@ -235,7 +230,6 @@ namespace SparkleShare {
s.Append (name_attributes);
Cell.AttributedStringValue = s;
SizeToFit ();
}

View file

@ -22,7 +22,6 @@ using System.Threading;
using MonoMac.Foundation;
using MonoMac.AppKit;
using MonoMac.ObjCRuntime;
using SparkleLib;
@ -93,56 +92,9 @@ namespace SparkleShare {
}
// Adds the SparkleShare folder to the user's
// list of bookmarked places
public override void AddToBookmarks ()
{/*
NSMutableDictionary sidebar_plist = NSMutableDictionary.FromDictionary (
NSUserDefaults.StandardUserDefaults.PersistentDomainForName ("com.apple.sidebarlists"));
// Go through the sidebar categories
foreach (NSString sidebar_category in sidebar_plist.Keys) {
// Find the favorites
if (sidebar_category.ToString ().Equals ("favorites")) {
// Get the favorites
NSMutableDictionary favorites = NSMutableDictionary.FromDictionary(
(NSDictionary) sidebar_plist.ValueForKey (sidebar_category));
// Go through the favorites
foreach (NSString favorite in favorites.Keys) {
// Find the custom favorites
if (favorite.ToString ().Equals ("VolumesList")) {
// Get the custom favorites
NSMutableArray custom_favorites = (NSMutableArray) favorites.ValueForKey (favorite);
NSMutableDictionary properties = new NSMutableDictionary ();
properties.SetValueForKey (new NSString ("1935819892"), new NSString ("com.apple.LSSharedFileList.TemplateSystemSelector"));
NSMutableDictionary new_favorite = new NSMutableDictionary ();
new_favorite.SetValueForKey (new NSString ("SparkleShare"), new NSString ("Name"));
new_favorite.SetValueForKey (NSData.FromString ("ImgR SYSL fldr"), new NSString ("Icon"));
new_favorite.SetValueForKey (NSData.FromString (SparkleConfig.DefaultConfig.FoldersPath),
new NSString ("Alias"));
new_favorite.SetValueForKey (properties, new NSString ("CustomItemProperties"));
// Add to the favorites
custom_favorites.Add (new_favorite);
favorites.SetValueForKey ((NSArray) custom_favorites, new NSString (favorite.ToString ()));
sidebar_plist.SetValueForKey (favorites, new NSString (sidebar_category.ToString ()));
}
}
}
}
NSUserDefaults.StandardUserDefaults.SetPersistentDomain (sidebar_plist, "com.apple.sidebarlists");*/
{
// TODO
}
@ -157,7 +109,6 @@ namespace SparkleShare {
Program.Controller.FoldersPath, 0);
return true;
}
return false;

View file

@ -376,15 +376,12 @@ namespace SparkleShare {
public class SparkleEventsDelegate : NSWindowDelegate {
public event WindowResizedHandler WindowResized;
public event WindowResizedHandler WindowResized = delegate { };
public delegate void WindowResizedHandler (SizeF new_window_size);
public override SizeF WillResize (NSWindow sender, SizeF to_frame_size)
{
if (WindowResized != null)
WindowResized (to_frame_size);
WindowResized (to_frame_size);
return to_frame_size;
}
@ -398,15 +395,13 @@ namespace SparkleShare {
public class SparkleWebPolicyDelegate : WebPolicyDelegate {
public event LinkClickedHandler LinkClicked;
public event LinkClickedHandler LinkClicked = delegate { };
public delegate void LinkClickedHandler (string href);
public override void DecidePolicyForNavigation (WebView web_view, NSDictionary action_info,
NSUrlRequest request, WebFrame frame, NSObject decision_token)
{
if (LinkClicked != null)
LinkClicked (request.Url.ToString ());
LinkClicked (request.Url.ToString ());
}
}
}

View file

@ -957,9 +957,8 @@ namespace SparkleShare {
[Register("SparkleDataSource")]
public class SparkleDataSource : NSTableViewDataSource {
public List<object> Items ;
public NSAttributedString [] Cells;
public NSAttributedString [] SelectedCells;
public List<object> Items;
public NSAttributedString [] Cells, SelectedCells;
public SparkleDataSource (List<SparklePlugin> plugins)
@ -1063,7 +1062,6 @@ namespace SparkleShare {
public event Action StringValueChanged = delegate { };
public override void Changed (NSNotification notification)
{
StringValueChanged ();
@ -1075,7 +1073,6 @@ namespace SparkleShare {
public event Action SelectionChanged = delegate { };
public override void SelectionDidChange (NSNotification notification)
{
SelectionChanged ();

View file

@ -89,9 +89,6 @@
<Compile Include="..\SparkleAboutController.cs">
<Link>SparkleAboutController.cs</Link>
</Compile>
<Compile Include="..\SparkleExtensions.cs">
<Link>SparkleExtensions.cs</Link>
</Compile>
<Compile Include="SparkleController.cs" />
<Compile Include="..\SparklePlugin.cs">
<Link>SparklePlugin.cs</Link>

View file

@ -26,8 +26,8 @@ namespace SparkleShare {
public static string PluginsPath = "";
public static string LocalPluginsPath = new string [] {
Environment.GetFolderPath (Environment.SpecialFolder.ApplicationData), "sparkleshare", "plugins" }.Combine ();
public static string LocalPluginsPath = IO.Path.Combine (
Environment.GetFolderPath (Environment.SpecialFolder.ApplicationData), "sparkleshare", "plugins");
public string Name { get { return GetValue ("info", "name"); } }
public string Description { get { return GetValue ("info", "description"); } }