[osx] Fix the event look to look native

This commit is contained in:
Hylke Bons 2011-02-06 16:51:46 +00:00
parent 1e4abe578b
commit 35535517e5
6 changed files with 156 additions and 52 deletions

View file

@ -22,6 +22,8 @@ using MonoMac.AppKit;
using MonoMac.ObjCRuntime;
using MonoMac.WebKit;
using System.IO;
namespace SparkleShare {
public class SparkleLog : NSWindow {
@ -83,7 +85,7 @@ namespace SparkleShare {
ContentView.AddSubview (CloseButton);
string name = System.IO.Path.GetFileName (LocalPath);
string name = Path.GetFileName (LocalPath);
Title = String.Format ("Recent Events in {0}", name);
OrderFrontRegardless ();
@ -100,10 +102,19 @@ namespace SparkleShare {
private WebView CreateEventLog ()
{
RectangleF frame = new RectangleF (0, 12 + 31 + 16, 480, 640 - (12 + 31 + 16));
RectangleF frame = new RectangleF (0, (12 + 31 + 16), 480, 618 - (12 + 31 + 16));
WebView = new WebView (frame, "", "");
WebView.MainFrameUrl = "http://www.google.nl/";
string folder_name = Path.GetFileName (LocalPath);
string html = SparkleShare.Controller.GetHTMLLog (folder_name);
html = html.Replace ("<!-- $body-font-family -->", "Lucida Grande");
html = html.Replace ("<!-- $body-font-size -->", "10pt");
html = html.Replace ("<!-- $secondary-font-color -->", "#bbb");
html = html.Replace ("<!-- $day-entry-header-background-color -->", "#f5f5f5");
html = html.Replace ("<!-- $a-color -->", "#0085cf");
WebView = new WebView (frame, "", "");
WebView.MainFrame.LoadHtmlString (html, new NSUrl (""));
return WebView;

View file

@ -49,8 +49,8 @@ namespace SparkleShare {
// list of bookmarked places
public override void AddToBookmarks ()
{
// TODO
}
@ -89,7 +89,67 @@ namespace SparkleShare {
process.Start ();
}
public override string EventLogHTML
{
get {
string resource_path = NSBundle.MainBundle.ResourcePath;
string html_path = Path.Combine (resource_path, "HTML", "event-log.html");
StreamReader reader = new StreamReader (html_path);
string html = reader.ReadToEnd ();
reader.Close ();
return html;
}
}
public override string DayEntryHTML
{
get {
string resource_path = NSBundle.MainBundle.ResourcePath;
string html_path = Path.Combine (resource_path, "HTML", "day-entry.html");
StreamReader reader = new StreamReader (html_path);
string html = reader.ReadToEnd ();
reader.Close ();
return html;
}
}
public override string EventEntryHTML
{
get {
string resource_path = NSBundle.MainBundle.ResourcePath;
string html_path = Path.Combine (resource_path, "HTML", "event-entry.html");
StreamReader reader = new StreamReader (html_path);
string html = reader.ReadToEnd ();
reader.Close ();
return html;
}
}
}
}

View file

@ -48,16 +48,41 @@ namespace SparkleShare {
SideSplash = new NSImage (NSBundle.MainBundle.ResourcePath + "/Pixmaps/side-splash.png");
SideSplash.Size = new SizeF (150, 480);
NSText tv = new NSText (new RectangleF (200, 200, 200, 200)) {
Value = "TEST"
NSButtonCell proto = new NSButtonCell {
Title = " Github"
};
ContentView.AddSubview (new NSImageView (new RectangleF (0, 0, 150, 480)) { Image = SideSplash});
ContentView.AddSubview (new NSTextField (new RectangleF (200, 100, 128, 31)) { BezelStyle = NSTextFieldBezelStyle.Rounded});
ContentView.AddSubview (tv);
NSText text = new NSText (new RectangleF (150,150,350,300)) {
Value = "DDDDDDDD"
};
proto.SetButtonType (NSButtonType.Radio) ;
NSButton button = new NSButton (new RectangleF (150, 0, 350, 300)) {
Cell = proto,
Font = NSFontManager.SharedFontManager.FontWithFamily ("Lucida Grande",
NSFontTraitMask.Bold,
0, 14)
};
NSMatrix matrix = new NSMatrix (new RectangleF (300, 00, 300, 300), NSMatrixMode.Radio, proto, 4, 1);
matrix.Cells [0].Title = "My own server:";
matrix.Cells [1].Title = "Github\nFree hosting";
matrix.Cells [2].Title = "Gitorious";
matrix.Cells [3].Title = "The GNOME Project";
ContentView.AddSubview (new NSImageView (new RectangleF (0, 0, 150, 480)) { Image = SideSplash});
ContentView.AddSubview (new NSTextField (new RectangleF (200, 100, 128, 25)) { BezelStyle = NSTextFieldBezelStyle.Square, Editable=false});
ContentView.AddSubview (button);
ContentView.AddSubview (text);
NSApplication.SharedApplication.ActivateIgnoringOtherApps (true);

View file

@ -233,12 +233,16 @@ namespace SparkleShare {
}
public abstract string EventLogHTML { get; }
public abstract string DayEntryHTML { get; }
public abstract string EventEntryHTML { get; }
public string GetHTMLLog (string name)
{
List <SparkleCommit> commits = GetLog (name);
List <ActivityDay> activity_days = new List <ActivityDay> ();
List <SparkleCommit> commits = GetLog (name);
List <ActivityDay> activity_days = new List <ActivityDay> ();
foreach (SparkleCommit commit in commits) {
@ -261,34 +265,20 @@ namespace SparkleShare {
if (!commit_inserted) {
ActivityDay activity_day = new ActivityDay (commit.DateTime);
activity_day.Add (commit);
activity_days.Add (activity_day);
ActivityDay activity_day = new ActivityDay (commit.DateTime);
activity_day.Add (commit);
activity_days.Add (activity_day);
}
}
StreamReader reader;
reader = new StreamReader (Defines.PREFIX + "/share/sparkleshare/html/event-log.html");
string event_log_html = reader.ReadToEnd ();
reader.Close ();
reader = new StreamReader (Defines.PREFIX + "/share/sparkleshare/html/day-entry.html");
string day_entry_html = reader.ReadToEnd ();
reader.Close ();
reader = new StreamReader (Defines.PREFIX + "/share/sparkleshare/html/event-entry.html");
string event_entry_html = reader.ReadToEnd ();
reader.Close ();
string event_log_html = EventLogHTML;
string day_entry_html = DayEntryHTML;
string event_entry_html = EventEntryHTML;
string event_log = "";
foreach (ActivityDay activity_day in activity_days) {
@ -305,13 +295,13 @@ namespace SparkleShare {
foreach (string file_path in change_set.Edited) {
if (File.Exists (SparkleHelpers.CombineMore (SparklePaths.SparklePath ,name , file_path))) {
if (File.Exists (SparkleHelpers.CombineMore (SparklePaths.SparklePath, name, file_path))) {
event_entry += "<dd><a href='#'>" + file_path + "</a></dd>";
} else {
event_entry += "<dd>" + SparkleHelpers.CombineMore (SparklePaths.SparklePath, name, file_path) + "</dd>";
event_entry += "<dd>" + file_path + "</dd>";
}
@ -326,13 +316,13 @@ namespace SparkleShare {
foreach (string file_path in change_set.Added) {
if (File.Exists (SparkleHelpers.CombineMore (SparklePaths.SparklePath ,name , file_path))) {
if (File.Exists (SparkleHelpers.CombineMore (SparklePaths.SparklePath, name, file_path))) {
event_entry += "<dd><a href='#'>" + file_path + "</a></dd>";
} else {
event_entry += "<dd>" + SparkleHelpers.CombineMore (SparklePaths.SparklePath ,name , file_path) + "</dd>";
event_entry += "<dd>" + file_path + "</dd>";
}
@ -346,33 +336,33 @@ namespace SparkleShare {
foreach (string file_path in change_set.Deleted) {
if (File.Exists (SparkleHelpers.CombineMore (SparklePaths.SparklePath ,name , file_path))) {
if (File.Exists (SparkleHelpers.CombineMore (SparklePaths.SparklePath, name, file_path))) {
event_entry += "<dd><a href='#'>" + file_path + "</a></dd>";
} else {
event_entry += "<dd>" + SparkleHelpers.CombineMore (SparklePaths.SparklePath ,name , file_path) + "</dd>";
event_entry += "<dd>" + file_path + "</dd>";
}
}
}
Console.WriteLine(GetAvatar (change_set.UserEmail, 32));
event_entry += "</dl>";
event_entries += event_entry_html.Replace ("<!-- $event-entry-content -->", event_entry)
.Replace ("<!-- $event-user-name -->", change_set.UserName)
.Replace ("<!-- $event-avatar-url -->", "file://" +GetAvatar (change_set.UserEmail, 32) )
.Replace ("<!-- $event-avatar-url -->", "file://" + GetAvatar (change_set.UserEmail, 32) )
.Replace ("<!-- $event-time -->", change_set.DateTime.ToString ("H:mm"));
}
string day_entry = "";
DateTime today = DateTime.Now;
DateTime today = DateTime.Now;
DateTime yesterday = DateTime.Now.AddDays (-1);
if (today.Day == activity_day.DateTime.Day &&
@ -398,7 +388,8 @@ Console.WriteLine(GetAvatar (change_set.UserEmail, 32));
}
string html = event_log_html.Replace ("<!-- $event-log-content -->", event_log);
return html;

View file

@ -89,11 +89,11 @@ namespace SparkleShare {
case PlatformID.Unix:
SetProcessName ("sparkleshare");
Controller = new SparkleLinController ();
//Controller = new SparkleLinController ();
break;
case PlatformID.MacOSX:
//Controller = new SparkleMacController ();
Controller = new SparkleMacController ();
break;
case PlatformID.Win32NT:

View file

@ -30,10 +30,23 @@
padding: 12px;
}
.dd {
dl {
padding: 0;
margin: 0;
padding-bottom: 18px;
}
dt {
padding-bottom: 12px;
padding-top: 12px;
}
dd {
padding-left: 0;
margin-left: 12px;
text-overflow: ellipsis;
}
a {
color: <!-- $a-color -->;
text-decoration: none;
@ -51,6 +64,10 @@
font-size: 80%;
color: <!-- $secondary-font-color -->;
}
img {
margin-right: 12px;
}
</style>