AddAction() public method

public AddAction ( string action, string label, ActionHandler handler ) : void
action string
label string
handler ActionHandler
return void
Esempio n. 1
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 ();

                });

            };
        }
Esempio n. 2
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();
                    }
                });
            };
        }
Esempio 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 (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 ();

                });

            };
        }
Esempio n. 4
0
        // Shows a notification bubble when someone
        // made a change to the repository
        public void ShowNewCommitBubble(string author, string email, string message, string repository_name)
        {
            string notify_settings_file = SparkleHelpers.CombineMore (SparklePaths.SparkleConfigPath,
                "sparkleshare.notify");

            if (File.Exists (notify_settings_file)) {

                SparkleBubble bubble = new SparkleBubble (author, message) {
                    Icon = SparkleUIHelpers.GetAvatar (email, 32)
                };

                bubble.AddAction ("", "Show Events", delegate {

                    string path = SparkleHelpers.CombineMore (SparklePaths.SparklePath, repository_name);

                    SparkleLog log = new SparkleLog (path);
                    log.ShowAll ();

                });

                bubble.Show ();

            }
        }
Esempio n. 5
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 ();

                });
            };
        }