[notifications] restructure and make commit messages translatable
This commit is contained in:
parent
264af48a54
commit
cde668fe77
|
@ -216,7 +216,7 @@ namespace SparkleLib {
|
|||
/// <event cref="NewCommit">
|
||||
/// Raised when the repository has received one or multiple new remote commits
|
||||
/// </event>
|
||||
public delegate void NewCommitEventHandler (object o, NewCommitArgs args);
|
||||
public delegate void NewCommitEventHandler (SparkleCommit commit, string repository_path);
|
||||
|
||||
/// <event cref="ConflictDetected">
|
||||
/// Raised when the newly fetched commits are conflicting with local changes
|
||||
|
@ -786,13 +786,10 @@ namespace SparkleLib {
|
|||
}
|
||||
|
||||
|
||||
Commit commit = Head.CurrentCommit;
|
||||
|
||||
NewCommitArgs new_commit_args = new NewCommitArgs (commit.Author.Name, commit.Author.EmailAddress,
|
||||
commit.Message, LocalPath);
|
||||
List <SparkleCommit> commits = GetCommits (1);
|
||||
|
||||
if (NewCommit != null)
|
||||
NewCommit (this, new_commit_args);
|
||||
NewCommit (commits [0], LocalPath);
|
||||
|
||||
}
|
||||
|
||||
|
@ -1023,7 +1020,7 @@ namespace SparkleLib {
|
|||
break;
|
||||
}
|
||||
|
||||
message = "added ‘" + file_name + "’";
|
||||
message = "+ ‘" + file_name + "’";
|
||||
|
||||
}
|
||||
|
||||
|
@ -1034,7 +1031,7 @@ namespace SparkleLib {
|
|||
break;
|
||||
}
|
||||
|
||||
message = "edited ‘" + file_name + "’";
|
||||
message = "/ ‘" + file_name + "’";
|
||||
|
||||
}
|
||||
|
||||
|
@ -1045,7 +1042,7 @@ namespace SparkleLib {
|
|||
break;
|
||||
}
|
||||
|
||||
message = "deleted ‘" + file_name + "’";
|
||||
message = "- ‘" + file_name + "’";
|
||||
|
||||
}
|
||||
|
||||
|
@ -1054,7 +1051,7 @@ namespace SparkleLib {
|
|||
status.Removed.Count);
|
||||
|
||||
if (changes_count > 1)
|
||||
message += " and " + (changes_count - 1) + " more";
|
||||
message += " + " + (changes_count - 1);
|
||||
|
||||
return message;
|
||||
|
||||
|
|
|
@ -58,8 +58,7 @@ namespace SparkleShare {
|
|||
public delegate void ConflictNotificationRaisedEventHandler ();
|
||||
|
||||
public event NotificationRaisedEventHandler NotificationRaised;
|
||||
public delegate void NotificationRaisedEventHandler (string author, string email, string message,
|
||||
string repository_path);
|
||||
public delegate void NotificationRaisedEventHandler (SparkleCommit commit, string repository_path);
|
||||
|
||||
|
||||
public SparkleController ()
|
||||
|
@ -356,9 +355,11 @@ namespace SparkleShare {
|
|||
|
||||
SparkleRepo repo = new SparkleRepo (folder_path);
|
||||
|
||||
repo.NewCommit += delegate (object o, NewCommitArgs args) {
|
||||
repo.NewCommit += delegate (SparkleCommit commit, string repository_path) {
|
||||
|
||||
if (NotificationsEnabled && NotificationRaised != null)
|
||||
NotificationRaised (args.Author, args.Email, args.Message, args.RepositoryPath);
|
||||
NotificationRaised (commit, repository_path);
|
||||
|
||||
};
|
||||
|
||||
repo.FetchingStarted += delegate {
|
||||
|
|
|
@ -487,13 +487,17 @@ namespace SparkleShare {
|
|||
|
||||
}
|
||||
|
||||
|
||||
private ProgressBar ProgressBar;
|
||||
// The page shown whilst syncing
|
||||
private void ShowSyncingPage (string name)
|
||||
{
|
||||
|
||||
Reset ();
|
||||
|
||||
ProgressBar = new ProgressBar () {
|
||||
Fraction = 0
|
||||
};
|
||||
|
||||
VBox layout_vertical = new VBox (false, 0);
|
||||
|
||||
Label header = new Label ("<span size='x-large'><b>" +
|
||||
|
@ -524,7 +528,7 @@ namespace SparkleShare {
|
|||
|
||||
SparkleSpinner spinner = new SparkleSpinner (22);
|
||||
|
||||
Table table = new Table (2, 2, false) {
|
||||
Table table = new Table (3, 2, false) {
|
||||
RowSpacing = 12,
|
||||
ColumnSpacing = 9
|
||||
};
|
||||
|
@ -534,6 +538,7 @@ namespace SparkleShare {
|
|||
table.Attach (spinner, 0, 1, 0, 1);
|
||||
table.Attach (header, 1, 2, 0, 1);
|
||||
table.Attach (information, 1, 2, 1, 2);
|
||||
table.Attach (ProgressBar, 2, 3, 0, 2);
|
||||
|
||||
box.PackStart (table, false, false, 0);
|
||||
|
||||
|
@ -640,6 +645,14 @@ namespace SparkleShare {
|
|||
};
|
||||
|
||||
|
||||
fetcher.Progress.ProgressChanged += delegate {
|
||||
Application.Invoke (delegate { ProgressBar.Fraction = fetcher.Progress.Fraction;
|
||||
ProgressBar.ShowAll ();
|
||||
});
|
||||
Console.WriteLine ("!!!!!!!!!!!UPDATED BAR!!!!!!!!1");
|
||||
};
|
||||
|
||||
|
||||
fetcher.CloningFinished += delegate {
|
||||
|
||||
DeleteEvent -= PreventClose;
|
||||
|
|
|
@ -146,12 +146,12 @@ namespace SparkleShare {
|
|||
|
||||
if (repo.LocalPath.Equals (LocalPath)) {
|
||||
|
||||
// Remove the eventhooks
|
||||
/* // Remove the eventhooks
|
||||
repo.NewCommit -= UpdateEventLog;
|
||||
repo.PushingFinished -= UpdateEventLog;
|
||||
repo.PushingFailed -= UpdateEventLog;
|
||||
repo.PushingFailed -= UpdateEventLog; TODO: Move to controller
|
||||
repo.FetchingFinished -= UpdateEventLog;
|
||||
repo.FetchingFailed -= UpdateEventLog;
|
||||
repo.FetchingFailed -= UpdateEventLog;*/
|
||||
|
||||
}
|
||||
|
||||
|
@ -162,7 +162,7 @@ namespace SparkleShare {
|
|||
}
|
||||
|
||||
|
||||
public void UpdateEventLog (object o, EventArgs args)
|
||||
public void UpdateEventLog (SparkleCommit commit, string repository_path)
|
||||
{
|
||||
|
||||
Application.Invoke (delegate {
|
||||
|
@ -190,16 +190,16 @@ namespace SparkleShare {
|
|||
|
||||
commits = repo.GetCommits (25);
|
||||
|
||||
// Update the log when there are new remote changes
|
||||
/* // Update the log when there are new remote changes
|
||||
repo.NewCommit += UpdateEventLog;
|
||||
|
||||
// Update the log when changes are being sent
|
||||
repo.PushingFinished += UpdateEventLog;
|
||||
repo.PushingFailed += UpdateEventLog;
|
||||
|
||||
repo.FetchingFinished += UpdateEventLog;
|
||||
repo.FetchingFinished += UpdateEventLog; TODO: Move to controller
|
||||
repo.FetchingFailed += UpdateEventLog;
|
||||
|
||||
*/
|
||||
break;
|
||||
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
using Gtk;
|
||||
using Mono.Unix;
|
||||
using Mono.Unix.Native;
|
||||
using SparkleLib;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
|
@ -71,13 +72,56 @@ namespace SparkleShare {
|
|||
};
|
||||
|
||||
// Show a bubble when there are new changes
|
||||
SparkleShare.Controller.NotificationRaised += delegate (string author, string email, string message,
|
||||
string repository_path) {
|
||||
SparkleShare.Controller.NotificationRaised += delegate (SparkleCommit commit, string repository_path) {
|
||||
|
||||
string file_name = "";
|
||||
string message = null;
|
||||
|
||||
if (commit.Added.Count > 0) {
|
||||
|
||||
foreach (string added in commit.Added) {
|
||||
file_name = added;
|
||||
break;
|
||||
}
|
||||
|
||||
message = String.Format (_("added ‘{0}’"), file_name);
|
||||
|
||||
}
|
||||
|
||||
if (commit.Edited.Count > 0) {
|
||||
|
||||
foreach (string modified in commit.Edited) {
|
||||
file_name = modified;
|
||||
break;
|
||||
}
|
||||
|
||||
message = String.Format (_("edited ‘{0}’"), file_name);
|
||||
|
||||
}
|
||||
|
||||
if (commit.Deleted.Count > 0) {
|
||||
|
||||
foreach (string removed in commit.Deleted) {
|
||||
file_name = removed;
|
||||
break;
|
||||
}
|
||||
|
||||
message = String.Format (_("deleted ‘{0}’"), file_name);
|
||||
|
||||
}
|
||||
|
||||
int changes_count = (commit.Added.Count +
|
||||
commit.Edited.Count +
|
||||
commit.Deleted.Count);
|
||||
|
||||
if (changes_count > 1)
|
||||
message += " + " + (changes_count - 1);
|
||||
|
||||
|
||||
Application.Invoke (delegate {
|
||||
|
||||
SparkleBubble bubble = new SparkleBubble (author, message) {
|
||||
Icon = SparkleUIHelpers.GetAvatar (email, 32)
|
||||
SparkleBubble bubble = new SparkleBubble (commit.UserName, message) {
|
||||
Icon = SparkleUIHelpers.GetAvatar (commit.UserEmail, 32)
|
||||
};
|
||||
|
||||
bubble.AddAction ("", "Show Events", delegate {
|
||||
|
|
Loading…
Reference in a new issue