diff --git a/SparkleDiff/Makefile.am b/SparkleDiff/Makefile.am index 74949719..59fd06ce 100644 --- a/SparkleDiff/Makefile.am +++ b/SparkleDiff/Makefile.am @@ -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 diff --git a/SparkleDiff/RevisionView.cs b/SparkleDiff/RevisionView.cs index e645ac7d..24e95f5e 100644 --- a/SparkleDiff/RevisionView.cs +++ b/SparkleDiff/RevisionView.cs @@ -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; + + } + + } + + } diff --git a/SparkleDiff/RightRevisionView.cs b/SparkleDiff/RightRevisionView.cs deleted file mode 100644 index 637dcca9..00000000 --- a/SparkleDiff/RightRevisionView.cs +++ /dev/null @@ -1,36 +0,0 @@ -// SparkleShare, an instant update workflow to Git. -// Copyright (C) 2010 Hylke Bons -// -// 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 . - -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; - - } - - } - -} diff --git a/SparkleDiff/SparkleDiff.cs b/SparkleDiff/SparkleDiff.cs index 637828e8..b8eb97f0 100644 --- a/SparkleDiff/SparkleDiff.cs +++ b/SparkleDiff/SparkleDiff.cs @@ -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 () { diff --git a/SparkleDiff/SparkleDiffWindow.cs b/SparkleDiff/SparkleDiffWindow.cs index 607ba038..bf27f823 100644 --- a/SparkleDiff/SparkleDiffWindow.cs +++ b/SparkleDiff/SparkleDiffWindow.cs @@ -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