compose an e-mail message in the user's e-mail client when a person is double clicked
This commit is contained in:
parent
45fdd36d9a
commit
7964006823
164
SparkleShare/SparkleDialog.cs
Normal file
164
SparkleShare/SparkleDialog.cs
Normal file
|
@ -0,0 +1,164 @@
|
||||||
|
// 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 SparkleShare;
|
||||||
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace SparkleShare {
|
||||||
|
|
||||||
|
// A dialog where the user can enter a folder
|
||||||
|
// name and url to sync changes with
|
||||||
|
public class SparkleDialog : Window {
|
||||||
|
|
||||||
|
// Short alias for the translations
|
||||||
|
public static string _ (string s) {
|
||||||
|
return Catalog.GetString (s);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Button AddButton;
|
||||||
|
private ComboBoxEntry RemoteUrlCombo;
|
||||||
|
private Table Table;
|
||||||
|
|
||||||
|
public SparkleDialog () : base ("") {
|
||||||
|
|
||||||
|
BorderWidth = 6;
|
||||||
|
IconName = "folder-sparkleshare";
|
||||||
|
Modal = true;
|
||||||
|
Resizable = false;
|
||||||
|
SetPosition (WindowPosition.Center);
|
||||||
|
Title = _("Add a Folder");
|
||||||
|
|
||||||
|
VBox VBox = new VBox (false, 0);
|
||||||
|
|
||||||
|
|
||||||
|
Label RemoteUrlLabel = new Label (_("Address: "));
|
||||||
|
|
||||||
|
string [] DefaultUrls = new string [4] { "ssh://git@github.com/",
|
||||||
|
"ssh://git@git.gnome.org/",
|
||||||
|
"ssh://git@fedorahosted.org/",
|
||||||
|
"ssh://git@gitorious.org/" };
|
||||||
|
|
||||||
|
RemoteUrlCombo = new ComboBoxEntry (DefaultUrls);
|
||||||
|
|
||||||
|
Label RemoteUrlExample = new Label (_("<span size='small'><i>These usually look something like this:\n ") +
|
||||||
|
_("‘ssh://git@github.com/hbons/SparkleShare’.</i></span>"));
|
||||||
|
RemoteUrlExample.UseMarkup = true;
|
||||||
|
RemoteUrlExample.SetAlignment (0, 0);
|
||||||
|
RemoteUrlLabel.Xalign = 1;
|
||||||
|
|
||||||
|
HButtonBox ButtonBox = new HButtonBox ();
|
||||||
|
ButtonBox.Layout = ButtonBoxStyle.End;
|
||||||
|
ButtonBox.Spacing = 6;
|
||||||
|
ButtonBox.BorderWidth = 6;
|
||||||
|
|
||||||
|
AddButton = new Button (Stock.Add);
|
||||||
|
Button CancelButton = new Button (Stock.Cancel);
|
||||||
|
|
||||||
|
CancelButton.Clicked += delegate {
|
||||||
|
Destroy ();
|
||||||
|
};
|
||||||
|
|
||||||
|
RemoteUrlCombo.Entry.Changed += CheckFields;
|
||||||
|
RemoteUrlCombo.WidthRequest = 320;
|
||||||
|
|
||||||
|
AddButton.Sensitive = false;
|
||||||
|
AddButton.Clicked += CloneRepo;
|
||||||
|
|
||||||
|
ButtonBox.Add (CancelButton);
|
||||||
|
ButtonBox.Add (AddButton);
|
||||||
|
|
||||||
|
Table = new Table(3, 2, false);
|
||||||
|
Table.RowSpacing = 6;
|
||||||
|
Table.BorderWidth = 6;
|
||||||
|
|
||||||
|
Table.Attach (RemoteUrlLabel, 0, 1, 0, 1);
|
||||||
|
Table.Attach (RemoteUrlCombo, 1, 2, 0, 1);
|
||||||
|
Table.Attach (RemoteUrlExample, 1, 2, 1, 2);
|
||||||
|
|
||||||
|
VBox.PackStart (Table, false, false, 0);
|
||||||
|
VBox.PackStart (ButtonBox, false, false, 0);
|
||||||
|
|
||||||
|
Add (VBox);
|
||||||
|
ShowAll ();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CloneRepo (object o, EventArgs args) {
|
||||||
|
|
||||||
|
Remove (Child);
|
||||||
|
VBox Box = new VBox (false, 24);
|
||||||
|
SparkleSpinner Spinner = new SparkleSpinner ();
|
||||||
|
Label Label = new Label (_("Downloading files,\n") +
|
||||||
|
_("this may take a while..."));
|
||||||
|
Box.PackStart (Spinner, false, false, 0);
|
||||||
|
Box.PackStart (Label, false, false, 0);
|
||||||
|
BorderWidth = 30;
|
||||||
|
Add (Box);
|
||||||
|
|
||||||
|
string RepoRemoteUrl = RemoteUrlCombo.Entry.Text;
|
||||||
|
string RepoName =
|
||||||
|
RepoRemoteUrl.Substring (RepoRemoteUrl.LastIndexOf ("/") + 1);
|
||||||
|
|
||||||
|
Process Process = new Process();
|
||||||
|
Process.EnableRaisingEvents = true;
|
||||||
|
Process.StartInfo.RedirectStandardOutput = true;
|
||||||
|
Process.StartInfo.UseShellExecute = false;
|
||||||
|
Process.StartInfo.FileName = "git";
|
||||||
|
Process.StartInfo.WorkingDirectory =
|
||||||
|
SparklePaths.SparkleTmpPath;
|
||||||
|
|
||||||
|
Process.StartInfo.Arguments =
|
||||||
|
"clone " + SparkleHelpers.CombineMore (RepoRemoteUrl, RepoName)
|
||||||
|
.Substring (2);
|
||||||
|
|
||||||
|
Process.Start ();
|
||||||
|
Process.Exited += delegate {
|
||||||
|
Directory.Move (
|
||||||
|
SparkleHelpers.CombineMore (SparklePaths.SparkleTmpPath,
|
||||||
|
RepoName),
|
||||||
|
SparkleHelpers.CombineMore (SparklePaths.SparklePath,
|
||||||
|
RepoName)
|
||||||
|
);
|
||||||
|
|
||||||
|
// Enable notifications and synchronisation by default
|
||||||
|
File.Create (SparkleHelpers.CombineMore (SparklePaths.SparklePath,
|
||||||
|
RepoName, ".git",
|
||||||
|
"sparkleshare.notify"));
|
||||||
|
|
||||||
|
File.Create (SparkleHelpers.CombineMore (SparklePaths.SparklePath,
|
||||||
|
RepoName, ".git",
|
||||||
|
"sparkleshare.sync"));
|
||||||
|
Destroy ();
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Enables the Add button when the fields are
|
||||||
|
// filled in correctly
|
||||||
|
public void CheckFields (object o, EventArgs args) {
|
||||||
|
if (SparkleHelpers.IsGitUrl (RemoteUrlCombo.Entry.Text))
|
||||||
|
AddButton.Sensitive = true;
|
||||||
|
else
|
||||||
|
AddButton.Sensitive = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -103,6 +103,7 @@ namespace SparkleShare {
|
||||||
public ScrolledWindow CreateEventLog () {
|
public ScrolledWindow CreateEventLog () {
|
||||||
|
|
||||||
ListStore LogStore = new ListStore (typeof (Gdk.Pixbuf),
|
ListStore LogStore = new ListStore (typeof (Gdk.Pixbuf),
|
||||||
|
typeof (string),
|
||||||
typeof (string),
|
typeof (string),
|
||||||
typeof (string),
|
typeof (string),
|
||||||
typeof (string));
|
typeof (string));
|
||||||
|
@ -118,7 +119,7 @@ namespace SparkleShare {
|
||||||
Process.StartInfo.WorkingDirectory = SparkleRepo.LocalPath;
|
Process.StartInfo.WorkingDirectory = SparkleRepo.LocalPath;
|
||||||
// We're using the snowman here to separate messages :)
|
// We're using the snowman here to separate messages :)
|
||||||
Process.StartInfo.Arguments =
|
Process.StartInfo.Arguments =
|
||||||
"log --format=\"%at☃%an %s☃%cr☃%ae\" -25";
|
"log --format=\"%at☃%s☃%an☃%cr☃%ae\" -25";
|
||||||
Process.Start();
|
Process.Start();
|
||||||
|
|
||||||
Output += "\n" + Process.StandardOutput.ReadToEnd().Trim ();
|
Output += "\n" + Process.StandardOutput.ReadToEnd().Trim ();
|
||||||
|
@ -139,30 +140,32 @@ namespace SparkleShare {
|
||||||
// Look for the snowman!
|
// Look for the snowman!
|
||||||
string [] Parts = Regex.Split (Line, "☃");
|
string [] Parts = Regex.Split (Line, "☃");
|
||||||
string Message = Parts [1];
|
string Message = Parts [1];
|
||||||
string TimeAgo = Parts [2];
|
string UserName = Parts [2];
|
||||||
string UserEmail = Parts [3];
|
string TimeAgo = Parts [3];
|
||||||
|
string UserEmail = Parts [4];
|
||||||
|
|
||||||
string IconFile = "document-edited";
|
string IconFile = "document-edited";
|
||||||
|
|
||||||
if (Message.IndexOf (" added ‘") > -1)
|
if (Message.IndexOf ("added ‘") > -1)
|
||||||
IconFile = "document-added";
|
IconFile = "document-added";
|
||||||
|
|
||||||
if (Message.IndexOf (" deleted ‘") > -1)
|
if (Message.IndexOf ("deleted ‘") > -1)
|
||||||
IconFile = "document-removed";
|
IconFile = "document-removed";
|
||||||
|
|
||||||
if (Message.IndexOf (" moved ‘") > -1 ||
|
if (Message.IndexOf ("moved ‘") > -1 ||
|
||||||
Message.IndexOf (" renamed ‘") > -1)
|
Message.IndexOf ("renamed ‘") > -1)
|
||||||
IconFile = "document-moved";
|
IconFile = "document-moved";
|
||||||
|
|
||||||
Gdk.Pixbuf ChangeIcon = SparkleHelpers.GetIcon (IconFile, 16);
|
Gdk.Pixbuf ChangeIcon = SparkleHelpers.GetIcon (IconFile, 16);
|
||||||
Iter = LogStore.Append ();
|
Iter = LogStore.Append ();
|
||||||
LogStore.SetValue (Iter, 0, ChangeIcon);
|
LogStore.SetValue (Iter, 0, ChangeIcon);
|
||||||
LogStore.SetValue (Iter, 1, Message);
|
LogStore.SetValue (Iter, 1, Message);
|
||||||
LogStore.SetValue (Iter, 2, " " + TimeAgo);
|
LogStore.SetValue (Iter, 2, UserName);
|
||||||
|
LogStore.SetValue (Iter, 3, TimeAgo);
|
||||||
|
|
||||||
// We're not showing e-mail, it's only
|
// We're not showing e-mail, it's only
|
||||||
// there for lookup purposes
|
// there for lookup purposes
|
||||||
LogStore.SetValue (Iter, 3, UserEmail);
|
LogStore.SetValue (Iter, 4, UserEmail);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,17 +182,19 @@ namespace SparkleShare {
|
||||||
|
|
||||||
LogView.AppendColumn ("", new Gtk.CellRendererPixbuf (), "pixbuf", 0);
|
LogView.AppendColumn ("", new Gtk.CellRendererPixbuf (), "pixbuf", 0);
|
||||||
LogView.AppendColumn ("", TextCellMiddle, "text", 1);
|
LogView.AppendColumn ("", TextCellMiddle, "text", 1);
|
||||||
LogView.AppendColumn ("", TextCellRight, "text", 2);
|
LogView.AppendColumn ("", TextCellMiddle, "text", 2);
|
||||||
|
LogView.AppendColumn ("", TextCellRight, "text", 3);
|
||||||
|
|
||||||
TreeViewColumn [] Columns = LogView.Columns;
|
TreeViewColumn [] Columns = LogView.Columns;
|
||||||
Columns [0].MinWidth = 32;
|
Columns [0].MinWidth = 32;
|
||||||
Columns [1].Expand = true;
|
Columns [1].Expand = true;
|
||||||
Columns [1].MaxWidth = 150;
|
Columns [2].Expand = true;
|
||||||
|
Columns [1].MinWidth = 300;
|
||||||
|
|
||||||
LogView.CursorChanged += delegate(object o, EventArgs args) {
|
LogView.CursorChanged += delegate(object o, EventArgs args) {
|
||||||
TreeModel Model;
|
TreeModel Model;
|
||||||
if (LogView.Selection.GetSelected (out Model, out Iter)) {
|
if (LogView.Selection.GetSelected (out Model, out Iter)) {
|
||||||
SelectedEmail = (string) Model.GetValue (Iter, 3);
|
SelectedEmail = (string) Model.GetValue (Iter, 4);
|
||||||
UpdatePeopleList ();
|
UpdatePeopleList ();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -267,6 +272,16 @@ namespace SparkleShare {
|
||||||
PeopleView.Orientation = Orientation.Horizontal;
|
PeopleView.Orientation = Orientation.Horizontal;
|
||||||
PeopleView.SelectionMode = SelectionMode.Single;
|
PeopleView.SelectionMode = SelectionMode.Single;
|
||||||
|
|
||||||
|
// Compose an e-mail when an item is activated
|
||||||
|
PeopleView.ItemActivated +=
|
||||||
|
delegate (object o, ItemActivatedArgs Args) {
|
||||||
|
if (SparklePlatform.Name.Equals ("GNOME")) {
|
||||||
|
Process.StartInfo.FileName = "xdg-open";
|
||||||
|
Process.StartInfo.Arguments = "mailto:" + SelectedEmail;
|
||||||
|
Process.Start ();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// Select the person matching with the committer event list
|
// Select the person matching with the committer event list
|
||||||
i = 0;
|
i = 0;
|
||||||
foreach (object [] Row in PeopleStore) {
|
foreach (object [] Row in PeopleStore) {
|
||||||
|
|
Loading…
Reference in a new issue