[sparklediff] Fix bug where GetPathFromGitRoot didn't return the right paths

This commit is contained in:
Hylke Bons 2010-07-07 18:03:23 +01:00
parent 5ce9e4b68a
commit 71cce0ab67
5 changed files with 76 additions and 78 deletions

View file

@ -8,8 +8,6 @@ $(top_srcdir)/SparkleShare/Defines.cs \
SparkleDiff.cs \
SparkleDiffWindow.cs \
RevisionView.cs \
RevisionImage.cs \
LeftRevisionView.cs \
RightRevisionView.cs
RevisionImage.cs
include $(top_srcdir)/build/build.mk

View file

@ -146,12 +146,46 @@ namespace SparkleShare {
}
public Image GetImage () {
public Image GetImage ()
{
return Image;
}
}
// Derived class for the image view on the left
public class LeftRevisionView : RevisionView {
public LeftRevisionView (string [] revisions) : base (revisions) {
ComboBox.Active = 1;
if (Direction == Gtk.TextDirection.Ltr)
ScrolledWindow.Placement = CornerType.TopRight;
else
ScrolledWindow.Placement = CornerType.TopLeft;
}
}
// Derived class for the image view on the right
public class RightRevisionView : RevisionView {
public RightRevisionView (string [] revisions) : base (revisions) {
ComboBox.Active = 0;
if (Direction == Gtk.TextDirection.Ltr)
ScrolledWindow.Placement = CornerType.TopLeft;
else
ScrolledWindow.Placement = CornerType.TopRight;
}
}
}

View file

@ -1,36 +0,0 @@
// SparkleShare, an instant update workflow to Git.
// Copyright (C) 2010 Hylke Bons <hylkebons@gmail.com>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// 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/>.
using Gtk;
namespace SparkleShare {
public class RightRevisionView : RevisionView {
public RightRevisionView (string [] revisions) : base (revisions) {
ComboBox.Active = 0;
if (Direction == Gtk.TextDirection.Ltr)
ScrolledWindow.Placement = CornerType.TopLeft;
else
ScrolledWindow.Placement = CornerType.TopRight;
}
}
}

View file

@ -36,7 +36,8 @@ namespace SparkleShare {
// Finds out the path relative to the Git root directory
public static string GetPathFromGitRoot (string file_path)
{
return file_path.TrimStart (GetGitRoot (file_path).ToCharArray ());
string git_root = GetGitRoot (file_path);
return file_path.Substring (git_root.Length + 1);
}
@ -59,6 +60,7 @@ namespace SparkleShare {
}
public static void Main (string [] args)
{
@ -77,8 +79,9 @@ namespace SparkleShare {
Environment.Exit (0);
}
// Don't allow running as root
UnixUserInfo UnixUserInfo = new UnixUserInfo (UnixEnvironment.UserName);
// Don't allow running as root
if (UnixUserInfo.UserId == 0) {
Console.WriteLine (_("Sorry, you can't run SparkleShare with these permissions."));
Console.WriteLine (_("Things would go utterly wrong."));
@ -122,10 +125,9 @@ namespace SparkleShare {
}
}
// Gets a list of all earlier revisions of this file
public static string [] GetRevisionsForFilePath (string file_path)
{
@ -149,7 +151,6 @@ namespace SparkleShare {
}
// Prints the help output
public static void ShowHelp ()
{

View file

@ -94,41 +94,42 @@ namespace SparkleShare {
ViewLeft.SetImage (new RevisionImage (file_path, Revisions [1]));
ViewRight.SetImage (new RevisionImage (file_path, Revisions [0]));
ViewLeft.ComboBox.Changed += delegate {
RevisionImage revision_image;
revision_image = new RevisionImage (file_path, Revisions [ViewLeft.ComboBox.Active]);
ViewLeft.SetImage (revision_image);
HookUpViews ();
ViewLeft.ScrolledWindow.Hadjustment = ViewRight.ScrolledWindow.Hadjustment;
ViewLeft.ScrolledWindow.Vadjustment = ViewRight.ScrolledWindow.Vadjustment;
ViewLeft.UpdateControls ();
};
ViewRight.ComboBox.Changed += delegate {
RevisionImage revision_image;
revision_image = new RevisionImage (file_path, Revisions [ViewRight.ComboBox.Active]);
ViewRight.SetImage (revision_image);
HookUpViews ();
ViewRight.ScrolledWindow.Hadjustment = ViewLeft.ScrolledWindow.Hadjustment;
ViewRight.ScrolledWindow.Vadjustment = ViewLeft.ScrolledWindow.Vadjustment;
ViewRight.UpdateControls ();
};
layout_horizontal.PackStart (ViewLeft);
layout_horizontal.PackStart (ViewRight);
ViewLeft.ComboBox.Changed += delegate {
RevisionImage revision_image;
revision_image = new RevisionImage (file_path, Revisions [ViewLeft.ComboBox.Active]);
ViewLeft.SetImage (revision_image);
HookUpViews ();
ViewLeft.ScrolledWindow.Hadjustment = ViewRight.ScrolledWindow.Hadjustment;
ViewLeft.ScrolledWindow.Vadjustment = ViewRight.ScrolledWindow.Vadjustment;
ViewLeft.UpdateControls ();
};
ViewRight.ComboBox.Changed += delegate {
RevisionImage revision_image;
revision_image = new RevisionImage (file_path, Revisions [ViewRight.ComboBox.Active]);
ViewRight.SetImage (revision_image);
HookUpViews ();
ViewRight.ScrolledWindow.Hadjustment = ViewLeft.ScrolledWindow.Hadjustment;
ViewRight.ScrolledWindow.Vadjustment = ViewLeft.ScrolledWindow.Vadjustment;
ViewRight.UpdateControls ();
};
ResizeToViews ();
// Order time view according to the user's reading direction