respect notify and sync settings
This commit is contained in:
parent
7101c9b074
commit
091b356249
|
@ -40,12 +40,11 @@ namespace SparkleShare {
|
||||||
|
|
||||||
public string UserEmail;
|
public string UserEmail;
|
||||||
public string UserName;
|
public string UserName;
|
||||||
public bool MonitorOnly;
|
public bool NotifyChanges;
|
||||||
|
public bool SyncChanges;
|
||||||
|
|
||||||
public SparkleRepo (string RepoPath) {
|
public SparkleRepo (string RepoPath) {
|
||||||
|
|
||||||
MonitorOnly = false;
|
|
||||||
|
|
||||||
Process = new Process();
|
Process = new Process();
|
||||||
Process.EnableRaisingEvents = false;
|
Process.EnableRaisingEvents = false;
|
||||||
Process.StartInfo.RedirectStandardOutput = true;
|
Process.StartInfo.RedirectStandardOutput = true;
|
||||||
|
@ -55,6 +54,17 @@ namespace SparkleShare {
|
||||||
LocalPath = RepoPath;
|
LocalPath = RepoPath;
|
||||||
Process.StartInfo.WorkingDirectory = LocalPath;
|
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"
|
// Get user.name, example: "User Name"
|
||||||
UserName = "Anonymous";
|
UserName = "Anonymous";
|
||||||
Process.StartInfo.FileName = "git";
|
Process.StartInfo.FileName = "git";
|
||||||
|
@ -121,7 +131,7 @@ namespace SparkleShare {
|
||||||
// Starts a time buffer when something changes
|
// Starts a time buffer when something changes
|
||||||
public void OnFileActivity (object o, FileSystemEventArgs args) {
|
public void OnFileActivity (object o, FileSystemEventArgs args) {
|
||||||
WatcherChangeTypes wct = args.ChangeType;
|
WatcherChangeTypes wct = args.ChangeType;
|
||||||
if (!ShouldIgnore (args.Name) && !MonitorOnly) {
|
if (!ShouldIgnore (args.Name) && SyncChanges) {
|
||||||
Console.WriteLine("[Event][" + Name + "] " + wct.ToString() +
|
Console.WriteLine("[Event][" + Name + "] " + wct.ToString() +
|
||||||
" '" + args.Name + "'");
|
" '" + args.Name + "'");
|
||||||
StartBufferTimer ();
|
StartBufferTimer ();
|
||||||
|
@ -381,18 +391,21 @@ namespace SparkleShare {
|
||||||
Gdk.Pixbuf Avatar,
|
Gdk.Pixbuf Avatar,
|
||||||
bool ShowButtons) {
|
bool ShowButtons) {
|
||||||
|
|
||||||
SparkleBubble StuffChangedBubble = new SparkleBubble (Title, "");
|
if (NotifyChanges) {
|
||||||
StuffChangedBubble.Icon = Avatar;
|
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";
|
|
||||||
} );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -254,38 +254,44 @@ namespace SparkleShare {
|
||||||
LocalPathBox.PackStart (Property2, false, false, 0);
|
LocalPathBox.PackStart (Property2, false, false, 0);
|
||||||
LocalPathBox.PackStart (Value2, false, false, 0);
|
LocalPathBox.PackStart (Value2, false, false, 0);
|
||||||
|
|
||||||
CheckButton NotifyCheckButton =
|
CheckButton NotifyChangesCheckButton =
|
||||||
new CheckButton ("Notify me when something changes");
|
new CheckButton ("Notify me when something changes");
|
||||||
|
|
||||||
string NotifyFileName =
|
string NotifyChangesFileName =
|
||||||
SparkleHelpers.CombineMore (SparkleRepo.LocalPath,
|
SparkleHelpers.CombineMore (SparkleRepo.LocalPath,
|
||||||
".git", "sparkleshare.notify");
|
".git", "sparkleshare.notify");
|
||||||
|
|
||||||
if (File.Exists (NotifyFileName))
|
if (File.Exists (NotifyChangesFileName))
|
||||||
NotifyCheckButton.Active = true;
|
NotifyChangesCheckButton.Active = true;
|
||||||
|
|
||||||
NotifyCheckButton.Toggled += delegate {
|
NotifyChangesCheckButton.Toggled += delegate {
|
||||||
if (File.Exists (NotifyFileName))
|
if (File.Exists (NotifyChangesFileName)) {
|
||||||
File.Delete (NotifyFileName);
|
SparkleRepo.NotifyChanges = false;
|
||||||
else
|
File.Delete (NotifyChangesFileName);
|
||||||
File.Create (NotifyFileName);
|
} else {
|
||||||
|
SparkleRepo.NotifyChanges = true;
|
||||||
|
File.Create (NotifyChangesFileName);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
CheckButton SyncCheckButton =
|
CheckButton SyncChangesCheckButton =
|
||||||
new CheckButton ("Synchronize my changes");
|
new CheckButton ("Synchronize my changes");
|
||||||
|
|
||||||
string SyncFileName =
|
string SyncChangesFileName =
|
||||||
SparkleHelpers.CombineMore (SparkleRepo.LocalPath,
|
SparkleHelpers.CombineMore (SparkleRepo.LocalPath,
|
||||||
".git", "sparkleshare.sync");
|
".git", "sparkleshare.sync");
|
||||||
|
|
||||||
if (File.Exists (SyncFileName))
|
if (File.Exists (SyncChangesFileName))
|
||||||
SyncCheckButton.Active = true;
|
SyncChangesCheckButton.Active = true;
|
||||||
|
|
||||||
SyncCheckButton.Toggled += delegate {
|
SyncChangesCheckButton.Toggled += delegate {
|
||||||
if (File.Exists (SyncFileName))
|
if (File.Exists (SyncChangesFileName)) {
|
||||||
File.Delete (SyncFileName);
|
SparkleRepo.SyncChanges = false;
|
||||||
else
|
File.Delete (SyncChangesFileName);
|
||||||
File.Create (SyncFileName);
|
} else {
|
||||||
|
SparkleRepo.SyncChanges = true;
|
||||||
|
File.Create (SyncChangesFileName);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
VBox VBox = new VBox (false, 0);
|
VBox VBox = new VBox (false, 0);
|
||||||
|
@ -295,8 +301,8 @@ namespace SparkleShare {
|
||||||
|
|
||||||
Table.Attach (RemoteUrlBox, 0, 2, 0, 1);
|
Table.Attach (RemoteUrlBox, 0, 2, 0, 1);
|
||||||
Table.Attach (LocalPathBox, 0, 2, 1, 2);
|
Table.Attach (LocalPathBox, 0, 2, 1, 2);
|
||||||
Table.Attach (NotifyCheckButton, 0, 2, 4, 5);
|
Table.Attach (NotifyChangesCheckButton, 0, 2, 4, 5);
|
||||||
Table.Attach (SyncCheckButton, 0, 2, 5, 6);
|
Table.Attach (SyncChangesCheckButton, 0, 2, 5, 6);
|
||||||
|
|
||||||
Label PeopleLabel =
|
Label PeopleLabel =
|
||||||
new Label ("<span font_size='large'><b>Active users" +
|
new Label ("<span font_size='large'><b>Active users" +
|
||||||
|
|
Loading…
Reference in a new issue