From 996f2b2ce73f8c5d525b12682052e53fc3826d6b Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Thu, 31 Mar 2016 15:46:17 +0100 Subject: [PATCH] linux: Fix build --- SparkleShare/Common/Avatars.cs | 3 +- SparkleShare/Common/BaseController.cs | 16 +++---- SparkleShare/Common/Presets/Makefile.am | 4 +- SparkleShare/Common/Presets/bitbucket.xml | 4 +- SparkleShare/Common/Presets/github.xml | 4 +- SparkleShare/Common/Presets/own-server.xml | 4 +- SparkleShare/Common/Presets/planio.xml | 4 +- SparkleShare/Linux/About.cs | 2 +- SparkleShare/Linux/Bubbles.cs | 4 +- SparkleShare/Linux/Controller.cs | 30 ++++++------ SparkleShare/Linux/EventLog.cs | 23 +++++----- SparkleShare/Linux/Note.cs | 6 +-- SparkleShare/Linux/Setup.cs | 46 +++++++++---------- SparkleShare/Linux/SetupWindow.cs | 2 +- SparkleShare/Linux/StatusIcon.cs | 18 ++++---- SparkleShare/Linux/UserInterface.cs | 18 ++++---- SparkleShare/Linux/UserInterfaceHelpers.cs | 8 ++-- SparkleShare/Mac/UserInterface/Setup.cs | 18 ++++---- SparkleShare/Windows/SparkleAbout.cs | 2 +- SparkleShare/Windows/SparkleBubbles.cs | 4 +- SparkleShare/Windows/SparkleEventLog.cs | 2 +- .../Windows/SparkleEventLogWindow.xaml.cs | 2 +- SparkleShare/Windows/SparkleNote.xaml.cs | 4 +- SparkleShare/Windows/SparkleSetup.cs | 4 +- SparkleShare/Windows/SparkleStatusIcon.cs | 12 ++--- SparkleShare/Windows/SparkleUI.cs | 2 +- Sparkles/BaseFetcher.cs | 2 +- Sparkles/Command.cs | 2 +- Sparkles/Extensions.cs | 11 ----- Sparkles/Git/GitCommand.cs | 3 ++ Sparkles/Git/GitFetcher.cs | 14 +++--- Sparkles/Git/GitRepository.cs | 18 ++++---- Sparkles/Logger.cs | 2 +- build/build.environment.mk | 2 +- 34 files changed, 147 insertions(+), 153 deletions(-) diff --git a/SparkleShare/Common/Avatars.cs b/SparkleShare/Common/Avatars.cs index 981c05d5..04af256d 100644 --- a/SparkleShare/Common/Avatars.cs +++ b/SparkleShare/Common/Avatars.cs @@ -43,8 +43,7 @@ namespace SparkleShare if (skipped_avatars.Contains (email)) return null; - string avatars_path = new string [] { Path.GetDirectoryName (target_path), - "avatars", size + "x" + size }.Combine (); + string avatars_path = Path.Combine (Path.GetDirectoryName (target_path), "avatars", size + "x" + size); // Search avatars by file name, ignore extension // Delete files over a day old diff --git a/SparkleShare/Common/BaseController.cs b/SparkleShare/Common/BaseController.cs index 46bb2487..9b11538f 100644 --- a/SparkleShare/Common/BaseController.cs +++ b/SparkleShare/Common/BaseController.cs @@ -36,7 +36,7 @@ namespace SparkleShare { } - private void AddRepository (BaseRepository repo) + void AddRepository (BaseRepository repo) { lock (this.repo_lock) { this.repositories.Add (repo); @@ -45,7 +45,7 @@ namespace SparkleShare { } - private void RemoveRepository (BaseRepository repo) + void RemoveRepository (BaseRepository repo) { lock (this.repo_lock) this.repositories.Remove (repo); @@ -186,12 +186,12 @@ namespace SparkleShare { public abstract string EventEntryHTML { get; } - private BaseFetcher fetcher; - private FileSystemWatcher watcher; - private Object repo_lock = new Object (); - private Object check_repos_lock = new Object (); - private List repositories = new List (); - private bool lost_folders_path = false; + BaseFetcher fetcher; + FileSystemWatcher watcher; + object repo_lock = new object (); + object check_repos_lock = new object (); + List repositories = new List (); + bool lost_folders_path = false; public BaseController () diff --git a/SparkleShare/Common/Presets/Makefile.am b/SparkleShare/Common/Presets/Makefile.am index 7cc5a110..46d770d8 100644 --- a/SparkleShare/Common/Presets/Makefile.am +++ b/SparkleShare/Common/Presets/Makefile.am @@ -1,4 +1,4 @@ -dist_plugins_DATA = \ +dist_presets_DATA = \ bitbucket.xml \ github.xml \ own-server.xml \ @@ -8,7 +8,7 @@ dist_plugins_DATA = \ planio.png \ own-server.png -pluginsdir = $(pkgdatadir)/presets/ +presetsdir = $(pkgdatadir)/presets/ MAINTAINERCLEANFILES = \ Makefile.in diff --git a/SparkleShare/Common/Presets/bitbucket.xml b/SparkleShare/Common/Presets/bitbucket.xml index 17374488..755c3ce8 100644 --- a/SparkleShare/Common/Presets/bitbucket.xml +++ b/SparkleShare/Common/Presets/bitbucket.xml @@ -1,6 +1,6 @@ - + Bitbucket Free code hosting for Git and Mercurial @@ -17,5 +17,5 @@ /username/project True - + diff --git a/SparkleShare/Common/Presets/github.xml b/SparkleShare/Common/Presets/github.xml index bf24fd0c..5bd9b858 100644 --- a/SparkleShare/Common/Presets/github.xml +++ b/SparkleShare/Common/Presets/github.xml @@ -1,6 +1,6 @@ - + GitHub Collaborate on projects hosted on GitHub @@ -16,5 +16,5 @@ /username/project - + diff --git a/SparkleShare/Common/Presets/own-server.xml b/SparkleShare/Common/Presets/own-server.xml index eb9b401a..d2097227 100644 --- a/SparkleShare/Common/Presets/own-server.xml +++ b/SparkleShare/Common/Presets/own-server.xml @@ -1,6 +1,6 @@ - + On my own server Everything under my control @@ -15,5 +15,5 @@ /path/to/project - + diff --git a/SparkleShare/Common/Presets/planio.xml b/SparkleShare/Common/Presets/planio.xml index 1e91c903..f4d22194 100644 --- a/SparkleShare/Common/Presets/planio.xml +++ b/SparkleShare/Common/Presets/planio.xml @@ -1,6 +1,6 @@ - + Planio 500MB of unlimited free hosted Git repos and project management @@ -17,5 +17,5 @@ /[account]-[project].git - + diff --git a/SparkleShare/Linux/About.cs b/SparkleShare/Linux/About.cs index 6a08c363..ddaec56b 100755 --- a/SparkleShare/Linux/About.cs +++ b/SparkleShare/Linux/About.cs @@ -78,7 +78,7 @@ namespace SparkleShare { private void CreateAbout () { CssProvider window_css_provider = new CssProvider (); - Image image = SparkleUIHelpers.GetImage("about.png"); + Image image = UserInterfaceHelpers.GetImage("about.png"); window_css_provider.LoadFromData ("GtkWindow {" + "background-image: url('" + image.File + "');" + diff --git a/SparkleShare/Linux/Bubbles.cs b/SparkleShare/Linux/Bubbles.cs index d1b9def4..744fccb5 100755 --- a/SparkleShare/Linux/Bubbles.cs +++ b/SparkleShare/Linux/Bubbles.cs @@ -37,7 +37,7 @@ namespace SparkleShare { private void ShowBubbleEvent (string title, string subtext, string image_path) { - if (!Program.Controller.NotificationsEnabled) + if (!SparkleShare.Controller.NotificationsEnabled) return; Application.Invoke (delegate { @@ -57,7 +57,7 @@ namespace SparkleShare { notification.Show (); } catch (Exception e) { - SparkleLogger.LogInfo ("Notification", "Error showing notification: ", e); + Logger.LogInfo ("Notification", "Error showing notification: ", e); } }); } diff --git a/SparkleShare/Linux/Controller.cs b/SparkleShare/Linux/Controller.cs index 5f231f86..8603f4ad 100755 --- a/SparkleShare/Linux/Controller.cs +++ b/SparkleShare/Linux/Controller.cs @@ -26,16 +26,16 @@ using Sparkles; namespace SparkleShare { - public class SparkleController : ControllerBase { + public class Controller : BaseController { - public SparkleController () + public Controller () { } public override string PresetsPath { get { - return Path.Combine (Defines.INSTALL_DIR, "plugins"); + return Path.Combine (InstallationInfo.Directory, "presets"); } } @@ -55,7 +55,7 @@ namespace SparkleShare { string autostart_exec = "sparkleshare"; - if (Defines.INSTALL_DIR.StartsWith ("/app/")) + if (InstallationInfo.Directory.StartsWith ("/app/")) autostart_exec = "xdg-app run org.sparkleshare.SparkleShare"; // TODO: Ship as .desktop file and copy in place @@ -69,10 +69,10 @@ namespace SparkleShare { "Terminal=false\n" + "X-GNOME-Autostart-enabled=true\n"); - SparkleLogger.LogInfo ("Controller", "Added SparkleShare to startup items"); + Logger.LogInfo ("Controller", "Added SparkleShare to startup items"); } catch (Exception e) { - SparkleLogger.LogInfo ("Controller", "Failed to add SparkleShare to startup items", e); + Logger.LogInfo ("Controller", "Failed to add SparkleShare to startup items", e); } } @@ -80,9 +80,9 @@ namespace SparkleShare { // Creates the SparkleShare folder in the user's home folder public override bool CreateSparkleShareFolder () { - if (!Directory.Exists (SparkleConfig.DefaultConfig.FoldersPath)) { - Directory.CreateDirectory (SparkleConfig.DefaultConfig.FoldersPath); - Syscall.chmod (SparkleConfig.DefaultConfig.FoldersPath, (FilePermissions) 448); // 448 -> 700 + if (!Directory.Exists (Configuration.DefaultConfig.FoldersPath)) { + Directory.CreateDirectory (Configuration.DefaultConfig.FoldersPath); + Syscall.chmod (Configuration.DefaultConfig.FoldersPath, (FilePermissions) 448); // 448 -> 700 return true; } @@ -93,8 +93,8 @@ namespace SparkleShare { public override string EventLogHTML { get { - string html_path = new string [] { Defines.INSTALL_DIR, "html", "event-log.html" }.Combine (); - string jquery_file_path = new string [] { Defines.INSTALL_DIR, "html", "jquery.js" }.Combine (); + string html_path = Path.Combine (InstallationInfo.Directory, "html", "event-log.html"); + string jquery_file_path = Path.Combine (InstallationInfo.Directory, "html", "jquery.js"); string html = File.ReadAllText (html_path); string jquery = File.ReadAllText (jquery_file_path); @@ -106,7 +106,7 @@ namespace SparkleShare { public override string DayEntryHTML { get { - string path = new string [] { Defines.INSTALL_DIR, "html", "day-entry.html" }.Combine (); + string path = Path.Combine (InstallationInfo.Directory, "html", "day-entry.html"); return File.ReadAllText (path); } } @@ -114,7 +114,7 @@ namespace SparkleShare { public override string EventEntryHTML { get { - string path = new string [] { Defines.INSTALL_DIR, "html", "event-entry.html" }.Combine (); + string path = Path.Combine (InstallationInfo.Directory, "html", "event-entry.html"); return File.ReadAllText (path); } } @@ -129,7 +129,7 @@ namespace SparkleShare { public override void SetFolderIcon () { - var process = new SparkleProcess ("gvfs-set-attribute", SparkleConfig.DefaultConfig.FoldersPath + " " + + var process = new Command ("gvfs-set-attribute", Configuration.DefaultConfig.FoldersPath + " " + "metadata::custom-icon-name org.sparkleshare.SparkleShare"); process.StartAndWaitForExit (); @@ -144,7 +144,7 @@ namespace SparkleShare { public override void OpenFile (string path) { - new SparkleProcess ("xdg-open", "\"" + path + "\"").Start (); + new Command ("xdg-open", "\"" + path + "\"").Start (); } diff --git a/SparkleShare/Linux/EventLog.cs b/SparkleShare/Linux/EventLog.cs index b9cb5dfc..3fb9d7ad 100755 --- a/SparkleShare/Linux/EventLog.cs +++ b/SparkleShare/Linux/EventLog.cs @@ -16,6 +16,7 @@ using System; +using IO = System.IO; using Gtk; // using WebKit; @@ -240,34 +241,34 @@ namespace SparkleShare { public void UpdateContent (string html) { - string pixmaps_path = new string [] {SparkleUI.AssetsPath, "pixmaps"}.Combine (); - string icons_path = new string [] {SparkleUI.AssetsPath, "icons", "hicolor", "12x12", "status"}.Combine (); + string pixmaps_path = IO.Path.Combine (UserInterface.AssetsPath, "pixmaps"); + string icons_path = IO.Path.Combine (UserInterface.AssetsPath, "icons", "hicolor", "12x12", "status"); html = html.Replace ("", "#009ff8"); html = html.Replace ("", "#0085cf"); html = html.Replace ("", StyleContext.GetFont (StateFlags.Normal).Family); html = html.Replace ("", (double) (StyleContext.GetFont (StateFlags.Normal).Size / 1024 + 3) + "px"); - html = html.Replace ("", SparkleUIHelpers.RGBAToHex (StyleContext.GetColor (StateFlags.Normal))); + html = html.Replace ("", UserInterfaceHelpers.RGBAToHex (StyleContext.GetColor (StateFlags.Normal))); // TODO // html = html.Replace ("", - // SparkleUIHelpers.RGBAToHex (new TreeView ().StyleContext.GetStyleProperty ("background-color"))); + // UserInterfaceHelpers.RGBAToHex (new TreeView ().StyleContext.GetStyleProperty ("background-color"))); html = html.Replace ("", (StyleContext.GetFont (StateFlags.Normal).Size / 1024 + 3) + "px"); html = html.Replace ("", - SparkleUIHelpers.RGBAToHex (StyleContext.GetBackgroundColor (StateFlags.Normal))); + UserInterfaceHelpers.RGBAToHex (StyleContext.GetBackgroundColor (StateFlags.Normal))); - html = html.Replace ("", SparkleUIHelpers.RGBAToHex (StyleContext.GetColor (StateFlags.Insensitive))); + html = html.Replace ("", UserInterfaceHelpers.RGBAToHex (StyleContext.GetColor (StateFlags.Insensitive))); - html = html.Replace ("", SparkleUIHelpers.RGBAToHex (StyleContext.GetColor (StateFlags.Insensitive))); + html = html.Replace ("", UserInterfaceHelpers.RGBAToHex (StyleContext.GetColor (StateFlags.Insensitive))); html = html.Replace ("", "90%"); html = html.Replace ("", pixmaps_path); - html = html.Replace ("", "file://" + new string [] {icons_path, "document-added.png"}.Combine ()); - html = html.Replace ("", "file://" + new string [] {icons_path, "document-edited.png"}.Combine ()); - html = html.Replace ("", "file://" + new string [] {icons_path, "document-deleted.png"}.Combine ()); - html = html.Replace ("", "file://" + new string [] {icons_path, "document-moved.png"}.Combine ()); + html = html.Replace ("", "file://" + IO.Path.Combine (icons_path, "document-added.png")); + html = html.Replace ("", "file://" + IO.Path.Combine (icons_path, "document-edited.png")); + html = html.Replace ("", "file://" + IO.Path.Combine (icons_path, "document-deleted.png")); + html = html.Replace ("", "file://" + IO.Path.Combine (icons_path, "document-moved.png")); this.spinner.Stop (); // this.scrolled_window.Remove (this.web_view); diff --git a/SparkleShare/Linux/Note.cs b/SparkleShare/Linux/Note.cs index 60a97744..c37f09b1 100755 --- a/SparkleShare/Linux/Note.cs +++ b/SparkleShare/Linux/Note.cs @@ -75,7 +75,7 @@ namespace SparkleShare { Image user_image = new Image (Controller.AvatarFilePath); /* TODO: Style the entry neatly, multiple lines, and add placeholder text - string balloon_image_path = new string [] { SparkleUI.AssetsPath, "pixmaps", "text-balloon.png" }.Combine (); + string balloon_image_path = new string [] { UserInterface.AssetsPath, "pixmaps", "text-balloon.png" }.Combine (); Image balloon_image = new Image (balloon_image_path); CssProvider balloon_css_provider = new CssProvider (); @@ -113,8 +113,8 @@ namespace SparkleShare { }; Label user_label = new Label () { - Markup = "" + Program.Controller.CurrentUser.Name + "\n" + - "" + Program.Controller.CurrentUser.Email + + Markup = "" + SparkleShare.Controller.CurrentUser.Name + "\n" + + "" + SparkleShare.Controller.CurrentUser.Email + "" }; diff --git a/SparkleShare/Linux/Setup.cs b/SparkleShare/Linux/Setup.cs index e45c95ae..21052081 100755 --- a/SparkleShare/Linux/Setup.cs +++ b/SparkleShare/Linux/Setup.cs @@ -137,7 +137,7 @@ namespace SparkleShare { VBox layout_address = new VBox (true, 0); VBox layout_path = new VBox (true, 0); - ListStore store = new ListStore (typeof (string), typeof (Gdk.Pixbuf), typeof (string), typeof (SparklePreset)); + ListStore store = new ListStore (typeof (string), typeof (Gdk.Pixbuf), typeof (string), typeof (Preset)); SparkleTreeView tree_view = new SparkleTreeView (store) { HeadersVisible = false }; ScrolledWindow scrolled_window = new ScrolledWindow () { ShadowType = ShadowType.In }; @@ -157,11 +157,11 @@ namespace SparkleShare { service_column.PackStart (service_cell, true); service_column.SetCellDataFunc (service_cell, new TreeCellDataFunc (RenderServiceColumn)); - foreach (SparklePreset plugin in Controller.Presets) { - store.AppendValues ("", new Gdk.Pixbuf (plugin.ImagePath), - "" + plugin.Name + "\n" + - "" + plugin.Description + "" + - "", plugin); + foreach (Preset preset in Controller.Presets) { + store.AppendValues ("", new Gdk.Pixbuf (preset.ImagePath), + "" + preset.Name + "\n" + + "" + preset.Description + "" + + "", preset); } tree_view.AppendColumn (service_column); @@ -183,14 +183,14 @@ namespace SparkleShare { Xalign = 0, UseMarkup = true, Markup = "" + Controller.SelectedPreset.AddressExample + "" + SparkleShare.UI.SecondaryTextColor + "\">" + Controller.SelectedPreset.AddressExample + "" }; Label path_example = new Label () { Xalign = 0, UseMarkup = true, Markup = "" + Controller.SelectedPreset.PathExample + "" + SparkleShare.UI.SecondaryTextColor + "\">" + Controller.SelectedPreset.PathExample + "" }; @@ -203,7 +203,7 @@ namespace SparkleShare { string address; try { - address = (model.GetValue (iter, 2) as SparklePreset).Address; + address = (model.GetValue (iter, 2) as Preset).Address; } catch (NullReferenceException) { address = ""; @@ -213,12 +213,12 @@ namespace SparkleShare { address.Equals (Controller.PreviousAddress)) { tree_view.SetCursor (path, service_column, false); - SparklePreset plugin = (SparklePreset) model.GetValue (iter, 2); + Preset preset = (Preset) model.GetValue (iter, 2); - if (plugin.Address != null) + if (preset.Address != null) address_entry.Sensitive = false; - if (plugin.Path != null) + if (preset.Path != null) path_entry.Sensitive = false; return true; @@ -280,7 +280,7 @@ namespace SparkleShare { address_entry.Text = text; address_entry.Sensitive = (state == FieldState.Enabled); address_example.Markup = "" + example_text + ""; + SparkleShare.UI.SecondaryTextColor + "\">" + example_text + ""; }); }; @@ -291,7 +291,7 @@ namespace SparkleShare { path_entry.Text = text; path_entry.Sensitive = (state == FieldState.Enabled); path_example.Markup = "" + example_text + ""; + + SparkleShare.UI.SecondaryTextColor + "\">" + example_text + ""; }); }; @@ -405,9 +405,9 @@ namespace SparkleShare { Header = "Oops! Something went wrong" + "…"; VBox points = new VBox (false, 0); - Image list_point_one = new Image (SparkleUIHelpers.GetIcon ("list-point", 16)); - Image list_point_two = new Image (SparkleUIHelpers.GetIcon ("list-point", 16)); - Image list_point_three = new Image (SparkleUIHelpers.GetIcon ("list-point", 16)); + Image list_point_one = new Image (UserInterfaceHelpers.GetIcon ("list-point", 16)); + Image list_point_two = new Image (UserInterfaceHelpers.GetIcon ("list-point", 16)); + Image list_point_three = new Image (UserInterfaceHelpers.GetIcon ("list-point", 16)); Label label_one = new Label () { Markup = "" + Controller.PreviousUrl + " is the address we’ve compiled. " + @@ -507,7 +507,7 @@ namespace SparkleShare { wrapper.PackStart (table, true, false, 0); Image warning_image = new Image ( - SparkleUIHelpers.GetIcon ("dialog-information", 24)); + UserInterfaceHelpers.GetIcon ("dialog-information", 24)); Label warning_label = new Label () { Xalign = 0, @@ -581,7 +581,7 @@ namespace SparkleShare { if (warnings.Length > 0) { - Image warning_image = new Image (SparkleUIHelpers.GetIcon ("dialog-information", 24)); + Image warning_image = new Image (UserInterfaceHelpers.GetIcon ("dialog-information", 24)); Label warning_label = new Label (warnings [0]) { Xalign = 0, @@ -658,7 +658,7 @@ namespace SparkleShare { HBox layout_horizontal = new HBox (false, 6); Entry link_code_entry = new Entry () { - Text = Program.Controller.UserAuthenticationInfo.PublicKey, + Text = SparkleShare.Controller.UserAuthenticationInfo.PublicKey, Sensitive = false }; @@ -690,7 +690,7 @@ namespace SparkleShare { } if (Controller.TutorialPageNumber < 4) { - Image slide = SparkleUIHelpers.GetImage ("tutorial-slide-" + Controller.TutorialPageNumber + ".png"); + Image slide = UserInterfaceHelpers.GetImage ("tutorial-slide-" + Controller.TutorialPageNumber + ".png"); Add (slide); } } @@ -704,9 +704,9 @@ namespace SparkleShare { TreeSelection selection = (column.TreeView as TreeView).Selection; if (selection.IterIsSelected (iter)) - markup = markup.Replace (Program.UI.SecondaryTextColor, Program.UI.SecondaryTextColorSelected); + markup = markup.Replace (SparkleShare.UI.SecondaryTextColor, SparkleShare.UI.SecondaryTextColorSelected); else - markup = markup.Replace (Program.UI.SecondaryTextColorSelected, Program.UI.SecondaryTextColor); + markup = markup.Replace (SparkleShare.UI.SecondaryTextColorSelected, SparkleShare.UI.SecondaryTextColor); (cell as CellRendererText).Markup = markup; } diff --git a/SparkleShare/Linux/SetupWindow.cs b/SparkleShare/Linux/SetupWindow.cs index dc0c66ed..35ae4fa3 100755 --- a/SparkleShare/Linux/SetupWindow.cs +++ b/SparkleShare/Linux/SetupWindow.cs @@ -62,7 +62,7 @@ namespace SparkleShare { layout_vertical.PackStart (this.content_area, true, true, 0); layout_vertical.PackStart (layout_actions, false, false, 15); - Image side_splash = SparkleUIHelpers.GetImage ("side-splash.png"); + Image side_splash = UserInterfaceHelpers.GetImage ("side-splash.png"); side_splash.Yalign = 1; layout_horizontal.PackStart (side_splash, false, false, 0); diff --git a/SparkleShare/Linux/StatusIcon.cs b/SparkleShare/Linux/StatusIcon.cs index 5e579cb0..0d0967c3 100644 --- a/SparkleShare/Linux/StatusIcon.cs +++ b/SparkleShare/Linux/StatusIcon.cs @@ -17,8 +17,10 @@ using System; using System.Collections.Generic; +using System.IO; using Gtk; + #if HAVE_APP_INDICATOR using AppIndicator3; #endif @@ -120,7 +122,7 @@ namespace SparkleShare { this.state_item = new MenuItem (Controller.StateText) { Sensitive = false }; ImageMenuItem folder_item = new SparkleMenuItem ("SparkleShare"); - folder_item.Image = new Image (SparkleUIHelpers.GetIcon ("org.sparkleshare.SparkleShare", 16)); + folder_item.Image = new Image (UserInterfaceHelpers.GetIcon ("org.sparkleshare.SparkleShare", 16)); this.menu.Add (this.state_item); this.menu.Add (new SeparatorMenuItem ()); @@ -148,12 +150,10 @@ namespace SparkleShare { MenuItem resume_item; if (project.UnsyncedChangesInfo.Count > 0) { - string icons_path = new string [] { - SparkleUI.AssetsPath, "icons", "hicolor", "12x12", "status"}.Combine (); + string icons_path = Path.Combine (UserInterface.AssetsPath, "icons", "hicolor", "12x12", "status"); foreach (KeyValuePair pair in project.UnsyncedChangesInfo) { - string icon_path = new string [] { - icons_path, pair.Value.Replace ("-12", "")}.Combine (); + string icon_path = Path.Combine (icons_path, pair.Value.Replace ("-12", "")); (item.Submenu as Menu).Add (new SparkleMenuItem (pair.Key) { Image = new Image (icon_path), @@ -208,16 +208,16 @@ namespace SparkleShare { #if HAVE_APP_INDICATOR MenuItem notify_item; - if (Program.Controller.NotificationsEnabled) + if (SparkleShare.Controller.NotificationsEnabled) notify_item = new MenuItem ("Turn Notifications Off"); else notify_item = new MenuItem ("Turn Notifications On"); notify_item.Activated += delegate { - Program.Controller.ToggleNotifications (); + SparkleShare.Controller.ToggleNotifications (); Application.Invoke (delegate { - if (Program.Controller.NotificationsEnabled) + if (SparkleShare.Controller.NotificationsEnabled) (notify_item.Child as Label).Text = "Turn Notifications Off"; else (notify_item.Child as Label).Text = "Turn Notifications On"; @@ -230,7 +230,7 @@ namespace SparkleShare { if (Controller.LinkCodeItemEnabled) { link_code_item.Submenu = new Menu (); - string link_code = Program.Controller.UserAuthenticationInfo.PublicKey.Substring (0, 20) + "..."; + string link_code = SparkleShare.Controller.UserAuthenticationInfo.PublicKey.Substring (0, 20) + "..."; MenuItem code_item = new MenuItem (link_code) { Sensitive = false }; MenuItem copy_item = new MenuItem ("Copy to Clipboard"); diff --git a/SparkleShare/Linux/UserInterface.cs b/SparkleShare/Linux/UserInterface.cs index 13f95948..b15b2857 100644 --- a/SparkleShare/Linux/UserInterface.cs +++ b/SparkleShare/Linux/UserInterface.cs @@ -26,7 +26,7 @@ namespace SparkleShare { public class UserInterface { - public static string AssetsPath = Defines.INSTALL_DIR; + public static string AssetsPath = InstallationInfo.Directory; public SparkleStatusIcon StatusIcon; public SparkleEventLog EventLog; @@ -48,15 +48,15 @@ namespace SparkleShare { application.Register (null); application.Activated += ApplicationActivatedDelegate; - Gdk.Color color = SparkleUIHelpers.RGBAToColor (new Label().StyleContext.GetColor (StateFlags.Insensitive)); - SecondaryTextColor = SparkleUIHelpers.ColorToHex (color); + Gdk.Color color = UserInterfaceHelpers.RGBAToColor (new Label().StyleContext.GetColor (StateFlags.Insensitive)); + SecondaryTextColor = UserInterfaceHelpers.ColorToHex (color); - color = SparkleUIHelpers.MixColors ( - SparkleUIHelpers.RGBAToColor (new TreeView ().StyleContext.GetColor (StateFlags.Selected)), - SparkleUIHelpers.RGBAToColor (new TreeView ().StyleContext.GetBackgroundColor (StateFlags.Selected)), + color = UserInterfaceHelpers.MixColors ( + UserInterfaceHelpers.RGBAToColor (new TreeView ().StyleContext.GetColor (StateFlags.Selected)), + UserInterfaceHelpers.RGBAToColor (new TreeView ().StyleContext.GetBackgroundColor (StateFlags.Selected)), 0.39); - SecondaryTextColorSelected = SparkleUIHelpers.ColorToHex (color); + SecondaryTextColorSelected = UserInterfaceHelpers.ColorToHex (color); } @@ -79,7 +79,7 @@ namespace SparkleShare { } if (!has_visible_windows) - Program.Controller.HandleReopen (); + SparkleShare.Controller.HandleReopen (); } else { Setup = new SparkleSetup (); @@ -93,7 +93,7 @@ namespace SparkleShare { EventLog.Application = application; About.Application = application; - Program.Controller.UIHasLoaded (); + SparkleShare.Controller.UIHasLoaded (); } } } diff --git a/SparkleShare/Linux/UserInterfaceHelpers.cs b/SparkleShare/Linux/UserInterfaceHelpers.cs index d147b00d..4647d4ef 100755 --- a/SparkleShare/Linux/UserInterfaceHelpers.cs +++ b/SparkleShare/Linux/UserInterfaceHelpers.cs @@ -16,16 +16,18 @@ using System; +using System.IO; + using Gtk; namespace SparkleShare { - public static class SparkleUIHelpers { + public static class UserInterfaceHelpers { public static Gdk.Pixbuf GetIcon (string name, int size) { IconTheme icon_theme = new IconTheme (); - icon_theme.AppendSearchPath (new string [] {SparkleUI.AssetsPath, "icons"}.Combine ()); + icon_theme.AppendSearchPath (Path.Combine (UserInterface.AssetsPath, "icons")); foreach (string search_path in IconTheme.Default.SearchPath) icon_theme.AppendSearchPath (search_path); @@ -46,7 +48,7 @@ namespace SparkleShare { public static Image GetImage (string name) { - string image_path = new string [] { SparkleUI.AssetsPath, "pixmaps", name }.Combine (); + string image_path = Path.Combine (UserInterface.AssetsPath, "pixmaps", name); return new Image (image_path); } diff --git a/SparkleShare/Mac/UserInterface/Setup.cs b/SparkleShare/Mac/UserInterface/Setup.cs index 7fc86314..70055ca7 100644 --- a/SparkleShare/Mac/UserInterface/Setup.cs +++ b/SparkleShare/Mac/UserInterface/Setup.cs @@ -730,28 +730,28 @@ namespace SparkleShare { int backing_scale_factor; - public SparkleDataSource (float backing_scale_factor, List plugins) + public SparkleDataSource (float backing_scale_factor, List presets) { Items = new List (); - Cells = new NSAttributedString [plugins.Count]; - SelectedCells = new NSAttributedString [plugins.Count]; + Cells = new NSAttributedString [presets.Count]; + SelectedCells = new NSAttributedString [presets.Count]; this.backing_scale_factor = (int) backing_scale_factor; int i = 0; - foreach (Preset plugin in plugins) { - Items.Add (plugin); + foreach (Preset preset in presets) { + Items.Add (preset); NSTextFieldCell cell = new NSTextFieldCell (); - NSData name_data = NSData.FromString ("" + plugin.Name + ""); + NSData name_data = NSData.FromString ("" + preset.Name + ""); NSDictionary name_dictionary = new NSDictionary(); NSAttributedString name_attributes = new NSAttributedString ( name_data, new NSUrl ("file://"), out name_dictionary); NSData description_data = NSData.FromString ( - "" + plugin.Description + ""); + "" + preset.Description + ""); NSDictionary description_dictionary = new NSDictionary(); NSAttributedString description_attributes = new NSAttributedString ( @@ -767,7 +767,7 @@ namespace SparkleShare { NSTextFieldCell selected_cell = new NSTextFieldCell (); NSData selected_name_data = NSData.FromString ( - "" + plugin.Name + ""); + "" + preset.Name + ""); NSDictionary selected_name_dictionary = new NSDictionary (); NSAttributedString selected_name_attributes = new NSAttributedString ( @@ -775,7 +775,7 @@ namespace SparkleShare { NSData selected_description_data = NSData.FromString ( "" + - plugin.Description + ""); + preset.Description + ""); NSDictionary selected_description_dictionary = new NSDictionary (); NSAttributedString selected_description_attributes = new NSAttributedString ( diff --git a/SparkleShare/Windows/SparkleAbout.cs b/SparkleShare/Windows/SparkleAbout.cs index 1e19fc92..6d34ed73 100644 --- a/SparkleShare/Windows/SparkleAbout.cs +++ b/SparkleShare/Windows/SparkleAbout.cs @@ -179,7 +179,7 @@ namespace SparkleShare { Content = text_block; MouseUp += delegate { - Program.Controller.OpenWebsite (url); + SparkleShare.Controller.OpenWebsite (url); }; } } diff --git a/SparkleShare/Windows/SparkleBubbles.cs b/SparkleShare/Windows/SparkleBubbles.cs index cbae16d0..e9b07136 100644 --- a/SparkleShare/Windows/SparkleBubbles.cs +++ b/SparkleShare/Windows/SparkleBubbles.cs @@ -27,10 +27,10 @@ namespace SparkleShare { public SparkleBubbles () { Controller.ShowBubbleEvent += delegate (string title, string subtext, string image_path) { - if (!Program.Controller.NotificationsEnabled) + if (!SparkleShare.Controller.NotificationsEnabled) return; - Program.UI.StatusIcon.ShowBalloon (title, subtext, image_path); + SparkleShare.UI.StatusIcon.ShowBalloon (title, subtext, image_path); }; } } diff --git a/SparkleShare/Windows/SparkleEventLog.cs b/SparkleShare/Windows/SparkleEventLog.cs index 7938d77d..008aded5 100644 --- a/SparkleShare/Windows/SparkleEventLog.cs +++ b/SparkleShare/Windows/SparkleEventLog.cs @@ -366,7 +366,7 @@ namespace SparkleShare { public void LinkClicked (string url) { - Program.UI.EventLog.Controller.LinkClicked (url); + SparkleShare.UI.EventLog.Controller.LinkClicked (url); } } } diff --git a/SparkleShare/Windows/SparkleEventLogWindow.xaml.cs b/SparkleShare/Windows/SparkleEventLogWindow.xaml.cs index a77f0edc..e9ce2305 100644 --- a/SparkleShare/Windows/SparkleEventLogWindow.xaml.cs +++ b/SparkleShare/Windows/SparkleEventLogWindow.xaml.cs @@ -254,7 +254,7 @@ namespace SparkleShare { public void LinkClicked(string url) { - Program.UI.EventLog.Controller.LinkClicked(url); + SparkleShare.UI.EventLog.Controller.LinkClicked(url); } } diff --git a/SparkleShare/Windows/SparkleNote.xaml.cs b/SparkleShare/Windows/SparkleNote.xaml.cs index 6dc34878..f5631905 100644 --- a/SparkleShare/Windows/SparkleNote.xaml.cs +++ b/SparkleShare/Windows/SparkleNote.xaml.cs @@ -93,8 +93,8 @@ namespace SparkleShare { this.user_image.ImageSource = avatar; this.Title = Controller.CurrentProject ?? "Add Note"; - this.user_name_text_block.Text = Program.Controller.CurrentUser.Name; - this.user_email_text_field.Text = Program.Controller.CurrentUser.Email; + this.user_name_text_block.Text = SparkleShare.Controller.CurrentUser.Name; + this.user_email_text_field.Text = SparkleShare.Controller.CurrentUser.Email; this.balloon_text_field.Text = default_text; ElementHost.EnableModelessKeyboardInterop (this); diff --git a/SparkleShare/Windows/SparkleSetup.cs b/SparkleShare/Windows/SparkleSetup.cs index 9b7043ac..1cd7b6cf 100644 --- a/SparkleShare/Windows/SparkleSetup.cs +++ b/SparkleShare/Windows/SparkleSetup.cs @@ -139,7 +139,7 @@ namespace SparkleShare { cancel_button.Click += delegate { Dispatcher.BeginInvoke ((Action) delegate { - Program.UI.StatusIcon.Dispose (); + SparkleShare.UI.StatusIcon.Dispose (); Controller.SetupPageCancelled (); }); }; @@ -928,7 +928,7 @@ namespace SparkleShare { TextBox link_code_text_box = new TextBox () { - Text = Program.Controller.CurrentUser.PublicKey, + Text = SparkleShare.Controller.CurrentUser.PublicKey, Width = 250, MaxLines = 1, TextWrapping = TextWrapping.NoWrap, diff --git a/SparkleShare/Windows/SparkleStatusIcon.cs b/SparkleShare/Windows/SparkleStatusIcon.cs index a4a77adb..7ba4552e 100644 --- a/SparkleShare/Windows/SparkleStatusIcon.cs +++ b/SparkleShare/Windows/SparkleStatusIcon.cs @@ -142,7 +142,7 @@ namespace SparkleShare { if(Controller.LinkCodeItemEnabled) { SparkleMenuItem code_item = new SparkleMenuItem { - Header = Program.Controller.CurrentUser.PublicKey.Substring(0, 20) + "..." + Header = SparkleShare.Controller.CurrentUser.PublicKey.Substring(0, 20) + "..." }; SparkleMenuItem copy_item = new SparkleMenuItem { @@ -159,7 +159,7 @@ namespace SparkleShare { CheckBox notify_check_box = new CheckBox { Margin = new Thickness(6, 0, 0, 0), - IsChecked = Program.Controller.NotificationsEnabled + IsChecked = SparkleShare.Controller.NotificationsEnabled }; SparkleMenuItem notify_item = new SparkleMenuItem { @@ -187,13 +187,13 @@ namespace SparkleShare { notify_check_box.Click += delegate { this.context_menu.IsOpen = false; - Program.Controller.ToggleNotifications(); - notify_check_box.IsChecked = Program.Controller.NotificationsEnabled; + SparkleShare.Controller.ToggleNotifications(); + notify_check_box.IsChecked = SparkleShare.Controller.NotificationsEnabled; }; notify_item.Click += delegate { - Program.Controller.ToggleNotifications(); - notify_check_box.IsChecked = Program.Controller.NotificationsEnabled; + SparkleShare.Controller.ToggleNotifications(); + notify_check_box.IsChecked = SparkleShare.Controller.NotificationsEnabled; }; this.exit_item.Click += delegate { diff --git a/SparkleShare/Windows/SparkleUI.cs b/SparkleShare/Windows/SparkleUI.cs index 447f0c6b..e0d35504 100644 --- a/SparkleShare/Windows/SparkleUI.cs +++ b/SparkleShare/Windows/SparkleUI.cs @@ -51,7 +51,7 @@ namespace SparkleShare { StatusIcon = new SparkleStatusIcon (); Note = new SparkleNote (); - Program.Controller.UIHasLoaded (); + SparkleShare.Controller.UIHasLoaded (); } diff --git a/Sparkles/BaseFetcher.cs b/Sparkles/BaseFetcher.cs index 77721bf1..5f90c42d 100644 --- a/Sparkles/BaseFetcher.cs +++ b/Sparkles/BaseFetcher.cs @@ -80,7 +80,7 @@ namespace Sparkles { protected List warnings = new List (); protected List errors = new List (); - protected string [] ExcludeRules = new string [] { + protected string [] ExcludeRules = { "*.autosave", // Various autosaving apps "*~", // gedit and emacs ".~lock.*", // LibreOffice diff --git a/Sparkles/Command.cs b/Sparkles/Command.cs index 701776e0..c7ec4580 100644 --- a/Sparkles/Command.cs +++ b/Sparkles/Command.cs @@ -99,7 +99,7 @@ namespace Sparkles { } - protected string LocateCommand (string name) + protected static string LocateCommand (string name) { string [] possible_command_paths = { Environment.GetFolderPath (Environment.SpecialFolder.Personal) + "/bin/" + name, diff --git a/Sparkles/Extensions.cs b/Sparkles/Extensions.cs index 06fc27b2..7ec1cd6b 100644 --- a/Sparkles/Extensions.cs +++ b/Sparkles/Extensions.cs @@ -24,17 +24,6 @@ namespace Sparkles { public static class Extensions { - public static string Combine (this string [] parts) - { - string new_path = ""; - - foreach (string part in parts) - new_path = Path.Combine (new_path, part); - - return new_path; - } - - public static string SHA1 (this string s) { SHA1 sha1 = new SHA1CryptoServiceProvider (); diff --git a/Sparkles/Git/GitCommand.cs b/Sparkles/Git/GitCommand.cs index b2f24a47..3e39d117 100644 --- a/Sparkles/Git/GitCommand.cs +++ b/Sparkles/Git/GitCommand.cs @@ -26,6 +26,9 @@ namespace Sparkles.Git { public static string GitVersion { get { + if (GitPath == null) + GitPath = LocateCommand ("git"); + string git_version = new Command (GitPath, "--version").StartAndReadStandardOutput (); return git_version.Replace ("git version ", ""); } diff --git a/Sparkles/Git/GitFetcher.cs b/Sparkles/Git/GitFetcher.cs index fec8a8b9..483c4e56 100644 --- a/Sparkles/Git/GitFetcher.cs +++ b/Sparkles/Git/GitFetcher.cs @@ -243,7 +243,7 @@ namespace Sparkles.Git { void InstallConfiguration () { - string [] settings = new string [] { + string [] settings = { "core.autocrlf input", "core.quotepath false", // Don't quote "unusual" characters in path names "core.ignorecase false", // Be case sensitive explicitly to work on Mac @@ -272,13 +272,13 @@ namespace Sparkles.Git { // Add a .gitignore file to the repo void InstallExcludeRules () { - string git_info_path = new string [] { TargetFolder, ".git", "info" }.Combine (); + string git_info_path = Path.Combine (TargetFolder, ".git", "info"); if (!Directory.Exists (git_info_path)) Directory.CreateDirectory (git_info_path); string exclude_rules = string.Join (Environment.NewLine, ExcludeRules); - string exclude_rules_file_path = new string [] { git_info_path, "exclude" }.Combine (); + string exclude_rules_file_path = Path.Combine (git_info_path, "exclude"); File.WriteAllText (exclude_rules_file_path, exclude_rules); } @@ -286,12 +286,12 @@ namespace Sparkles.Git { void InstallAttributeRules () { - string attribute_rules_file_path = new string [] { TargetFolder, ".git", "info", "attributes" }.Combine (); + string attribute_rules_file_path = Path.Combine (TargetFolder, ".git", "info", "attributes"); TextWriter writer = new StreamWriter (attribute_rules_file_path); // Compile a list of files we don't want Git to compress. // Not compressing already compressed files decreases memory usage and increases speed - string [] extensions = new string [] { + string [] extensions = { "jpg", "jpeg", "png", "tiff", "gif", // Images "flac", "mp3", "ogg", "oga", // Audio "avi", "mov", "mpg", "mpeg", "mkv", "ogv", "ogx", "webm", // Video @@ -326,11 +326,11 @@ namespace Sparkles.Git { git_config_clean.StartAndWaitForExit (); // Pass all files through the encryption filter - string git_attributes_file_path = new string [] { TargetFolder, ".git", "info", "attributes" }.Combine (); + string git_attributes_file_path = Path.Combine (TargetFolder, ".git", "info", "attributes"); File.WriteAllText (git_attributes_file_path, "* filter=encryption"); // Store the password - string password_file_path = new string [] { TargetFolder, ".git", "info", "encryption_password" }.Combine (); + string password_file_path = Path.Combine (TargetFolder, ".git", "info", "encryption_password"); File.WriteAllText (password_file_path, password.SHA256 (this.password_salt)); } diff --git a/Sparkles/Git/GitRepository.cs b/Sparkles/Git/GitRepository.cs index 7145838d..ab049794 100644 --- a/Sparkles/Git/GitRepository.cs +++ b/Sparkles/Git/GitRepository.cs @@ -78,7 +78,7 @@ namespace Sparkles.Git { private bool in_merge { get { - string merge_file_path = new string [] { LocalPath, ".git", "MERGE_HEAD" }.Combine (); + string merge_file_path = Path.Combine (LocalPath, ".git", "MERGE_HEAD"); return File.Exists (merge_file_path); } } @@ -111,7 +111,7 @@ namespace Sparkles.Git { public override double Size { get { - string file_path = new string [] { LocalPath, ".git", "info", "size" }.Combine (); + string file_path = Path.Combine (LocalPath, ".git", "info", "size"); try { string size = File.ReadAllText (file_path); @@ -126,7 +126,7 @@ namespace Sparkles.Git { public override double HistorySize { get { - string file_path = new string [] { LocalPath, ".git", "info", "history_size" }.Combine (); + string file_path = Path.Combine (LocalPath, ".git", "info", "history_size"); try { string size = File.ReadAllText (file_path); @@ -144,8 +144,8 @@ namespace Sparkles.Git { double size = CalculateSizes (new DirectoryInfo (LocalPath)); double history_size = CalculateSizes (new DirectoryInfo (Path.Combine (LocalPath, ".git"))); - string size_file_path = new string [] { LocalPath, ".git", "info", "size" }.Combine (); - string history_size_file_path = new string [] { LocalPath, ".git", "info", "history_size" }.Combine (); + string size_file_path = Path.Combine (LocalPath, ".git", "info", "size"); + string history_size_file_path = Path.Combine (LocalPath, ".git", "info", "history_size"); File.WriteAllText (size_file_path, size.ToString ()); File.WriteAllText (history_size_file_path, history_size.ToString ()); @@ -377,12 +377,12 @@ namespace Sparkles.Git { public override bool HasUnsyncedChanges { get { - string unsynced_file_path = new string [] { LocalPath, ".git", "has_unsynced_changes" }.Combine (); + string unsynced_file_path = Path.Combine (LocalPath, ".git", "has_unsynced_changes"); return File.Exists (unsynced_file_path); } set { - string unsynced_file_path = new string [] { LocalPath, ".git", "has_unsynced_changes" }.Combine (); + string unsynced_file_path = Path.Combine (LocalPath, ".git", "has_unsynced_changes"); if (value) File.WriteAllText (unsynced_file_path, ""); @@ -1110,7 +1110,7 @@ namespace Sparkles.Git { // Recursively gets a folder's size in bytes - private long CalculateSizes (DirectoryInfo parent) + long CalculateSizes (DirectoryInfo parent) { long size = 0; @@ -1149,7 +1149,7 @@ namespace Sparkles.Git { } - private bool IsSymlink (string file) + bool IsSymlink (string file) { FileAttributes attributes = File.GetAttributes (file); return ((attributes & FileAttributes.ReparsePoint) == FileAttributes.ReparsePoint); diff --git a/Sparkles/Logger.cs b/Sparkles/Logger.cs index 2abd59ab..0b3adf32 100644 --- a/Sparkles/Logger.cs +++ b/Sparkles/Logger.cs @@ -68,7 +68,7 @@ namespace Sparkles { if (InstallationInfo.Platform == PlatformID.Win32NT) home_path = Environment.GetFolderPath (Environment.SpecialFolder.UserProfile); - string crash_report_file_path = new string [] { home_path, "SparkleShare", "crash_report.txt" }.Combine (); + string crash_report_file_path = Path.Combine (home_path, "SparkleShare", "crash_report.txt"); string n = Environment.NewLine; string crash_report = diff --git a/build/build.environment.mk b/build/build.environment.mk index 24866848..e976b8eb 100755 --- a/build/build.environment.mk +++ b/build/build.environment.mk @@ -15,7 +15,7 @@ LINK_WEBKIT = $(WEBKITGTK_SHARP_LIBS) LINK_APP_INDICATOR = $(APP_INDICATOR_LIBS) REF_SPARKLES = $(LINK_SYSTEM) $(LINK_MONO_POSIX) -LINK_SPARKLES = -r:$(DIR_BIN)/Sparkles.dll +LINK_SPARKLES = -r:$(DIR_BIN)/Sparkles.dll -r:$(DIR_BIN)/Sparkles.Git.dll LINK_SPARKLES_DEPS = $(REF_SPARKLES) $(LINK_SPARKLES) REF_SPARKLESHARE = $(LINK_GTK) $(LINK_SPARKLES_DEPS) $(LINK_APP_INDICATOR) $(LINK_WEBKIT)