fix some bugs and crashes
This commit is contained in:
parent
f0a540f204
commit
10c2862bef
|
@ -16,13 +16,15 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace SparkleShare
|
namespace SparkleShare {
|
||||||
{
|
|
||||||
public class Defines
|
public class Defines {
|
||||||
{
|
|
||||||
public const string VERSION = "@VERSION@";
|
public const string VERSION = "@VERSION@";
|
||||||
public const string LOCALE_DIR = "@prefix@/share/locale";
|
public const string LOCALE_DIR = "@prefix@/share/locale";
|
||||||
public const string GETTEXT_PACKAGE = "@GETTEXT_PACKAGE@";
|
public const string GETTEXT_PACKAGE = "@GETTEXT_PACKAGE@";
|
||||||
public const string PREFIX = "@prefix@";
|
public const string PREFIX = "@prefix@";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -268,7 +268,7 @@ namespace SparkleShare {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Enables or disables the "Next" button depending on the
|
// Enables or disables the 'Next' button depending on the
|
||||||
// entries filled in by the user
|
// entries filled in by the user
|
||||||
private void CheckFields ()
|
private void CheckFields ()
|
||||||
{
|
{
|
||||||
|
@ -361,7 +361,6 @@ namespace SparkleShare {
|
||||||
process.StartInfo.FileName = "ssh-keygen";
|
process.StartInfo.FileName = "ssh-keygen";
|
||||||
process.StartInfo.Arguments = "-t rsa -P " + user_email + " -f " + key_file_name;
|
process.StartInfo.Arguments = "-t rsa -P " + user_email + " -f " + key_file_name;
|
||||||
|
|
||||||
process.WaitForExit ();
|
|
||||||
process.Start ();
|
process.Start ();
|
||||||
|
|
||||||
process.Exited += delegate {
|
process.Exited += delegate {
|
||||||
|
|
|
@ -25,7 +25,7 @@ using System.Timers;
|
||||||
|
|
||||||
namespace SparkleShare {
|
namespace SparkleShare {
|
||||||
|
|
||||||
// SparkleRepo class holds repository information and timers
|
// Holds repository information and timers
|
||||||
public class SparkleRepo
|
public class SparkleRepo
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -55,8 +55,14 @@ namespace SparkleShare {
|
||||||
public delegate void PushedEventHandler (object o, SparkleEventArgs args);
|
public delegate void PushedEventHandler (object o, SparkleEventArgs args);
|
||||||
public event PushedEventHandler Pushed;
|
public event PushedEventHandler Pushed;
|
||||||
|
|
||||||
public delegate void FetchedEventHandler (object o, SparkleEventArgs args);
|
public delegate void FetchingStartedEventHandler (object o, SparkleEventArgs args);
|
||||||
public event FetchedEventHandler Fetched;
|
public event FetchingStartedEventHandler FetchingStarted;
|
||||||
|
|
||||||
|
public delegate void FetchingFinishedEventHandler (object o, SparkleEventArgs args);
|
||||||
|
public event FetchingFinishedEventHandler FetchingFinished;
|
||||||
|
|
||||||
|
public delegate void NewCommitEventHandler (object o, SparkleEventArgs args);
|
||||||
|
public event NewCommitEventHandler NewCommit;
|
||||||
|
|
||||||
|
|
||||||
public static string _ (string s)
|
public static string _ (string s)
|
||||||
|
@ -221,9 +227,6 @@ namespace SparkleShare {
|
||||||
|
|
||||||
SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Changes staged.");
|
SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Changes staged.");
|
||||||
|
|
||||||
// SparkleUI.NotificationIcon.SetSyncingState ();
|
|
||||||
// SparkleUI.NotificationIcon.SetIdleState ();
|
|
||||||
|
|
||||||
SparkleEventArgs args = new SparkleEventArgs ("Added");
|
SparkleEventArgs args = new SparkleEventArgs ("Added");
|
||||||
|
|
||||||
if (Added != null)
|
if (Added != null)
|
||||||
|
@ -258,7 +261,11 @@ namespace SparkleShare {
|
||||||
|
|
||||||
FetchTimer.Stop ();
|
FetchTimer.Stop ();
|
||||||
|
|
||||||
// SparkleUI.NotificationIcon.SetSyncingState ();
|
SparkleEventArgs args;
|
||||||
|
args = new SparkleEventArgs ("FetchingStarted");
|
||||||
|
|
||||||
|
if (FetchingStarted != null)
|
||||||
|
FetchingStarted (this, args);
|
||||||
|
|
||||||
SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Fetching changes...");
|
SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Fetching changes...");
|
||||||
|
|
||||||
|
@ -270,16 +277,15 @@ namespace SparkleShare {
|
||||||
|
|
||||||
SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Changes fetched.");
|
SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Changes fetched.");
|
||||||
|
|
||||||
SparkleEventArgs args = new SparkleEventArgs ("Fetched");
|
args = new SparkleEventArgs ("FetchingFinished");
|
||||||
|
|
||||||
if (Fetched != null)
|
if (FetchingFinished != null)
|
||||||
Fetched (this, args);
|
FetchingFinished (this, args);
|
||||||
|
|
||||||
|
// Rebase if there are changes
|
||||||
if (!Output.Contains ("up to date"))
|
if (!Output.Contains ("up to date"))
|
||||||
Rebase ();
|
Rebase ();
|
||||||
|
|
||||||
// SparkleUI.NotificationIcon.SetIdleState ();
|
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
|
|
||||||
FetchTimer.Start ();
|
FetchTimer.Start ();
|
||||||
|
@ -297,7 +303,7 @@ namespace SparkleShare {
|
||||||
|
|
||||||
SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Rebasing changes...");
|
SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Rebasing changes...");
|
||||||
|
|
||||||
Process.StartInfo.Arguments = "rebase origin";
|
Process.StartInfo.Arguments = "rebase -v master";
|
||||||
Process.WaitForExit ();
|
Process.WaitForExit ();
|
||||||
Process.Start ();
|
Process.Start ();
|
||||||
|
|
||||||
|
@ -339,7 +345,7 @@ namespace SparkleShare {
|
||||||
Process.Start ();
|
Process.Start ();
|
||||||
|
|
||||||
string conflict_title = "A mid-air collision happened!\n";
|
string conflict_title = "A mid-air collision happened!\n";
|
||||||
string conflict_subtext = "Don't worry, SparkleShare made\na copy of the conflicting files.";
|
string conflict_subtext = "Don't worry, SparkleShare made\na copy of each conflicting file.";
|
||||||
|
|
||||||
// SparkleBubble ConflictBubble =
|
// SparkleBubble ConflictBubble =
|
||||||
// new SparkleBubble(_(ConflictTitle), _(ConflictSubtext));
|
// new SparkleBubble(_(ConflictTitle), _(ConflictSubtext));
|
||||||
|
@ -385,6 +391,11 @@ namespace SparkleShare {
|
||||||
|
|
||||||
SparkleHelpers.DebugInfo ("Notification", "[" + Name + "] Showing message...");
|
SparkleHelpers.DebugInfo ("Notification", "[" + Name + "] Showing message...");
|
||||||
|
|
||||||
|
SparkleEventArgs args = new SparkleEventArgs ("NewCommit");
|
||||||
|
|
||||||
|
if (NewCommit != null)
|
||||||
|
NewCommit (this, args);
|
||||||
|
|
||||||
// SparkleBubble StuffChangedBubble = new SparkleBubble (LastCommitUserName, LastCommitMessage);
|
// SparkleBubble StuffChangedBubble = new SparkleBubble (LastCommitUserName, LastCommitMessage);
|
||||||
// StuffChangedBubble.Icon = SparkleHelpers.GetAvatar (LastCommitEmail, 32);
|
// StuffChangedBubble.Icon = SparkleHelpers.GetAvatar (LastCommitEmail, 32);
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,6 @@ namespace SparkleShare {
|
||||||
return Catalog.GetString (s);
|
return Catalog.GetString (s);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SparkleRepo [] Repositories;
|
|
||||||
public static SparkleUI SparkleUI;
|
public static SparkleUI SparkleUI;
|
||||||
|
|
||||||
public static void Main (string [] args)
|
public static void Main (string [] args)
|
||||||
|
|
|
@ -30,6 +30,8 @@ namespace SparkleShare {
|
||||||
private Timer Timer;
|
private Timer Timer;
|
||||||
private int SyncingState;
|
private int SyncingState;
|
||||||
|
|
||||||
|
public int SyncingReposCount;
|
||||||
|
|
||||||
// Short alias for the translations
|
// Short alias for the translations
|
||||||
public static string _ (string s) {
|
public static string _ (string s) {
|
||||||
return Catalog.GetString (s);
|
return Catalog.GetString (s);
|
||||||
|
@ -49,6 +51,8 @@ namespace SparkleShare {
|
||||||
Timer = new Timer ();
|
Timer = new Timer ();
|
||||||
Activate += ShowMenu;
|
Activate += ShowMenu;
|
||||||
|
|
||||||
|
SyncingReposCount = 0;
|
||||||
|
|
||||||
// 0 = Everything up to date
|
// 0 = Everything up to date
|
||||||
// 1 = Syncing in progress
|
// 1 = Syncing in progress
|
||||||
// -1 = Error syncing
|
// -1 = Error syncing
|
||||||
|
@ -82,7 +86,7 @@ namespace SparkleShare {
|
||||||
Menu.Add (StatusMenuItem);
|
Menu.Add (StatusMenuItem);
|
||||||
Menu.Add (new SeparatorMenuItem ());
|
Menu.Add (new SeparatorMenuItem ());
|
||||||
|
|
||||||
Gtk.Action FolderAction = new Gtk.Action ("", "SparkleShare");
|
Gtk.Action FolderAction = new Gtk.Action ("", "SparkleShare Folder");
|
||||||
FolderAction.IconName = "folder-sparkleshare";
|
FolderAction.IconName = "folder-sparkleshare";
|
||||||
FolderAction.IsImportant = true;
|
FolderAction.IsImportant = true;
|
||||||
FolderAction.Activated += delegate {
|
FolderAction.Activated += delegate {
|
||||||
|
@ -101,10 +105,10 @@ namespace SparkleShare {
|
||||||
Menu.Add (FolderAction.CreateMenuItem ());
|
Menu.Add (FolderAction.CreateMenuItem ());
|
||||||
|
|
||||||
Gtk.Action [] FolderItems =
|
Gtk.Action [] FolderItems =
|
||||||
new Gtk.Action [SparkleShare.Repositories.Length];
|
new Gtk.Action [SparkleUI.Repositories.Length];
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
foreach (SparkleRepo SparkleRepo in SparkleShare.Repositories) {
|
foreach (SparkleRepo SparkleRepo in SparkleUI.Repositories) {
|
||||||
FolderItems [i] = new Gtk.Action ("", SparkleRepo.Name);
|
FolderItems [i] = new Gtk.Action ("", SparkleRepo.Name);
|
||||||
FolderItems [i].IconName = "folder";
|
FolderItems [i].IconName = "folder";
|
||||||
FolderItems [i].IsImportant = true;
|
FolderItems [i].IsImportant = true;
|
||||||
|
@ -113,7 +117,7 @@ namespace SparkleShare {
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
MenuItem AddItem = new MenuItem (_("Add a Remote Folder…"));
|
MenuItem AddItem = new MenuItem (_("Add Remote Folder…"));
|
||||||
AddItem.Activated += delegate {
|
AddItem.Activated += delegate {
|
||||||
SparkleDialog SparkleDialog = new SparkleDialog ("");
|
SparkleDialog SparkleDialog = new SparkleDialog ("");
|
||||||
SparkleDialog.ShowAll ();
|
SparkleDialog.ShowAll ();
|
||||||
|
@ -139,7 +143,7 @@ namespace SparkleShare {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
MenuItem AboutItem = new MenuItem (_("Visit Website"));
|
MenuItem AboutItem = new MenuItem (_("About"));
|
||||||
AboutItem.Activated += delegate {
|
AboutItem.Activated += delegate {
|
||||||
Process Process = new Process ();
|
Process Process = new Process ();
|
||||||
switch (SparklePlatform.Name) {
|
switch (SparklePlatform.Name) {
|
||||||
|
@ -163,10 +167,22 @@ namespace SparkleShare {
|
||||||
Menu.Popup (null, null, SetPosition, 0, Global.CurrentEventTime);
|
Menu.Popup (null, null, SetPosition, 0, Global.CurrentEventTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void UpdateState ()
|
||||||
|
{
|
||||||
|
|
||||||
|
if (SyncingReposCount > 0)
|
||||||
|
SetSyncingState ();
|
||||||
|
else
|
||||||
|
SetIdleState ();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void SetIdleState ()
|
public void SetIdleState ()
|
||||||
{
|
{
|
||||||
Timer.Stop ();
|
Timer.Stop ();
|
||||||
Pixbuf = SparkleHelpers.GetIcon ("folder-sparkleshare", 24);
|
IconName = "folder-sparkleshare";
|
||||||
SyncingState = 0;
|
SyncingState = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,9 +192,11 @@ namespace SparkleShare {
|
||||||
public void SetSyncingState ()
|
public void SetSyncingState ()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
IconName = "view-refresh";
|
||||||
|
|
||||||
SyncingState = 1;
|
SyncingState = 1;
|
||||||
|
|
||||||
int CycleDuration = 250;
|
/* int CycleDuration = 250;
|
||||||
int CurrentStep = 0;
|
int CurrentStep = 0;
|
||||||
int Size = 24;
|
int Size = 24;
|
||||||
|
|
||||||
|
@ -209,7 +227,7 @@ namespace SparkleShare {
|
||||||
Pixbuf = Images [CurrentStep];
|
Pixbuf = Images [CurrentStep];
|
||||||
};
|
};
|
||||||
Timer.Start ();
|
Timer.Start ();
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
// Changes the status icon to the error icon
|
// Changes the status icon to the error icon
|
||||||
|
|
|
@ -27,6 +27,7 @@ namespace SparkleShare {
|
||||||
public class SparkleUI {
|
public class SparkleUI {
|
||||||
|
|
||||||
private Process Process;
|
private Process Process;
|
||||||
|
public static SparkleRepo [] Repositories;
|
||||||
|
|
||||||
// Short alias for the translations
|
// Short alias for the translations
|
||||||
public static string _(string s)
|
public static string _(string s)
|
||||||
|
@ -64,7 +65,7 @@ namespace SparkleShare {
|
||||||
|
|
||||||
NotificationIcon = new SparkleStatusIcon ();
|
NotificationIcon = new SparkleStatusIcon ();
|
||||||
// Show a notification if there are no folders yet
|
// Show a notification if there are no folders yet
|
||||||
if (SparkleShare.Repositories.Length == 0) {
|
if (Repositories.Length == 0) {
|
||||||
|
|
||||||
SparkleBubble NoFoldersBubble;
|
SparkleBubble NoFoldersBubble;
|
||||||
NoFoldersBubble = new SparkleBubble (_("Welcome to SparkleShare!"),
|
NoFoldersBubble = new SparkleBubble (_("Welcome to SparkleShare!"),
|
||||||
|
@ -238,11 +239,27 @@ namespace SparkleShare {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void Test (object o, SparkleEventArgs args) {
|
public void ShowNewCommitBubble (object o, SparkleEventArgs args) {
|
||||||
Console.WriteLine ("AAAAAAAAAAAAAAAAAA");
|
Console.WriteLine ("AAAAAAAAAAAAAAAAAA");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void UpdateStatusIcon (object o, SparkleEventArgs args) {
|
||||||
|
|
||||||
|
if (args.Message.Equals ("FetchingStarted")) {
|
||||||
|
NotificationIcon.SyncingReposCount++;
|
||||||
|
NotificationIcon.UpdateState ();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.Message.Equals ("FetchingFinished")) {
|
||||||
|
NotificationIcon.SyncingReposCount--;
|
||||||
|
NotificationIcon.UpdateState ();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// TODO: Make this a List instead of an array
|
||||||
public void UpdateRepositories ()
|
public void UpdateRepositories ()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -257,32 +274,18 @@ namespace SparkleShare {
|
||||||
if (Directory.Exists (SparkleHelpers.CombineMore (folder, ".git"))) {
|
if (Directory.Exists (SparkleHelpers.CombineMore (folder, ".git"))) {
|
||||||
|
|
||||||
TmpRepos [FolderCount] = new SparkleRepo (folder);
|
TmpRepos [FolderCount] = new SparkleRepo (folder);
|
||||||
|
TmpRepos [FolderCount].NewCommit += ShowNewCommitBubble;
|
||||||
|
TmpRepos [FolderCount].FetchingStarted += UpdateStatusIcon;
|
||||||
|
TmpRepos [FolderCount].FetchingFinished += UpdateStatusIcon;
|
||||||
FolderCount++;
|
FolderCount++;
|
||||||
|
|
||||||
// TODO: emblems don't show up in nautilus
|
|
||||||
// Attach emblems
|
|
||||||
switch (SparklePlatform.Name) {
|
|
||||||
case "GNOME":
|
|
||||||
|
|
||||||
Process.StartInfo.FileName = "gvfs-set-attribute";
|
|
||||||
Process.StartInfo.Arguments = "-t string \"" + folder +
|
|
||||||
"\" metadata::emblems [synced]";
|
|
||||||
Process.Start ();
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
SparkleRepo a = TmpRepos [0];
|
Repositories = new SparkleRepo [FolderCount];
|
||||||
a.Added += Test;
|
Array.Copy (TmpRepos, Repositories, FolderCount);
|
||||||
|
|
||||||
|
|
||||||
SparkleShare.Repositories = new SparkleRepo [FolderCount];
|
|
||||||
Array.Copy (TmpRepos, SparkleShare.Repositories, FolderCount);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,13 +99,15 @@ namespace SparkleShare {
|
||||||
private ScrolledWindow CreateEventLog ()
|
private ScrolledWindow CreateEventLog ()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
int number_of_events = 50;
|
||||||
|
|
||||||
Process process = new Process ();
|
Process process = new Process ();
|
||||||
process.EnableRaisingEvents = true;
|
process.EnableRaisingEvents = true;
|
||||||
process.StartInfo.RedirectStandardOutput = true;
|
process.StartInfo.RedirectStandardOutput = true;
|
||||||
process.StartInfo.UseShellExecute = false;
|
process.StartInfo.UseShellExecute = false;
|
||||||
process.StartInfo.WorkingDirectory = SparkleRepo.LocalPath;
|
process.StartInfo.WorkingDirectory = SparkleRepo.LocalPath;
|
||||||
process.StartInfo.FileName = "git";
|
process.StartInfo.FileName = "git";
|
||||||
process.StartInfo.Arguments = "log --format=\"%at☃%an☃%ae☃%s\" -50";
|
process.StartInfo.Arguments = "log --format=\"%at☃%an☃%ae☃%s\" -" + number_of_events;
|
||||||
|
|
||||||
string output = "";
|
string output = "";
|
||||||
|
|
||||||
|
@ -122,7 +124,7 @@ namespace SparkleShare {
|
||||||
|
|
||||||
List <ActivityDay> activity_days = new List <ActivityDay> ();
|
List <ActivityDay> activity_days = new List <ActivityDay> ();
|
||||||
|
|
||||||
for (int i = 0; i < 25 && i < lines.Length; i++) {
|
for (int i = 0; i < number_of_events && i < lines.Length; i++) {
|
||||||
|
|
||||||
string line = lines [i];
|
string line = lines [i];
|
||||||
|
|
||||||
|
@ -214,7 +216,7 @@ namespace SparkleShare {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
layout_vertical.PackStart (date_label, true, true, 0);
|
layout_vertical.PackStart (date_label, false, false, 0);
|
||||||
|
|
||||||
IconView icon_view = new IconView (list_store) {
|
IconView icon_view = new IconView (list_store) {
|
||||||
ItemWidth = 480,
|
ItemWidth = 480,
|
||||||
|
@ -224,7 +226,7 @@ namespace SparkleShare {
|
||||||
Spacing = 9
|
Spacing = 9
|
||||||
};
|
};
|
||||||
|
|
||||||
layout_vertical.PackStart (icon_view);
|
layout_vertical.PackStart (icon_view, false, false, 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue