linux bring log UI in line with Mac
This commit is contained in:
parent
19a3b797f0
commit
d3bdd357e8
|
@ -145,8 +145,8 @@ namespace SparkleShare {
|
|||
|
||||
// A short delay is less annoying than
|
||||
// a flashing window
|
||||
if (watch.ElapsedMilliseconds < 300 && !silent)
|
||||
Thread.Sleep (300 - (int) watch.ElapsedMilliseconds);
|
||||
if (watch.ElapsedMilliseconds < 500 && !silent)
|
||||
Thread.Sleep (500 - (int) watch.ElapsedMilliseconds);
|
||||
|
||||
AddHTML ();
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ SOURCES = \
|
|||
SparkleInfobar.cs \
|
||||
SparkleIntro.cs \
|
||||
SparkleLinController.cs \
|
||||
SparkleLog.cs \
|
||||
SparkleEventLog.cs \
|
||||
SparkleShare.cs \
|
||||
SparkleSpinner.cs \
|
||||
SparkleStatusIcon.cs \
|
||||
|
|
|
@ -28,9 +28,7 @@ using WebKit;
|
|||
|
||||
namespace SparkleShare {
|
||||
|
||||
public class SparkleLog : Window {
|
||||
|
||||
public readonly string LocalPath;
|
||||
public class SparkleEventLog : Window {
|
||||
|
||||
private ScrolledWindow ScrolledWindow;
|
||||
private MenuBar MenuBar;
|
||||
|
@ -39,6 +37,10 @@ namespace SparkleShare {
|
|||
private SparkleSpinner Spinner;
|
||||
private string HTML;
|
||||
private EventBox LogContent;
|
||||
private List<SparkleChangeSet> change_sets;
|
||||
private string selected_log = null;
|
||||
private ComboBox combo_box;
|
||||
private HBox layout_horizontal;
|
||||
|
||||
|
||||
// Short alias for the translations
|
||||
|
@ -48,48 +50,35 @@ namespace SparkleShare {
|
|||
}
|
||||
|
||||
|
||||
public SparkleLog (string path) : base ("")
|
||||
public SparkleEventLog () : base ("")
|
||||
{
|
||||
LocalPath = path;
|
||||
|
||||
string name = System.IO.Path.GetFileName (LocalPath);
|
||||
SetSizeRequest (480, 640);
|
||||
|
||||
Resizable = false;
|
||||
|
||||
BorderWidth = 0;
|
||||
SetPosition (WindowPosition.Center);
|
||||
|
||||
// Open slightly off center for each consecutive window
|
||||
if (SparkleUI.OpenLogs.Count > 0) {
|
||||
Resizable = false;
|
||||
BorderWidth = 0;
|
||||
|
||||
int x, y;
|
||||
GetPosition (out x, out y);
|
||||
Move (x + SparkleUI.OpenLogs.Count * 20, y + SparkleUI.OpenLogs.Count * 20);
|
||||
|
||||
}
|
||||
|
||||
// TRANSLATORS: {0} is a folder name, and {1} is a server address
|
||||
Title = String.Format(_("Events in ‘{0}’"), name);
|
||||
Title = _("Recent Events");
|
||||
IconName = "folder-sparkleshare";
|
||||
|
||||
DeleteEvent += Close;
|
||||
DeleteEvent += Close;
|
||||
|
||||
CreateEventLog ();
|
||||
UpdateEventLog ();
|
||||
CreateEvents ();
|
||||
UpdateEvents (false);
|
||||
UpdateChooser ();
|
||||
}
|
||||
|
||||
|
||||
private void CreateEventLog ()
|
||||
private void CreateEvents ()
|
||||
{
|
||||
LogContent = new EventBox ();
|
||||
VBox layout_vertical = new VBox (false, 0);
|
||||
LogContent = new EventBox ();
|
||||
|
||||
ScrolledWindow = new ScrolledWindow ();
|
||||
ScrolledWindow = new ScrolledWindow ();
|
||||
|
||||
WebView = new WebView () {
|
||||
Editable = false
|
||||
};
|
||||
WebView = new WebView () {
|
||||
Editable = false
|
||||
};
|
||||
|
||||
WebView.HoveringOverLink += delegate (object o, WebKit.HoveringOverLinkArgs args) {
|
||||
LinkStatus = args.Link;
|
||||
|
@ -103,50 +92,77 @@ namespace SparkleShare {
|
|||
process.StartInfo.Arguments = args.Request.Uri.Replace (" ", "\\ "); // Escape space-characters
|
||||
process.Start ();
|
||||
|
||||
UpdateEventLog ();
|
||||
UpdateEvents ();
|
||||
}
|
||||
};
|
||||
|
||||
ScrolledWindow.Add (WebView);
|
||||
LogContent.Add (ScrolledWindow);
|
||||
ScrolledWindow.Add (WebView);
|
||||
LogContent.Add (ScrolledWindow);
|
||||
|
||||
this.layout_horizontal = new HBox (true, 0);
|
||||
this.layout_horizontal.PackStart (new Label (""), true, true, 0);
|
||||
this.layout_horizontal.PackStart (new Label (""), true, true, 0);
|
||||
|
||||
layout_vertical.PackStart (layout_horizontal, false, false, 0);
|
||||
layout_vertical.PackStart (LogContent, true, true, 0);
|
||||
|
||||
HButtonBox dialog_buttons = new HButtonBox {
|
||||
Layout = ButtonBoxStyle.Edge,
|
||||
BorderWidth = 12
|
||||
};
|
||||
|
||||
Button open_folder_button = new Button (_("_Open Folder")) {
|
||||
UseUnderline = true
|
||||
};
|
||||
|
||||
open_folder_button.Clicked += delegate (object o, EventArgs args) {
|
||||
SparkleShare.Controller.OpenSparkleShareFolder (LocalPath);
|
||||
};
|
||||
|
||||
Button close_button = new Button (Stock.Close);
|
||||
|
||||
close_button.Clicked += delegate {
|
||||
HideAll ();
|
||||
};
|
||||
|
||||
dialog_buttons.Add (open_folder_button);
|
||||
dialog_buttons.Add (close_button);
|
||||
|
||||
// We have to hide the menubar somewhere...
|
||||
layout_vertical.PackStart (CreateShortcutsBar (), false, false, 0);
|
||||
layout_vertical.PackStart (dialog_buttons, false, false, 0);
|
||||
|
||||
Add (layout_vertical);
|
||||
|
||||
ShowAll ();
|
||||
}
|
||||
|
||||
|
||||
public void UpdateEventLog ()
|
||||
public void UpdateChooser ()
|
||||
{
|
||||
if (HTML == null) { // TODO: there may be a race condition here
|
||||
if (this.combo_box != null && this.combo_box.Parent != null)
|
||||
this.layout_horizontal.Remove (this.combo_box);
|
||||
|
||||
this.combo_box = new ComboBox ();
|
||||
this.layout_horizontal.BorderWidth = 9;
|
||||
|
||||
CellRendererText cell = new CellRendererText();
|
||||
this.combo_box.PackStart (cell, false);
|
||||
this.combo_box.AddAttribute (cell, "text", 0);
|
||||
ListStore store = new ListStore (typeof (string));
|
||||
this.combo_box.Model = store;
|
||||
|
||||
store.AppendValues (_("All Folders"));
|
||||
|
||||
foreach (string folder_name in SparkleShare.Controller.Folders)
|
||||
store.AppendValues (folder_name);
|
||||
|
||||
this.combo_box.Active = 0;
|
||||
|
||||
this.combo_box.Changed += delegate {
|
||||
TreeIter iter;
|
||||
this.combo_box.GetActiveIter (out iter);
|
||||
|
||||
string selection = (string) this.combo_box.Model.GetValue (iter, 0);
|
||||
|
||||
if (selection.Equals (_("All Folders")))
|
||||
this.selected_log = null;
|
||||
else
|
||||
this.selected_log = selection;
|
||||
|
||||
UpdateEvents (false);
|
||||
};
|
||||
|
||||
this.layout_horizontal.PackStart (this.combo_box, true, true, 0);
|
||||
this.layout_horizontal.ShowAll ();
|
||||
}
|
||||
|
||||
|
||||
public void UpdateEvents ()
|
||||
{
|
||||
UpdateEvents (true);
|
||||
}
|
||||
|
||||
|
||||
public void UpdateEvents (bool silent)
|
||||
{
|
||||
if (!silent) {
|
||||
LogContent.Remove (LogContent.Child);
|
||||
Spinner = new SparkleSpinner (22);
|
||||
LogContent.Add (Spinner);
|
||||
|
@ -154,7 +170,17 @@ namespace SparkleShare {
|
|||
}
|
||||
|
||||
Thread thread = new Thread (new ThreadStart (delegate {
|
||||
Stopwatch watch = new Stopwatch ();
|
||||
watch.Start ();
|
||||
this.change_sets = SparkleShare.Controller.GetLog (this.selected_log);
|
||||
GenerateHTML ();
|
||||
watch.Stop ();
|
||||
|
||||
// A short delay is less annoying than
|
||||
// a flashing window
|
||||
if (watch.ElapsedMilliseconds < 500 && !silent)
|
||||
Thread.Sleep (500 - (int) watch.ElapsedMilliseconds);
|
||||
|
||||
AddHTML ();
|
||||
}));
|
||||
|
||||
|
@ -164,7 +190,7 @@ namespace SparkleShare {
|
|||
|
||||
private void GenerateHTML ()
|
||||
{
|
||||
HTML = SparkleShare.Controller.GetHTMLLog (System.IO.Path.GetFileName (LocalPath));
|
||||
HTML = SparkleShare.Controller.GetHTMLLog (this.change_sets);
|
||||
|
||||
HTML = HTML.Replace ("<!-- $body-font-size -->", (double) (Style.FontDescription.Size / 1024 + 3) + "px");
|
||||
HTML = HTML.Replace ("<!-- $day-entry-header-font-size -->", (Style.FontDescription.Size / 1024 + 3) + "px");
|
||||
|
@ -179,6 +205,18 @@ namespace SparkleShare {
|
|||
HTML = HTML.Replace ("<!-- $no-buddy-icon-background-image -->", "file://" +
|
||||
SparkleHelpers.CombineMore (Defines.PREFIX, "share", "sparkleshare", "icons",
|
||||
"hicolor", "32x32", "status", "avatar-default.png"));
|
||||
HTML = HTML.Replace ("<!-- $document-added-background-image -->", "file://" +
|
||||
SparkleHelpers.CombineMore (Defines.PREFIX, "share", "sparkleshare", "icons",
|
||||
"hicolor", "12x12", "status", "document-added.png"));
|
||||
HTML = HTML.Replace ("<!-- $document-edited-background-image -->", "file://" +
|
||||
SparkleHelpers.CombineMore (Defines.PREFIX, "share", "sparkleshare", "icons",
|
||||
"hicolor", "12x12", "status", "document-edited.png"));
|
||||
HTML = HTML.Replace ("<!-- $document-deleted-background-image -->", "file://" +
|
||||
SparkleHelpers.CombineMore (Defines.PREFIX, "share", "sparkleshare", "icons",
|
||||
"hicolor", "12x12", "status", "document-deleted.png"));
|
||||
HTML = HTML.Replace ("<!-- $document-moved-background-image -->", "file://" +
|
||||
SparkleHelpers.CombineMore (Defines.PREFIX, "share", "sparkleshare", "icons",
|
||||
"hicolor", "12x12", "status", "document-moved.png"));
|
||||
}
|
||||
|
||||
|
||||
|
@ -248,3 +286,4 @@ namespace SparkleShare {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -156,20 +156,19 @@ namespace SparkleShare {
|
|||
if (SparkleShare.Controller.Folders.Count > 0) {
|
||||
|
||||
// Creates a menu item for each repository with a link to their logs
|
||||
foreach (string path in SparkleShare.Controller.Folders) {
|
||||
foreach (string folder_name in SparkleShare.Controller.Folders) {
|
||||
|
||||
Gdk.Pixbuf folder_icon = IconTheme.Default.LoadIcon ("folder", 16,
|
||||
IconLookupFlags.GenericFallback);
|
||||
|
||||
ImageMenuItem subfolder_item = new SparkleMenuItem (Path.GetFileName (path)) {
|
||||
ImageMenuItem subfolder_item = new SparkleMenuItem (folder_name) {
|
||||
Image = new Image (folder_icon)
|
||||
};
|
||||
|
||||
// if (repo.HasUnsyncedChanges)
|
||||
// if (repo.HasUnsyncedChanges) TODO
|
||||
// folder_action.IconName = "dialog-error";
|
||||
|
||||
subfolder_item.Activated += OpenEventLogDelegate (path);
|
||||
|
||||
subfolder_item.Activated += OpenFolderDelegate (folder_name);
|
||||
Menu.Add (subfolder_item);
|
||||
}
|
||||
|
||||
|
@ -206,7 +205,24 @@ namespace SparkleShare {
|
|||
Menu.Add (sync_item);
|
||||
Menu.Add (new SeparatorMenuItem ());
|
||||
|
||||
MenuItem notify_item;
|
||||
MenuItem recent_events_item = new MenuItem (_("Show Recent Events"));
|
||||
|
||||
if (SparkleShare.Controller.FirstRun) // TODO in mac version too
|
||||
recent_events_item.Sensitive = false;
|
||||
|
||||
recent_events_item.Activated += delegate {
|
||||
Application.Invoke (delegate {
|
||||
if (SparkleUI.EventLog == null)
|
||||
SparkleUI.EventLog = new SparkleEventLog ();
|
||||
|
||||
SparkleUI.EventLog.ShowAll ();
|
||||
SparkleUI.EventLog.Present ();
|
||||
});
|
||||
};
|
||||
|
||||
Menu.Add (recent_events_item);
|
||||
|
||||
MenuItem notify_item;
|
||||
|
||||
if (SparkleShare.Controller.NotificationsEnabled)
|
||||
notify_item = new MenuItem (_("Turn Notifications Off"));
|
||||
|
@ -246,10 +262,10 @@ namespace SparkleShare {
|
|||
|
||||
// A method reference that makes sure that opening the
|
||||
// event log for each repository works correctly
|
||||
private EventHandler OpenEventLogDelegate (string path)
|
||||
private EventHandler OpenFolderDelegate (string name)
|
||||
{
|
||||
return delegate {
|
||||
SparkleShare.UI.AddEventLog (path);
|
||||
SparkleShare.Controller.OpenSparkleShareFolder (name);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ namespace SparkleShare {
|
|||
public class SparkleUI {
|
||||
|
||||
public static SparkleStatusIcon StatusIcon;
|
||||
public static List <SparkleLog> OpenLogs;
|
||||
public static SparkleEventLog EventLog;
|
||||
public static SparkleIntro Intro;
|
||||
|
||||
|
||||
|
@ -47,7 +47,7 @@ namespace SparkleShare {
|
|||
public SparkleUI ()
|
||||
{
|
||||
// Initialize the application
|
||||
Application.Init ();Console.WriteLine ("OOOOOOOOO");
|
||||
Application.Init ();
|
||||
|
||||
foreach (SparkleChangeSet change_set in SparkleShare.Controller.GetLog ()) {
|
||||
Console.WriteLine (change_set.Timestamp.ToString ());
|
||||
|
@ -55,9 +55,6 @@ namespace SparkleShare {
|
|||
// Create the statusicon
|
||||
StatusIcon = new SparkleStatusIcon ();
|
||||
|
||||
// Keep track of which event logs are open
|
||||
OpenLogs = new List <SparkleLog> ();
|
||||
|
||||
if (SparkleShare.Controller.FirstRun) {
|
||||
Intro = new SparkleIntro ();
|
||||
Intro.ShowAccountForm ();
|
||||
|
@ -78,10 +75,8 @@ namespace SparkleShare {
|
|||
SparkleShare.Controller.NotificationRaised += delegate (string user_name, string user_email,
|
||||
string message, string repository_path) {
|
||||
Application.Invoke (delegate {
|
||||
foreach (SparkleLog log in OpenLogs) {
|
||||
if (log.LocalPath.Equals (repository_path))
|
||||
log.UpdateEventLog ();
|
||||
}
|
||||
if (EventLog != null)
|
||||
EventLog.UpdateEvents ();
|
||||
|
||||
if (!SparkleShare.Controller.NotificationsEnabled)
|
||||
return;
|
||||
|
@ -94,10 +89,6 @@ namespace SparkleShare {
|
|||
else
|
||||
bubble.Icon = SparkleUIHelpers.GetIcon ("avatar-default", 32);
|
||||
|
||||
bubble.AddAction ("", "Show Events", delegate {
|
||||
AddEventLog (repository_path);
|
||||
});
|
||||
|
||||
bubble.Show ();
|
||||
});
|
||||
};
|
||||
|
@ -114,38 +105,25 @@ namespace SparkleShare {
|
|||
|
||||
SparkleShare.Controller.AvatarFetched += delegate {
|
||||
Application.Invoke (delegate {
|
||||
foreach (SparkleLog log in OpenLogs)
|
||||
log.UpdateEventLog ();
|
||||
if (EventLog != null)
|
||||
EventLog.UpdateEvents ();
|
||||
});
|
||||
};
|
||||
|
||||
SparkleShare.Controller.OnIdle += delegate {
|
||||
Application.Invoke (delegate {
|
||||
foreach (SparkleLog log in OpenLogs)
|
||||
log.UpdateEventLog ();
|
||||
if (EventLog != null)
|
||||
EventLog.UpdateEvents ();
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public void AddEventLog (string path)
|
||||
{
|
||||
SparkleLog log = SparkleUI.OpenLogs.Find (delegate (SparkleLog l) {
|
||||
return l.LocalPath.Equals (path);
|
||||
});
|
||||
|
||||
// Check whether the log is already open, create a new one if
|
||||
// that's not the case or present it to the user if it is
|
||||
if (log == null) {
|
||||
OpenLogs.Add (new SparkleLog (path));
|
||||
OpenLogs [OpenLogs.Count - 1].ShowAll ();
|
||||
OpenLogs [OpenLogs.Count - 1].Present ();
|
||||
} else {
|
||||
log.ShowAll ();
|
||||
log.Present ();
|
||||
}
|
||||
}
|
||||
|
||||
SparkleShare.Controller.FolderListChanged += delegate {
|
||||
Application.Invoke (delegate {
|
||||
if (EventLog != null)
|
||||
EventLog.UpdateChooser ();
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
// Runs the application
|
||||
public void Run ()
|
||||
|
|
Loading…
Reference in a new issue