[build] Remove FriendFace and SparkleDiff
This commit is contained in:
parent
e5d064b0e3
commit
58705625d2
|
@ -1,153 +0,0 @@
|
||||||
// FriendFace creates an icon theme of buddy icons from the web
|
|
||||||
// Copyright (C) 2010 Hylke Bons
|
|
||||||
//
|
|
||||||
// This library is free software; you can redistribute it and/or
|
|
||||||
// modify it under the terms of the GNU Lesser General Public
|
|
||||||
// License as published by the Free Software Foundation; either
|
|
||||||
// version 2.1 of the License, or (at your option) any later version.
|
|
||||||
//
|
|
||||||
// This library 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
|
|
||||||
// Lesser General Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser General Public License
|
|
||||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
using Gtk;
|
|
||||||
using Mono.Unix;
|
|
||||||
using System;
|
|
||||||
using System.IO;
|
|
||||||
|
|
||||||
namespace FriendFace {
|
|
||||||
|
|
||||||
public class FaceCollection : IconTheme {
|
|
||||||
|
|
||||||
public bool UseFlickr;
|
|
||||||
public bool UseGravatar;
|
|
||||||
public bool UseIdentica;
|
|
||||||
public bool UseTwitter;
|
|
||||||
|
|
||||||
private string Path;
|
|
||||||
|
|
||||||
public FaceCollection ()
|
|
||||||
{
|
|
||||||
|
|
||||||
UnixUserInfo unix_user_info = new UnixUserInfo (UnixEnvironment.UserName);
|
|
||||||
string default_theme_path = CombineMore (unix_user_info.HomeDirectory, ".icons");
|
|
||||||
new FaceCollection (default_theme_path);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public FaceCollection (string path)
|
|
||||||
{
|
|
||||||
CustomTheme = "FriendFace";
|
|
||||||
SetThemePath (path);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void SetThemePath (string path)
|
|
||||||
{
|
|
||||||
|
|
||||||
Path = path;
|
|
||||||
|
|
||||||
if (!Directory.Exists (Path))
|
|
||||||
Directory.CreateDirectory (Path);
|
|
||||||
|
|
||||||
AppendSearchPath (path);
|
|
||||||
|
|
||||||
Refresh ();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public string GetThemePath ()
|
|
||||||
{
|
|
||||||
return Path;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public Gdk.Pixbuf GetFace (string identifier, int size)
|
|
||||||
{
|
|
||||||
return LoadIcon ("avatar-default-" + identifier, size, IconLookupFlags.GenericFallback);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void Refresh ()
|
|
||||||
{foreach (string i in SearchPath) {Console.WriteLine (i);}
|
|
||||||
|
|
||||||
IconProvider provider = new IconProvider ("");
|
|
||||||
string folder = provider.GetTargetFolderPath ();
|
|
||||||
string [] files = Directory.GetFiles (folder);
|
|
||||||
|
|
||||||
int [] sizes = {16, 24, 32, 48};
|
|
||||||
|
|
||||||
foreach (string file_path in files) {
|
|
||||||
|
|
||||||
Gdk.Pixbuf pixbuf = new Gdk.Pixbuf (file_path);
|
|
||||||
|
|
||||||
FileInfo file_info = new FileInfo (file_path);
|
|
||||||
|
|
||||||
// Delete the icon if it turns out to be empty
|
|
||||||
if (file_info.Length == 0) {
|
|
||||||
File.Delete (file_path);
|
|
||||||
Console.WriteLine ("Deleted: " + file_path);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < 4; i++) {
|
|
||||||
|
|
||||||
int size = sizes [i];
|
|
||||||
|
|
||||||
Gdk.Pixbuf pixbuf_copy = pixbuf.Copy ();
|
|
||||||
|
|
||||||
if (pixbuf.Width != size || pixbuf.Height != size)
|
|
||||||
pixbuf_copy = pixbuf.ScaleSimple (size, size, Gdk.InterpType.Hyper);
|
|
||||||
|
|
||||||
string size_folder_path = CombineMore (Path, size + "x" + size, "status");
|
|
||||||
string size_file_path = CombineMore (size_folder_path, System.IO.Path.GetFileName (file_path));
|
|
||||||
|
|
||||||
Directory.CreateDirectory (size_folder_path);
|
|
||||||
|
|
||||||
if (File.Exists (size_file_path))
|
|
||||||
File.Delete (size_file_path);
|
|
||||||
|
|
||||||
pixbuf_copy.Save (size_file_path, "png");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
File.Delete (file_path);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
RescanIfNeeded ();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public bool AddFace (string identifier)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (UseGravatar) {
|
|
||||||
GravatarIconProvider provider = new GravatarIconProvider (identifier);
|
|
||||||
provider.RetrieveIcon ();
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Makes it possible to combine more than
|
|
||||||
// two paths at once
|
|
||||||
private string CombineMore (params string [] parts)
|
|
||||||
{
|
|
||||||
string new_path = "";
|
|
||||||
foreach (string part in parts)
|
|
||||||
new_path = System.IO.Path.Combine (new_path, part);
|
|
||||||
return new_path;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,50 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<PropertyGroup>
|
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
|
||||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
|
||||||
<ProductVersion>8.0.50727</ProductVersion>
|
|
||||||
<SchemaVersion>2.0</SchemaVersion>
|
|
||||||
<ProjectGuid>{3BA434AF-494F-4F5D-9D21-B7BD24FD67AF}</ProjectGuid>
|
|
||||||
<OutputType>Library</OutputType>
|
|
||||||
<RootNamespace>FriendFace</RootNamespace>
|
|
||||||
<AssemblyName>FriendFace</AssemblyName>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
|
||||||
<DebugSymbols>true</DebugSymbols>
|
|
||||||
<DebugType>full</DebugType>
|
|
||||||
<Optimize>false</Optimize>
|
|
||||||
<OutputPath>..\bin</OutputPath>
|
|
||||||
<DefineConstants>DEBUG</DefineConstants>
|
|
||||||
<ErrorReport>prompt</ErrorReport>
|
|
||||||
<WarningLevel>4</WarningLevel>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
|
||||||
<DebugType>none</DebugType>
|
|
||||||
<Optimize>false</Optimize>
|
|
||||||
<OutputPath>..\bin</OutputPath>
|
|
||||||
<ErrorReport>prompt</ErrorReport>
|
|
||||||
<WarningLevel>4</WarningLevel>
|
|
||||||
</PropertyGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<Reference Include="gtk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
|
|
||||||
<Package>gtk-sharp-2.0</Package>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="gdk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
|
|
||||||
<Package>gtk-sharp-2.0</Package>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="Mono.Posix" />
|
|
||||||
<Reference Include="System" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<Compile Include="FriendFace.cs" />
|
|
||||||
<Compile Include="GravatarIconProvider.cs" />
|
|
||||||
<Compile Include="IconProvider.cs" />
|
|
||||||
</ItemGroup>
|
|
||||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
|
||||||
<ProjectExtensions>
|
|
||||||
<MonoDevelop>
|
|
||||||
<Properties InternalTargetFrameworkVersion="3.5" />
|
|
||||||
</MonoDevelop>
|
|
||||||
</ProjectExtensions>
|
|
||||||
</Project>
|
|
|
@ -1,65 +0,0 @@
|
||||||
// FriendFace creates an icon theme of buddy icons from the web
|
|
||||||
// Copyright (C) 2010 Hylke Bons
|
|
||||||
//
|
|
||||||
// This library is free software; you can redistribute it and/or
|
|
||||||
// modify it under the terms of the GNU Lesser General Public
|
|
||||||
// License as published by the Free Software Foundation; either
|
|
||||||
// version 2.1 of the License, or (at your option) any later version.
|
|
||||||
//
|
|
||||||
// This library 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
|
|
||||||
// Lesser General Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser General Public License
|
|
||||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.using Gtk;
|
|
||||||
|
|
||||||
using Gtk;
|
|
||||||
using System;
|
|
||||||
using System.IO;
|
|
||||||
using System.Net;
|
|
||||||
using System.Security.Cryptography;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace FriendFace {
|
|
||||||
|
|
||||||
public class GravatarIconProvider : IconProvider {
|
|
||||||
|
|
||||||
public GravatarIconProvider (string email) : base (email)
|
|
||||||
{
|
|
||||||
ServiceName = "gravatar";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
new public void RetrieveIcon ()
|
|
||||||
{
|
|
||||||
|
|
||||||
string target_file_path = GetTargetFilePath ();
|
|
||||||
|
|
||||||
if (File.Exists (target_file_path))
|
|
||||||
return;
|
|
||||||
|
|
||||||
WebClient web_client = new WebClient ();
|
|
||||||
Uri icon_uri = new Uri ("http://www.gravatar.com/avatar/" + MD5 (Identifier) + ".jpg?s=48&d=404");
|
|
||||||
|
|
||||||
web_client.DownloadFileAsync (icon_uri, target_file_path);
|
|
||||||
|
|
||||||
web_client.DownloadFileCompleted += delegate {
|
|
||||||
base.RetrieveIcon ();
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Creates an MD5 hash of input
|
|
||||||
public static string MD5 (string s)
|
|
||||||
{
|
|
||||||
MD5 md5 = new MD5CryptoServiceProvider ();
|
|
||||||
Byte[] bytes = ASCIIEncoding.Default.GetBytes (s);
|
|
||||||
Byte[] encoded_bytes = md5.ComputeHash (bytes);
|
|
||||||
return BitConverter.ToString (encoded_bytes).ToLower ().Replace ("-", "");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,110 +0,0 @@
|
||||||
// IconProvider is a base class that can be extended to pull buddy
|
|
||||||
// icons from sources so that they can be used by FaceCollection.
|
|
||||||
//
|
|
||||||
// Copyright (C) 2010 Hylke Bons
|
|
||||||
//
|
|
||||||
// This library is free software; you can redistribute it and/or
|
|
||||||
// modify it under the terms of the GNU Lesser General Public
|
|
||||||
// License as published by the Free Software Foundation; either
|
|
||||||
// version 2.1 of the License, or (at your option) any later version.
|
|
||||||
//
|
|
||||||
// This library 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
|
|
||||||
// Lesser General Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser General Public License
|
|
||||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.using Gtk;
|
|
||||||
|
|
||||||
using Gtk;
|
|
||||||
using System;
|
|
||||||
using System.IO;
|
|
||||||
|
|
||||||
namespace FriendFace {
|
|
||||||
|
|
||||||
public class IconProvider {
|
|
||||||
|
|
||||||
public string Identifier;
|
|
||||||
public string ServiceName;
|
|
||||||
|
|
||||||
private string TargetFolderPath;
|
|
||||||
private string TargetFilePath;
|
|
||||||
|
|
||||||
public IconProvider (string identifier)
|
|
||||||
{
|
|
||||||
|
|
||||||
Identifier = identifier;
|
|
||||||
|
|
||||||
string XDG_CACHE_HOME = Environment.GetEnvironmentVariable ("XDG_CACHE_HOME");
|
|
||||||
|
|
||||||
if (XDG_CACHE_HOME != null)
|
|
||||||
SetTargetFolderPath (CombineMore (XDG_CACHE_HOME, "friendface"));
|
|
||||||
else
|
|
||||||
SetTargetFolderPath (CombineMore (System.IO.Path.DirectorySeparatorChar.ToString (),
|
|
||||||
"tmp", "friendface"));
|
|
||||||
|
|
||||||
string file_name = "avatar-default-" + Identifier;
|
|
||||||
TargetFilePath = CombineMore (TargetFolderPath, file_name);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void RetrieveIcon ()
|
|
||||||
{
|
|
||||||
|
|
||||||
if (File.Exists (TargetFilePath)) {
|
|
||||||
|
|
||||||
FileInfo file_info = new FileInfo (TargetFilePath);
|
|
||||||
|
|
||||||
// Delete the icon if it turns out to be empty
|
|
||||||
if (file_info.Length == 0) {
|
|
||||||
File.Delete (TargetFilePath);
|
|
||||||
Console.WriteLine ("Deleted: " + TargetFilePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void SetTargetFolderPath (string path)
|
|
||||||
{
|
|
||||||
|
|
||||||
TargetFolderPath = path;
|
|
||||||
|
|
||||||
if (!Directory.Exists (TargetFolderPath))
|
|
||||||
Directory.CreateDirectory (TargetFolderPath);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public string GetTargetFolderPath ()
|
|
||||||
{
|
|
||||||
return TargetFolderPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void SetTargetFilePath (string path)
|
|
||||||
{
|
|
||||||
TargetFilePath = path;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public string GetTargetFilePath ()
|
|
||||||
{
|
|
||||||
return TargetFilePath;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Makes it possible to combine more than two paths at once
|
|
||||||
public string CombineMore (params string [] parts)
|
|
||||||
{
|
|
||||||
string new_path = "";
|
|
||||||
foreach (string part in parts)
|
|
||||||
new_path = Path.Combine (new_path, part);
|
|
||||||
return new_path;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,11 +0,0 @@
|
||||||
ASSEMBLY = FriendFace
|
|
||||||
TARGET = library
|
|
||||||
|
|
||||||
LINK = $(REF_FRIENDFACE)
|
|
||||||
|
|
||||||
SOURCES = \
|
|
||||||
FriendFace.cs \
|
|
||||||
GravatarIconProvider.cs \
|
|
||||||
IconProvider.cs
|
|
||||||
|
|
||||||
include $(top_srcdir)/build/build.mk
|
|
|
@ -2,11 +2,9 @@ SUBDIRS = \
|
||||||
build \
|
build \
|
||||||
help \
|
help \
|
||||||
NotifySharp \
|
NotifySharp \
|
||||||
FriendFace \
|
|
||||||
SmartIrc4net \
|
SmartIrc4net \
|
||||||
SparkleLib \
|
SparkleLib \
|
||||||
SparkleShare \
|
SparkleShare \
|
||||||
SparkleDiff \
|
|
||||||
data \
|
data \
|
||||||
po
|
po
|
||||||
|
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
ASSEMBLY = SparkleDiff
|
|
||||||
TARGET = exe
|
|
||||||
|
|
||||||
LINK = $(REF_SPARKLEDIFF)
|
|
||||||
|
|
||||||
SOURCES = \
|
|
||||||
RevisionImage.cs \
|
|
||||||
RevisionView.cs \
|
|
||||||
SparkleDiff.cs \
|
|
||||||
SparkleDiffWindow.cs
|
|
||||||
|
|
||||||
include $(top_srcdir)/build/build.mk
|
|
|
@ -1,52 +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 System;
|
|
||||||
using Gtk;
|
|
||||||
using SparkleShare;
|
|
||||||
using System.Diagnostics;
|
|
||||||
|
|
||||||
namespace SparkleShare {
|
|
||||||
|
|
||||||
// An image grabbed from a stream generated by Git
|
|
||||||
public class RevisionImage : Image
|
|
||||||
{
|
|
||||||
|
|
||||||
public string Revision;
|
|
||||||
public string FilePath;
|
|
||||||
|
|
||||||
public RevisionImage (string file_path, string revision) : base ()
|
|
||||||
{
|
|
||||||
|
|
||||||
Revision = revision;
|
|
||||||
FilePath = file_path;
|
|
||||||
|
|
||||||
Process process = new Process ();
|
|
||||||
process.EnableRaisingEvents = true;
|
|
||||||
process.StartInfo.RedirectStandardOutput = true;
|
|
||||||
process.StartInfo.UseShellExecute = false;
|
|
||||||
|
|
||||||
process.StartInfo.WorkingDirectory = SparkleDiff.GetGitRoot (file_path);
|
|
||||||
process.StartInfo.FileName = "git";
|
|
||||||
process.StartInfo.Arguments = "show " + Revision + ":" + SparkleDiff.GetPathFromGitRoot (FilePath);
|
|
||||||
process.Start ();
|
|
||||||
|
|
||||||
Pixbuf = new Gdk.Pixbuf ((System.IO.Stream) process.StandardOutput.BaseStream);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,306 +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;
|
|
||||||
using Mono.Unix;
|
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace SparkleShare {
|
|
||||||
|
|
||||||
// A custom widget containing an image view,
|
|
||||||
// previous/next buttons and a combobox
|
|
||||||
public class RevisionView : VBox
|
|
||||||
{
|
|
||||||
|
|
||||||
// Short alias for the translations
|
|
||||||
public static string _ (string s)
|
|
||||||
{
|
|
||||||
return Catalog.GetString (s);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public ScrolledWindow ScrolledWindow;
|
|
||||||
public IconView IconView;
|
|
||||||
public int Selected;
|
|
||||||
|
|
||||||
public ToggleButton ToggleButton;
|
|
||||||
private Viewport Viewport;
|
|
||||||
private ListStore Store;
|
|
||||||
private Image Image;
|
|
||||||
private int Count;
|
|
||||||
private string SecondaryTextColor;
|
|
||||||
private string SelectedTextColor;
|
|
||||||
|
|
||||||
|
|
||||||
public RevisionView () : base (false, 0)
|
|
||||||
{
|
|
||||||
|
|
||||||
Count = 0;
|
|
||||||
Selected = 0;
|
|
||||||
|
|
||||||
TreeView treeview = new TreeView ();
|
|
||||||
SelectedTextColor = GdkColorToHex (treeview.Style.Foreground (StateType.Selected));
|
|
||||||
|
|
||||||
Window window = new Window ("");
|
|
||||||
SecondaryTextColor = GdkColorToHex (window.Style.Foreground (StateType.Insensitive));
|
|
||||||
|
|
||||||
ToggleButton = new ToggleButton ();
|
|
||||||
ToggleButton.Clicked += ToggleView;
|
|
||||||
ToggleButton.Relief = ReliefStyle.None;
|
|
||||||
|
|
||||||
ScrolledWindow = new ScrolledWindow ();
|
|
||||||
|
|
||||||
Viewport = new Viewport ();
|
|
||||||
Viewport.Add (new Label (""));
|
|
||||||
|
|
||||||
Store = new ListStore (typeof (Gdk.Pixbuf),
|
|
||||||
typeof (string),
|
|
||||||
typeof (int));
|
|
||||||
|
|
||||||
IconView = new IconView (Store);
|
|
||||||
IconView.SelectionChanged += ChangeSelection;
|
|
||||||
IconView.MarkupColumn = 1;
|
|
||||||
IconView.Margin = 12;
|
|
||||||
IconView.Orientation = Orientation.Horizontal;
|
|
||||||
IconView.PixbufColumn = 0;
|
|
||||||
IconView.Spacing = 12;
|
|
||||||
|
|
||||||
Image = new Image ();
|
|
||||||
|
|
||||||
ScrolledWindow.Add (Viewport);
|
|
||||||
PackStart (ScrolledWindow, true, true, 0);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Changes the selection and enforces a policy of always having something selected
|
|
||||||
public void ChangeSelection (object o, EventArgs args)
|
|
||||||
{
|
|
||||||
|
|
||||||
TreeIter iter;
|
|
||||||
Store.GetIter (out iter, new TreePath (GetSelected ().ToString ()));
|
|
||||||
string text = (string) Store.GetValue (iter, 1);
|
|
||||||
Store.SetValue (iter, 1, text.Replace (SelectedTextColor, SecondaryTextColor));
|
|
||||||
|
|
||||||
if (IconView.SelectedItems.Length > 0) {
|
|
||||||
|
|
||||||
Store.GetIter (out iter, IconView.SelectedItems [0]);
|
|
||||||
SetSelected ((int) Store.GetValue (iter, 2));
|
|
||||||
|
|
||||||
text = (string) Store.GetValue (iter, 1);
|
|
||||||
text = text.Replace (SecondaryTextColor, SelectedTextColor);
|
|
||||||
Store.SetValue (iter, 1, text);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
IconView.SelectPath (new TreePath (GetSelected ().ToString()));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Converts a Gdk RGB color to a hex value.
|
|
||||||
// Example: from "rgb:0,0,0" to "#000000"
|
|
||||||
public string GdkColorToHex (Gdk.Color color)
|
|
||||||
{
|
|
||||||
|
|
||||||
return String.Format("#{0:X2}{1:X2}{2:X2}",
|
|
||||||
(int) Math.Truncate(color.Red / 256.00),
|
|
||||||
(int) Math.Truncate(color.Green / 256.00),
|
|
||||||
(int) Math.Truncate(color.Blue / 256.00));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Makes sure everything is in place before showing the widget
|
|
||||||
new public void ShowAll ()
|
|
||||||
{
|
|
||||||
|
|
||||||
if (Children.Length == 2) {
|
|
||||||
|
|
||||||
ToggleButton = (ToggleButton) Children [0];
|
|
||||||
ToggleButton.Remove (ToggleButton.Child);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
ToggleButton = new ToggleButton ();
|
|
||||||
ToggleButton.Relief = ReliefStyle.None;
|
|
||||||
ToggleButton.Clicked += ToggleView;
|
|
||||||
PackStart (ToggleButton, false, false, 6);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
HBox layout_horizontal = new HBox (false, 12);
|
|
||||||
layout_horizontal.BorderWidth = 6;
|
|
||||||
|
|
||||||
TreeIter iter;
|
|
||||||
Store.GetIter (out iter, new TreePath (GetSelected ().ToString()));
|
|
||||||
|
|
||||||
string text = (string) Store.GetValue (iter, 1);
|
|
||||||
Gdk.Pixbuf pixbuf = (Gdk.Pixbuf) Store.GetValue (iter, 0);
|
|
||||||
|
|
||||||
Label label = new Label (text.Replace (SelectedTextColor, SecondaryTextColor));
|
|
||||||
label.UseMarkup = true;
|
|
||||||
|
|
||||||
Arrow arrow_down = new Arrow (ArrowType.Down, ShadowType.None);
|
|
||||||
|
|
||||||
layout_horizontal.PackStart (new Image (pixbuf), false, false, 0);
|
|
||||||
layout_horizontal.PackStart (label, false, false, 0);
|
|
||||||
layout_horizontal.PackStart (new Label (""), true, true, 0);
|
|
||||||
layout_horizontal.PackStart (arrow_down, false, false, 0);
|
|
||||||
|
|
||||||
ToggleButton.Add (layout_horizontal);
|
|
||||||
ReorderChild (ToggleButton, 0);
|
|
||||||
|
|
||||||
TreePath path = new TreePath (Selected.ToString());
|
|
||||||
IconView.SelectPath (path);
|
|
||||||
|
|
||||||
base.ShowAll ();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Adds a revision to the combobox
|
|
||||||
public void AddRow (Gdk.Pixbuf pixbuf, string header, string subtext)
|
|
||||||
{
|
|
||||||
|
|
||||||
Store.AppendValues (pixbuf, "<b>" + header + "</b>\n" +
|
|
||||||
"<span fgcolor='" + SecondaryTextColor + "'>" + subtext + "</span>",
|
|
||||||
Count);
|
|
||||||
|
|
||||||
IconView.Model = Store;
|
|
||||||
Count++;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Toggles between a displayed image and a list of revisions
|
|
||||||
public void ToggleView (object o, EventArgs args)
|
|
||||||
{
|
|
||||||
|
|
||||||
Viewport.Remove (Viewport.Child);
|
|
||||||
|
|
||||||
if (ToggleButton.Active) {
|
|
||||||
|
|
||||||
Viewport.Add (IconView);
|
|
||||||
TreePath path = new TreePath (GetSelected ().ToString());
|
|
||||||
|
|
||||||
IconView.ScrollToPath (path, (float) 0.5, (float) 0.5);
|
|
||||||
IconView.GrabFocus ();
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
Viewport.Add (Image);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
ShowAll ();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Changes the image that is viewed
|
|
||||||
public void SetImage (Image image)
|
|
||||||
{
|
|
||||||
|
|
||||||
Image = image;
|
|
||||||
Viewport.Remove (Viewport.Child);
|
|
||||||
Viewport.Add (Image);
|
|
||||||
ToggleButton.Active = false;
|
|
||||||
ShowAll ();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Returns the image that is currently viewed
|
|
||||||
public Image GetImage ()
|
|
||||||
{
|
|
||||||
return Image;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Selects an item by number
|
|
||||||
public bool SetSelected (int i)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (i > -1 && i <= Count) {
|
|
||||||
Selected = i;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Returns the number of the currently selected item
|
|
||||||
public int GetSelected ()
|
|
||||||
{
|
|
||||||
return Selected;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Looks up an icon from the system's theme
|
|
||||||
public Gdk.Pixbuf GetIcon (string name, int size)
|
|
||||||
{
|
|
||||||
IconTheme icon_theme = new IconTheme ();
|
|
||||||
icon_theme.AppendSearchPath (System.IO.Path.Combine ("/usr/share/sparkleshare", "icons"));
|
|
||||||
return icon_theme.LoadIcon (name, size, IconLookupFlags.GenericFallback);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Derived class for the image view on the left
|
|
||||||
public class LeftRevisionView : RevisionView
|
|
||||||
{
|
|
||||||
|
|
||||||
public LeftRevisionView () : base ()
|
|
||||||
{
|
|
||||||
|
|
||||||
// Select the second revision
|
|
||||||
Selected = 1;
|
|
||||||
|
|
||||||
// Take reading direction for time into account
|
|
||||||
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 () : base ()
|
|
||||||
{
|
|
||||||
|
|
||||||
// Take reading direction for time into account
|
|
||||||
if (Direction == Gtk.TextDirection.Ltr)
|
|
||||||
ScrolledWindow.Placement = CornerType.TopLeft;
|
|
||||||
else
|
|
||||||
ScrolledWindow.Placement = CornerType.TopRight;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,180 +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;
|
|
||||||
using Mono.Unix;
|
|
||||||
using System;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using System.IO;
|
|
||||||
using System.Text.RegularExpressions;
|
|
||||||
using SparkleLib;
|
|
||||||
|
|
||||||
namespace SparkleShare {
|
|
||||||
|
|
||||||
public class SparkleDiff
|
|
||||||
{
|
|
||||||
|
|
||||||
// Short alias for the translations
|
|
||||||
public static string _ (string s)
|
|
||||||
{
|
|
||||||
return Catalog.GetString (s);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Finds out the path relative to the Git root directory
|
|
||||||
public static string GetPathFromGitRoot (string file_path)
|
|
||||||
{
|
|
||||||
string git_root = GetGitRoot (file_path);
|
|
||||||
return file_path.Substring (git_root.Length + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Finds out the path relative to the Git root directory
|
|
||||||
public static string GetGitRoot (string file_path)
|
|
||||||
{
|
|
||||||
|
|
||||||
file_path = System.IO.Path.GetDirectoryName (file_path);
|
|
||||||
|
|
||||||
while (file_path != null) {
|
|
||||||
|
|
||||||
if (Directory.Exists (System.IO.Path.Combine (file_path, ".git")))
|
|
||||||
return file_path;
|
|
||||||
|
|
||||||
file_path = Directory.GetParent (file_path).FullName;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static void Main (string [] args)
|
|
||||||
{
|
|
||||||
|
|
||||||
Catalog.Init (Defines.GETTEXT_PACKAGE, Defines.LOCALE_DIR);
|
|
||||||
|
|
||||||
// Check whether git is installed
|
|
||||||
Process Process = new Process ();
|
|
||||||
Process.StartInfo.FileName = "git";
|
|
||||||
Process.StartInfo.RedirectStandardOutput = true;
|
|
||||||
Process.StartInfo.UseShellExecute = false;
|
|
||||||
Process.Start ();
|
|
||||||
|
|
||||||
if (Process.StandardOutput.ReadToEnd ().IndexOf ("version") == -1) {
|
|
||||||
Console.WriteLine (_("Git wasn't found."));
|
|
||||||
Console.WriteLine (_("You can get Git from http://git-scm.com/."));
|
|
||||||
Environment.Exit (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
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."));
|
|
||||||
Environment.Exit (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.Length > 0) {
|
|
||||||
|
|
||||||
if (args [0].Equals ("--help") || args [0].Equals ("-h")) {
|
|
||||||
ShowHelp ();
|
|
||||||
Environment.Exit (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
string file_path = System.IO.Path.GetFullPath (args [0]);
|
|
||||||
|
|
||||||
if (File.Exists (file_path)) {
|
|
||||||
|
|
||||||
Gtk.Application.Init ();
|
|
||||||
|
|
||||||
string [] revisions = GetRevisionsForFilePath (file_path);
|
|
||||||
|
|
||||||
// Quit if the given file doesn't have any history
|
|
||||||
if (revisions.Length < 2) {
|
|
||||||
Console.WriteLine ("SparkleDiff: " + file_path + ": File has no history.");
|
|
||||||
Environment.Exit (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
SparkleDiffWindow sparkle_diff_window;
|
|
||||||
sparkle_diff_window = new SparkleDiffWindow (file_path, revisions);
|
|
||||||
sparkle_diff_window.ShowAll ();
|
|
||||||
|
|
||||||
// The main loop
|
|
||||||
Gtk.Application.Run ();
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
Console.WriteLine ("SparkleDiff: " + file_path + ": No such file or directory.");
|
|
||||||
Environment.Exit (-1);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
ShowHelp ();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Gets a list of all earlier revisions of this file
|
|
||||||
public static string [] GetRevisionsForFilePath (string file_path)
|
|
||||||
{
|
|
||||||
|
|
||||||
Process process = new Process ();
|
|
||||||
process.EnableRaisingEvents = true;
|
|
||||||
process.StartInfo.RedirectStandardOutput = true;
|
|
||||||
process.StartInfo.UseShellExecute = false;
|
|
||||||
|
|
||||||
process.StartInfo.WorkingDirectory = SparkleDiff.GetGitRoot (file_path);
|
|
||||||
process.StartInfo.FileName = "git";
|
|
||||||
process.StartInfo.Arguments = "log --format=\"%H\" " + SparkleDiff.GetPathFromGitRoot (file_path);
|
|
||||||
|
|
||||||
process.Start ();
|
|
||||||
|
|
||||||
string output = process.StandardOutput.ReadToEnd ();
|
|
||||||
string [] revisions = Regex.Split (output.Trim (), "\n");
|
|
||||||
|
|
||||||
return revisions;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Prints the help output
|
|
||||||
public static void ShowHelp ()
|
|
||||||
{
|
|
||||||
Console.WriteLine (_("SparkleDiff Copyright (C) 2010 Hylke Bons"));
|
|
||||||
Console.WriteLine (" ");
|
|
||||||
Console.WriteLine (_("This program comes with ABSOLUTELY NO WARRANTY."));
|
|
||||||
Console.WriteLine (_("This is free software, and you are welcome to redistribute it "));
|
|
||||||
Console.WriteLine (_("under certain conditions. Please read the GNU GPLv3 for details."));
|
|
||||||
Console.WriteLine (" ");
|
|
||||||
Console.WriteLine (_("SparkleDiff let's you compare revisions of an image file side by side."));
|
|
||||||
Console.WriteLine (" ");
|
|
||||||
Console.WriteLine (_("Usage: sparklediff [FILE]"));
|
|
||||||
Console.WriteLine (_("Open an image file to show its revisions"));
|
|
||||||
Console.WriteLine (" ");
|
|
||||||
Console.WriteLine (_("Arguments:"));
|
|
||||||
Console.WriteLine (_("\t -h, --help\t\tDisplay this help text."));
|
|
||||||
Console.WriteLine (" ");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,70 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<PropertyGroup>
|
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
|
||||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
|
||||||
<ProductVersion>8.0.50727</ProductVersion>
|
|
||||||
<SchemaVersion>2.0</SchemaVersion>
|
|
||||||
<ProjectGuid>{17BF02CB-852A-4756-BA05-EC454643C428}</ProjectGuid>
|
|
||||||
<OutputType>Exe</OutputType>
|
|
||||||
<RootNamespace>SparkleDiff</RootNamespace>
|
|
||||||
<AssemblyName>SparkleDiff</AssemblyName>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
|
||||||
<DebugSymbols>true</DebugSymbols>
|
|
||||||
<DebugType>full</DebugType>
|
|
||||||
<Optimize>false</Optimize>
|
|
||||||
<OutputPath>..\bin</OutputPath>
|
|
||||||
<DefineConstants>DEBUG</DefineConstants>
|
|
||||||
<ErrorReport>prompt</ErrorReport>
|
|
||||||
<WarningLevel>4</WarningLevel>
|
|
||||||
<ConsolePause>false</ConsolePause>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
|
||||||
<DebugType>none</DebugType>
|
|
||||||
<Optimize>false</Optimize>
|
|
||||||
<OutputPath>..\bin</OutputPath>
|
|
||||||
<ErrorReport>prompt</ErrorReport>
|
|
||||||
<WarningLevel>4</WarningLevel>
|
|
||||||
<ConsolePause>false</ConsolePause>
|
|
||||||
</PropertyGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<Compile Include="SparkleDiff.cs" />
|
|
||||||
<Compile Include="SparkleDiffWindow.cs" />
|
|
||||||
<Compile Include="RevisionView.cs" />
|
|
||||||
<Compile Include="RevisionImage.cs" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\FriendFace\FriendFace.csproj">
|
|
||||||
<Project>{3BA434AF-494F-4F5D-9D21-B7BD24FD67AF}</Project>
|
|
||||||
<Name>FriendFace</Name>
|
|
||||||
</ProjectReference>
|
|
||||||
<ProjectReference Include="..\SparkleLib\SparkleLib.csproj">
|
|
||||||
<Project>{2C914413-B31C-4362-93C7-1AE34F09112A}</Project>
|
|
||||||
<Name>SparkleLib</Name>
|
|
||||||
</ProjectReference>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<Reference Include="System" />
|
|
||||||
<Reference Include="gtk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
|
|
||||||
<Package>gtk-sharp-2.0</Package>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="Mono.Posix" />
|
|
||||||
</ItemGroup>
|
|
||||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
|
||||||
<ProjectExtensions>
|
|
||||||
<MonoDevelop>
|
|
||||||
<Properties InternalTargetFrameworkVersion="3.5">
|
|
||||||
<MonoDevelop.Autotools.MakefileInfo IntegrationEnabled="true" RelativeMakefileName="Makefile.am">
|
|
||||||
<BuildFilesVar Sync="true" Name="SOURCES" />
|
|
||||||
<DeployFilesVar />
|
|
||||||
<ResourcesVar />
|
|
||||||
<OthersVar />
|
|
||||||
<GacRefVar />
|
|
||||||
<AsmRefVar />
|
|
||||||
<ProjectRefVar />
|
|
||||||
</MonoDevelop.Autotools.MakefileInfo>
|
|
||||||
</Properties>
|
|
||||||
</MonoDevelop>
|
|
||||||
</ProjectExtensions>
|
|
||||||
</Project>
|
|
|
@ -1,263 +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 FriendFace;
|
|
||||||
using Gtk;
|
|
||||||
using Mono.Unix;
|
|
||||||
using System;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using System.Text.RegularExpressions;
|
|
||||||
|
|
||||||
namespace SparkleShare {
|
|
||||||
|
|
||||||
// The main window for SparkleDiff
|
|
||||||
public class SparkleDiffWindow : Window
|
|
||||||
{
|
|
||||||
|
|
||||||
// Short alias for the translations
|
|
||||||
public static string _ (string s)
|
|
||||||
{
|
|
||||||
return Catalog.GetString (s);
|
|
||||||
}
|
|
||||||
|
|
||||||
private RevisionView ViewLeft;
|
|
||||||
private RevisionView ViewRight;
|
|
||||||
|
|
||||||
private string [] Revisions;
|
|
||||||
|
|
||||||
public SparkleDiffWindow (string file_path, string [] revisions) : base ("")
|
|
||||||
{
|
|
||||||
|
|
||||||
string file_name = System.IO.Path.GetFileName (file_path);
|
|
||||||
Revisions = revisions;
|
|
||||||
|
|
||||||
SetPosition (WindowPosition.Center);
|
|
||||||
BorderWidth = 12;
|
|
||||||
IconName = "image-x-generic";
|
|
||||||
|
|
||||||
FaceCollection face_collection = new FaceCollection ();
|
|
||||||
face_collection.UseGravatar = true;
|
|
||||||
|
|
||||||
DeleteEvent += Quit;
|
|
||||||
|
|
||||||
Title = file_name;
|
|
||||||
|
|
||||||
VBox layout_vertical = new VBox (false, 12);
|
|
||||||
|
|
||||||
HBox layout_horizontal = new HBox (true, 6);
|
|
||||||
|
|
||||||
Process process = new Process ();
|
|
||||||
process.EnableRaisingEvents = true;
|
|
||||||
process.StartInfo.RedirectStandardOutput = true;
|
|
||||||
process.StartInfo.UseShellExecute = false;
|
|
||||||
|
|
||||||
process.StartInfo.WorkingDirectory = System.IO.Path.GetDirectoryName (file_path);
|
|
||||||
process.StartInfo.FileName = "git";
|
|
||||||
process.StartInfo.Arguments = "log --format=\"%ct\t%an\t%ae\" " + file_name;
|
|
||||||
process.Start ();
|
|
||||||
|
|
||||||
ViewLeft = new LeftRevisionView ();
|
|
||||||
ViewRight = new RightRevisionView ();
|
|
||||||
|
|
||||||
string output = process.StandardOutput.ReadToEnd ();
|
|
||||||
string [] revisions_info = Regex.Split (output.Trim (), "\n");
|
|
||||||
|
|
||||||
int i = 0;
|
|
||||||
foreach (string revision_info in revisions_info) {
|
|
||||||
|
|
||||||
string [] parts = Regex.Split (revision_info.Trim (), "\t");
|
|
||||||
|
|
||||||
int timestamp = int.Parse (parts [0]);
|
|
||||||
string author = parts [1];
|
|
||||||
string email = parts [2];
|
|
||||||
|
|
||||||
string date;
|
|
||||||
// TRANSLATORS: This is a format specifier according to System.Globalization.DateTimeFormatInfo
|
|
||||||
if (i == 0)
|
|
||||||
date = "Latest Revision";
|
|
||||||
else
|
|
||||||
date = String.Format (_("{0} at {1}"),
|
|
||||||
UnixTimestampToDateTime (timestamp).ToString (_("ddd MMM d, yyyy")),
|
|
||||||
UnixTimestampToDateTime (timestamp).ToString (_("H:mm")));
|
|
||||||
|
|
||||||
face_collection.AddFace (email);
|
|
||||||
|
|
||||||
ViewLeft.AddRow (face_collection.GetFace (email, 32), author, date);
|
|
||||||
ViewRight.AddRow (face_collection.GetFace (email, 32), author, date);
|
|
||||||
|
|
||||||
i++;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
ViewLeft.SetImage (new RevisionImage (file_path, Revisions [1]));
|
|
||||||
ViewRight.SetImage (new RevisionImage (file_path, Revisions [0]));
|
|
||||||
|
|
||||||
ViewLeft.IconView.SelectionChanged += delegate {
|
|
||||||
|
|
||||||
ViewLeft.SetImage (new RevisionImage (file_path, Revisions [ViewLeft.GetSelected ()]));
|
|
||||||
|
|
||||||
ViewLeft.ScrolledWindow.Hadjustment = ViewRight.ScrolledWindow.Hadjustment;
|
|
||||||
ViewLeft.ScrolledWindow.Vadjustment = ViewRight.ScrolledWindow.Vadjustment;
|
|
||||||
|
|
||||||
HookUpViews ();
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
ViewRight.IconView.SelectionChanged += delegate {
|
|
||||||
|
|
||||||
ViewRight.SetImage (new RevisionImage (file_path, Revisions [ViewRight.GetSelected ()]));
|
|
||||||
|
|
||||||
ViewRight.ScrolledWindow.Hadjustment = ViewLeft.ScrolledWindow.Hadjustment;
|
|
||||||
ViewRight.ScrolledWindow.Vadjustment = ViewLeft.ScrolledWindow.Vadjustment;
|
|
||||||
|
|
||||||
HookUpViews ();
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
ViewLeft.ToggleButton.Clicked += delegate {
|
|
||||||
if (ViewLeft.ToggleButton.Active)
|
|
||||||
DetachViews ();
|
|
||||||
else
|
|
||||||
HookUpViews ();
|
|
||||||
};
|
|
||||||
|
|
||||||
ViewRight.ToggleButton.Clicked += delegate {
|
|
||||||
if (ViewLeft.ToggleButton.Active)
|
|
||||||
DetachViews ();
|
|
||||||
else
|
|
||||||
HookUpViews ();
|
|
||||||
};
|
|
||||||
|
|
||||||
layout_horizontal.PackStart (ViewLeft);
|
|
||||||
layout_horizontal.PackStart (ViewRight);
|
|
||||||
|
|
||||||
ResizeToViews ();
|
|
||||||
|
|
||||||
// Order time view according to the user's reading direction
|
|
||||||
if (Direction == Gtk.TextDirection.Rtl)
|
|
||||||
layout_horizontal.ReorderChild (ViewLeft, 1);
|
|
||||||
|
|
||||||
HookUpViews ();
|
|
||||||
|
|
||||||
HButtonBox dialog_buttons = new HButtonBox ();
|
|
||||||
dialog_buttons.Layout = ButtonBoxStyle.End;
|
|
||||||
dialog_buttons.BorderWidth = 0;
|
|
||||||
|
|
||||||
Button close_button = new Button (Stock.Close);
|
|
||||||
close_button.Clicked += delegate (object o, EventArgs args) {
|
|
||||||
Environment.Exit (0);
|
|
||||||
};
|
|
||||||
|
|
||||||
dialog_buttons.Add (close_button);
|
|
||||||
|
|
||||||
layout_vertical.PackStart (layout_horizontal, true, true, 0);
|
|
||||||
layout_vertical.PackStart (dialog_buttons, false, false, 0);
|
|
||||||
|
|
||||||
Add (layout_vertical);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Resizes the window so it will fit the content in the best possible way
|
|
||||||
private void ResizeToViews ()
|
|
||||||
{
|
|
||||||
|
|
||||||
int new_width = ViewLeft.GetImage ().Pixbuf.Width + ViewRight.GetImage ().Pixbuf.Width + 200;
|
|
||||||
int new_height = 200;
|
|
||||||
|
|
||||||
if (ViewLeft.GetImage ().Pixbuf.Height > ViewRight.GetImage ().Pixbuf.Height)
|
|
||||||
new_height += ViewLeft.GetImage ().Pixbuf.Height;
|
|
||||||
else
|
|
||||||
new_height += ViewRight.GetImage ().Pixbuf.Height;
|
|
||||||
|
|
||||||
if (new_width >= Screen.Width || new_height >= Screen.Height)
|
|
||||||
Maximize ();
|
|
||||||
else
|
|
||||||
SetSizeRequest (new_width, new_height);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Hooks up two views so their scrollbars will be kept in sync
|
|
||||||
private void HookUpViews ()
|
|
||||||
{
|
|
||||||
|
|
||||||
ViewLeft.ScrolledWindow.Hadjustment.ValueChanged += SyncViewsHorizontally;
|
|
||||||
ViewLeft.ScrolledWindow.Vadjustment.ValueChanged += SyncViewsVertically;
|
|
||||||
ViewRight.ScrolledWindow.Hadjustment.ValueChanged += SyncViewsHorizontally;
|
|
||||||
ViewRight.ScrolledWindow.Vadjustment.ValueChanged += SyncViewsVertically;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Detach the two views from each other so they don't try to sync anymore
|
|
||||||
private void DetachViews ()
|
|
||||||
{
|
|
||||||
|
|
||||||
ViewLeft.ScrolledWindow.Hadjustment.ValueChanged -= SyncViewsHorizontally;
|
|
||||||
ViewLeft.ScrolledWindow.Vadjustment.ValueChanged -= SyncViewsVertically;
|
|
||||||
ViewRight.ScrolledWindow.Hadjustment.ValueChanged -= SyncViewsHorizontally;
|
|
||||||
ViewRight.ScrolledWindow.Vadjustment.ValueChanged -= SyncViewsVertically;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Keeps the two image views in sync horizontally
|
|
||||||
private void SyncViewsHorizontally (object o, EventArgs args)
|
|
||||||
{
|
|
||||||
|
|
||||||
Adjustment source_adjustment = (Adjustment) o;
|
|
||||||
|
|
||||||
if (source_adjustment == ViewLeft.ScrolledWindow.Hadjustment)
|
|
||||||
ViewRight.ScrolledWindow.Hadjustment = source_adjustment;
|
|
||||||
else
|
|
||||||
ViewLeft.ScrolledWindow.Hadjustment = source_adjustment;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Keeps the two image views in sync vertically
|
|
||||||
private void SyncViewsVertically (object o, EventArgs args)
|
|
||||||
{
|
|
||||||
|
|
||||||
Adjustment source_adjustment = (Adjustment) o;
|
|
||||||
|
|
||||||
if (source_adjustment == ViewLeft.ScrolledWindow.Vadjustment)
|
|
||||||
ViewRight.ScrolledWindow.Vadjustment = source_adjustment;
|
|
||||||
else
|
|
||||||
ViewLeft.ScrolledWindow.Vadjustment = source_adjustment;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Converts a UNIX timestamp to a more usable time object
|
|
||||||
public DateTime UnixTimestampToDateTime (int timestamp)
|
|
||||||
{
|
|
||||||
DateTime unix_epoch = new DateTime (1970, 1, 1, 0, 0, 0, 0);
|
|
||||||
return unix_epoch.AddSeconds (timestamp);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Quits the program
|
|
||||||
private void Quit (object o, EventArgs args)
|
|
||||||
{
|
|
||||||
Environment.Exit (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,13 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
case $1 in
|
|
||||||
|
|
||||||
--help | help)
|
|
||||||
mono "@expanded_libdir@/@PACKAGE@/SparkleDiff.exe" --help
|
|
||||||
;;
|
|
||||||
|
|
||||||
*)
|
|
||||||
mono "@expanded_libdir@/@PACKAGE@/SparkleDiff.exe" $1
|
|
||||||
;;
|
|
||||||
|
|
||||||
esac
|
|
|
@ -101,9 +101,7 @@ build/m4/shave/shave-libtool
|
||||||
data/Makefile
|
data/Makefile
|
||||||
data/icons/Makefile
|
data/icons/Makefile
|
||||||
help/Makefile
|
help/Makefile
|
||||||
FriendFace/Makefile
|
|
||||||
NotifySharp/Makefile
|
NotifySharp/Makefile
|
||||||
SparkleDiff/Makefile
|
|
||||||
SparkleLib/AssemblyInfo.cs
|
SparkleLib/AssemblyInfo.cs
|
||||||
SparkleLib/Defines.cs
|
SparkleLib/Defines.cs
|
||||||
SparkleLib/Makefile
|
SparkleLib/Makefile
|
||||||
|
|
Loading…
Reference in a new issue