history: implement windows save dialog
This commit is contained in:
parent
bee4bda492
commit
63df2267d8
|
@ -10,8 +10,9 @@
|
||||||
$('dl dd:nth-child(-n+10)').css('display', 'block');
|
$('dl dd:nth-child(-n+10)').css('display', 'block');
|
||||||
$('.day-entry-content .event-entry:last-child').css('border', 'none');
|
$('.day-entry-content .event-entry:last-child').css('border', 'none');
|
||||||
|
|
||||||
$('dd a.windows').click(function () {
|
$('a').click(function (event) {
|
||||||
window.external.LinkClicked($(this).attr("href"));
|
window.external.LinkClicked($(this).attr("href"));
|
||||||
|
event.preventDefault();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Update the Today and Yesterday labels after midnight
|
// Update the Today and Yesterday labels after midnight
|
||||||
|
@ -26,7 +27,7 @@
|
||||||
}
|
}
|
||||||
}, 60 * 1000);
|
}, 60 * 1000);
|
||||||
|
|
||||||
// Hide the 'Show all' link when there are less than 10 events
|
// Hide the 'Show all' link when there are fewer than 10 events
|
||||||
$('.show').each (function () {
|
$('.show').each (function () {
|
||||||
var entry_count = $(this).parent ().find ('dl').children ().length;
|
var entry_count = $(this).parent ().find ('dl').children ().length;
|
||||||
|
|
||||||
|
@ -124,7 +125,6 @@
|
||||||
border-bottom: 1px #ddd solid;
|
border-bottom: 1px #ddd solid;
|
||||||
background-repeat: no-repeat;
|
background-repeat: no-repeat;
|
||||||
background-position: 36px 24px;
|
background-position: 36px 24px;
|
||||||
min-height: 100px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.event-user-name {
|
.event-user-name {
|
||||||
|
@ -166,34 +166,32 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
table {
|
table {
|
||||||
padding: 18px 32px;
|
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.table-wrapper {
|
||||||
|
padding: 64px 32px;
|
||||||
|
}
|
||||||
|
|
||||||
td {
|
td {
|
||||||
padding: 0;
|
padding: 0;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
td.name {
|
td.name {
|
||||||
width: 45%;
|
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
|
width: 45%;
|
||||||
}
|
}
|
||||||
|
|
||||||
td.time {
|
td.time {
|
||||||
font-size: <!-- $small-font-size -->;
|
|
||||||
color: <!-- $secondary-font-color -->;
|
color: <!-- $secondary-font-color -->;
|
||||||
padding-right: 9px;
|
padding-right: 9px;
|
||||||
width: 20px;
|
|
||||||
padding-top: 2px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
td.date {
|
td.date {
|
||||||
font-size: <!-- $small-font-size -->;
|
|
||||||
color: <!-- $secondary-font-color -->;
|
color: <!-- $secondary-font-color -->;
|
||||||
text-align: right;
|
text-align: right;
|
||||||
padding-right: 6px;
|
padding-right: 6px;
|
||||||
padding-top: 2px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
td.restore {
|
td.restore {
|
||||||
|
|
|
@ -224,6 +224,8 @@ namespace SparkleShare {
|
||||||
|
|
||||||
public void LinkClicked (string url)
|
public void LinkClicked (string url)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
url = url.Replace ("%20", " ");
|
url = url.Replace ("%20", " ");
|
||||||
|
|
||||||
if (url.StartsWith ("file://") ||
|
if (url.StartsWith ("file://") ||
|
||||||
|
@ -256,7 +258,6 @@ namespace SparkleShare {
|
||||||
Path.GetDirectoryName (this.restore_revision_info.FilePath));
|
Path.GetDirectoryName (this.restore_revision_info.FilePath));
|
||||||
|
|
||||||
ShowSaveDialogEvent (file_name, target_folder_path);
|
ShowSaveDialogEvent (file_name, target_folder_path);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (url.StartsWith ("back://")) {
|
} else if (url.StartsWith ("back://")) {
|
||||||
|
@ -275,14 +276,9 @@ namespace SparkleShare {
|
||||||
string folder = url.Replace ("history://", "").Split ("/".ToCharArray ()) [0];
|
string folder = url.Replace ("history://", "").Split ("/".ToCharArray ()) [0];
|
||||||
string file_path = url.Replace ("history://" + folder + "/", "");
|
string file_path = url.Replace ("history://" + folder + "/", "");
|
||||||
|
|
||||||
SparkleRepoBase repo;
|
foreach (SparkleRepoBase repo in Program.Controller.Repositories) {
|
||||||
|
if (!repo.Name.Equals (folder))
|
||||||
foreach (SparkleRepoBase test_repo in Program.Controller.Repositories) {
|
continue;
|
||||||
if (test_repo.Name.Equals (folder)) {
|
|
||||||
repo = test_repo;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
new Thread (() => {
|
new Thread (() => {
|
||||||
Stopwatch watch = new Stopwatch ();
|
Stopwatch watch = new Stopwatch ();
|
||||||
|
@ -300,6 +296,9 @@ namespace SparkleShare {
|
||||||
UpdateContentEvent (html);
|
UpdateContentEvent (html);
|
||||||
|
|
||||||
}).Start ();
|
}).Start ();
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -365,7 +364,7 @@ namespace SparkleShare {
|
||||||
|
|
||||||
public string GetHistoryHTMLLog (List<SparkleChangeSet> change_sets, string file_path)
|
public string GetHistoryHTMLLog (List<SparkleChangeSet> change_sets, string file_path)
|
||||||
{
|
{
|
||||||
string html = "<div class='history-header'><a href='back://'>« Back</a> | ";
|
string html = "<div class='history-header'><a class='windows' href='back://'>« Back</a> | ";
|
||||||
|
|
||||||
if (change_sets.Count > 1)
|
if (change_sets.Count > 1)
|
||||||
html += "Revisions for “";
|
html += "Revisions for “";
|
||||||
|
@ -373,7 +372,7 @@ namespace SparkleShare {
|
||||||
html += "No revisions for “";
|
html += "No revisions for “";
|
||||||
|
|
||||||
html += Path.GetFileName (file_path) + "”";
|
html += Path.GetFileName (file_path) + "”";
|
||||||
html += "</div><table>";
|
html += "</div><div class='table-wrapper'><table>";
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
foreach (SparkleChangeSet change_set in change_sets) {
|
foreach (SparkleChangeSet change_set in change_sets) {
|
||||||
|
@ -405,9 +404,10 @@ namespace SparkleShare {
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
html += "</table>";
|
html += "</table></div>";
|
||||||
|
html = Program.Controller.EventLogHTML.Replace ("<!-- $event-log-content -->", html);
|
||||||
|
|
||||||
return Program.Controller.EventLogHTML.Replace ("<!-- $event-log-content -->", html);
|
return html.Replace ("<!-- $midnight -->", "1000000000000000000");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program. If not, see (http://www.gnu.org/licenses/).
|
// along with this program. If not, see (http://www.gnu.org/licenses/).
|
||||||
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
@ -26,6 +25,7 @@ using System.Windows.Controls;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using System.Windows.Media.Imaging;
|
using System.Windows.Media.Imaging;
|
||||||
|
|
||||||
|
using Microsoft.Win32;
|
||||||
using Shapes = System.Windows.Shapes;
|
using Shapes = System.Windows.Shapes;
|
||||||
|
|
||||||
namespace SparkleShare {
|
namespace SparkleShare {
|
||||||
|
@ -104,6 +104,8 @@ namespace SparkleShare {
|
||||||
|
|
||||||
this.web_browser.ObjectForScripting = new SparkleScriptingObject ();
|
this.web_browser.ObjectForScripting = new SparkleScriptingObject ();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
spinner = new SparkleSpinner (22);
|
spinner = new SparkleSpinner (22);
|
||||||
|
|
||||||
// Disable annoying IE clicking sound
|
// Disable annoying IE clicking sound
|
||||||
|
@ -177,6 +179,12 @@ namespace SparkleShare {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Controller.UpdateChooserEnablementEvent += delegate (bool enabled) {
|
||||||
|
Dispatcher.BeginInvoke ((Action) delegate {
|
||||||
|
this.combo_box.IsEnabled = enabled;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
Controller.UpdateContentEvent += delegate (string html) {
|
Controller.UpdateContentEvent += delegate (string html) {
|
||||||
Dispatcher.BeginInvoke ((Action) delegate {
|
Dispatcher.BeginInvoke ((Action) delegate {
|
||||||
UpdateContent (html);
|
UpdateContent (html);
|
||||||
|
@ -191,6 +199,25 @@ namespace SparkleShare {
|
||||||
this.canvas.Children.Remove (this.web_browser);
|
this.canvas.Children.Remove (this.web_browser);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Controller.ShowSaveDialogEvent += delegate (string file_name, string target_folder_path) {
|
||||||
|
Dispatcher.BeginInvoke ((Action) delegate {
|
||||||
|
SaveFileDialog dialog = new SaveFileDialog () {
|
||||||
|
FileName = file_name,
|
||||||
|
InitialDirectory = target_folder_path,
|
||||||
|
Title = "Restore from History",
|
||||||
|
DefaultExt = "." + Path.GetExtension (file_name),
|
||||||
|
Filter = "All Files|*.*"
|
||||||
|
};
|
||||||
|
|
||||||
|
Nullable<bool> result = dialog.ShowDialog (this);
|
||||||
|
|
||||||
|
if (result == true)
|
||||||
|
Controller.SaveDialogCompleted (dialog.FileName);
|
||||||
|
else
|
||||||
|
Controller.SaveDialogCancelled ();
|
||||||
|
});
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -262,6 +289,7 @@ namespace SparkleShare {
|
||||||
html = html.Replace ("<!-- $body-font-size -->", "12px");
|
html = html.Replace ("<!-- $body-font-size -->", "12px");
|
||||||
html = html.Replace ("<!-- $secondary-font-color -->", "#bbb");
|
html = html.Replace ("<!-- $secondary-font-color -->", "#bbb");
|
||||||
html = html.Replace ("<!-- $small-color -->", "#ddd");
|
html = html.Replace ("<!-- $small-color -->", "#ddd");
|
||||||
|
html = html.Replace ("<!-- $small-font-size -->", "90%");
|
||||||
html = html.Replace ("<!-- $day-entry-header-background-color -->", "#f5f5f5");
|
html = html.Replace ("<!-- $day-entry-header-background-color -->", "#f5f5f5");
|
||||||
html = html.Replace ("<!-- $a-color -->", "#0085cf");
|
html = html.Replace ("<!-- $a-color -->", "#0085cf");
|
||||||
html = html.Replace ("<!-- $a-hover-color -->", "#009ff8");
|
html = html.Replace ("<!-- $a-hover-color -->", "#009ff8");
|
||||||
|
@ -282,9 +310,17 @@ namespace SparkleShare {
|
||||||
|
|
||||||
Dispatcher.BeginInvoke ((Action) delegate {
|
Dispatcher.BeginInvoke ((Action) delegate {
|
||||||
this.spinner.Stop ();
|
this.spinner.Stop ();
|
||||||
|
this.web_browser.ObjectForScripting = new SparkleScriptingObject ();
|
||||||
|
//if (html != null) {
|
||||||
this.web_browser.NavigateToString (html);
|
this.web_browser.NavigateToString (html);
|
||||||
|
SparkleLib.SparkleLogger.LogInfo ("FFF", ""+html);
|
||||||
|
//}
|
||||||
|
/* this.web_browser.Navigating += delegate(object sender, System.Windows.Navigation.NavigatingCancelEventArgs e) {
|
||||||
|
Program.UI.EventLog.Controller.LinkClicked (e.Uri.ToString());
|
||||||
|
if (e.Uri.ToString().StartsWith ("back://"))
|
||||||
|
e.Cancel = true;
|
||||||
|
|
||||||
|
};*/
|
||||||
if (!this.canvas.Children.Contains (this.web_browser)) {
|
if (!this.canvas.Children.Contains (this.web_browser)) {
|
||||||
this.canvas.Children.Add (this.web_browser);
|
this.canvas.Children.Add (this.web_browser);
|
||||||
Canvas.SetLeft (this.web_browser, 0);
|
Canvas.SetLeft (this.web_browser, 0);
|
||||||
|
@ -322,8 +358,8 @@ namespace SparkleShare {
|
||||||
string [] actions = new string [] {"added", "deleted", "edited", "moved"};
|
string [] actions = new string [] {"added", "deleted", "edited", "moved"};
|
||||||
|
|
||||||
foreach (string action in actions) {
|
foreach (string action in actions) {
|
||||||
BitmapSource image = SparkleUIHelpers.GetImageSource ("document-" + action + "-12");
|
image = SparkleUIHelpers.GetImageSource ("document-" + action + "-12");
|
||||||
string file_path = Path.Combine (pixmaps_path, "document-" + action + "-12.png");
|
file_path = Path.Combine (pixmaps_path, "document-" + action + "-12.png");
|
||||||
|
|
||||||
using (FileStream stream = new FileStream (file_path, FileMode.Create))
|
using (FileStream stream = new FileStream (file_path, FileMode.Create))
|
||||||
{
|
{
|
||||||
|
@ -345,8 +381,8 @@ namespace SparkleShare {
|
||||||
[DllImport ("urlmon.dll")]
|
[DllImport ("urlmon.dll")]
|
||||||
[PreserveSig]
|
[PreserveSig]
|
||||||
[return:MarshalAs (UnmanagedType.Error)]
|
[return:MarshalAs (UnmanagedType.Error)]
|
||||||
static extern int CoInternetSetFeatureEnabled (
|
static extern int CoInternetSetFeatureEnabled (int feature,
|
||||||
int feature, [MarshalAs (UnmanagedType.U4)] int flags, bool enable);
|
[MarshalAs (UnmanagedType.U4)] int flags, bool enable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue