Merge [invitation] into [controller] and [intro]
This commit is contained in:
parent
b75b470b17
commit
4bb48a2e51
|
@ -14,7 +14,6 @@ SOURCES = \
|
||||||
SparkleEntry.cs \
|
SparkleEntry.cs \
|
||||||
SparkleInfobar.cs \
|
SparkleInfobar.cs \
|
||||||
SparkleIntro.cs \
|
SparkleIntro.cs \
|
||||||
SparkleInvitation.cs \
|
|
||||||
SparkleLinController.cs \
|
SparkleLinController.cs \
|
||||||
SparkleLink.cs \
|
SparkleLink.cs \
|
||||||
SparkleLog.cs \
|
SparkleLog.cs \
|
||||||
|
|
|
@ -59,7 +59,7 @@ namespace SparkleShare {
|
||||||
public delegate void OnErrorEventHandler ();
|
public delegate void OnErrorEventHandler ();
|
||||||
|
|
||||||
public event OnInvitationEventHandler OnInvitation;
|
public event OnInvitationEventHandler OnInvitation;
|
||||||
public delegate void OnInvitationEventHandler (string invitation_file_path);
|
public delegate void OnInvitationEventHandler (string server, string name, string token);
|
||||||
|
|
||||||
public event ConflictNotificationRaisedEventHandler ConflictNotificationRaised;
|
public event ConflictNotificationRaisedEventHandler ConflictNotificationRaised;
|
||||||
public delegate void ConflictNotificationRaisedEventHandler ();
|
public delegate void ConflictNotificationRaisedEventHandler ();
|
||||||
|
@ -80,43 +80,7 @@ namespace SparkleShare {
|
||||||
|
|
||||||
FolderSize = GetFolderSize ();
|
FolderSize = GetFolderSize ();
|
||||||
|
|
||||||
// Watch the SparkleShare folder
|
|
||||||
FileSystemWatcher watcher = new FileSystemWatcher (SparklePaths.SparklePath) {
|
|
||||||
IncludeSubdirectories = false,
|
|
||||||
EnableRaisingEvents = true,
|
|
||||||
Filter = "*"
|
|
||||||
};
|
|
||||||
|
|
||||||
// Remove the repository when a delete event occurs
|
|
||||||
watcher.Deleted += delegate (object o, FileSystemEventArgs args) {
|
|
||||||
|
|
||||||
RemoveRepository (args.FullPath);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
// Add the repository when a create event occurs
|
|
||||||
watcher.Created += delegate (object o, FileSystemEventArgs args) {
|
|
||||||
|
|
||||||
// Handle invitations when the user saves an
|
|
||||||
// invitation into the SparkleShare folder
|
|
||||||
if (args.Name.EndsWith (".sparkle")) {
|
|
||||||
|
|
||||||
Console.WriteLine ("YYYYYYYYYYYQQ!!!!!!!");
|
|
||||||
|
|
||||||
if (OnInvitation != null)
|
|
||||||
OnInvitation (args.FullPath);
|
|
||||||
|
|
||||||
} else if (Directory.Exists (Path.Combine (args.FullPath, ".git"))) {
|
|
||||||
|
|
||||||
AddRepository (args.FullPath);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
CreateConfigurationFolders ();
|
|
||||||
|
|
||||||
string global_config_file_path = SparkleHelpers.CombineMore (SparklePaths.SparkleConfigPath, "config");
|
string global_config_file_path = SparkleHelpers.CombineMore (SparklePaths.SparkleConfigPath, "config");
|
||||||
|
|
||||||
// Show the introduction screen if SparkleShare isn't configured
|
// Show the introduction screen if SparkleShare isn't configured
|
||||||
|
@ -130,6 +94,51 @@ namespace SparkleShare {
|
||||||
AddKey ();
|
AddKey ();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Watch the SparkleShare folder
|
||||||
|
FileSystemWatcher watcher = new FileSystemWatcher (SparklePaths.SparklePath) {
|
||||||
|
IncludeSubdirectories = false,
|
||||||
|
EnableRaisingEvents = true,
|
||||||
|
Filter = "*"
|
||||||
|
};
|
||||||
|
|
||||||
|
// Remove the repository when a delete event occurs
|
||||||
|
watcher.Deleted += delegate (object o, FileSystemEventArgs args) {
|
||||||
|
|
||||||
|
if (Directory.Exists (args.FullPath))
|
||||||
|
RemoveRepository (args.FullPath);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
// Add the repository when a create event occurs
|
||||||
|
watcher.Created += delegate (object o, FileSystemEventArgs args) {
|
||||||
|
|
||||||
|
// Handle invitations when the user saves an
|
||||||
|
// invitation into the SparkleShare folder
|
||||||
|
if (args.FullPath.StartsWith (".sparkle")) {
|
||||||
|
|
||||||
|
XmlDocument xml_doc = new XmlDocument ();
|
||||||
|
xml_doc.Load (args.Name);
|
||||||
|
|
||||||
|
string server = xml_doc.GetElementsByTagName ("server") [0].InnerText;
|
||||||
|
string folder = xml_doc.GetElementsByTagName ("folder") [0].InnerText;
|
||||||
|
string token = xml_doc.GetElementsByTagName ("token") [0].InnerText;
|
||||||
|
|
||||||
|
if (OnInvitation != null)
|
||||||
|
OnInvitation (server, folder, token);
|
||||||
|
|
||||||
|
|
||||||
|
} else if (Directory.Exists (Path.Combine (args.FullPath, ".git"))) {
|
||||||
|
|
||||||
|
AddRepository (args.FullPath);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
CreateConfigurationFolders ();
|
||||||
|
|
||||||
Thread thread = new Thread (
|
Thread thread = new Thread (
|
||||||
new ThreadStart (PopulateRepositories)
|
new ThreadStart (PopulateRepositories)
|
||||||
|
@ -139,7 +148,45 @@ namespace SparkleShare {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Uploads the user's public key to the server
|
||||||
|
public bool AcceptInvitation (string server, string folder, string token)
|
||||||
|
{
|
||||||
|
|
||||||
|
// The location of the user's public key for SparkleShare
|
||||||
|
string public_key_file_path = SparkleHelpers.CombineMore (SparklePaths.HomePath, ".ssh",
|
||||||
|
"sparkleshare." + SparkleShare.Controller.UserEmail + ".key.pub");
|
||||||
|
|
||||||
|
if (!File.Exists (public_key_file_path))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
StreamReader reader = new StreamReader (public_key_file_path);
|
||||||
|
string public_key = reader.ReadToEnd ();
|
||||||
|
reader.Close ();
|
||||||
|
|
||||||
|
string url = "https://" + server + "/?folder=" + folder +
|
||||||
|
"&token=" + token + "&pubkey=" + public_key;
|
||||||
|
|
||||||
|
SparkleHelpers.DebugInfo ("WebRequest", url);
|
||||||
|
|
||||||
|
HttpWebRequest request = (HttpWebRequest) WebRequest.Create (url);
|
||||||
|
HttpWebResponse response = (HttpWebResponse) request.GetResponse();
|
||||||
|
|
||||||
|
if (response.StatusCode == HttpStatusCode.OK) {
|
||||||
|
|
||||||
|
response.Close ();
|
||||||
|
return true;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
response.Close ();
|
||||||
|
return false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public List <string> Folders
|
public List <string> Folders
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -309,13 +356,13 @@ namespace SparkleShare {
|
||||||
private void RemoveRepository (string folder_path)
|
private void RemoveRepository (string folder_path)
|
||||||
{
|
{
|
||||||
|
|
||||||
string repo_name = Path.GetFileName (folder_path);
|
string folder_name = Path.GetFileName (folder_path);
|
||||||
|
|
||||||
for (int i = 0; i < Repositories.Count; i++) {
|
for (int i = 0; i < Repositories.Count; i++) {
|
||||||
|
|
||||||
SparkleRepo repo = Repositories [i];
|
SparkleRepo repo = Repositories [i];
|
||||||
|
|
||||||
if (repo.Name.Equals (repo_name)) {
|
if (repo.Name.Equals (folder_name)) {
|
||||||
|
|
||||||
Repositories.Remove (repo);
|
Repositories.Remove (repo);
|
||||||
repo.Dispose ();
|
repo.Dispose ();
|
||||||
|
@ -659,6 +706,8 @@ namespace SparkleShare {
|
||||||
public void FetchFolder (string url, string name)
|
public void FetchFolder (string url, string name)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
SparkleHelpers.DebugInfo ("Controller", "Formed URL: " + url);
|
||||||
|
|
||||||
// Strip the '.git' from the name
|
// Strip the '.git' from the name
|
||||||
string canonical_name = System.IO.Path.GetFileNameWithoutExtension (name);
|
string canonical_name = System.IO.Path.GetFileNameWithoutExtension (name);
|
||||||
string tmp_folder = SparkleHelpers.CombineMore (SparklePaths.SparkleTmpPath, canonical_name);
|
string tmp_folder = SparkleHelpers.CombineMore (SparklePaths.SparkleTmpPath, canonical_name);
|
||||||
|
|
|
@ -48,12 +48,10 @@ namespace SparkleShare {
|
||||||
ServerFormOnly = false;
|
ServerFormOnly = false;
|
||||||
SecondaryTextColor = SparkleUIHelpers.GdkColorToHex (Style.Foreground (StateType.Insensitive));
|
SecondaryTextColor = SparkleUIHelpers.GdkColorToHex (Style.Foreground (StateType.Insensitive));
|
||||||
|
|
||||||
ShowAccountForm ();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void ShowAccountForm ()
|
public void ShowAccountForm ()
|
||||||
{
|
{
|
||||||
|
|
||||||
Reset ();
|
Reset ();
|
||||||
|
@ -430,6 +428,105 @@ namespace SparkleShare {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void ShowInvitationPage (string server, string folder, string token)
|
||||||
|
{
|
||||||
|
|
||||||
|
VBox layout_vertical = new VBox (false, 0);
|
||||||
|
|
||||||
|
Label header = new Label ("<span size='x-large'><b>" +
|
||||||
|
_("Invitation received!") +
|
||||||
|
"</b></span>") {
|
||||||
|
UseMarkup = true,
|
||||||
|
Xalign = 0
|
||||||
|
};
|
||||||
|
|
||||||
|
Label information = new Label (_("You've received an invitation to join a shared folder.\n" +
|
||||||
|
"We're ready to hook you up immediately if you wish.")) {
|
||||||
|
Xalign = 0,
|
||||||
|
Wrap = true
|
||||||
|
};
|
||||||
|
|
||||||
|
Label question = new Label (_("Do you accept this invitation?")) {
|
||||||
|
Xalign = 0,
|
||||||
|
Wrap = true
|
||||||
|
};
|
||||||
|
|
||||||
|
Table table = new Table (2, 2, false) {
|
||||||
|
RowSpacing = 6
|
||||||
|
};
|
||||||
|
|
||||||
|
Label server_label = new Label (_("Server Address:")) {
|
||||||
|
Xalign = 0
|
||||||
|
};
|
||||||
|
|
||||||
|
Label server_text = new Label ("<b>" + server + "</b>") {
|
||||||
|
UseMarkup = true,
|
||||||
|
Xalign = 0
|
||||||
|
};
|
||||||
|
|
||||||
|
Label folder_label = new Label (_("Folder Name:")) {
|
||||||
|
Xalign = 0
|
||||||
|
};
|
||||||
|
|
||||||
|
Label folder_text = new Label ("<b>" + folder + "</b>") {
|
||||||
|
UseMarkup = true,
|
||||||
|
Xalign = 0
|
||||||
|
};
|
||||||
|
|
||||||
|
table.Attach (folder_label, 0, 1, 0, 1);
|
||||||
|
table.Attach (folder_text, 1, 2, 0, 1);
|
||||||
|
table.Attach (server_label, 0, 1, 1, 2);
|
||||||
|
table.Attach (server_text, 1, 2, 1, 2);
|
||||||
|
|
||||||
|
Button reject_button = new Button (_("Reject"));
|
||||||
|
Button accept_button = new Button (_("Accept and Sync"));
|
||||||
|
|
||||||
|
reject_button.Clicked += delegate {
|
||||||
|
|
||||||
|
Destroy ();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
accept_button.Clicked += delegate {
|
||||||
|
|
||||||
|
string url = "ssh://git@" + server + "/" + folder;
|
||||||
|
|
||||||
|
SparkleShare.Controller.FolderFetched += delegate {
|
||||||
|
|
||||||
|
Application.Invoke (delegate {
|
||||||
|
ShowSuccessPage (folder);
|
||||||
|
});
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
SparkleShare.Controller.FolderFetchError += delegate {
|
||||||
|
|
||||||
|
Application.Invoke (delegate { ShowErrorPage (); });
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
SparkleShare.Controller.FetchFolder (url, folder);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
AddButton (reject_button);
|
||||||
|
AddButton (accept_button);
|
||||||
|
|
||||||
|
layout_vertical.PackStart (header, false, false, 0);
|
||||||
|
layout_vertical.PackStart (information, false, false, 21);
|
||||||
|
layout_vertical.PackStart (new Label (""), false, false, 0);
|
||||||
|
layout_vertical.PackStart (table, false, false, 0);
|
||||||
|
layout_vertical.PackStart (new Label (""), false, false, 0);
|
||||||
|
layout_vertical.PackStart (question, false, false, 21);
|
||||||
|
|
||||||
|
Add (layout_vertical);
|
||||||
|
|
||||||
|
ShowAll ();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// The page shown when syncing has failed
|
// The page shown when syncing has failed
|
||||||
private void ShowErrorPage ()
|
private void ShowErrorPage ()
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,351 +1,5 @@
|
||||||
// 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 SparkleLib;
|
|
||||||
using System;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using System.IO;
|
|
||||||
using System.Net;
|
|
||||||
using System.Xml;
|
|
||||||
|
|
||||||
namespace SparkleShare {
|
|
||||||
|
|
||||||
class SparkleInvitation : SparkleWindow {
|
|
||||||
|
|
||||||
public string Server;
|
|
||||||
public string Folder;
|
|
||||||
public string InviteKey;
|
|
||||||
public string FilePath;
|
|
||||||
|
|
||||||
|
|
||||||
// Short alias for the translations
|
|
||||||
public static string _ (string s)
|
|
||||||
{
|
|
||||||
return Catalog.GetString (s);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public SparkleInvitation (string file_path)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (!File.Exists (file_path))
|
|
||||||
return;
|
|
||||||
|
|
||||||
FilePath = file_path;
|
|
||||||
|
|
||||||
XmlDocument xml_doc = new XmlDocument ();
|
|
||||||
xml_doc.Load (file_path);
|
|
||||||
|
|
||||||
XmlNodeList server_xml = xml_doc.GetElementsByTagName ("server");
|
|
||||||
XmlNodeList folder_xml = xml_doc.GetElementsByTagName ("folder");
|
|
||||||
XmlNodeList invite_key_xml = xml_doc.GetElementsByTagName ("invite_key");
|
|
||||||
|
|
||||||
Server = server_xml [0].InnerText;
|
|
||||||
Folder = folder_xml [0].InnerText;
|
|
||||||
InviteKey = invite_key_xml [0].InnerText;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Uploads the user's public key to the
|
|
||||||
// server and starts the syncing process
|
|
||||||
public void Configure ()
|
|
||||||
{
|
|
||||||
|
|
||||||
// TODO: Move to controller
|
|
||||||
|
|
||||||
// The location of the user's public key for SparkleShare
|
|
||||||
string public_key_file_path = SparkleHelpers.CombineMore (SparklePaths.HomePath, ".ssh",
|
|
||||||
"sparkleshare." + SparkleShare.Controller.UserEmail + ".key.pub");
|
|
||||||
|
|
||||||
if (!File.Exists (public_key_file_path))
|
|
||||||
return;
|
|
||||||
|
|
||||||
StreamReader reader = new StreamReader (public_key_file_path);
|
|
||||||
string public_key = reader.ReadToEnd ();
|
|
||||||
reader.Close ();
|
|
||||||
|
|
||||||
string url = "http://" + Server + "/folder=" + Folder +
|
|
||||||
"&invite=" + InviteKey +
|
|
||||||
"&key=" + public_key;
|
|
||||||
|
|
||||||
SparkleHelpers.DebugInfo ("WebRequest", url);
|
|
||||||
|
|
||||||
HttpWebRequest request = (HttpWebRequest) WebRequest.Create (url);
|
|
||||||
HttpWebResponse response = (HttpWebResponse) request.GetResponse();
|
|
||||||
|
|
||||||
if (response.StatusCode == HttpStatusCode.OK)
|
|
||||||
File.Delete (FilePath);
|
|
||||||
|
|
||||||
response.Close ();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
new public void Present ()
|
|
||||||
{
|
|
||||||
|
|
||||||
VBox layout_vertical = new VBox (false, 0);
|
|
||||||
|
|
||||||
Label header = new Label ("<span size='x-large'><b>" +
|
|
||||||
_("Invitation received!") +
|
|
||||||
"</b></span>") {
|
|
||||||
UseMarkup = true,
|
|
||||||
Xalign = 0
|
|
||||||
};
|
|
||||||
|
|
||||||
Label information = new Label (_("You've received an invitation to join a shared folder.\n" +
|
|
||||||
"We're ready to hook you up immediately if you wish.")) {
|
|
||||||
Xalign = 0,
|
|
||||||
Wrap = true
|
|
||||||
};
|
|
||||||
|
|
||||||
Label question = new Label (_("Do you accept this invitation?")) {
|
|
||||||
Xalign = 0,
|
|
||||||
Wrap = true
|
|
||||||
};
|
|
||||||
|
|
||||||
Table table = new Table (2, 2, false) {
|
|
||||||
RowSpacing = 6
|
|
||||||
};
|
|
||||||
|
|
||||||
Label server_label = new Label (_("Server Address:")) {
|
|
||||||
Xalign = 0
|
|
||||||
};
|
|
||||||
|
|
||||||
Label server = new Label ("<b>" + Server + "</b>") {
|
|
||||||
UseMarkup = true,
|
|
||||||
Xalign = 0
|
|
||||||
};
|
|
||||||
|
|
||||||
Label folder_label = new Label (_("Folder Name:")) {
|
|
||||||
Xalign = 0
|
|
||||||
};
|
|
||||||
|
|
||||||
Label folder = new Label ("<b>" + Folder + "</b>") {
|
|
||||||
UseMarkup = true,
|
|
||||||
Xalign = 0
|
|
||||||
};
|
|
||||||
|
|
||||||
table.Attach (folder_label, 0, 1, 0, 1);
|
|
||||||
table.Attach (folder, 1, 2, 0, 1);
|
|
||||||
table.Attach (server_label, 0, 1, 1, 2);
|
|
||||||
table.Attach (server, 1, 2, 1, 2);
|
|
||||||
|
|
||||||
Button reject_button = new Button (_("Reject"));
|
|
||||||
Button accept_button = new Button (_("Accept and Sync"));
|
|
||||||
|
|
||||||
reject_button.Clicked += delegate {
|
|
||||||
|
|
||||||
Destroy ();
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
accept_button.Clicked += delegate {
|
|
||||||
|
|
||||||
string url = "ssh://git@" + Server + "/" + Folder;
|
|
||||||
SparkleHelpers.DebugInfo ("Git", "[" + Folder + "] Formed URL: " + url);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
SparkleShare.Controller.FolderFetched += delegate {
|
|
||||||
|
|
||||||
Application.Invoke (delegate {
|
|
||||||
ShowSuccessPage (Folder);
|
|
||||||
});
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
SparkleShare.Controller.FolderFetchError += delegate {
|
|
||||||
|
|
||||||
Application.Invoke (delegate { ShowErrorPage (); });
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
SparkleShare.Controller.FetchFolder (url, Folder);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
AddButton (reject_button);
|
|
||||||
AddButton (accept_button);
|
|
||||||
|
|
||||||
layout_vertical.PackStart (header, false, false, 0);
|
|
||||||
layout_vertical.PackStart (information, false, false, 21);
|
|
||||||
layout_vertical.PackStart (new Label (""), false, false, 0);
|
|
||||||
layout_vertical.PackStart (table, false, false, 0);
|
|
||||||
layout_vertical.PackStart (new Label (""), false, false, 0);
|
|
||||||
layout_vertical.PackStart (question, false, false, 21);
|
|
||||||
|
|
||||||
Add (layout_vertical);
|
|
||||||
|
|
||||||
ShowAll ();
|
|
||||||
|
|
||||||
base.Present ();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void ShowErrorPage ()
|
|
||||||
{
|
|
||||||
|
|
||||||
Reset ();
|
|
||||||
|
|
||||||
VBox layout_vertical = new VBox (false, 0);
|
|
||||||
|
|
||||||
Label header = new Label ("<span size='x-large'><b>" +
|
|
||||||
_("Something went wrong…") +
|
|
||||||
"</b></span>\n") {
|
|
||||||
UseMarkup = true,
|
|
||||||
Xalign = 0
|
|
||||||
};
|
|
||||||
|
|
||||||
Button close_button = new Button (_("Close")) {
|
|
||||||
Sensitive = true
|
|
||||||
};
|
|
||||||
|
|
||||||
close_button.Clicked += delegate (object o, EventArgs args) {
|
|
||||||
Destroy ();
|
|
||||||
};
|
|
||||||
|
|
||||||
AddButton (close_button);
|
|
||||||
|
|
||||||
layout_vertical.PackStart (header, false, false, 0);
|
|
||||||
|
|
||||||
Add (layout_vertical);
|
|
||||||
|
|
||||||
ShowAll ();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void ShowSuccessPage (string name)
|
|
||||||
{
|
|
||||||
|
|
||||||
Reset ();
|
|
||||||
|
|
||||||
VBox layout_vertical = new VBox (false, 0);
|
|
||||||
|
|
||||||
Label header = new Label ("<span size='x-large'><b>" +
|
|
||||||
_("Folder synced successfully!") +
|
|
||||||
"</b></span>") {
|
|
||||||
UseMarkup = true,
|
|
||||||
Xalign = 0
|
|
||||||
};
|
|
||||||
|
|
||||||
Label information = new Label (String.Format(_("Now you can access the synced files from ‘{0}’ in your SparkleShare folder."),
|
|
||||||
name)) {
|
|
||||||
Xalign = 0,
|
|
||||||
Wrap = true,
|
|
||||||
UseMarkup = true
|
|
||||||
};
|
|
||||||
|
|
||||||
Button open_folder_button = new Button (_("Open Folder"));
|
|
||||||
|
|
||||||
open_folder_button.Clicked += delegate (object o, EventArgs args) {
|
|
||||||
|
|
||||||
string path = SparkleHelpers.CombineMore (SparklePaths.SparklePath, name);
|
|
||||||
|
|
||||||
Process process = new Process ();
|
|
||||||
process.StartInfo.FileName = "xdg-open";
|
|
||||||
process.StartInfo.Arguments = path.Replace (" ", "\\ "); // Escape space-characters
|
|
||||||
process.Start ();
|
|
||||||
|
|
||||||
Destroy ();
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
Button finish_button = new Button (_("Finish"));
|
|
||||||
|
|
||||||
finish_button.Clicked += delegate (object o, EventArgs args) {
|
|
||||||
Destroy ();
|
|
||||||
};
|
|
||||||
|
|
||||||
AddButton (open_folder_button);
|
|
||||||
AddButton (finish_button);
|
|
||||||
|
|
||||||
layout_vertical.PackStart (header, false, false, 0);
|
|
||||||
layout_vertical.PackStart (information, false, false, 21);
|
|
||||||
|
|
||||||
Add (layout_vertical);
|
|
||||||
|
|
||||||
ShowAll ();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: These pages are identical to the intro ones,
|
|
||||||
// find a way to remove duplication
|
|
||||||
private void ShowSyncingPage (string name)
|
|
||||||
{
|
|
||||||
|
|
||||||
Reset ();
|
|
||||||
|
|
||||||
VBox layout_vertical = new VBox (false, 0);
|
|
||||||
|
|
||||||
Label header = new Label ("<span size='x-large'><b>" +
|
|
||||||
String.Format (_("Syncing folder ‘{0}’…"), name) +
|
|
||||||
"</b></span>") {
|
|
||||||
UseMarkup = true,
|
|
||||||
Xalign = 0,
|
|
||||||
Wrap = true
|
|
||||||
};
|
|
||||||
|
|
||||||
Label information = new Label (_("This may take a while.\n") +
|
|
||||||
_("You sure it’s not coffee o-clock?")) {
|
|
||||||
UseMarkup = true,
|
|
||||||
Xalign = 0
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
Button button = new Button () {
|
|
||||||
Sensitive = false,
|
|
||||||
Label = _("Finish")
|
|
||||||
};
|
|
||||||
|
|
||||||
button.Clicked += delegate {
|
|
||||||
Destroy ();
|
|
||||||
};
|
|
||||||
|
|
||||||
AddButton (button);
|
|
||||||
|
|
||||||
SparkleSpinner spinner = new SparkleSpinner (22);
|
|
||||||
|
|
||||||
Table table = new Table (2, 2, false) {
|
|
||||||
RowSpacing = 12,
|
|
||||||
ColumnSpacing = 9
|
|
||||||
};
|
|
||||||
|
|
||||||
HBox box = new HBox (false, 0);
|
|
||||||
|
|
||||||
table.Attach (spinner, 0, 1, 0, 1);
|
|
||||||
table.Attach (header, 1, 2, 0, 1);
|
|
||||||
table.Attach (information, 1, 2, 1, 2);
|
|
||||||
|
|
||||||
box.PackStart (table, false, false, 0);
|
|
||||||
|
|
||||||
layout_vertical.PackStart (box, false, false, 0);
|
|
||||||
|
|
||||||
Add (layout_vertical);
|
|
||||||
|
|
||||||
ShowAll ();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -55,22 +55,22 @@ namespace SparkleShare {
|
||||||
|
|
||||||
if (SparkleShare.Controller.FirstRun) {
|
if (SparkleShare.Controller.FirstRun) {
|
||||||
|
|
||||||
SparkleIntro intro = new SparkleIntro ();
|
SparkleIntro intro = new SparkleIntro ();
|
||||||
intro.ShowAll ();
|
intro.ShowAccountForm ();
|
||||||
intro.Present ();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SparkleShare.Controller.OnQuitWhileSyncing += delegate {
|
SparkleShare.Controller.OnQuitWhileSyncing += delegate {
|
||||||
|
|
||||||
// TODO: Pop up a warning when quitting whilst syncing
|
// TODO: Pop up a warning when quitting whilst syncing
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
SparkleShare.Controller.OnInvitation += delegate (string invitation_file_path) {
|
SparkleShare.Controller.OnInvitation += delegate (string server, string folder, string token) {
|
||||||
Application.Invoke (delegate {
|
Application.Invoke (delegate {
|
||||||
|
|
||||||
Console.WriteLine ("INVITATION RECEIVED!!!!1");
|
SparkleIntro intro = new SparkleIntro ();
|
||||||
SparkleInvitation invitation = new SparkleInvitation (invitation_file_path);
|
intro.ShowInvitationPage (server, folder, token);
|
||||||
invitation.Present ();
|
|
||||||
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
|
||||||
<sparkleshare_invitation>
|
<sparkleshare_invitation>
|
||||||
<server="git.gnome.org" />
|
|
||||||
<repository="gnome-design" />
|
<server>git.gnome.org</server>
|
||||||
<key="a22bc6f4b9ffe8e5acd4be0838d41aa10a1187dd" />
|
<folder>gnome-design</folder>
|
||||||
<email="hylkebons@gmail.com" />
|
<token>a22bc6f4b9ffe8e5acd4be0838d41aa10a1187dd</token>
|
||||||
|
|
||||||
</sparkleshare_invitation>
|
</sparkleshare_invitation>
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
|
||||||
<sparkleshare_invitation>
|
|
||||||
<server>git.gnome.org</server>
|
|
||||||
<repository>gnome-design</repository>
|
|
||||||
<key>a22bc6f4b9ffe8e5acd4be0838d41aa10a1187dd</key>
|
|
||||||
</sparkleshare_invitation>
|
|
Loading…
Reference in a new issue