Exemplo n.º 1
0
        public SparkleUI()
        {
            NSApplication.Init();

            SetSparkleIcon();

            // TODO: Getting crashes when I remove this
            NSApplication.SharedApplication.ApplicationIconImage
                = NSImage.ImageNamed("sparkleshare.icns");


            if (!SparkleShare.Controller.BackendIsPresent)
            {
                Alert = new SparkleAlert();
                Alert.RunModal();
                return;
            }

            Font = NSFontManager.SharedFontManager.FontWithFamily
                       ("Lucida Grande", NSFontTraitMask.Condensed, 0, 13);

//            new SparkleAbout ();

            OpenLogs   = new List <SparkleLog> ();
            StatusIcon = new SparkleStatusIcon();


            SparkleShare.Controller.NotificationRaised += delegate(string user_name, string user_email,
                                                                   string message, string repository_path) {
                InvokeOnMainThread(delegate {
                    foreach (SparkleLog log in OpenLogs)
                    {
                        if (log.LocalPath.Equals(repository_path))
                        {
                            log.UpdateEventLog();
                        }
                    }

                    if (SparkleShare.Controller.NotificationsEnabled)
                    {
                        if (NSApplication.SharedApplication.DockTile.BadgeLabel == null)
                        {
                            NSApplication.SharedApplication.DockTile.BadgeLabel = "1";
                        }
                        else
                        {
                            NSApplication.SharedApplication.DockTile.BadgeLabel =
                                (int.Parse(NSApplication.SharedApplication.DockTile.BadgeLabel) + 1).ToString();
                        }

                        NSApplication.SharedApplication.RequestUserAttention
                            (NSRequestUserAttentionType.InformationalRequest);
                    }
                });
            };


            SparkleShare.Controller.AvatarFetched += delegate {
                InvokeOnMainThread(delegate {
                    foreach (SparkleLog log in SparkleUI.OpenLogs)
                    {
                        log.UpdateEventLog();
                    }
                });
            };


            SparkleShare.Controller.OnIdle += delegate {
                InvokeOnMainThread(delegate {
                    foreach (SparkleLog log in SparkleUI.OpenLogs)
                    {
                        log.UpdateEventLog();
                    }
                });
            };


            if (SparkleShare.Controller.FirstRun)
            {
                Intro = new SparkleIntro();
                Intro.ShowAccountForm();
            }
        }
Exemplo n.º 2
0
        public SparkleUI()
        {
            // Initialize the application
            Application.Init ();

            foreach (SparkleChangeSet change_set in SparkleShare.Controller.GetLog ()) {
                Console.WriteLine (change_set.Timestamp.ToString ());
            }
            // Create the statusicon
            StatusIcon = new SparkleStatusIcon ();

            if (SparkleShare.Controller.FirstRun) {
                Intro = new SparkleIntro ();
                Intro.ShowAccountForm ();
            }

            SparkleShare.Controller.OnQuitWhileSyncing += delegate {
                // TODO: Pop up a warning when quitting whilst syncing
            };

            SparkleShare.Controller.OnInvitation += delegate (string server, string folder, string token) {
                Application.Invoke (delegate {
                    SparkleIntro intro = new SparkleIntro ();
                    intro.ShowInvitationPage (server, folder, token);
                });
            };

            // Show a bubble when there are new changes
            SparkleShare.Controller.NotificationRaised += delegate (string user_name, string user_email,
                                                                    string message, string repository_path) {
                Application.Invoke (delegate {
                    if (EventLog != null)
                        EventLog.UpdateEvents ();

                    if (!SparkleShare.Controller.NotificationsEnabled)
                        return;

                    SparkleBubble bubble    = new SparkleBubble (user_name, message);
                    string avatar_file_path = SparkleShare.Controller.GetAvatar (user_email, 32);

                    if (avatar_file_path != null)
                        bubble.Icon = new Gdk.Pixbuf (avatar_file_path);
                    else
                        bubble.Icon = SparkleUIHelpers.GetIcon ("avatar-default", 32);

                    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.");

                    new SparkleBubble (title, subtext).Show ();
                });
            };

            SparkleShare.Controller.AvatarFetched += delegate {
                Application.Invoke (delegate {
                    if (EventLog != null)
                        EventLog.UpdateEvents ();
                });
            };

            SparkleShare.Controller.OnIdle += delegate {
                Application.Invoke (delegate {
                    if (EventLog != null)
                        EventLog.UpdateEvents ();
                });
            };

            SparkleShare.Controller.FolderListChanged += delegate {
                Application.Invoke (delegate {
                    if (EventLog != null)
                        EventLog.UpdateChooser ();
                });
            };
        }
Exemplo n.º 3
0
        public SparkleUI()
        {
            // Initialize the application
            Application.Init ();

            // 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 ();

            }

            SparkleShare.Controller.OnQuitWhileSyncing += delegate {

                // TODO: Pop up a warning when quitting whilst syncing

            };

            SparkleShare.Controller.OnInvitation += delegate (string server, string folder, string token) {
                Application.Invoke (delegate {

                    SparkleIntro intro = new SparkleIntro ();
                    intro.ShowInvitationPage (server, folder, token);

                });
            };

            // Show a bubble when there are new changes
            SparkleShare.Controller.NotificationRaised += delegate (SparkleCommit commit, string repository_path) {

                foreach (SparkleLog log in OpenLogs) {
                    if (log.LocalPath.Equals (repository_path)) {
                        Application.Invoke (delegate {
                            log.UpdateEventLog ();
                        });
                    }
                }

                // TODO: move to controller and do translation here

                if (!SparkleShare.Controller.NotificationsEnabled)
                    return;

                string file_name = "";
                string message = null;

                if (commit.Added.Count > 0) {

                    foreach (string added in commit.Added) {
                        file_name = added;
                        break;
                    }

                    message = String.Format (_("added ‘{0}’"), file_name);

                }

                if (commit.Edited.Count > 0) {

                    foreach (string modified in commit.Edited) {
                        file_name = modified;
                        break;
                    }

                    message = String.Format (_("edited ‘{0}’"), file_name);

                }

                if (commit.Deleted.Count > 0) {

                    foreach (string removed in commit.Deleted) {
                        file_name = removed;
                        break;
                    }

                    message = String.Format (_("deleted ‘{0}’"), file_name);

                }

                int changes_count = (commit.Added.Count +
                                     commit.Edited.Count +
                                     commit.Deleted.Count);

                if (changes_count > 1)
                    message += " + " + (changes_count - 1);

                Application.Invoke (delegate {

                    SparkleBubble bubble = new SparkleBubble (commit.UserName, message);

                    string avatar_file_path = SparkleUIHelpers.GetAvatar (commit.UserEmail, 32);

                    if (avatar_file_path != null)
                        bubble.Icon = new Gdk.Pixbuf (avatar_file_path);
                    else
                        bubble.Icon = SparkleUIHelpers.GetIcon ("avatar-default", 32);

                    bubble.AddAction ("", "Show Events", delegate {
                        AddEventLog (repository_path);
                    });

                    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.");

                    new SparkleBubble (title, subtext).Show ();

                });
            };

            SparkleShare.Controller.AvatarFetched += delegate {

                Application.Invoke (delegate {

                    foreach (SparkleLog log in OpenLogs)
                        log.UpdateEventLog ();

                });

            };

            SparkleShare.Controller.OnIdle += delegate {

                Application.Invoke (delegate {

                    foreach (SparkleLog log in OpenLogs)
                        log.UpdateEventLog ();

                });

            };
        }
Exemplo n.º 4
0
        public SparkleUI()
        {
            // Initialize the application
            Application.Init();

            // 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();
            }

            SparkleShare.Controller.OnQuitWhileSyncing += delegate {
                // TODO: Pop up a warning when quitting whilst syncing
            };

            SparkleShare.Controller.OnInvitation += delegate(string server, string folder, string token) {
                Application.Invoke(delegate {
                    SparkleIntro intro = new SparkleIntro();
                    intro.ShowInvitationPage(server, folder, token);
                });
            };

            // Show a bubble when there are new changes
            SparkleShare.Controller.NotificationRaised += delegate(string user_name, string user_email,
                                                                   string message, string repository_path) {
                foreach (SparkleLog log in OpenLogs)
                {
                    if (log.LocalPath.Equals(repository_path))
                    {
                        Application.Invoke(delegate {
                            log.UpdateEventLog();
                        });
                    }
                }

                // TODO: move to controller and do translation here

                if (!SparkleShare.Controller.NotificationsEnabled)
                {
                    return;
                }

                Application.Invoke(delegate {
                    SparkleBubble bubble = new SparkleBubble(user_name, message);

                    string avatar_file_path = SparkleUIHelpers.GetAvatar(user_email, 32);

                    if (avatar_file_path != null)
                    {
                        bubble.Icon = new Gdk.Pixbuf(avatar_file_path);
                    }
                    else
                    {
                        bubble.Icon = SparkleUIHelpers.GetIcon("avatar-default", 32);
                    }

                    bubble.AddAction("", "Show Events", delegate {
                        AddEventLog(repository_path);
                    });

                    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.");

                    new SparkleBubble(title, subtext).Show();
                });
            };


            SparkleShare.Controller.AvatarFetched += delegate {
                Application.Invoke(delegate {
                    foreach (SparkleLog log in OpenLogs)
                    {
                        log.UpdateEventLog();
                    }
                });
            };


            SparkleShare.Controller.OnIdle += delegate {
                Application.Invoke(delegate {
                    foreach (SparkleLog log in OpenLogs)
                    {
                        log.UpdateEventLog();
                    }
                });
            };
        }
Exemplo n.º 5
0
        public SparkleUI()
        {
            string content_path = Directory.GetParent (
                System.AppDomain.CurrentDomain.BaseDirectory).ToString ();

            string app_path     = Directory.GetParent (content_path).ToString ();
            string growl_path   = Path.Combine (app_path, "Frameworks", "Growl.framework", "Growl");

            // Needed for Growl
            Dlfcn.dlopen (growl_path, 0);
            NSApplication.Init ();

            using (NSAutoreleasePool pool = new NSAutoreleasePool ()) {

                // Needed for Growl
                GrowlApplicationBridge.WeakDelegate = this;

                NSApplication.SharedApplication.ApplicationIconImage
                    = NSImage.ImageNamed ("sparkleshare.icns");

                SetFolderIcon ();

                if (!SparkleShare.Controller.BackendIsPresent) {
                    this.alert = new SparkleAlert ();
                    this.alert.RunModal ();
                    return;
                }

                Font = NSFontManager.SharedFontManager.FontWithFamily
                    ("Lucida Grande", NSFontTraitMask.Condensed, 0, 13);

                StatusIcon = new SparkleStatusIcon ();
            }

            SparkleShare.Controller.NotificationRaised += delegate (string user_name, string user_email,
                                                                    string message, string repository_path) {
                InvokeOnMainThread (delegate {
                    if (EventLog != null)
                        EventLog.UpdateEvents ();

                    if (SparkleShare.Controller.NotificationsEnabled) {
                        if (NSApplication.SharedApplication.DockTile.BadgeLabel == null)
                            NSApplication.SharedApplication.DockTile.BadgeLabel = "1";
                        else
                            NSApplication.SharedApplication.DockTile.BadgeLabel =
                                (int.Parse (NSApplication.SharedApplication.DockTile.BadgeLabel) + 1).ToString ();

                        if (GrowlApplicationBridge.IsGrowlRunning ()) {
                            SparkleBubble bubble = new SparkleBubble (user_name, message) {
                                ImagePath = SparkleShare.Controller.GetAvatar (user_email, 36)
                            };

                            bubble.Show ();

                        } else {
                            NSApplication.SharedApplication.RequestUserAttention
                                (NSRequestUserAttentionType.InformationalRequest);
                        }
                    }
                });
            };

            SparkleShare.Controller.ConflictNotificationRaised += delegate {
                    string title   = "Ouch! Mid-air collision!";
                    string subtext = "Don't worry, SparkleShare made a copy of each conflicting file.";

                    new SparkleBubble (title, subtext).Show ();
            };

            SparkleShare.Controller.AvatarFetched += delegate {
                InvokeOnMainThread (delegate {
                    if (EventLog != null)
                        EventLog.UpdateEvents ();
                });
            };

            SparkleShare.Controller.OnIdle += delegate {
                InvokeOnMainThread (delegate {
                    if (EventLog != null)
                        EventLog.UpdateEvents ();
                });
            };

            SparkleShare.Controller.FolderListChanged += delegate {
                InvokeOnMainThread (delegate {
                    if (EventLog != null) {
                        EventLog.UpdateChooser ();
                        EventLog.UpdateEvents ();
                    }
                });
            };

            if (SparkleShare.Controller.FirstRun) {
                Intro = new SparkleIntro ();
                Intro.ShowAccountForm ();
            }
        }
Exemplo n.º 6
0
        public SparkleUI()
        {
            NSApplication.Init ();

            SetSparkleIcon ();

            // TODO: Getting crashes when I remove this
            NSApplication.SharedApplication.ApplicationIconImage
                = NSImage.ImageNamed ("sparkleshare.icns");

            if (!SparkleShare.Controller.BackendIsPresent) {

                Alert = new SparkleAlert ();
                Alert.RunModal ();
                return;

            }

            Font = NSFontManager.SharedFontManager.FontWithFamily
                ("Lucida Grande", NSFontTraitMask.Condensed, 0, 13);

            OpenLogs   = new List <SparkleLog> ();
            StatusIcon = new SparkleStatusIcon ();

            SparkleShare.Controller.NotificationRaised += delegate {

                InvokeOnMainThread (delegate {

                    foreach (SparkleLog log in SparkleUI.OpenLogs)
                        log.UpdateEventLog ();

                    if (SparkleShare.Controller.NotificationsEnabled) {

                        if (NSApplication.SharedApplication.DockTile.BadgeLabel == null)
                            NSApplication.SharedApplication.DockTile.BadgeLabel = "1";
                        else
                            NSApplication.SharedApplication.DockTile.BadgeLabel =
                                (int.Parse (NSApplication.SharedApplication.DockTile.BadgeLabel) + 1).ToString ();

                        NSApplication.SharedApplication.RequestUserAttention
                            (NSRequestUserAttentionType.InformationalRequest);

                    }

                });

            };

            SparkleShare.Controller.AvatarFetched += delegate {

                InvokeOnMainThread (delegate {

                    foreach (SparkleLog log in SparkleUI.OpenLogs)
                        log.UpdateEventLog ();

                });

            };

            SparkleShare.Controller.OnIdle += delegate {

                InvokeOnMainThread (delegate {

                    foreach (SparkleLog log in SparkleUI.OpenLogs)
                        log.UpdateEventLog ();

                });

            };

            if (SparkleShare.Controller.FirstRun) {

                Intro = new SparkleIntro ();
                Intro.ShowAccountForm ();

            }
        }
Exemplo n.º 7
0
        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 ();
        }
Exemplo n.º 8
0
        public SparkleUI()
        {
            // Initialize the application
            Application.Init ();

            // 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 ();

            }

            SparkleShare.Controller.OnQuitWhileSyncing += delegate {

                // TODO: Pop up a warning when quitting whilst syncing

            };

            SparkleShare.Controller.OnInvitation += delegate (string server, string folder, string token) {
                Application.Invoke (delegate {

                    SparkleIntro intro = new SparkleIntro ();
                    intro.ShowInvitationPage (server, folder, token);

                });
            };

            // Show a bubble when there are new changes
            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 (!SparkleShare.Controller.NotificationsEnabled)
                        return;

                    SparkleBubble bubble    = new SparkleBubble (user_name, message);
                    string avatar_file_path = SparkleUIHelpers.GetAvatar (user_email, 32);

                    if (avatar_file_path != null)
                        bubble.Icon = new Gdk.Pixbuf (avatar_file_path);
                    else
                        bubble.Icon = SparkleUIHelpers.GetIcon ("avatar-default", 32);

                    bubble.AddAction ("", "Show Events", delegate {
                        AddEventLog (repository_path);
                    });

                    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.");

                    new SparkleBubble (title, subtext).Show ();

                });
            };

            SparkleShare.Controller.AvatarFetched += delegate {

                Application.Invoke (delegate {

                    foreach (SparkleLog log in OpenLogs)
                        log.UpdateEventLog ();

                });

            };

            SparkleShare.Controller.OnIdle += delegate {

                Application.Invoke (delegate {

                    foreach (SparkleLog log in OpenLogs)
                        log.UpdateEventLog ();

                });

            };
        }
Exemplo n.º 9
0
        // Creates the menu that is popped up when the
        // user clicks the statusicon
        public void CreateMenu()
        {
            Menu = new Menu ();

                    // The menu item showing the status and size of the SparkleShare folder
                    StatusMenuItem = new MenuItem (StateText) {
                        Sensitive = false
                    };

                Menu.Add (StatusMenuItem);
                Menu.Add (new SeparatorMenuItem ());

                    // A menu item that provides a link to the SparkleShare folder
                    Gtk.Action folder_action = new Gtk.Action ("", "SparkleShare") {
                        IconName    = "folder-sparkleshare",
                        IsImportant = true
                    };

                    folder_action.Activated += delegate {

                        Process process = new Process ();
                        process.StartInfo.FileName = "xdg-open";
                        process.StartInfo.Arguments = SparklePaths.SparklePath;
                        process.Start ();

                    };

                Menu.Add (folder_action.CreateMenuItem ());

                if (SparkleUI.Repositories.Count > 0) {

                    // Creates a menu item for each repository with a link to their logs
                    foreach (SparkleRepo repo in SparkleUI.Repositories) {

                        folder_action = new Gtk.Action ("", repo.Name) {
                            IconName    = "folder",
                            IsImportant = true
                        };

                        folder_action.Activated += OpenLogDelegate (repo.LocalPath);

                        MenuItem menu_item = (MenuItem) folder_action.CreateMenuItem ();

                        if (repo.Description != null)
                            menu_item.TooltipText = repo.Description;

                        Menu.Add (menu_item);

                    }

                } else {

                    MenuItem no_folders_item = new MenuItem (_("No Shared Folders Yet")) {
                        Sensitive   = false
                    };

                    Menu.Add (no_folders_item);

                }

                // Opens the wizard to add a new remote folder
                MenuItem add_item = new MenuItem (_("Sync Remote Folder…"));

                    add_item.Activated += delegate {

                        SparkleIntro intro = new SparkleIntro ();

                        // Only show the server form in the wizard
                        intro.ShowServerForm (true);

                    };

                Menu.Add (add_item);
                Menu.Add (new SeparatorMenuItem ());

                // A checkbutton to toggle whether or not to show notifications
                CheckMenuItem notify_item =	new CheckMenuItem (_("Show Notifications"));

                    // Whether notifications are shown depends existence of this file
                    string notify_setting_file_path = SparkleHelpers.CombineMore (SparklePaths.SparkleConfigPath,
                        "sparkleshare.notify");

                    if (File.Exists (notify_setting_file_path))
                        notify_item.Active = true;

                    notify_item.Toggled += delegate {

                        if (File.Exists (notify_setting_file_path))
                            File.Delete (notify_setting_file_path);
                        else
                            File.Create (notify_setting_file_path);

                    };

                Menu.Add (notify_item);
                Menu.Add (new SeparatorMenuItem ());

                // A menu item that takes the use to sparkleshare.org
                MenuItem about_item = new MenuItem (_("Visit Website"));

                    about_item.Activated += delegate {

                        Process process = new Process ();

                        process.StartInfo.FileName  = "xdg-open";
                        process.StartInfo.Arguments = "http://www.sparkleshare.org/";

                        process.Start ();

                    };

                Menu.Add (about_item);
                Menu.Add (new SeparatorMenuItem ());

                    // A menu item that quits the application
                    MenuItem quit_item = new MenuItem (_("Quit"));
                    quit_item.Activated += Quit;

                Menu.Add (quit_item);
        }
Exemplo n.º 10
0
        public SparkleUI()
        {
            NSApplication.Init ();

            SetSparkleIcon ();

            // TODO: Getting crashes when I remove this
            NSApplication.SharedApplication.ApplicationIconImage
                = NSImage.ImageNamed ("sparkleshare.icns");

            Font = NSFontManager.SharedFontManager.FontWithFamily
                ("Lucida Grande", NSFontTraitMask.Condensed, 0, 13);

            OpenLogs   = new List <SparkleLog> ();
            StatusIcon = new SparkleStatusIcon ();

            NewEvents = 0;

            SparkleShare.Controller.NotificationRaised += delegate {

                InvokeOnMainThread (delegate {

                    NewEvents++;
                    NSApplication.SharedApplication.DockTile.BadgeLabel = NewEvents.ToString ();

                    foreach (SparkleLog log in SparkleUI.OpenLogs)
                        log.UpdateEventLog ();

                    NSApplication.SharedApplication.RequestUserAttention
                        (NSRequestUserAttentionType.InformationalRequest);

                });

            };

            SparkleShare.Controller.AvatarFetched += delegate {

                InvokeOnMainThread (delegate {

                    foreach (SparkleLog log in SparkleUI.OpenLogs)
                        log.UpdateEventLog ();

                });

            };

            SparkleShare.Controller.OnIdle += delegate {

                InvokeOnMainThread (delegate {

                    foreach (SparkleLog log in SparkleUI.OpenLogs)
                        log.UpdateEventLog ();

                });

            };

            if (SparkleShare.Controller.FirstRun) {

                Intro = new SparkleIntro ();
                Intro.ShowAccountForm ();

            }
        }
Exemplo n.º 11
0
        // Creates the menu that is popped up when the
        // user clicks the status icon
        public void CreateMenu()
        {
            Menu = new Menu ();

                // The menu item showing the status and size of the SparkleShare folder
                MenuItem status_menu_item = new MenuItem (StateText) {
                    Sensitive = false
                };

                // A menu item that provides a link to the SparkleShare folder
                Gtk.Action folder_action = new Gtk.Action ("", "SparkleShare") {
                    IconName    = "folder-sparkleshare",
                    IsImportant = true
                };

                folder_action.Activated += delegate {
                    SparkleShare.Controller.OpenSparkleShareFolder ();
                };

            Menu.Add (status_menu_item);
            Menu.Add (new SeparatorMenuItem ());
            Menu.Add (folder_action.CreateMenuItem ());

                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) {

                        folder_action = new Gtk.Action ("", Path.GetFileName (path)) {
                            IconName    = "folder",
                            IsImportant = true
                        };

            //						if (repo.HasUnsyncedChanges)
            //							folder_action.IconName = "dialog-error";

                        folder_action.Activated += OpenEventLogDelegate (path);

                        MenuItem menu_item = (MenuItem) folder_action.CreateMenuItem ();

                        Menu.Add (menu_item);

                    }

                } else {

                    MenuItem no_folders_item = new MenuItem (_("No Remote Folders Yet")) {
                        Sensitive   = false
                    };

                    Menu.Add (no_folders_item);

                }

                // Opens the wizard to add a new remote folder
                MenuItem sync_item = new MenuItem (_("Sync Remote Folder…"));

                if (SparkleShare.Controller.FirstRun)
                    sync_item.Sensitive = false;

                sync_item.Activated += delegate {
                    Application.Invoke (delegate {

                        SparkleIntro intro = new SparkleIntro ();
                        intro.ShowServerForm (true);

                    });
                };

            Menu.Add (sync_item);
            Menu.Add (new SeparatorMenuItem ());

                // A checkbutton to toggle whether or not to show notifications
                CheckMenuItem notify_item =	new CheckMenuItem (_("Show Notifications"));

                if (SparkleShare.Controller.NotificationsEnabled)
                    notify_item.Active = true;

                notify_item.Toggled += delegate {
                    SparkleShare.Controller.ToggleNotifications ();
                };

            Menu.Add (notify_item);
            Menu.Add (new SeparatorMenuItem ());

                // A menu item that takes the user to http://www.sparkleshare.org/
                MenuItem about_item = new MenuItem (_("About"));

                about_item.Activated += delegate {

                    SparkleDialog dialog = new SparkleDialog ();
                    dialog.ShowAll ();

                };

            Menu.Add (about_item);
            Menu.Add (new SeparatorMenuItem ());

                // A menu item that quits the application
                MenuItem quit_item = new MenuItem (_("Quit"));

                quit_item.Activated += delegate {
                    SparkleShare.Controller.Quit ();
                };

            Menu.Add (quit_item);

            Menu.ShowAll ();
        }
Exemplo n.º 12
0
        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 ();

                });
            };
        }