[osx] Fix the event look to look native
This commit is contained in:
parent
bf08710f60
commit
065b70df61
|
@ -22,6 +22,8 @@ using MonoMac.AppKit;
|
||||||
using MonoMac.ObjCRuntime;
|
using MonoMac.ObjCRuntime;
|
||||||
using MonoMac.WebKit;
|
using MonoMac.WebKit;
|
||||||
|
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
namespace SparkleShare {
|
namespace SparkleShare {
|
||||||
|
|
||||||
public class SparkleLog : NSWindow {
|
public class SparkleLog : NSWindow {
|
||||||
|
@ -83,7 +85,7 @@ namespace SparkleShare {
|
||||||
ContentView.AddSubview (CloseButton);
|
ContentView.AddSubview (CloseButton);
|
||||||
|
|
||||||
|
|
||||||
string name = System.IO.Path.GetFileName (LocalPath);
|
string name = Path.GetFileName (LocalPath);
|
||||||
Title = String.Format ("Recent Events in ‘{0}’", name);
|
Title = String.Format ("Recent Events in ‘{0}’", name);
|
||||||
|
|
||||||
OrderFrontRegardless ();
|
OrderFrontRegardless ();
|
||||||
|
@ -100,10 +102,19 @@ namespace SparkleShare {
|
||||||
private WebView CreateEventLog ()
|
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));
|
||||||
|
|
||||||
|
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 = new WebView (frame, "", "");
|
||||||
WebView.MainFrameUrl = "http://www.google.nl/";
|
WebView.MainFrame.LoadHtmlString (html, new NSUrl (""));
|
||||||
|
|
||||||
return WebView;
|
return WebView;
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ namespace SparkleShare {
|
||||||
public override void AddToBookmarks ()
|
public override void AddToBookmarks ()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,6 +90,66 @@ namespace SparkleShare {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -50,14 +50,39 @@ namespace SparkleShare {
|
||||||
SideSplash.Size = new SizeF (150, 480);
|
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});
|
NSText text = new NSText (new RectangleF (150,150,350,300)) {
|
||||||
ContentView.AddSubview (new NSTextField (new RectangleF (200, 100, 128, 31)) { BezelStyle = NSTextFieldBezelStyle.Rounded});
|
Value = "DDDDDDDD"
|
||||||
ContentView.AddSubview (tv);
|
};
|
||||||
|
|
||||||
|
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);
|
NSApplication.SharedApplication.ActivateIgnoringOtherApps (true);
|
||||||
|
|
|
@ -233,11 +233,15 @@ namespace SparkleShare {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public abstract string EventLogHTML { get; }
|
||||||
|
public abstract string DayEntryHTML { get; }
|
||||||
|
public abstract string EventEntryHTML { get; }
|
||||||
|
|
||||||
|
|
||||||
public string GetHTMLLog (string name)
|
public string GetHTMLLog (string name)
|
||||||
{
|
{
|
||||||
|
|
||||||
List <SparkleCommit> commits = GetLog (name);
|
List <SparkleCommit> commits = GetLog (name);
|
||||||
|
|
||||||
List <ActivityDay> activity_days = new List <ActivityDay> ();
|
List <ActivityDay> activity_days = new List <ActivityDay> ();
|
||||||
|
|
||||||
foreach (SparkleCommit commit in commits) {
|
foreach (SparkleCommit commit in commits) {
|
||||||
|
@ -270,23 +274,9 @@ namespace SparkleShare {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
string event_log_html = EventLogHTML;
|
||||||
|
string day_entry_html = DayEntryHTML;
|
||||||
StreamReader reader;
|
string event_entry_html = EventEntryHTML;
|
||||||
|
|
||||||
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 = "";
|
string event_log = "";
|
||||||
|
@ -305,13 +295,13 @@ namespace SparkleShare {
|
||||||
|
|
||||||
foreach (string file_path in change_set.Edited) {
|
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>";
|
event_entry += "<dd><a href='#'>" + file_path + "</a></dd>";
|
||||||
|
|
||||||
} else {
|
} 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) {
|
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>";
|
event_entry += "<dd><a href='#'>" + file_path + "</a></dd>";
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
event_entry += "<dd>" + SparkleHelpers.CombineMore (SparklePaths.SparklePath ,name , file_path) + "</dd>";
|
event_entry += "<dd>" + file_path + "</dd>";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -346,30 +336,30 @@ namespace SparkleShare {
|
||||||
|
|
||||||
foreach (string file_path in change_set.Deleted) {
|
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>";
|
event_entry += "<dd><a href='#'>" + file_path + "</a></dd>";
|
||||||
|
|
||||||
} else {
|
} 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_entry += "</dl>";
|
||||||
|
|
||||||
event_entries += event_entry_html.Replace ("<!-- $event-entry-content -->", event_entry)
|
event_entries += event_entry_html.Replace ("<!-- $event-entry-content -->", event_entry)
|
||||||
.Replace ("<!-- $event-user-name -->", change_set.UserName)
|
.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"));
|
.Replace ("<!-- $event-time -->", change_set.DateTime.ToString ("H:mm"));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
string day_entry = "";
|
string day_entry = "";
|
||||||
|
|
||||||
DateTime today = DateTime.Now;
|
DateTime today = DateTime.Now;
|
||||||
|
@ -399,6 +389,7 @@ Console.WriteLine(GetAvatar (change_set.UserEmail, 32));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
string html = event_log_html.Replace ("<!-- $event-log-content -->", event_log);
|
string html = event_log_html.Replace ("<!-- $event-log-content -->", event_log);
|
||||||
|
|
||||||
return html;
|
return html;
|
||||||
|
@ -1074,4 +1065,21 @@ Console.WriteLine(GetAvatar (change_set.UserEmail, 32));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// All commits that happened on a day
|
||||||
|
public class ActivityDay : List <SparkleCommit>
|
||||||
|
{
|
||||||
|
|
||||||
|
public DateTime DateTime;
|
||||||
|
|
||||||
|
public ActivityDay (DateTime date_time)
|
||||||
|
{
|
||||||
|
|
||||||
|
DateTime = date_time;
|
||||||
|
DateTime = new DateTime (DateTime.Year, DateTime.Month, DateTime.Day);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -89,11 +89,11 @@ namespace SparkleShare {
|
||||||
|
|
||||||
case PlatformID.Unix:
|
case PlatformID.Unix:
|
||||||
SetProcessName ("sparkleshare");
|
SetProcessName ("sparkleshare");
|
||||||
Controller = new SparkleLinController ();
|
//Controller = new SparkleLinController ();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PlatformID.MacOSX:
|
case PlatformID.MacOSX:
|
||||||
//Controller = new SparkleMacController ();
|
Controller = new SparkleMacController ();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PlatformID.Win32NT:
|
case PlatformID.Win32NT:
|
||||||
|
|
|
@ -30,7 +30,20 @@
|
||||||
padding: 12px;
|
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;
|
text-overflow: ellipsis;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,6 +65,10 @@
|
||||||
color: <!-- $secondary-font-color -->;
|
color: <!-- $secondary-font-color -->;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
img {
|
||||||
|
margin-right: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
|
|
Loading…
Reference in a new issue