Fix a lot of crashes due to calling to GTK UI updates from multiple threads.
This commit is contained in:
parent
d1b8f1904b
commit
42d305654b
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -38,3 +38,4 @@ build/m4/shave/shave-libtool
|
|||
Defines.cs
|
||||
SparkleShare/sparkleshare
|
||||
po/sparkleshare.pot
|
||||
SparkleShare/Nautilus/sparkleshare-nautilus-extension.py
|
||||
|
|
1
AUTHORS
1
AUTHORS
|
@ -12,6 +12,7 @@ Contributors:
|
|||
Łukasz Jernaś <deejay1@srem.org>
|
||||
Oleg Khlystov <pktfag@gmail.com>
|
||||
Philipp Gildein <rmbl@openspeak-project.org>
|
||||
Ruben Vermeersch <rubenv@gnome.org>
|
||||
Sandy Armstrong <sanfordarmstrong@gmail.com>
|
||||
Simon Pither <simon@pither.com>
|
||||
Steven Harms <sharms@ubuntu.com>
|
||||
|
|
|
@ -59,7 +59,8 @@ namespace SparkleShare {
|
|||
HBox layout_horizontal = new HBox (false, 6);
|
||||
|
||||
// TODO: Fix the path
|
||||
Image side_splash = new Image ("/home/hbons/github/SparkleShare/data/side-splash.png");
|
||||
Image side_splash = new Image (SparkleHelpers.CombineMore (Defines.PREFIX, "share", "sparkleshare",
|
||||
"pixmaps", "side-splash.png"));
|
||||
|
||||
VBox wrapper = new VBox (false, 0);
|
||||
|
||||
|
|
|
@ -52,8 +52,11 @@ namespace SparkleShare {
|
|||
public delegate void CommitedEventHandler (object o, SparkleEventArgs args);
|
||||
public event CommitedEventHandler Commited;
|
||||
|
||||
public delegate void PushedEventHandler (object o, SparkleEventArgs args);
|
||||
public event PushedEventHandler Pushed;
|
||||
public delegate void PushingStartedEventHandler (object o, SparkleEventArgs args);
|
||||
public event PushingStartedEventHandler PushingStarted;
|
||||
|
||||
public delegate void PushingFinishedEventHandler (object o, SparkleEventArgs args);
|
||||
public event PushingFinishedEventHandler PushingFinished;
|
||||
|
||||
public delegate void FetchingStartedEventHandler (object o, SparkleEventArgs args);
|
||||
public event FetchingStartedEventHandler FetchingStarted;
|
||||
|
@ -61,7 +64,7 @@ namespace SparkleShare {
|
|||
public delegate void FetchingFinishedEventHandler (object o, SparkleEventArgs args);
|
||||
public event FetchingFinishedEventHandler FetchingFinished;
|
||||
|
||||
public delegate void NewCommitEventHandler (object o, SparkleEventArgs args);
|
||||
public delegate void NewCommitEventHandler (object o, NewCommitArgs args);
|
||||
public event NewCommitEventHandler NewCommit;
|
||||
|
||||
|
||||
|
@ -139,8 +142,6 @@ namespace SparkleShare {
|
|||
private void CheckForChanges ()
|
||||
{
|
||||
|
||||
SparkleHelpers.DebugInfo ("Buffer", "[" + Name + "] Checking for changes.");
|
||||
|
||||
lock (ChangeLock) {
|
||||
|
||||
if (HasChanged) {
|
||||
|
@ -270,8 +271,8 @@ namespace SparkleShare {
|
|||
SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Fetching changes...");
|
||||
|
||||
Process.StartInfo.Arguments = "fetch -v";
|
||||
Process.Start ();
|
||||
Process.WaitForExit ();
|
||||
Process.Start ();
|
||||
|
||||
string Output = Process.StandardOutput.ReadToEnd ().Trim (); // TODO: This doesn't work :(
|
||||
|
||||
|
@ -369,56 +370,26 @@ namespace SparkleShare {
|
|||
|
||||
}
|
||||
|
||||
// Get the last commiter
|
||||
Process.StartInfo.Arguments = "log --format=\"%an\" -1";
|
||||
Process.Start ();
|
||||
string author = Process.StandardOutput.ReadToEnd ().Trim ();
|
||||
|
||||
// Get the last committer e-mail
|
||||
Process.StartInfo.Arguments = "log --format=\"%ae\" -1";
|
||||
Process.Start ();
|
||||
string LastCommitEmail = Process.StandardOutput.ReadToEnd ().Trim ();
|
||||
string email = Process.StandardOutput.ReadToEnd ().Trim ();
|
||||
|
||||
// Get the last commit message
|
||||
Process.StartInfo.Arguments = "log --format=\"%s\" -1";
|
||||
Process.Start ();
|
||||
string LastCommitMessage = Process.StandardOutput.ReadToEnd ().Trim ();
|
||||
string message = Process.StandardOutput.ReadToEnd ().Trim ();
|
||||
|
||||
// Get the last commiter
|
||||
Process.StartInfo.Arguments = "log --format=\"%an\" -1";
|
||||
Process.Start ();
|
||||
string LastCommitUserName = Process.StandardOutput.ReadToEnd ().Trim ();
|
||||
|
||||
string NotifySettingFile = SparkleHelpers.CombineMore (SparklePaths.SparkleConfigPath,
|
||||
"sparkleshare.notify");
|
||||
|
||||
if (File.Exists (NotifySettingFile)) {
|
||||
|
||||
SparkleHelpers.DebugInfo ("Notification", "[" + Name + "] Showing message...");
|
||||
|
||||
SparkleEventArgs args = new SparkleEventArgs ("NewCommit");
|
||||
NewCommitArgs args = new NewCommitArgs (author, email, message);
|
||||
|
||||
if (NewCommit != null)
|
||||
NewCommit (this, args);
|
||||
|
||||
// SparkleBubble StuffChangedBubble = new SparkleBubble (LastCommitUserName, LastCommitMessage);
|
||||
// StuffChangedBubble.Icon = SparkleHelpers.GetAvatar (LastCommitEmail, 32);
|
||||
|
||||
// Add a button to open the folder where the changed file is
|
||||
/* StuffChangedBubble.AddAction ("", _("Open Folder"),
|
||||
delegate {
|
||||
switch (SparklePlatform.Name) {
|
||||
case "GNOME":
|
||||
Process.StartInfo.FileName = "xdg-open";
|
||||
break;
|
||||
case "OSX":
|
||||
Process.StartInfo.FileName = "open";
|
||||
break;
|
||||
}
|
||||
Process.StartInfo.Arguments = LocalPath;
|
||||
Process.Start ();
|
||||
Process.StartInfo.FileName = "git";
|
||||
} );
|
||||
|
||||
StuffChangedBubble.Show ();
|
||||
*/
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Watcher.EnableRaisingEvents = true;
|
||||
|
@ -431,20 +402,27 @@ namespace SparkleShare {
|
|||
public void Push ()
|
||||
{
|
||||
|
||||
SparkleEventArgs args = new SparkleEventArgs ("PushingStarted");
|
||||
|
||||
if (PushingStarted != null)
|
||||
PushingStarted (this, args);
|
||||
|
||||
SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Pushing changes...");
|
||||
|
||||
Process.StartInfo.Arguments = "push";
|
||||
Process.Start ();
|
||||
Process.WaitForExit ();
|
||||
|
||||
Process.Exited += delegate {
|
||||
|
||||
SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Changes pushed.");
|
||||
|
||||
SparkleEventArgs args = new SparkleEventArgs ("Pushed");
|
||||
args = new SparkleEventArgs ("PushingFinished");
|
||||
|
||||
if (Pushed != null)
|
||||
Pushed (this, args);
|
||||
if (PushingFinished != null)
|
||||
PushingFinished (this, args);
|
||||
|
||||
// SparkleUI.NotificationIcon.SetIdleState ();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
@ -701,8 +679,20 @@ namespace SparkleShare {
|
|||
|
||||
}
|
||||
|
||||
|
||||
public class NewCommitArgs : System.EventArgs {
|
||||
|
||||
public string Author;
|
||||
public string Email;
|
||||
public string Message;
|
||||
|
||||
public NewCommitArgs (string author, string email, string message)
|
||||
{
|
||||
Author = author;
|
||||
Email = email;
|
||||
Message = message;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -51,6 +51,7 @@ namespace SparkleShare {
|
|||
string SparklePath = SparklePaths.SparklePath;
|
||||
|
||||
EnableSystemAutostart ();
|
||||
InstallLauncher ();
|
||||
CreateSparkleShareFolder ();
|
||||
|
||||
// Create a directory to store temporary files in
|
||||
|
@ -138,10 +139,6 @@ namespace SparkleShare {
|
|||
public void EnableSystemAutostart ()
|
||||
{
|
||||
|
||||
switch (SparklePlatform.Name) {
|
||||
|
||||
case "GNOME":
|
||||
|
||||
string autostart_path = SparkleHelpers.CombineMore (SparklePaths.HomePath, ".config", "autostart");
|
||||
string desktopfile_path = SparkleHelpers.CombineMore (autostart_path, "sparkleshare.desktop");
|
||||
|
||||
|
@ -151,15 +148,14 @@ namespace SparkleShare {
|
|||
Directory.CreateDirectory (autostart_path);
|
||||
|
||||
TextWriter writer = new StreamWriter (desktopfile_path);
|
||||
|
||||
writer.WriteLine ("[Desktop Entry]\n" +
|
||||
"Type=Application\n" +
|
||||
"Name=SparkleShare\n" +
|
||||
"Exec=sparkleshare start\n" +
|
||||
"Icon=folder-sparkleshare\n" +
|
||||
"Terminal=false\n" +
|
||||
"X-GNOME-Autostart-enabled=true");
|
||||
|
||||
"X-GNOME-Autostart-enabled=true\n" +
|
||||
"Categories=Network");
|
||||
writer.Close ();
|
||||
|
||||
// Give the launcher the right permissions so it can be launched by the user
|
||||
|
@ -169,7 +165,35 @@ namespace SparkleShare {
|
|||
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
public void InstallLauncher ()
|
||||
{
|
||||
|
||||
string apps_path = SparkleHelpers.CombineMore (SparklePaths.HomePath, ".local", "share", "applications");
|
||||
string desktopfile_path = SparkleHelpers.CombineMore (apps_path, "sparkleshare.desktop");
|
||||
|
||||
if (!File.Exists (desktopfile_path)) {
|
||||
|
||||
if (!Directory.Exists (apps_path))
|
||||
Directory.CreateDirectory (apps_path);
|
||||
|
||||
TextWriter writer = new StreamWriter (desktopfile_path);
|
||||
writer.WriteLine ("[Desktop Entry]\n" +
|
||||
"Type=Application\n" +
|
||||
"Name=SparkleShare\n" +
|
||||
"Comment=Share documents\n" +
|
||||
"Exec=sparkleshare start\n" +
|
||||
"Icon=folder-sparkleshare\n" +
|
||||
"Terminal=false\n" +
|
||||
"Categories=Network");
|
||||
writer.Close ();
|
||||
|
||||
// Give the launcher the right permissions so it can be launched by the user
|
||||
Syscall.chmod (desktopfile_path, FilePermissions.S_IRWXU);
|
||||
|
||||
SparkleHelpers.DebugInfo ("Config", "Created '" + desktopfile_path + "'");
|
||||
|
||||
}
|
||||
|
||||
|
@ -233,24 +257,36 @@ namespace SparkleShare {
|
|||
}
|
||||
|
||||
|
||||
public void ShowNewCommitBubble (object o, SparkleEventArgs args) {
|
||||
public void ShowNewCommitBubble (string author, string email, string message) {
|
||||
|
||||
// TODO: Show bubble
|
||||
string notify_settings_file = SparkleHelpers.CombineMore (SparklePaths.SparkleConfigPath,
|
||||
"sparkleshare.notify");
|
||||
|
||||
if (File.Exists (notify_settings_file)) {
|
||||
|
||||
SparkleBubble bubble= new SparkleBubble (author, message);
|
||||
bubble.Icon = SparkleHelpers.GetAvatar (email, 32);
|
||||
bubble.Show ();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void UpdateStatusIcon (object o, SparkleEventArgs args) {
|
||||
public void UpdateStatusIconSyncing (object o, EventArgs args)
|
||||
{
|
||||
|
||||
if (args.Message.Equals ("FetchingStarted")) {
|
||||
NotificationIcon.SyncingReposCount++;
|
||||
NotificationIcon.ShowState ();
|
||||
|
||||
}
|
||||
|
||||
if (args.Message.Equals ("FetchingFinished")) {
|
||||
|
||||
public void UpdateStatusIconIdle (object o, EventArgs args)
|
||||
{
|
||||
|
||||
NotificationIcon.SyncingReposCount--;
|
||||
NotificationIcon.ShowState ();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -269,9 +305,25 @@ namespace SparkleShare {
|
|||
|
||||
SparkleRepo repo = new SparkleRepo (folder);
|
||||
|
||||
repo.NewCommit += ShowNewCommitBubble;
|
||||
repo.FetchingStarted += UpdateStatusIcon;
|
||||
repo.FetchingFinished += UpdateStatusIcon;
|
||||
repo.NewCommit += delegate (object o, NewCommitArgs args) {
|
||||
Application.Invoke (delegate { ShowNewCommitBubble (args.Author, args.Email, args.Message); });
|
||||
};
|
||||
|
||||
repo.FetchingStarted += delegate {
|
||||
Application.Invoke (UpdateStatusIconSyncing);
|
||||
};
|
||||
|
||||
repo.FetchingFinished += delegate {
|
||||
Application.Invoke (UpdateStatusIconIdle);
|
||||
};
|
||||
|
||||
repo.PushingStarted += delegate {
|
||||
Application.Invoke (UpdateStatusIconSyncing);
|
||||
};
|
||||
|
||||
repo.PushingFinished += delegate {
|
||||
Application.Invoke (UpdateStatusIconIdle);
|
||||
};
|
||||
|
||||
Repositories.Add (repo);
|
||||
|
||||
|
|
|
@ -2,8 +2,15 @@ SUBDIRS = \
|
|||
icons
|
||||
|
||||
EXTRA_DIST = \
|
||||
sparkleshare.svg
|
||||
sparkleshare.svg \
|
||||
side-splash.png
|
||||
|
||||
MAINTAINERCLEANFILES = \
|
||||
Makefile.in
|
||||
|
||||
install-data-local:
|
||||
$(mkinstalldirs) $(DESTDIR)$(datadir)/pixmaps
|
||||
$(INSTALL_DATA) $(srcdir)/side-splash.png $(DESTDIR)$(datadir)/pixmaps/side-splash.png
|
||||
|
||||
uninstall-hook:
|
||||
rm -f $(DESTDIR)$(datadir)/pixmaps/side-splash.png
|
||||
|
|
Loading…
Reference in a new issue