cleanup log and fix some small porting bugs

This commit is contained in:
Hylke Bons 2011-07-23 20:57:36 +01:00
parent d42dfe728f
commit 1ed107e6e9
5 changed files with 55 additions and 52 deletions

View file

@ -371,14 +371,15 @@ namespace SparkleLib {
// Returns a list of the latest change sets // Returns a list of the latest change sets
public override List <SparkleChangeSet> GetChangeSets (int count) public override List <SparkleChangeSet> GetChangeSets (int since_days_ago)
{ {
if (count < 1) if (since_days_ago < 1)
count = 30; since_days_ago = 7;
List <SparkleChangeSet> change_sets = new List <SparkleChangeSet> (); List <SparkleChangeSet> change_sets = new List <SparkleChangeSet> ();
SparkleGit git_log = new SparkleGit (LocalPath, "log -" + count + " --raw -M --date=iso"); SparkleGit git_log = new SparkleGit (LocalPath, "log --since=\"" + since_days_ago +
" days ago\" --raw -M --date=iso");
Console.OutputEncoding = System.Text.Encoding.Unicode; Console.OutputEncoding = System.Text.Encoding.Unicode;
git_log.Start (); git_log.Start ();

View file

@ -28,18 +28,23 @@ namespace SparkleShare {
public SparkleBubblesController () public SparkleBubblesController ()
{ {
SparkleShare.Controller.ConflictNotificationRaised += delegate { SparkleShare.Controller.ConflictNotificationRaised += delegate {
if (ShowBubbleEvent != null && SparkleShare.Controller.NotificationsEnabled) ShowBubble ("Ouch! Mid-air collision!",
ShowBubbleEvent ("Ouch! Mid-air collision!", "Don't worry, SparkleShare made a copy of each conflicting file.",
"Don't worry, SparkleShare made a copy of each conflicting file.", null); null);
}; };
SparkleShare.Controller.NotificationRaised += delegate (string user_name, string user_email, SparkleShare.Controller.NotificationRaised += delegate (string user_name, string user_email,
string message, string folder_path) { string message, string folder_path) {
ShowBubble (user_name, message,
if (ShowBubbleEvent != null && SparkleShare.Controller.NotificationsEnabled) SparkleShare.Controller.GetAvatar (user_email, 36));
ShowBubbleEvent (user_name, message,
SparkleShare.Controller.GetAvatar (user_email, 36));
}; };
} }
public void ShowBubble (string title, string subtext, string image_path)
{
if (ShowBubbleEvent != null && SparkleShare.Controller.NotificationsEnabled)
ShowBubbleEvent (title, subtext, image_path);
}
} }
} }

View file

@ -23,23 +23,21 @@ using System.Threading;
using Gtk; using Gtk;
using Mono.Unix; using Mono.Unix;
using SparkleLib;
using WebKit; using WebKit;
namespace SparkleShare { namespace SparkleShare {
public class SparkleEventLog : Window { public class SparkleEventLog : Window {
private SparkleEventLogController controller = new SparkleEventLogController (); public SparkleEventLogController Controller = new SparkleEventLogController ();
private HBox layout_horizontal;
private ComboBox combo_box;
private EventBox content_wrapper;
private ScrolledWindow scrolled_window; private ScrolledWindow scrolled_window;
private WebView web_view; private WebView web_view;
private EventBox content_wrapper = new EventBox (); private SparkleSpinner spinner;
private MenuBar MenuBar; private string link_status;
private string LinkStatus;
private SparkleSpinner spinner = new SparkleSpinner (22);
private ComboBox combo_box;
private HBox layout_horizontal;
// Short alias for the translations // Short alias for the translations
@ -62,10 +60,9 @@ namespace SparkleShare {
DeleteEvent += Close; DeleteEvent += Close;
VBox layout_vertical = new VBox (false, 0); VBox layout_vertical = new VBox (false, 0);
this.spinner = new SparkleSpinner (22);
this.content_wrapper = new EventBox ();
this.scrolled_window = new ScrolledWindow (); this.scrolled_window = new ScrolledWindow ();
this.web_view = new WebView () { this.web_view = new WebView () {
@ -73,17 +70,19 @@ namespace SparkleShare {
}; };
this.web_view.HoveringOverLink += delegate (object o, WebKit.HoveringOverLinkArgs args) { this.web_view.HoveringOverLink += delegate (object o, WebKit.HoveringOverLinkArgs args) {
LinkStatus = args.Link; this.link_status = args.Link;
}; };
this.web_view.NavigationRequested += delegate (object o, WebKit.NavigationRequestedArgs args) { this.web_view.NavigationRequested += delegate (object o, WebKit.NavigationRequestedArgs args) {
if (args.Request.Uri == LinkStatus) { if (args.Request.Uri == this.link_status) {
// TODO: controller
Process process = new Process (); Process process = new Process ();
process.StartInfo.FileName = "xdg-open"; process.StartInfo.FileName = "xdg-open";
process.StartInfo.Arguments = args.Request.Uri.Replace (" ", "\\ "); // Escape space-characters process.StartInfo.Arguments = args.Request.Uri.Replace (" ", "\\ "); // Escape space-characters
process.Start (); process.Start ();
} else { } else {
//TODO: controller
Regex regex = new Regex (@"(.+)~(.+)~(.+)"); Regex regex = new Regex (@"(.+)~(.+)~(.+)");
Match match = regex.Match (args.Request.Uri); Match match = regex.Match (args.Request.Uri);
@ -115,36 +114,33 @@ namespace SparkleShare {
this.layout_horizontal.PackStart (new Label (""), true, true, 0); this.layout_horizontal.PackStart (new Label (""), true, true, 0);
layout_vertical.PackStart (this.layout_horizontal, false, false, 0); layout_vertical.PackStart (this.layout_horizontal, false, false, 0);
layout_vertical.PackStart (CreateShortcutsBar (), false, false, 0);
layout_vertical.PackStart (this.content_wrapper, true, true, 0); layout_vertical.PackStart (this.content_wrapper, true, true, 0);
// We have to hide the menubar somewhere...
layout_vertical.PackStart (CreateShortcutsBar (), false, false, 0);
Add (layout_vertical); Add (layout_vertical);
ShowAll ();
UpdateChooser (null); UpdateChooser (null);
UpdateContent (null); UpdateContent (null);
ShowAll ();
// Hook up the controller events // Hook up the controller events
this.controller.UpdateChooserEvent += delegate (string [] folders) { Controller.UpdateChooserEvent += delegate (string [] folders) {
Application.Invoke (delegate { Application.Invoke (delegate {
UpdateChooser (folders); UpdateChooser (folders);
}); });
}; };
this.controller.UpdateContentEvent += delegate (string html) { Controller.UpdateContentEvent += delegate (string html) {
Application.Invoke (delegate { Application.Invoke (delegate {
UpdateContent (html); UpdateContent (html);
}); });
}; };
this.controller.ContentLoadingEvent += delegate { Controller.ContentLoadingEvent += delegate {
Application.Invoke (delegate { Application.Invoke (delegate {
if (this.content_wrapper.Child == this.scrolled_window) if (this.content_wrapper.Child != null)
this.content_wrapper.Remove (this.scrolled_window); this.content_wrapper.Remove (this.content_wrapper.Child);
this.content_wrapper.Add (this.spinner); this.content_wrapper.Add (this.spinner);
this.spinner.Start (); this.spinner.Start ();
@ -157,7 +153,7 @@ namespace SparkleShare {
public void UpdateChooser (string [] folders) public void UpdateChooser (string [] folders)
{ {
if (folders == null) if (folders == null)
folders = this.controller.Folders; folders = Controller.Folders;
if (this.combo_box != null && this.combo_box.Parent != null) if (this.combo_box != null && this.combo_box.Parent != null)
this.layout_horizontal.Remove (this.combo_box); this.layout_horizontal.Remove (this.combo_box);
@ -190,9 +186,9 @@ namespace SparkleShare {
string selection = (string) this.combo_box.Model.GetValue (iter, 0); string selection = (string) this.combo_box.Model.GetValue (iter, 0);
if (selection.Equals (_("All Folders"))) if (selection.Equals (_("All Folders")))
this.controller.SelectedFolder = null; Controller.SelectedFolder = null;
else else
this.controller.SelectedFolder = selection; Controller.SelectedFolder = selection;
}; };
this.layout_horizontal.BorderWidth = 9; this.layout_horizontal.BorderWidth = 9;
@ -205,7 +201,7 @@ namespace SparkleShare {
{ {
Thread thread = new Thread (new ThreadStart (delegate { Thread thread = new Thread (new ThreadStart (delegate {
if (html == null) if (html == null)
html = this.controller.HTML; html = Controller.HTML;
html = html.Replace ("<!-- $body-font-size -->", (double) (Style.FontDescription.Size / 1024 + 3) + "px"); 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"); html = html.Replace ("<!-- $day-entry-header-font-size -->", (Style.FontDescription.Size / 1024 + 3) + "px");
@ -218,25 +214,25 @@ namespace SparkleShare {
html = html.Replace ("<!-- $secondary-font-color -->", SparkleUIHelpers.GdkColorToHex (Style.Foreground (StateType.Insensitive))); html = html.Replace ("<!-- $secondary-font-color -->", SparkleUIHelpers.GdkColorToHex (Style.Foreground (StateType.Insensitive)));
html = html.Replace ("<!-- $small-color -->", SparkleUIHelpers.GdkColorToHex (Style.Foreground (StateType.Insensitive))); html = html.Replace ("<!-- $small-color -->", SparkleUIHelpers.GdkColorToHex (Style.Foreground (StateType.Insensitive)));
html = html.Replace ("<!-- $no-buddy-icon-background-image -->", "file://" + html = html.Replace ("<!-- $no-buddy-icon-background-image -->", "file://" +
SparkleHelpers.CombineMore (Defines.PREFIX, "share", "sparkleshare", "icons", System.IO.Path.Combine (SparkleUI.AssetsPath, "icons",
"hicolor", "32x32", "status", "avatar-default.png")); "hicolor", "32x32", "status", "avatar-default.png"));
html = html.Replace ("<!-- $document-added-background-image -->", "file://" + html = html.Replace ("<!-- $document-added-background-image -->", "file://" +
SparkleHelpers.CombineMore (Defines.PREFIX, "share", "sparkleshare", "icons", System.IO.Path.Combine (SparkleUI.AssetsPath, "icons",
"hicolor", "12x12", "status", "document-added.png")); "hicolor", "12x12", "status", "document-added.png"));
html = html.Replace ("<!-- $document-edited-background-image -->", "file://" + html = html.Replace ("<!-- $document-edited-background-image -->", "file://" +
SparkleHelpers.CombineMore (Defines.PREFIX, "share", "sparkleshare", "icons", System.IO.Path.Combine (SparkleUI.AssetsPath, "icons",
"hicolor", "12x12", "status", "document-edited.png")); "hicolor", "12x12", "status", "document-edited.png"));
html = html.Replace ("<!-- $document-deleted-background-image -->", "file://" + html = html.Replace ("<!-- $document-deleted-background-image -->", "file://" +
SparkleHelpers.CombineMore (Defines.PREFIX, "share", "sparkleshare", "icons", System.IO.Path.Combine (SparkleUI.AssetsPath, "icons",
"hicolor", "12x12", "status", "document-deleted.png")); "hicolor", "12x12", "status", "document-deleted.png"));
html = html.Replace ("<!-- $document-moved-background-image -->", "file://" + html = html.Replace ("<!-- $document-moved-background-image -->", "file://" +
SparkleHelpers.CombineMore (Defines.PREFIX, "share", "sparkleshare", "icons", System.IO.Path.Combine (SparkleUI.AssetsPath, "icons",
"hicolor", "12x12", "status", "document-moved.png")); "hicolor", "12x12", "status", "document-moved.png"));
Application.Invoke (delegate { Application.Invoke (delegate {
this.spinner.Stop (); this.spinner.Stop ();
this.web_view.LoadString (html, null, null, "file://"); this.web_view.LoadString (html, null, null, "file://");
this.content_wrapper.Remove (this.spinner); this.content_wrapper.Remove (this.content_wrapper.Child);
this.content_wrapper.Add (this.scrolled_window); this.content_wrapper.Add (this.scrolled_window);
this.content_wrapper.ShowAll (); this.content_wrapper.ShowAll ();
}); });
@ -250,7 +246,6 @@ namespace SparkleShare {
{ {
HideAll (); HideAll ();
args.RetVal = true; args.RetVal = true;
// TODO: window positions aren't saved
} }
@ -258,7 +253,7 @@ namespace SparkleShare {
{ {
// Adds a hidden menubar that contains to enable keyboard // Adds a hidden menubar that contains to enable keyboard
// shortcuts to close the log // shortcuts to close the log
MenuBar = new MenuBar (); MenuBar menu_bar = new MenuBar ();
MenuItem file_item = new MenuItem ("File"); MenuItem file_item = new MenuItem ("File");
@ -287,14 +282,14 @@ namespace SparkleShare {
file_item.Submenu = file_menu; file_item.Submenu = file_menu;
MenuBar.Append (file_item); menu_bar.Append (file_item);
// Hacky way to hide the menubar, but the accellerators // Hacky way to hide the menubar, but the accellerators
// will simply be disabled when using Hide () // will simply be disabled when using Hide ()
MenuBar.HeightRequest = 1; menu_bar.HeightRequest = 1;
MenuBar.ModifyBg (StateType.Normal, Style.Background (StateType.Normal)); menu_bar.ModifyBg (StateType.Normal, Style.Background (StateType.Normal));
return MenuBar; return menu_bar;
} }
} }
} }

View file

@ -368,7 +368,7 @@ namespace SparkleShare {
string title = String.Format (_("{0} has been successfully added"), Controller.SyncingFolder); string title = String.Format (_("{0} has been successfully added"), Controller.SyncingFolder);
string subtext = _(""); string subtext = _("");
//TODO new SparkleBubble (title, subtext).Show (); SparkleUI.Bubbles.Controller.ShowBubble (title, subtext, null);
} }
Header = _("Folder synced successfully!"); Header = _("Folder synced successfully!");

View file

@ -34,8 +34,10 @@ namespace SparkleShare {
public static SparkleStatusIcon StatusIcon; public static SparkleStatusIcon StatusIcon;
public static SparkleEventLog EventLog; public static SparkleEventLog EventLog;
public static SparkleBubbles Bubbles;
public static SparkleSetup Setup; public static SparkleSetup Setup;
public static SparkleAbout About; public static SparkleAbout About;
public static string AssetsPath = Path.Combine (Defines.PREFIX, "share", "sparkleshare");
// Short alias for the translations // Short alias for the translations
@ -53,8 +55,8 @@ namespace SparkleShare {
// Use translations // Use translations
Catalog.Init (Defines.GETTEXT_PACKAGE, Defines.LOCALE_DIR); Catalog.Init (Defines.GETTEXT_PACKAGE, Defines.LOCALE_DIR);
// Create the statusicon
StatusIcon = new SparkleStatusIcon (); StatusIcon = new SparkleStatusIcon ();
Bubbles = new SparkleBubbles ();
if (SparkleShare.Controller.FirstRun) { if (SparkleShare.Controller.FirstRun) {
Setup = new SparkleSetup (); Setup = new SparkleSetup ();