public SparkleUI(bool HideUI) { BusG.Init (); Gtk.Application.Init (); SetProcessName ("sparkleshare"); // The list of repositories Repositories = new List <SparkleRepo> (); EnableSystemAutostart (); InstallLauncher (); // Create the SparkleShare folder and add it to the bookmarks if (!Directory.Exists (SparklePaths.SparklePath)) { CreateSparkleShareFolder (); AddToBookmarks (); } // Watch the SparkleShare folder and update the repo list // when a deletion occurs. FileSystemWatcher watcher = new FileSystemWatcher (SparklePaths.SparklePath) { IncludeSubdirectories = false, EnableRaisingEvents = true, Filter = "*" }; // Remove the repository when a delete event occurs watcher.Deleted += delegate (object o, FileSystemEventArgs args) { RemoveRepository (args.FullPath); }; // Add the repository when a create event occurs watcher.Created += delegate (object o, FileSystemEventArgs args) { // Handle invitations when the user saves an // invitation into the SparkleShare folder if (args.Name.EndsWith ("sparkleshare.invitation")) { SparkleInvitation invitation; invitation = new SparkleInvitation (args.FullPath); Application.Invoke (delegate { invitation.PresentInvitation (); }); } else if (Directory.Exists (args.FullPath)) { AddRepository (args.FullPath); } }; CreateConfigurationFolders (); // Don't create the window and status icon when // the --disable-gui command line argument was given if (!HideUI) { string global_config_file_path = SparkleHelpers.CombineMore (SparklePaths.SparkleConfigPath, "config"); // Show the introduction screen if SparkleShare isn't configured if (!File.Exists (global_config_file_path)) { SparkleIntro intro = new SparkleIntro (); intro.ShowAll (); } else { SparkleShare.UserName = SparkleShare.GetUserName (); SparkleShare.UserEmail = SparkleShare.GetUserEmail (); SparkleShare.AddKey (); } // Create the statusicon NotificationIcon = new SparkleStatusIcon (); } PopulateRepositories (); }
public SparkleUI() { // Initialize the application Application.Init (); // Create the statusicon StatusIcon = new SparkleStatusIcon (); // Keep track of event logs are open SparkleUI.OpenLogs = new List <SparkleLog> (); SparkleShare.Controller.OnFirstRun += delegate { Application.Invoke (delegate { SparkleIntro intro = new SparkleIntro (); intro.ShowAll (); }); }; SparkleShare.Controller.OnInvitation += delegate (string invitation_file_path) { Application.Invoke (delegate { SparkleInvitation invitation = new SparkleInvitation (invitation_file_path); invitation.Present (); }); }; // Show a bubble when there are new changes SparkleShare.Controller.NotificationRaised += delegate (string author, string email, string message, string repository_path) { Application.Invoke (delegate { SparkleBubble bubble = new SparkleBubble (author, message) { Icon = SparkleUIHelpers.GetAvatar (email, 32) }; bubble.AddAction ("", "Show Events", delegate { SparkleLog log = new SparkleLog (repository_path); log.ShowAll (); }); bubble.Show (); }); }; // Show a bubble when there was a conflict SparkleShare.Controller.ConflictNotificationRaised += delegate { Application.Invoke (delegate { string title = _("Ouch! Mid-air collision!"); string subtext = _("Don't worry, SparkleShare made a copy of each conflicting file."); SparkleBubble bubble = new SparkleBubble(title, subtext); bubble.Show (); }); }; }