Merge pull request #320 from wimh/pullreq2

miscellaneous changes
This commit is contained in:
Hylke Bons 2011-09-07 10:31:59 -07:00
commit f35a24164f
19 changed files with 96 additions and 85 deletions

View file

@ -45,6 +45,9 @@ namespace SparkleLib {
string output = git.StandardOutput.ReadToEnd ();
git.WaitForExit ();
if (output.Length < 40)
return null;
return output.Substring (0, 40);
}
}
@ -490,7 +493,8 @@ namespace SparkleLib {
if ((change_set.Added.Count +
change_set.Edited.Count +
change_set.Deleted.Count) > 0) {
change_set.Deleted.Count +
change_set.MovedFrom.Count) > 0) {
change_set.Notes.AddRange (GetNotes (change_set.Revision));
change_sets.Add (change_set);

View file

@ -32,6 +32,7 @@ namespace SparkleLib {
public SparkleBackend (string name, string [] paths)
{
Name = name;
Path = "git";
foreach (string path in paths) {
if (File.Exists (path)) {

View file

@ -444,22 +444,25 @@ namespace SparkleLib {
if (SyncStatusChanged != null)
SyncStatusChanged (SyncStatus.Idle);
SparkleChangeSet change_set = GetChangeSets (1) [0];
List<SparkleChangeSet> change_sets = GetChangeSets (1);
if (change_sets != null && change_sets.Count > 0) {
SparkleChangeSet change_set = change_sets [0];
bool note_added = false;
foreach (string added in change_set.Added) {
if (added.Contains (".notes")) {
if (NewNote != null)
NewNote (change_set.User.Name, change_set.User.Email);
bool note_added = false;
foreach (string added in change_set.Added) {
if (added.Contains (".notes")) {
if (NewNote != null)
NewNote (change_set.User.Name, change_set.User.Email);
note_added = true;
break;
note_added = true;
break;
}
}
}
if (!note_added) {
if (NewChangeSet != null)
NewChangeSet (change_set);
if (!note_added) {
if (NewChangeSet != null)
NewChangeSet (change_set);
}
}
// There could be changes from a resolved

View file

@ -212,7 +212,7 @@ namespace SparkleShare {
string note = match.Groups [3].Value;
Thread thread = new Thread (new ThreadStart (delegate {
SparkleShare.Controller.AddNoteToFolder (folder_name, revision, note);
Program.Controller.AddNoteToFolder (folder_name, revision, note);
}));
thread.Start ();

View file

@ -75,8 +75,8 @@ namespace SparkleShare {
UserInfoForm.Cells [0].LineBreakMode = NSLineBreakMode.TruncatingTail;
UserInfoForm.Cells [1].LineBreakMode = NSLineBreakMode.TruncatingTail;
UserInfoForm.Cells [0].StringValue = SparkleShare.Controller.UserName;
UserInfoForm.Cells [1].StringValue = SparkleShare.Controller.UserEmail;
UserInfoForm.Cells [0].StringValue = Program.Controller.UserName;
UserInfoForm.Cells [1].StringValue = Program.Controller.UserEmail;
// TODO: Ugly hack, do properly with events
timer = new Timer () {
@ -102,7 +102,7 @@ namespace SparkleShare {
InvokeOnMainThread (delegate {
bool name_is_valid = !UserInfoForm.Cells [0].StringValue.Trim ().Equals ("");
bool email_is_valid = SparkleShare.Controller.IsValidEmail (
bool email_is_valid = Program.Controller.IsValidEmail (
UserInfoForm.Cells [1].StringValue.Trim ());
ContinueButton.Enabled = (name_is_valid && email_is_valid);
@ -370,7 +370,7 @@ namespace SparkleShare {
};
OpenFolderButton.Activated += delegate {
SparkleShare.Controller.OpenSparkleShareFolder (Controller.SyncingFolder);
Program.Controller.OpenSparkleShareFolder (Controller.SyncingFolder);
};
Buttons.Add (FinishButton);

View file

@ -80,8 +80,8 @@
<Compile Include="SparkleMacController.cs" />
<Compile Include="SparkleStatusIcon.cs" />
<Compile Include="SparkleUI.cs" />
<Compile Include="..\SparkleShare.cs">
<Link>SparkleShare.cs</Link>
<Compile Include="..\Program.cs">
<Link>Program.cs</Link>
</Compile>
<Compile Include="SparkleAbout.cs" />
<Compile Include="SparkleAlert.cs" />

View file

@ -142,7 +142,7 @@ namespace SparkleShare {
};
FolderMenuItem.Activated += delegate {
SparkleShare.Controller.OpenSparkleShareFolder ();
Program.Controller.OpenSparkleShareFolder ();
};
FolderMenuItem.Image = NSImage.ImageNamed ("sparkleshare-mac");
@ -150,18 +150,18 @@ namespace SparkleShare {
Menu.AddItem (FolderMenuItem);
FolderMenuItems = new NSMenuItem [SparkleShare.Controller.Folders.Count];
FolderMenuItems = new NSMenuItem [Program.Controller.Folders.Count];
if (Controller.Folders.Length > 0) {
Tasks = new EventHandler [SparkleShare.Controller.Folders.Count];
Tasks = new EventHandler [Program.Controller.Folders.Count];
int i = 0;
foreach (string folder_name in SparkleShare.Controller.Folders) {
foreach (string folder_name in Program.Controller.Folders) {
NSMenuItem item = new NSMenuItem ();
item.Title = folder_name;
if (SparkleShare.Controller.UnsyncedFolders.Contains (folder_name))
if (Program.Controller.UnsyncedFolders.Contains (folder_name))
item.Image = NSImage.ImageNamed ("NSCaution");
else
item.Image = NSImage.ImageNamed ("NSFolder");
@ -192,7 +192,7 @@ namespace SparkleShare {
Title = "Add Remote Folder…"
};
if (!SparkleShare.Controller.FirstRun) {
if (!Program.Controller.FirstRun) {
SyncMenuItem.Activated += delegate {
InvokeOnMainThread (delegate {
NSApplication.SharedApplication.ActivateIgnoringOtherApps (true);
@ -236,16 +236,16 @@ namespace SparkleShare {
NotificationsMenuItem = new NSMenuItem ();
if (SparkleShare.Controller.NotificationsEnabled)
if (Program.Controller.NotificationsEnabled)
NotificationsMenuItem.Title = "Turn Notifications Off";
else
NotificationsMenuItem.Title = "Turn Notifications On";
NotificationsMenuItem.Activated += delegate {
SparkleShare.Controller.ToggleNotifications ();
Program.Controller.ToggleNotifications ();
InvokeOnMainThread (delegate {
if (SparkleShare.Controller.NotificationsEnabled)
if (Program.Controller.NotificationsEnabled)
NotificationsMenuItem.Title = "Turn Notifications Off";
else
NotificationsMenuItem.Title = "Turn Notifications On";
@ -285,7 +285,7 @@ namespace SparkleShare {
private EventHandler OpenFolderDelegate (string name)
{
return delegate {
SparkleShare.Controller.OpenSparkleShareFolder (name);
Program.Controller.OpenSparkleShareFolder (name);
};
}

View file

@ -65,7 +65,7 @@ namespace SparkleShare {
NSApplication.SharedApplication.ApplicationIconImage
= NSImage.ImageNamed ("sparkleshare.icns");
if (!SparkleShare.Controller.BackendIsPresent) {
if (!Program.Controller.BackendIsPresent) {
this.alert = new SparkleAlert ();
this.alert.RunModal ();
return;
@ -79,7 +79,7 @@ namespace SparkleShare {
StatusIcon = new SparkleStatusIcon ();
Bubbles = new SparkleBubbles ();
if (SparkleShare.Controller.FirstRun) {
if (Program.Controller.FirstRun) {
Setup = new SparkleSetup ();
Setup.Controller.ShowSetupPage ();
}
@ -95,7 +95,7 @@ namespace SparkleShare {
NSImage folder_icon = new NSImage (folder_icon_path);
NSWorkspace.SharedWorkspace.SetIconforFile (folder_icon,
SparkleShare.Controller.SparklePath, 0);
Program.Controller.SparklePath, 0);
}
@ -123,7 +123,7 @@ namespace SparkleShare {
public override void WillTerminate (NSNotification notification)
{
SparkleShare.Controller.Quit ();
Program.Controller.Quit ();
}
}
}

View file

@ -25,7 +25,7 @@ SOURCES = \
SparkleSetup.cs \
SparkleSetupController.cs \
SparkleSetupWindow.cs \
SparkleShare.cs \
Program.cs \
SparkleSpinner.cs \
SparkleStatusIcon.cs \
SparkleStatusIconController.cs \
@ -41,7 +41,7 @@ SOURCES = \
SparkleSetup.cs \
SparkleSetupController.cs \
SparkleSetupWindow.cs \
SparkleShare.cs \
Program.cs \
SparkleSpinner.cs \
SparkleStatusIcon.cs \
SparkleStatusIconController.cs \

View file

@ -30,7 +30,7 @@ using SparkleLib.Options;
namespace SparkleShare {
// This is SparkleShare!
public class SparkleShare {
public class Program {
public static SparkleController Controller;
public static SparkleUI UI;

View file

@ -27,23 +27,23 @@ namespace SparkleShare {
public SparkleBubblesController ()
{
SparkleShare.Controller.ConflictNotificationRaised += delegate {
Program.Controller.ConflictNotificationRaised += delegate {
ShowBubble ("Ouch! Mid-air collision!",
"Don't worry, SparkleShare made a copy of each conflicting file.",
null);
};
SparkleShare.Controller.NotificationRaised += delegate (string user_name, string user_email,
Program.Controller.NotificationRaised += delegate (string user_name, string user_email,
string message, string folder_path) {
ShowBubble (user_name, message,
SparkleShare.Controller.GetAvatar (user_email, 36));
Program.Controller.GetAvatar (user_email, 36));
};
}
public void ShowBubble (string title, string subtext, string image_path)
{
if (ShowBubbleEvent != null && SparkleShare.Controller.NotificationsEnabled)
if (ShowBubbleEvent != null && Program.Controller.NotificationsEnabled)
ShowBubbleEvent (title, subtext, image_path);
}
}

View file

@ -92,7 +92,7 @@ namespace SparkleShare {
string note = match.Groups [3].Value;
Thread thread = new Thread (new ThreadStart (delegate {
SparkleShare.Controller.AddNoteToFolder (folder_name, revision, note);
Program.Controller.AddNoteToFolder (folder_name, revision, note);
}));
thread.Start ();
@ -203,6 +203,9 @@ namespace SparkleShare {
if (html == null)
html = Controller.HTML;
if (html == null)
return;
html = html.Replace ("<!-- $body-font-size -->", (double) (Style.FontDescription.Size / 1024 + 3) + "px");
html = html.Replace ("<!-- $day-entry-header-font-size -->", (Style.FontDescription.Size / 1024 + 3) + "px");
html = html.Replace ("<!-- $a-color -->", "#0085cf");

View file

@ -69,14 +69,14 @@ namespace SparkleShare {
public string HTML {
get {
List<SparkleChangeSet> change_sets = SparkleShare.Controller.GetLog (this.selected_folder);
return SparkleShare.Controller.GetHTMLLog (change_sets);
List<SparkleChangeSet> change_sets = Program.Controller.GetLog (this.selected_folder);
return Program.Controller.GetHTMLLog (change_sets);
}
}
public string [] Folders {
get {
return SparkleShare.Controller.Folders.ToArray ();
return Program.Controller.Folders.ToArray ();
}
}
@ -86,19 +86,19 @@ namespace SparkleShare {
public SparkleEventLogController ()
{
SparkleShare.Controller.AvatarFetched += delegate {
Program.Controller.AvatarFetched += delegate {
if (UpdateContentEvent != null)
UpdateContentEvent (HTML);
};
SparkleShare.Controller.OnIdle += delegate {
Program.Controller.OnIdle += delegate {
if (UpdateContentEvent != null)
UpdateContentEvent (HTML);
};
SparkleShare.Controller.FolderListChanged += delegate {
Program.Controller.FolderListChanged += delegate {
if (this.selected_folder != null &&
!SparkleShare.Controller.Folders.Contains (this.selected_folder)) {
!Program.Controller.Folders.Contains (this.selected_folder)) {
this.selected_folder = null;
}
@ -110,7 +110,7 @@ namespace SparkleShare {
UpdateContentEvent (HTML);
};
SparkleShare.Controller.NotificationRaised += delegate {
Program.Controller.NotificationRaised += delegate {
if (UpdateContentEvent != null)
UpdateContentEvent (HTML);
};

View file

@ -77,7 +77,7 @@ namespace SparkleShare {
Xalign = 0
};
NameEntry = new Entry (SparkleShare.Controller.UserName);
NameEntry = new Entry (Program.Controller.UserName);
NameEntry.Changed += delegate {
CheckSetupPage ();
};
@ -149,7 +149,7 @@ namespace SparkleShare {
ListStore server_store = new ListStore (typeof (string));
foreach (string host in SparkleShare.Controller.PreviousHosts)
foreach (string host in Program.Controller.PreviousHosts)
server_store.AppendValues (host);
ServerEntry.Completion.Model = server_store;
@ -239,7 +239,7 @@ namespace SparkleShare {
ListStore folder_store = new ListStore (typeof (string));
//foreach (string host in SparkleShare.Controller.FolderPaths)
//foreach (string host in Program.Controller.FolderPaths)
// folder_store.AppendValues (host);
FolderEntry.Completion.Model = folder_store;
@ -411,7 +411,7 @@ namespace SparkleShare {
Button open_folder_button = new Button (_("Open Folder"));
open_folder_button.Clicked += delegate {
SparkleShare.Controller.OpenSparkleShareFolder (Controller.SyncingFolder);
Program.Controller.OpenSparkleShareFolder (Controller.SyncingFolder);
};
Button finish_button = new Button (_("Finish"));
@ -441,7 +441,7 @@ namespace SparkleShare {
private void CheckSetupPage ()
{
if (NameEntry.Text.Length > 0 &&
SparkleShare.Controller.IsValidEmail (EmailEntry.Text)) {
Program.Controller.IsValidEmail (EmailEntry.Text)) {
NextButton.Sensitive = true;
} else {

View file

@ -97,11 +97,11 @@ namespace SparkleShare {
public void SetupPageCompleted (string full_name, string email)
{
SparkleShare.Controller.UserName = full_name;
SparkleShare.Controller.UserEmail = email;
Program.Controller.UserName = full_name;
Program.Controller.UserEmail = email;
SparkleShare.Controller.GenerateKeyPair ();
SparkleShare.Controller.UpdateState ();
Program.Controller.GenerateKeyPair ();
Program.Controller.UpdateState ();
if (ChangePageEvent != null)
ChangePageEvent (PageType.Add);
@ -117,14 +117,14 @@ namespace SparkleShare {
if (ChangePageEvent != null)
ChangePageEvent (PageType.Syncing);
SparkleShare.Controller.FolderFetched += delegate {
Program.Controller.FolderFetched += delegate {
if (ChangePageEvent != null)
ChangePageEvent (PageType.Finished);
this.syncing_folder = "";
};
SparkleShare.Controller.FolderFetchError += delegate (string remote_url) {
Program.Controller.FolderFetchError += delegate (string remote_url) {
this.previous_url = remote_url;
if (ChangePageEvent != null)
@ -133,12 +133,12 @@ namespace SparkleShare {
this.syncing_folder = "";
};
SparkleShare.Controller.FolderFetching += delegate (double percentage) {
Program.Controller.FolderFetching += delegate (double percentage) {
if (UpdateProgressBarEvent != null)
UpdateProgressBarEvent (percentage);
};
SparkleShare.Controller.FetchFolder (server, folder_name);
Program.Controller.FetchFolder (server, folder_name);
}
@ -151,7 +151,7 @@ namespace SparkleShare {
public void SyncingCancelled ()
{
SparkleShare.Controller.StopFetcher ();
Program.Controller.StopFetcher ();
if (ChangePageEvent != null)
ChangePageEvent (PageType.Add);
@ -162,7 +162,7 @@ namespace SparkleShare {
{
this.previous_server = "";
this.previous_folder = "";
SparkleShare.Controller.UpdateState ();
Program.Controller.UpdateState ();
}
}
}

View file

@ -67,7 +67,7 @@
<Compile Include="SparkleSetup.cs" />
<Compile Include="SparkleSetupController.cs" />
<Compile Include="SparkleSetupWindow.cs" />
<Compile Include="SparkleShare.cs" />
<Compile Include="Program.cs" />
<Compile Include="SparkleSpinner.cs" />
<Compile Include="SparkleStatusIcon.cs" />
<Compile Include="SparkleStatusIconController.cs" />

View file

@ -193,18 +193,18 @@ namespace SparkleShare {
};
folder_item.Activated += delegate {
SparkleShare.Controller.OpenSparkleShareFolder ();
Program.Controller.OpenSparkleShareFolder ();
};
Menu.Add (folder_item);
if (SparkleShare.Controller.Folders.Count > 0) {
if (Program.Controller.Folders.Count > 0) {
// Creates a menu item for each repository with a link to their logs
foreach (string folder_name in SparkleShare.Controller.Folders) {
foreach (string folder_name in Program.Controller.Folders) {
Gdk.Pixbuf folder_icon;
if (SparkleShare.Controller.UnsyncedFolders.Contains (folder_name)) {
if (Program.Controller.UnsyncedFolders.Contains (folder_name)) {
folder_icon = IconTheme.Default.LoadIcon ("dialog-error", 16,
IconLookupFlags.GenericFallback);
@ -234,7 +234,7 @@ namespace SparkleShare {
// Opens the wizard to add a new remote folder
MenuItem sync_item = new MenuItem (_("Add Remote Folder…"));
if (SparkleShare.Controller.FirstRun)
if (Program.Controller.FirstRun)
sync_item.Sensitive = false;
sync_item.Activated += delegate {
@ -258,7 +258,7 @@ namespace SparkleShare {
MenuItem recent_events_item = new MenuItem (_("Show Recent Events"));
if (SparkleShare.Controller.Folders.Count < 1)
if (Program.Controller.Folders.Count < 1)
recent_events_item.Sensitive = false;
recent_events_item.Activated += delegate {
@ -275,13 +275,13 @@ namespace SparkleShare {
MenuItem notify_item;
if (SparkleShare.Controller.NotificationsEnabled)
if (Program.Controller.NotificationsEnabled)
notify_item = new MenuItem (_("Turn Notifications Off"));
else
notify_item = new MenuItem (_("Turn Notifications On"));
notify_item.Activated += delegate {
SparkleShare.Controller.ToggleNotifications ();
Program.Controller.ToggleNotifications ();
CreateMenu ();
};
@ -308,7 +308,7 @@ namespace SparkleShare {
MenuItem quit_item = new MenuItem (_("Quit"));
quit_item.Activated += delegate {
SparkleShare.Controller.Quit ();
Program.Controller.Quit ();
};
Menu.Add (quit_item);
@ -325,7 +325,7 @@ namespace SparkleShare {
private EventHandler OpenFolderDelegate (string name)
{
return delegate {
SparkleShare.Controller.OpenSparkleShareFolder (name);
Program.Controller.OpenSparkleShareFolder (name);
};
}

View file

@ -38,29 +38,29 @@ namespace SparkleShare {
public string [] Folders {
get {
return SparkleShare.Controller.Folders.ToArray ();
return Program.Controller.Folders.ToArray ();
}
}
public string FolderSize {
get {
return SparkleShare.Controller.FolderSize;
return Program.Controller.FolderSize;
}
}
public SparkleStatusIconController ()
{
SparkleShare.Controller.FolderSizeChanged += delegate {
Program.Controller.FolderSizeChanged += delegate {
if (UpdateMenuEvent != null)
UpdateMenuEvent (CurrentState);
};
SparkleShare.Controller.FolderListChanged += delegate {
Program.Controller.FolderListChanged += delegate {
if (UpdateMenuEvent != null)
UpdateMenuEvent (CurrentState);
};
SparkleShare.Controller.OnIdle += delegate {
Program.Controller.OnIdle += delegate {
if (CurrentState != IconState.Error)
CurrentState = IconState.Idle;
@ -68,7 +68,7 @@ namespace SparkleShare {
UpdateMenuEvent (CurrentState);
};
SparkleShare.Controller.OnSyncing += delegate {
Program.Controller.OnSyncing += delegate {
CurrentState = IconState.Syncing;
// TODO up down both
@ -77,7 +77,7 @@ namespace SparkleShare {
UpdateMenuEvent (IconState.Syncing);
};
SparkleShare.Controller.OnError += delegate {
Program.Controller.OnError += delegate {
CurrentState = IconState.Error;
if (UpdateMenuEvent != null)

View file

@ -59,12 +59,12 @@ namespace SparkleShare {
StatusIcon = new SparkleStatusIcon ();
Bubbles = new SparkleBubbles ();
if (SparkleShare.Controller.FirstRun) {
if (Program.Controller.FirstRun) {
Setup = new SparkleSetup ();
Setup.Controller.ShowSetupPage ();
}
SparkleShare.Controller.OnQuitWhileSyncing += delegate {
Program.Controller.OnQuitWhileSyncing += delegate {
// TODO: Pop up a warning when quitting whilst syncing
};
}