fix some bugs and crashes

This commit is contained in:
Hylke Bons 2010-07-22 22:10:38 +01:00
parent f0a540f204
commit 10c2862bef
7 changed files with 96 additions and 62 deletions

View file

@ -12,17 +12,19 @@
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System;
namespace SparkleShare
{
public class Defines
{
public const string VERSION = "@VERSION@";
public const string LOCALE_DIR = "@prefix@/share/locale";
namespace SparkleShare {
public class Defines {
public const string VERSION = "@VERSION@";
public const string LOCALE_DIR = "@prefix@/share/locale";
public const string GETTEXT_PACKAGE = "@GETTEXT_PACKAGE@";
public const string PREFIX = "@prefix@";
public const string PREFIX = "@prefix@";
}
}

View file

@ -12,7 +12,7 @@
// GNU General private License for more details.
//
// You should have received a copy of the GNU General private License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using Gtk;
using Mono.Unix;
@ -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
private void CheckFields ()
{
@ -361,7 +361,6 @@ namespace SparkleShare {
process.StartInfo.FileName = "ssh-keygen";
process.StartInfo.Arguments = "-t rsa -P " + user_email + " -f " + key_file_name;
process.WaitForExit ();
process.Start ();
process.Exited += delegate {

View file

@ -12,7 +12,7 @@
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using Gtk;
using Mono.Unix;
@ -25,7 +25,7 @@ using System.Timers;
namespace SparkleShare {
// SparkleRepo class holds repository information and timers
// Holds repository information and timers
public class SparkleRepo
{
@ -55,8 +55,14 @@ namespace SparkleShare {
public delegate void PushedEventHandler (object o, SparkleEventArgs args);
public event PushedEventHandler Pushed;
public delegate void FetchedEventHandler (object o, SparkleEventArgs args);
public event FetchedEventHandler Fetched;
public delegate void FetchingStartedEventHandler (object o, SparkleEventArgs args);
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)
@ -221,9 +227,6 @@ namespace SparkleShare {
SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Changes staged.");
// SparkleUI.NotificationIcon.SetSyncingState ();
// SparkleUI.NotificationIcon.SetIdleState ();
SparkleEventArgs args = new SparkleEventArgs ("Added");
if (Added != null)
@ -258,7 +261,11 @@ namespace SparkleShare {
FetchTimer.Stop ();
// SparkleUI.NotificationIcon.SetSyncingState ();
SparkleEventArgs args;
args = new SparkleEventArgs ("FetchingStarted");
if (FetchingStarted != null)
FetchingStarted (this, args);
SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Fetching changes...");
@ -270,16 +277,15 @@ namespace SparkleShare {
SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Changes fetched.");
SparkleEventArgs args = new SparkleEventArgs ("Fetched");
args = new SparkleEventArgs ("FetchingFinished");
if (Fetched != null)
Fetched (this, args);
if (FetchingFinished != null)
FetchingFinished (this, args);
// Rebase if there are changes
if (!Output.Contains ("up to date"))
Rebase ();
// SparkleUI.NotificationIcon.SetIdleState ();
} finally {
FetchTimer.Start ();
@ -297,7 +303,7 @@ namespace SparkleShare {
SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Rebasing changes...");
Process.StartInfo.Arguments = "rebase origin";
Process.StartInfo.Arguments = "rebase -v master";
Process.WaitForExit ();
Process.Start ();
@ -339,7 +345,7 @@ namespace SparkleShare {
Process.Start ();
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 =
// new SparkleBubble(_(ConflictTitle), _(ConflictSubtext));
@ -385,6 +391,11 @@ namespace SparkleShare {
SparkleHelpers.DebugInfo ("Notification", "[" + Name + "] Showing message...");
SparkleEventArgs args = new SparkleEventArgs ("NewCommit");
if (NewCommit != null)
NewCommit (this, args);
// SparkleBubble StuffChangedBubble = new SparkleBubble (LastCommitUserName, LastCommitMessage);
// StuffChangedBubble.Icon = SparkleHelpers.GetAvatar (LastCommitEmail, 32);

View file

@ -30,7 +30,6 @@ namespace SparkleShare {
return Catalog.GetString (s);
}
public static SparkleRepo [] Repositories;
public static SparkleUI SparkleUI;
public static void Main (string [] args)

View file

@ -12,7 +12,7 @@
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using Gtk;
using Mono.Unix;
@ -30,6 +30,8 @@ namespace SparkleShare {
private Timer Timer;
private int SyncingState;
public int SyncingReposCount;
// Short alias for the translations
public static string _ (string s) {
return Catalog.GetString (s);
@ -49,6 +51,8 @@ namespace SparkleShare {
Timer = new Timer ();
Activate += ShowMenu;
SyncingReposCount = 0;
// 0 = Everything up to date
// 1 = Syncing in progress
// -1 = Error syncing
@ -82,7 +86,7 @@ namespace SparkleShare {
Menu.Add (StatusMenuItem);
Menu.Add (new SeparatorMenuItem ());
Gtk.Action FolderAction = new Gtk.Action ("", "SparkleShare");
Gtk.Action FolderAction = new Gtk.Action ("", "SparkleShare Folder");
FolderAction.IconName = "folder-sparkleshare";
FolderAction.IsImportant = true;
FolderAction.Activated += delegate {
@ -101,10 +105,10 @@ namespace SparkleShare {
Menu.Add (FolderAction.CreateMenuItem ());
Gtk.Action [] FolderItems =
new Gtk.Action [SparkleShare.Repositories.Length];
new Gtk.Action [SparkleUI.Repositories.Length];
int i = 0;
foreach (SparkleRepo SparkleRepo in SparkleShare.Repositories) {
foreach (SparkleRepo SparkleRepo in SparkleUI.Repositories) {
FolderItems [i] = new Gtk.Action ("", SparkleRepo.Name);
FolderItems [i].IconName = "folder";
FolderItems [i].IsImportant = true;
@ -113,7 +117,7 @@ namespace SparkleShare {
i++;
}
MenuItem AddItem = new MenuItem (_("Add a Remote Folder…"));
MenuItem AddItem = new MenuItem (_("Add Remote Folder…"));
AddItem.Activated += delegate {
SparkleDialog SparkleDialog = new SparkleDialog ("");
SparkleDialog.ShowAll ();
@ -139,7 +143,7 @@ namespace SparkleShare {
}
};
MenuItem AboutItem = new MenuItem (_("Visit Website"));
MenuItem AboutItem = new MenuItem (_("About"));
AboutItem.Activated += delegate {
Process Process = new Process ();
switch (SparklePlatform.Name) {
@ -163,10 +167,22 @@ namespace SparkleShare {
Menu.Popup (null, null, SetPosition, 0, Global.CurrentEventTime);
}
public void UpdateState ()
{
if (SyncingReposCount > 0)
SetSyncingState ();
else
SetIdleState ();
}
public void SetIdleState ()
{
Timer.Stop ();
Pixbuf = SparkleHelpers.GetIcon ("folder-sparkleshare", 24);
IconName = "folder-sparkleshare";
SyncingState = 0;
}
@ -176,9 +192,11 @@ namespace SparkleShare {
public void SetSyncingState ()
{
IconName = "view-refresh";
SyncingState = 1;
int CycleDuration = 250;
/* int CycleDuration = 250;
int CurrentStep = 0;
int Size = 24;
@ -209,7 +227,7 @@ namespace SparkleShare {
Pixbuf = Images [CurrentStep];
};
Timer.Start ();
*/
}
// Changes the status icon to the error icon

View file

@ -12,7 +12,7 @@
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using Gtk;
using Mono.Unix;
@ -27,6 +27,7 @@ namespace SparkleShare {
public class SparkleUI {
private Process Process;
public static SparkleRepo [] Repositories;
// Short alias for the translations
public static string _(string s)
@ -64,7 +65,7 @@ namespace SparkleShare {
NotificationIcon = new SparkleStatusIcon ();
// Show a notification if there are no folders yet
if (SparkleShare.Repositories.Length == 0) {
if (Repositories.Length == 0) {
SparkleBubble NoFoldersBubble;
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");
}
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 ()
{
@ -257,32 +274,18 @@ namespace SparkleShare {
if (Directory.Exists (SparkleHelpers.CombineMore (folder, ".git"))) {
TmpRepos [FolderCount] = new SparkleRepo (folder);
TmpRepos [FolderCount].NewCommit += ShowNewCommitBubble;
TmpRepos [FolderCount].FetchingStarted += UpdateStatusIcon;
TmpRepos [FolderCount].FetchingFinished += UpdateStatusIcon;
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];
a.Added += Test;
SparkleShare.Repositories = new SparkleRepo [FolderCount];
Array.Copy (TmpRepos, SparkleShare.Repositories, FolderCount);
Repositories = new SparkleRepo [FolderCount];
Array.Copy (TmpRepos, Repositories, FolderCount);
}

View file

@ -99,13 +99,15 @@ namespace SparkleShare {
private ScrolledWindow CreateEventLog ()
{
int number_of_events = 50;
Process process = new Process ();
process.EnableRaisingEvents = true;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.UseShellExecute = false;
process.StartInfo.WorkingDirectory = SparkleRepo.LocalPath;
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 = "";
@ -122,7 +124,7 @@ namespace SparkleShare {
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];
@ -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) {
ItemWidth = 480,
@ -224,7 +226,7 @@ namespace SparkleShare {
Spacing = 9
};
layout_vertical.PackStart (icon_view);
layout_vertical.PackStart (icon_view, false, false, 0);
}