make global setting for notifications work

This commit is contained in:
Hylke Bons 2010-05-19 12:21:15 +01:00
parent 44ad4a9b45
commit 1e04bade71
2 changed files with 21 additions and 33 deletions

View file

@ -40,8 +40,6 @@ namespace SparkleShare {
public string UserEmail; public string UserEmail;
public string UserName; public string UserName;
public bool NotifyChanges;
public bool SyncChanges;
public SparkleRepo (string RepoPath) { public SparkleRepo (string RepoPath) {
@ -54,17 +52,6 @@ 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";
@ -131,7 +118,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) && SyncChanges) { if (!ShouldIgnore (args.Name)) {
Console.WriteLine ("[Event][" + Name + "] " + wct.ToString() + Console.WriteLine ("[Event][" + Name + "] " + wct.ToString() +
" '" + args.Name + "'"); " '" + args.Name + "'");
StartBufferTimer (); StartBufferTimer ();
@ -261,9 +248,14 @@ namespace SparkleShare {
Process.Start(); Process.Start();
string LastCommitUserName = Process.StandardOutput.ReadToEnd().Trim (); string LastCommitUserName = Process.StandardOutput.ReadToEnd().Trim ();
ShowEventBubble (LastCommitUserName + " " + LastCommitMessage, string NotifySettingFile =
SparkleHelpers.GetAvatar (LastCommitEmail, 48), SparkleHelpers.CombineMore (SparklePaths.SparkleConfigPath,
true); "sparkleshare.notify");
if (File.Exists (NotifySettingFile))
ShowEventBubble (LastCommitUserName + " " + LastCommitMessage,
SparkleHelpers.GetAvatar (LastCommitEmail, 48),
true);
} }
@ -391,20 +383,18 @@ namespace SparkleShare {
Gdk.Pixbuf Avatar, Gdk.Pixbuf Avatar,
bool ShowButtons) { bool ShowButtons) {
if (NotifyChanges) {
SparkleBubble StuffChangedBubble = new SparkleBubble (Title, ""); SparkleBubble StuffChangedBubble = new SparkleBubble (Title, "");
StuffChangedBubble.Icon = Avatar; StuffChangedBubble.Icon = Avatar;
// Add a button to open the folder where the changed file is // Add a button to open the folder where the changed file is
if (ShowButtons) if (ShowButtons)
StuffChangedBubble.AddAction ("", "Open Folder", StuffChangedBubble.AddAction ("", "Open Folder",
delegate { delegate {
Process.StartInfo.FileName = "xdg-open"; Process.StartInfo.FileName = "xdg-open";
Process.StartInfo.Arguments = LocalPath; Process.StartInfo.Arguments = LocalPath;
Process.Start(); Process.Start();
Process.StartInfo.FileName = "git"; Process.StartInfo.FileName = "git";
} ); } );
}
} }

View file

@ -18,6 +18,7 @@ using Gtk;
using Mono.Unix; using Mono.Unix;
using SparkleShare; using SparkleShare;
using System; using System;
using System.IO;
using System.Diagnostics; using System.Diagnostics;
namespace SparkleShare { namespace SparkleShare {
@ -69,27 +70,24 @@ namespace SparkleShare {
Menu.Add (NotifyCheckMenuItem); Menu.Add (NotifyCheckMenuItem);
Menu.Add (new SeparatorMenuItem ()); Menu.Add (new SeparatorMenuItem ());
/*
string NotifyChangesFileName = string NotifyChangesFileName =
SparkleHelpers.CombineMore (SparkleRepo.LocalPath, SparkleHelpers.CombineMore (SparklePaths.SparkleConfigPath,
".git", "sparkleshare.notify"); "sparkleshare.notify");
if (File.Exists (NotifyChangesFileName)) if (System.IO.File.Exists (NotifyChangesFileName))
NotifyChangesCheckButton.Active = true; NotifyCheckMenuItem.Active = true;
NotifyChangesCheckButton.Toggled += delegate { NotifyCheckMenuItem.Toggled += delegate {
if (File.Exists (NotifyChangesFileName)) { if (System.IO.File.Exists (NotifyChangesFileName)) {
SparkleRepo.NotifyChanges = false;
File.Delete (NotifyChangesFileName); File.Delete (NotifyChangesFileName);
} else { } else {
SparkleRepo.NotifyChanges = true; System.IO.File.Create (NotifyChangesFileName);
File.Create (NotifyChangesFileName);
} }
}; };
*/
MenuItem OpenFolderItem = new MenuItem (_("Open Sharing Folder")); MenuItem OpenFolderItem = new MenuItem (_("Open Sharing Folder"));
OpenFolderItem.Activated += delegate { OpenFolderItem.Activated += delegate {