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');
|
||||
$('.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"));
|
||||
event.preventDefault();
|
||||
});
|
||||
|
||||
// Update the Today and Yesterday labels after midnight
|
||||
|
@ -26,7 +27,7 @@
|
|||
}
|
||||
}, 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 () {
|
||||
var entry_count = $(this).parent ().find ('dl').children ().length;
|
||||
|
||||
|
@ -124,7 +125,6 @@
|
|||
border-bottom: 1px #ddd solid;
|
||||
background-repeat: no-repeat;
|
||||
background-position: 36px 24px;
|
||||
min-height: 100px;
|
||||
}
|
||||
|
||||
.event-user-name {
|
||||
|
@ -166,34 +166,32 @@
|
|||
}
|
||||
|
||||
table {
|
||||
padding: 18px 32px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.table-wrapper {
|
||||
padding: 64px 32px;
|
||||
}
|
||||
|
||||
td {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
td.name {
|
||||
width: 45%;
|
||||
font-weight: bold;
|
||||
width: 45%;
|
||||
}
|
||||
|
||||
td.time {
|
||||
font-size: <!-- $small-font-size -->;
|
||||
color: <!-- $secondary-font-color -->;
|
||||
padding-right: 9px;
|
||||
width: 20px;
|
||||
padding-top: 2px;
|
||||
}
|
||||
|
||||
td.date {
|
||||
font-size: <!-- $small-font-size -->;
|
||||
color: <!-- $secondary-font-color -->;
|
||||
text-align: right;
|
||||
padding-right: 6px;
|
||||
padding-top: 2px;
|
||||
}
|
||||
|
||||
td.restore {
|
||||
|
|
|
@ -224,6 +224,8 @@ namespace SparkleShare {
|
|||
|
||||
public void LinkClicked (string url)
|
||||
{
|
||||
|
||||
|
||||
url = url.Replace ("%20", " ");
|
||||
|
||||
if (url.StartsWith ("file://") ||
|
||||
|
@ -256,7 +258,6 @@ namespace SparkleShare {
|
|||
Path.GetDirectoryName (this.restore_revision_info.FilePath));
|
||||
|
||||
ShowSaveDialogEvent (file_name, target_folder_path);
|
||||
|
||||
}
|
||||
|
||||
} else if (url.StartsWith ("back://")) {
|
||||
|
@ -275,14 +276,9 @@ namespace SparkleShare {
|
|||
string folder = url.Replace ("history://", "").Split ("/".ToCharArray ()) [0];
|
||||
string file_path = url.Replace ("history://" + folder + "/", "");
|
||||
|
||||
SparkleRepoBase repo;
|
||||
|
||||
foreach (SparkleRepoBase test_repo in Program.Controller.Repositories) {
|
||||
if (test_repo.Name.Equals (folder)) {
|
||||
repo = test_repo;
|
||||
break;
|
||||
}
|
||||
}
|
||||
foreach (SparkleRepoBase repo in Program.Controller.Repositories) {
|
||||
if (!repo.Name.Equals (folder))
|
||||
continue;
|
||||
|
||||
new Thread (() => {
|
||||
Stopwatch watch = new Stopwatch ();
|
||||
|
@ -300,6 +296,9 @@ namespace SparkleShare {
|
|||
UpdateContentEvent (html);
|
||||
|
||||
}).Start ();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -365,7 +364,7 @@ namespace SparkleShare {
|
|||
|
||||
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)
|
||||
html += "Revisions for “";
|
||||
|
@ -373,7 +372,7 @@ namespace SparkleShare {
|
|||
html += "No revisions for “";
|
||||
|
||||
html += Path.GetFileName (file_path) + "”";
|
||||
html += "</div><table>";
|
||||
html += "</div><div class='table-wrapper'><table>";
|
||||
|
||||
int count = 0;
|
||||
foreach (SparkleChangeSet change_set in change_sets) {
|
||||
|
@ -405,9 +404,10 @@ namespace SparkleShare {
|
|||
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
|
||||
// along with this program. If not, see (http://www.gnu.org/licenses/).
|
||||
|
||||
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
|
@ -26,6 +25,7 @@ using System.Windows.Controls;
|
|||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
|
||||
using Microsoft.Win32;
|
||||
using Shapes = System.Windows.Shapes;
|
||||
|
||||
namespace SparkleShare {
|
||||
|
@ -50,7 +50,7 @@ namespace SparkleShare {
|
|||
ResizeMode = ResizeMode.NoResize; // TODO
|
||||
Background = new SolidColorBrush (Color.FromRgb (240, 240, 240));
|
||||
AllowsTransparency = false;
|
||||
Icon = SparkleUIHelpers.GetImageSource("sparkleshare-app", "ico");
|
||||
Icon = SparkleUIHelpers.GetImageSource ("sparkleshare-app", "ico");
|
||||
|
||||
int x = (int) (SystemParameters.PrimaryScreenWidth * 0.61);
|
||||
int y = (int) (SystemParameters.PrimaryScreenHeight * 0.5 - (Height * 0.5));
|
||||
|
@ -104,6 +104,8 @@ namespace SparkleShare {
|
|||
|
||||
this.web_browser.ObjectForScripting = new SparkleScriptingObject ();
|
||||
|
||||
|
||||
|
||||
spinner = new SparkleSpinner (22);
|
||||
|
||||
// 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) {
|
||||
Dispatcher.BeginInvoke ((Action) delegate {
|
||||
UpdateContent (html);
|
||||
|
@ -191,6 +199,25 @@ namespace SparkleShare {
|
|||
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 ("<!-- $secondary-font-color -->", "#bbb");
|
||||
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 ("<!-- $a-color -->", "#0085cf");
|
||||
html = html.Replace ("<!-- $a-hover-color -->", "#009ff8");
|
||||
|
@ -282,9 +310,17 @@ namespace SparkleShare {
|
|||
|
||||
Dispatcher.BeginInvoke ((Action) delegate {
|
||||
this.spinner.Stop ();
|
||||
|
||||
this.web_browser.ObjectForScripting = new SparkleScriptingObject ();
|
||||
//if (html != null) {
|
||||
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)) {
|
||||
this.canvas.Children.Add (this.web_browser);
|
||||
Canvas.SetLeft (this.web_browser, 0);
|
||||
|
@ -322,8 +358,8 @@ namespace SparkleShare {
|
|||
string [] actions = new string [] {"added", "deleted", "edited", "moved"};
|
||||
|
||||
foreach (string action in actions) {
|
||||
BitmapSource image = SparkleUIHelpers.GetImageSource ("document-" + action + "-12");
|
||||
string file_path = Path.Combine (pixmaps_path, "document-" + action + "-12.png");
|
||||
image = SparkleUIHelpers.GetImageSource ("document-" + action + "-12");
|
||||
file_path = Path.Combine (pixmaps_path, "document-" + action + "-12.png");
|
||||
|
||||
using (FileStream stream = new FileStream (file_path, FileMode.Create))
|
||||
{
|
||||
|
@ -345,8 +381,8 @@ namespace SparkleShare {
|
|||
[DllImport ("urlmon.dll")]
|
||||
[PreserveSig]
|
||||
[return:MarshalAs (UnmanagedType.Error)]
|
||||
static extern int CoInternetSetFeatureEnabled (
|
||||
int feature, [MarshalAs (UnmanagedType.U4)] int flags, bool enable);
|
||||
static extern int CoInternetSetFeatureEnabled (int feature,
|
||||
[MarshalAs (UnmanagedType.U4)] int flags, bool enable);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue