respect notify and sync settings

This commit is contained in:
Hylke Bons 2010-05-15 11:10:38 +01:00
parent 7101c9b074
commit 091b356249
2 changed files with 54 additions and 35 deletions

View file

@ -40,12 +40,11 @@ namespace SparkleShare {
public string UserEmail;
public string UserName;
public bool MonitorOnly;
public bool NotifyChanges;
public bool SyncChanges;
public SparkleRepo (string RepoPath) {
MonitorOnly = false;
Process = new Process();
Process.EnableRaisingEvents = false;
Process.StartInfo.RedirectStandardOutput = true;
@ -55,6 +54,17 @@ namespace SparkleShare {
LocalPath = RepoPath;
Process.StartInfo.WorkingDirectory = LocalPath;
string NotifyChangesFileName =
SparkleHelpers.CombineMore (LocalPath, ".git",
"sparkleshare.notify");
string SyncChangesFileName =
SparkleHelpers.CombineMore (LocalPath, ".git",
"sparkleshare.sync");
NotifyChanges = File.Exists (NotifyChangesFileName);
SyncChanges = File.Exists (SyncChangesFileName);
// Get user.name, example: "User Name"
UserName = "Anonymous";
Process.StartInfo.FileName = "git";
@ -121,7 +131,7 @@ namespace SparkleShare {
// Starts a time buffer when something changes
public void OnFileActivity (object o, FileSystemEventArgs args) {
WatcherChangeTypes wct = args.ChangeType;
if (!ShouldIgnore (args.Name) && !MonitorOnly) {
if (!ShouldIgnore (args.Name) && SyncChanges) {
Console.WriteLine("[Event][" + Name + "] " + wct.ToString() +
" '" + args.Name + "'");
StartBufferTimer ();
@ -381,18 +391,21 @@ namespace SparkleShare {
Gdk.Pixbuf Avatar,
bool ShowButtons) {
SparkleBubble StuffChangedBubble = new SparkleBubble (Title, "");
StuffChangedBubble.Icon = Avatar;
if (NotifyChanges) {
SparkleBubble StuffChangedBubble = new SparkleBubble (Title, "");
StuffChangedBubble.Icon = Avatar;
// Add a button to open the folder where the changed file is
if (ShowButtons)
StuffChangedBubble.AddAction ("", "Open Folder",
delegate {
Process.StartInfo.FileName = "xdg-open";
Process.StartInfo.Arguments = LocalPath;
Process.Start();
Process.StartInfo.FileName = "git";
} );
}
// Add a button to open the folder where the changed file is
if (ShowButtons)
StuffChangedBubble.AddAction ("", "Open Folder",
delegate {
Process.StartInfo.FileName = "xdg-open";
Process.StartInfo.Arguments = LocalPath;
Process.Start();
Process.StartInfo.FileName = "git";
} );
}
}

View file

@ -254,38 +254,44 @@ namespace SparkleShare {
LocalPathBox.PackStart (Property2, false, false, 0);
LocalPathBox.PackStart (Value2, false, false, 0);
CheckButton NotifyCheckButton =
CheckButton NotifyChangesCheckButton =
new CheckButton ("Notify me when something changes");
string NotifyFileName =
string NotifyChangesFileName =
SparkleHelpers.CombineMore (SparkleRepo.LocalPath,
".git", "sparkleshare.notify");
if (File.Exists (NotifyFileName))
NotifyCheckButton.Active = true;
if (File.Exists (NotifyChangesFileName))
NotifyChangesCheckButton.Active = true;
NotifyCheckButton.Toggled += delegate {
if (File.Exists (NotifyFileName))
File.Delete (NotifyFileName);
else
File.Create (NotifyFileName);
NotifyChangesCheckButton.Toggled += delegate {
if (File.Exists (NotifyChangesFileName)) {
SparkleRepo.NotifyChanges = false;
File.Delete (NotifyChangesFileName);
} else {
SparkleRepo.NotifyChanges = true;
File.Create (NotifyChangesFileName);
}
};
CheckButton SyncCheckButton =
CheckButton SyncChangesCheckButton =
new CheckButton ("Synchronize my changes");
string SyncFileName =
string SyncChangesFileName =
SparkleHelpers.CombineMore (SparkleRepo.LocalPath,
".git", "sparkleshare.sync");
if (File.Exists (SyncFileName))
SyncCheckButton.Active = true;
if (File.Exists (SyncChangesFileName))
SyncChangesCheckButton.Active = true;
SyncCheckButton.Toggled += delegate {
if (File.Exists (SyncFileName))
File.Delete (SyncFileName);
else
File.Create (SyncFileName);
SyncChangesCheckButton.Toggled += delegate {
if (File.Exists (SyncChangesFileName)) {
SparkleRepo.SyncChanges = false;
File.Delete (SyncChangesFileName);
} else {
SparkleRepo.SyncChanges = true;
File.Create (SyncChangesFileName);
}
};
VBox VBox = new VBox (false, 0);
@ -295,8 +301,8 @@ namespace SparkleShare {
Table.Attach (RemoteUrlBox, 0, 2, 0, 1);
Table.Attach (LocalPathBox, 0, 2, 1, 2);
Table.Attach (NotifyCheckButton, 0, 2, 4, 5);
Table.Attach (SyncCheckButton, 0, 2, 5, 6);
Table.Attach (NotifyChangesCheckButton, 0, 2, 4, 5);
Table.Attach (SyncChangesCheckButton, 0, 2, 5, 6);
Label PeopleLabel =
new Label ("<span font_size='large'><b>Active users" +