public void ShowServerForm()
        {
            Reset ();

            VBox layout_vertical = new VBox (false, 0);

                Label header = new Label ("<span size='large'><b>" +
                                                _("Where is your remote folder?") +
                                                "</b></span>") {
                    UseMarkup = true,
                    Xalign = 0
                };

                Table table = new Table (7, 2, false) {
                    RowSpacing = 12
                };

                    HBox layout_server = new HBox (true, 0);

                        ServerEntry = new SparkleEntry () {
                            ExampleText = _("address-to-server.com")
                        };

                        ServerEntry.Changed += CheckServerForm;

                        RadioButton radio_button = new RadioButton ("<b>" + _("On my own server:") + "</b>");

                    layout_server.Add (radio_button);
                    layout_server.Add (ServerEntry);

                    string github_text = "<b>" + "Github" + "</b>\n" +
                          "<span fgcolor='" + SecondaryTextColor + "' size='small'>" +
                        _("Free hosting for Free and Open Source Software projects.") + "\n" +
                        _("Also has paid accounts for extra private space and bandwidth.") +
                          "</span>";

                    RadioButton radio_button_github = new RadioButton (radio_button, github_text);

                    (radio_button_github.Child as Label).UseMarkup = true;
                    (radio_button_github.Child as Label).Wrap      = true;

                    string gnome_text = "<b>" + _("The GNOME Project") + "</b>\n" +
                          "<span fgcolor='" + SecondaryTextColor + "' size='small'>" +
                        _("GNOME is an easy to understand interface to your computer.") + "\n" +
                        _("Select this option if you’re a developer or designer working on GNOME.") +
                          "</span>";

                    RadioButton radio_button_gnome = new RadioButton (radio_button, gnome_text);

                    (radio_button_gnome.Child as Label).UseMarkup = true;
                    (radio_button_gnome.Child as Label).Wrap      = true;

                    string gitorious_text = "<b>" + _("Gitorious") + "</b>\n" +
                          "<span fgcolor='" + SecondaryTextColor + "' size='small'>" +
                        _("Completely Free as in Freedom infrastructure.") + "\n" +
                        _("Free accounts for Free and Open Source projects.") +
                          "</span>";
                    RadioButton radio_button_gitorious = new RadioButton (radio_button, gitorious_text) {
                        Xalign = 0
                    };

                    (radio_button_gitorious.Child as Label).UseMarkup = true;
                    (radio_button_gitorious.Child as Label).Wrap      = true;

                    radio_button_github.Toggled += delegate {
                        if (radio_button_github.Active)
                            FolderEntry.ExampleText = _("Username/Folder");
                    };

                    radio_button_gitorious.Toggled += delegate {
                        if (radio_button_gitorious.Active)
                            FolderEntry.ExampleText = _("Project/Folder");
                    };

                    radio_button_gnome.Toggled += delegate {
                        if (radio_button_gnome.Active)
                            FolderEntry.ExampleText = _("Project");
                    };

                    radio_button.Toggled += delegate {
                        if (radio_button.Active) {
                            FolderEntry.ExampleText = _("Folder");
                            ServerEntry.Sensitive   = true;
                            CheckServerForm ();
                        } else {
                            ServerEntry.Sensitive = false;
                            CheckServerForm ();
                        }

                        ShowAll ();
                    };

                table.Attach (layout_server,          0, 2, 1, 2);
                table.Attach (radio_button_github,    0, 2, 2, 3);
                table.Attach (radio_button_gitorious, 0, 2, 3, 4);
                table.Attach (radio_button_gnome,     0, 2, 4, 5);

                HBox layout_folder = new HBox (true, 0);

                    FolderEntry = new SparkleEntry () {
                        ExampleText = _("Folder")
                    };

                    FolderEntry.Changed += CheckServerForm;

                    Label folder_label = new Label (_("Folder Name:")) {
                        UseMarkup = true,
                        Xalign    = 1
                    };

                (radio_button.Child as Label).UseMarkup = true;

                layout_folder.PackStart (folder_label, true, true, 12);
                layout_folder.PackStart (FolderEntry, true, true, 0);

                    SyncButton = new Button (_("Sync"));

                    SyncButton.Clicked += delegate {
                        string folder_name    = FolderEntry.Text;
                        string server         = ServerEntry.Text;
                        string canonical_name = System.IO.Path.GetFileNameWithoutExtension (folder_name);

                        if (radio_button_gitorious.Active)
                            server = "gitorious.org";

                        if (radio_button_github.Active)
                            server = "github.com";

                        if (radio_button_gnome.Active)
                            server = "gnome.org";

                        Application.Invoke (delegate {
                            Deletable = false;
                            ShowSyncingPage (canonical_name);
                        });

                        SparkleShare.Controller.FolderFetched += delegate {
                            Application.Invoke (delegate {
                                this.progress_bar_pulse_timer.Stop ();
                                Deletable = true;
                                UrgencyHint = true;
                                ShowSuccessPage (canonical_name);
                            });
                        };

                        SparkleShare.Controller.FolderFetchError += delegate {
                            Application.Invoke (delegate {
                                this.progress_bar_pulse_timer.Stop ();
                                Deletable = true;
                                ShowErrorPage ();
                            });
                        };

                        SparkleShare.Controller.FetchFolder (server, folder_name);
                    };

                if (ServerFormOnly) {
                    Button cancel_button = new Button (_("Cancel"));

                    cancel_button.Clicked += delegate {
                        Close ();
                    };

                    AddButton (cancel_button);
                } else {
                    Button skip_button = new Button (_("Skip"));

                    skip_button.Clicked += delegate {
                        ShowCompletedPage ();
                    };

                    AddButton (skip_button);
                }

            AddButton (SyncButton);

            layout_vertical.PackStart (header, false, false, 0);
            layout_vertical.PackStart (new Label (""), false, false, 3);
            layout_vertical.PackStart (table, false, false, 0);
            layout_vertical.PackStart (layout_folder, false, false, 6);

            Add (layout_vertical);
            CheckServerForm ();
            ShowAll ();
        }
        public void ShowServerForm()
        {
            Reset ();

            VBox layout_vertical = new VBox (false, 0);

                Label header = new Label ("<span size='x-large'><b>" +
                                                _("Where is your remote folder?") +
                                                "</b></span>") {
                    UseMarkup = true,
                    Xalign = 0
                };

                Table table = new Table (7, 2, false) {
                    RowSpacing = 12
                };

                    HBox layout_server = new HBox (true, 0);

                        ServerEntry = new SparkleEntry () {
                            ExampleText = _("address-to-server.com")
                        };

                        ServerEntry.Changed += CheckServerForm;

                        RadioButton radio_button = new RadioButton ("<b>" + _("On my own server:") + "</b>");

                    layout_server.Add (radio_button);
                    layout_server.Add (ServerEntry);

                    string github_text = "<b>" + "Github" + "</b>\n" +
                          "<span fgcolor='" + SecondaryTextColor + "' size='small'>" +
                        _("Free hosting for Free and Open Source Software projects.") + "\n" +
                        _("Also has paid accounts for extra private space and bandwidth.") +
                          "</span>";

                    RadioButton radio_button_github = new RadioButton (radio_button, github_text);

                    (radio_button_github.Child as Label).UseMarkup = true;
                    (radio_button_github.Child as Label).Wrap      = true;

                    string gnome_text = "<b>" + _("The GNOME Project") + "</b>\n" +
                          "<span fgcolor='" + SecondaryTextColor + "' size='small'>" +
                        _("GNOME is an easy to understand interface to your computer.") + "\n" +
                        _("Select this option if you’re a developer or designer working on GNOME.") +
                          "</span>";

                    RadioButton radio_button_gnome = new RadioButton (radio_button, gnome_text);

                    (radio_button_gnome.Child as Label).UseMarkup = true;
                    (radio_button_gnome.Child as Label).Wrap      = true;

                    string gitorious_text = "<b>" + _("Gitorious") + "</b>\n" +
                          "<span fgcolor='" + SecondaryTextColor + "' size='small'>" +
                        _("Completely Free as in Freedom infrastructure.") + "\n" +
                        _("Free accounts for Free and Open Source projects.") +
                          "</span>";
                    RadioButton radio_button_gitorious = new RadioButton (radio_button, gitorious_text) {
                        Xalign = 0
                    };

                    (radio_button_gitorious.Child as Label).UseMarkup = true;
                    (radio_button_gitorious.Child as Label).Wrap      = true;

                    radio_button_github.Toggled += delegate {

                        if (radio_button_github.Active)
                            FolderEntry.ExampleText = _("Username/Folder");

                    };

                    radio_button_gitorious.Toggled += delegate {

                        if (radio_button_gitorious.Active)
                            FolderEntry.ExampleText = _("Project/Folder");

                    };

                    radio_button_gnome.Toggled += delegate {

                        if (radio_button_gnome.Active)
                            FolderEntry.ExampleText = _("Project");

                    };

                    radio_button.Toggled += delegate {

                        if (radio_button.Active) {

                            FolderEntry.ExampleText = _("Folder");
                            ServerEntry.Sensitive   = true;
                            CheckServerForm ();

                        } else {

                            ServerEntry.Sensitive = false;
                            CheckServerForm ();

                        }

                        ShowAll ();

                    };

                table.Attach (layout_server,          0, 2, 1, 2);
                table.Attach (radio_button_github,    0, 2, 2, 3);
                table.Attach (radio_button_gitorious, 0, 2, 3, 4);
                table.Attach (radio_button_gnome,     0, 2, 4, 5);

                HBox layout_folder = new HBox (true, 0);

                    FolderEntry = new SparkleEntry () {
                        ExampleText = _("Folder")
                    };

                    FolderEntry.Changed += CheckServerForm;

                    Label folder_label = new Label ("<b>" + _("Folder Name:") + "</b>") {
                        UseMarkup = true,
                        Xalign    = 1
                    };

                (radio_button.Child as Label).UseMarkup = true;

                layout_folder.PackStart (folder_label, true, true, 12);
                layout_folder.PackStart (FolderEntry, true, true, 0);

                    SyncButton = new Button (_("Sync"));

                    SyncButton.Clicked += delegate {

                        string name = FolderEntry.Text;

                        // Remove the starting slash if there is one
                        if (name.StartsWith ("/"))
                            name = name.Substring (1);

                        string server = ServerEntry.Text;

                        if (name.EndsWith ("/"))
                            name = name.TrimEnd ("/".ToCharArray ());

                        if (name.StartsWith ("/"))
                            name = name.TrimStart ("/".ToCharArray ());

                        if (server.StartsWith ("ssh://"))
                            server = server.Substring (6);

                        if (radio_button.Active) {

                            // Use the default user 'git' if no username is specified
                            if (!server.Contains ("@"))
                                server = "git@" + server;

                            // Prepend the Secure Shell protocol when it isn't specified
                            if (!server.StartsWith ("ssh://"))
                                server = "ssh://" + server;

                            // Remove the trailing slash if there is one
                            if (server.EndsWith ("/"))
                                server = server.TrimEnd ("/".ToCharArray ());

                        }

                        if (radio_button_gitorious.Active) {

                            server = "ssh://[email protected]";

                            if (!name.EndsWith (".git")) {

                                if (!name.Contains ("/"))
                                    name = name + "/" + name;

                                name += ".git";

                            }

                        }

                        if (radio_button_github.Active)
                            server = "ssh://[email protected]";

                        if (radio_button_gnome.Active)
                            server = "ssh://[email protected]/git/";

                        string url  = server + "/" + name;
                        Console.WriteLine ("View", "[" + name + "] Formed URL: " + url);

                        string canonical_name = System.IO.Path.GetFileNameWithoutExtension (name);

                        DeleteEvent += PreventClose;
                        ShowSyncingPage (canonical_name);

                        SparkleShare.Controller.FolderFetched += delegate {

                            DeleteEvent -= PreventClose;

                            Application.Invoke (delegate {
                                ShowSuccessPage (name);
                            });

                        };

                        SparkleShare.Controller.FolderFetchError += delegate {

                            DeleteEvent -= PreventClose;

                            Application.Invoke (delegate { ShowErrorPage (); });

                        };

                        SparkleShare.Controller.FetchFolder (url, name);

                    };

                if (ServerFormOnly) {

                    Button cancel_button = new Button (_("Cancel"));

                    cancel_button.Clicked += delegate {
                        Destroy ();
                    };

                    AddButton (cancel_button);

                } else {

                    Button skip_button = new Button (_("Skip"));

                    skip_button.Clicked += delegate {
                        ShowCompletedPage ();
                    };

                    AddButton (skip_button);

                }

                AddButton (SyncButton);

            layout_vertical.PackStart (header, false, false, 0);
            layout_vertical.PackStart (new Label (""), false, false, 3);
            layout_vertical.PackStart (table, false, false, 0);
            layout_vertical.PackStart (layout_folder, false, false, 6);

            Add (layout_vertical);

            CheckServerForm ();

            ShowAll ();
        }
Exemple #3
0
        public void ShowServerForm()
        {
            Reset();

            VBox layout_vertical = new VBox(false, 0);

            Label header = new Label("<span size='large'><b>" +
                                     _("Where is your remote folder?") +
                                     "</b></span>")
            {
                UseMarkup = true,
                Xalign    = 0
            };

            Table table = new Table(7, 2, false)
            {
                RowSpacing = 12
            };

            HBox layout_server = new HBox(true, 0);

            ServerEntry = new SparkleEntry()
            {
                ExampleText = _("address-to-server.com")
            };

            ServerEntry.Changed += CheckServerForm;

            RadioButton radio_button = new RadioButton("<b>" + _("On my own server:") + "</b>");

            layout_server.Add(radio_button);
            layout_server.Add(ServerEntry);

            string github_text = "<b>" + "Github" + "</b>\n" +
                                 "<span fgcolor='" + SecondaryTextColor + "' size='small'>" +
                                 _("Free hosting for Free and Open Source Software projects.") + "\n" +
                                 _("Also has paid accounts for extra private space and bandwidth.") +
                                 "</span>";

            RadioButton radio_button_github = new RadioButton(radio_button, github_text);

            (radio_button_github.Child as Label).UseMarkup = true;
            (radio_button_github.Child as Label).Wrap      = true;

            string gnome_text = "<b>" + _("The GNOME Project") + "</b>\n" +
                                "<span fgcolor='" + SecondaryTextColor + "' size='small'>" +
                                _("GNOME is an easy to understand interface to your computer.") + "\n" +
                                _("Select this option if you’re a developer or designer working on GNOME.") +
                                "</span>";

            RadioButton radio_button_gnome = new RadioButton(radio_button, gnome_text);

            (radio_button_gnome.Child as Label).UseMarkup = true;
            (radio_button_gnome.Child as Label).Wrap      = true;

            string gitorious_text = "<b>" + _("Gitorious") + "</b>\n" +
                                    "<span fgcolor='" + SecondaryTextColor + "' size='small'>" +
                                    _("Completely Free as in Freedom infrastructure.") + "\n" +
                                    _("Free accounts for Free and Open Source projects.") +
                                    "</span>";
            RadioButton radio_button_gitorious = new RadioButton(radio_button, gitorious_text)
            {
                Xalign = 0
            };

            (radio_button_gitorious.Child as Label).UseMarkup = true;
            (radio_button_gitorious.Child as Label).Wrap      = true;

            radio_button_github.Toggled += delegate {
                if (radio_button_github.Active)
                {
                    FolderEntry.ExampleText = _("Username/Folder");
                }
            };

            radio_button_gitorious.Toggled += delegate {
                if (radio_button_gitorious.Active)
                {
                    FolderEntry.ExampleText = _("Project/Folder");
                }
            };

            radio_button_gnome.Toggled += delegate {
                if (radio_button_gnome.Active)
                {
                    FolderEntry.ExampleText = _("Project");
                }
            };


            radio_button.Toggled += delegate {
                if (radio_button.Active)
                {
                    FolderEntry.ExampleText = _("Folder");
                    ServerEntry.Sensitive   = true;
                    CheckServerForm();
                }
                else
                {
                    ServerEntry.Sensitive = false;
                    CheckServerForm();
                }

                ShowAll();
            };

            table.Attach(layout_server, 0, 2, 1, 2);
            table.Attach(radio_button_github, 0, 2, 2, 3);
            table.Attach(radio_button_gitorious, 0, 2, 3, 4);
            table.Attach(radio_button_gnome, 0, 2, 4, 5);

            HBox layout_folder = new HBox(true, 0);

            FolderEntry = new SparkleEntry()
            {
                ExampleText = _("Folder")
            };

            FolderEntry.Changed += CheckServerForm;

            Label folder_label = new Label(_("Folder Name:"))
            {
                UseMarkup = true,
                Xalign    = 1
            };

            (radio_button.Child as Label).UseMarkup = true;

            layout_folder.PackStart(folder_label, true, true, 12);
            layout_folder.PackStart(FolderEntry, true, true, 0);

            SyncButton = new Button(_("Sync"));

            SyncButton.Clicked += delegate {
                string name = FolderEntry.Text;

                // Remove the starting slash if there is one
                if (name.StartsWith("/"))
                {
                    name = name.Substring(1);
                }

                string server = ServerEntry.Text;

                if (name.EndsWith("/"))
                {
                    name = name.TrimEnd("/".ToCharArray());
                }

                if (name.StartsWith("/"))
                {
                    name = name.TrimStart("/".ToCharArray());
                }

                if (server.StartsWith("ssh://"))
                {
                    server = server.Substring(6);
                }

                if (radio_button.Active)
                {
                    // Use the default user 'git' if no username is specified
                    if (!server.Contains("@"))
                    {
                        server = "git@" + server;
                    }

                    // Prepend the Secure Shell protocol when it isn't specified
                    if (!server.StartsWith("ssh://"))
                    {
                        server = "ssh://" + server;
                    }

                    // Remove the trailing slash if there is one
                    if (server.EndsWith("/"))
                    {
                        server = server.TrimEnd("/".ToCharArray());
                    }
                }

                if (radio_button_gitorious.Active)
                {
                    server = "ssh://[email protected]";

                    if (!name.EndsWith(".git"))
                    {
                        if (!name.Contains("/"))
                        {
                            name = name + "/" + name;
                        }

                        name += ".git";
                    }
                }

                if (radio_button_github.Active)
                {
                    server = "ssh://[email protected]";
                }

                if (radio_button_gnome.Active)
                {
                    server = "ssh://[email protected]/git/";
                }

                string url = server + "/" + name;
                Console.WriteLine("View", "[" + name + "] Formed URL: " + url);

                string canonical_name = System.IO.Path.GetFileNameWithoutExtension(name);

                ShowSyncingPage(canonical_name);

                SparkleShare.Controller.FolderFetched += delegate {
                    Application.Invoke(delegate {
                        Deletable = true;
                        ShowSuccessPage(name);
                    });
                };

                SparkleShare.Controller.FolderFetchError += delegate {
                    Application.Invoke(delegate {
                        Deletable = true;
                        ShowErrorPage();
                    });
                };


                SparkleShare.Controller.FetchFolder(url, name);
            };


            if (ServerFormOnly)
            {
                Button cancel_button = new Button(_("Cancel"));

                cancel_button.Clicked += delegate {
                    Close();
                };

                AddButton(cancel_button);
            }
            else
            {
                Button skip_button = new Button(_("Skip"));

                skip_button.Clicked += delegate {
                    ShowCompletedPage();
                };

                AddButton(skip_button);
            }

            AddButton(SyncButton);

            layout_vertical.PackStart(header, false, false, 0);
            layout_vertical.PackStart(new Label(""), false, false, 3);
            layout_vertical.PackStart(table, false, false, 0);
            layout_vertical.PackStart(layout_folder, false, false, 6);

            Add(layout_vertical);

            CheckServerForm();

            ShowAll();
        }
        public SparkleSetup()
            : base()
        {
            SecondaryTextColor         = SparkleUIHelpers.GdkColorToHex (Style.Foreground (StateType.Insensitive));
            SecondaryTextColorSelected =
                SparkleUIHelpers.GdkColorToHex (
                    MixColors (
                        new TreeView ().Style.Foreground (StateType.Selected),
                        new TreeView ().Style.Background (StateType.Selected),
                        0.15
                    )
                );

            Controller.ChangePageEvent += delegate (PageType type) {
                Application.Invoke (delegate {
                    Reset ();

                    switch (type) {
                    case PageType.Setup: {

                        Header = _("Welcome to SparkleShare!");
                        Description = _("Before we can create a SparkleShare folder on this " +
                                        "computer, we need a few bits of information from you.");

                        Table = new Table (4, 2, true) {
                            RowSpacing = 6
                        };

                            Label name_label = new Label ("<b>" + _("Full Name:") + "</b>") {
                                UseMarkup = true,
                                Xalign    = 0
                            };

                            NameEntry = new Entry (Controller.GuessedUserName);
                            NameEntry.Changed += delegate {
                                CheckSetupPage ();
                            };

                            EmailEntry = new Entry (Controller.GuessedUserEmail);
                            EmailEntry.Changed += delegate {
                                CheckSetupPage ();
                            };

                            Label email_label = new Label ("<b>" + _("Email:") + "</b>") {
                                UseMarkup = true,
                                Xalign    = 0
                            };

                        Table.Attach (name_label, 0, 1, 0, 1);
                        Table.Attach (NameEntry, 1, 2, 0, 1);
                        Table.Attach (email_label, 0, 1, 1, 2);
                        Table.Attach (EmailEntry, 1, 2, 1, 2);

                            NextButton = new Button (_("Next")) {
                                Sensitive = false
                            };

                            NextButton.Clicked += delegate (object o, EventArgs args) {
                                string full_name = NameEntry.Text;
                                string email     = EmailEntry.Text;

                                Controller.SetupPageCompleted (full_name, email);
                            };

                        AddButton (NextButton);
                        Add (Table);

                        CheckSetupPage ();

                        break;
                    }

                    case PageType.Add: {

                        Header = _("Where's your project hosted?");

                        VBox layout_vertical = new VBox (false, 12);
                        HBox layout_fields   = new HBox (true, 12);
                        VBox layout_address  = new VBox (true, 0);
                        VBox layout_path     = new VBox (true, 0);

                        ListStore store = new ListStore (typeof (Gdk.Pixbuf),
                            typeof (string), typeof (SparklePlugin));

                        TreeView tree = new TreeView (store) { HeadersVisible = false };
                        ScrolledWindow scrolled_window = new ScrolledWindow ();
                        scrolled_window.AddWithViewport (tree);

                        // Icon column
                        tree.AppendColumn ("Icon", new Gtk.CellRendererPixbuf (), "pixbuf", 0);
                        tree.Columns [0].Cells [0].Xpad = 6;

                        // Service column
                        TreeViewColumn service_column = new TreeViewColumn () { Title = "Service" };
                        CellRendererText service_cell = new CellRendererText () { Ypad = 4 };
                        service_column.PackStart (service_cell, true);
                        service_column.SetCellDataFunc (service_cell, new TreeCellDataFunc (RenderServiceColumn));

                        foreach (SparklePlugin plugin in Controller.Plugins) {
                            store.AppendValues (
                                new Gdk.Pixbuf (plugin.ImagePath),
                                "<span size=\"small\"><b>" + plugin.Name + "</b>\n" +
                                  "<span fgcolor=\"" + SecondaryTextColorSelected + "\">" +
                                  plugin.Description + "</span>" +
                                "</span>",
                                plugin);
                        }

                        tree.AppendColumn (service_column);

                        PathEntry = new SparkleEntry ();
                        AddressEntry = new SparkleEntry ();

                        // Select the first plugin by default
                        TreeSelection default_selection = tree.Selection;
                        TreePath default_path = new TreePath ("0");
                        default_selection.SelectPath (default_path);
                        Controller.SelectedPluginChanged (0);

                        Controller.ChangeAddressFieldEvent += delegate (string text,
                            string example_text, FieldState state) {
                            Console.WriteLine ("> " +  text);
                            Application.Invoke (delegate {
                                AddressEntry.Text        = text;
                                AddressEntry.Sensitive   = (state == FieldState.Enabled);

                                if (string.IsNullOrEmpty (example_text))
                                    AddressEntry.ExampleText = null;
                                else
                                    AddressEntry.ExampleText = example_text;

                                if (string.IsNullOrEmpty (text))
                                    AddressEntry.ExampleTextActive = true;
                                else
                                    AddressEntry.ExampleTextActive = false;
                            });
                        };

                        Controller.ChangePathFieldEvent += delegate (string text,
                            string example_text, FieldState state) {

                            Application.Invoke (delegate {
                                PathEntry.Text        = text;
                                PathEntry.Sensitive   = (state == FieldState.Enabled);

                                if (string.IsNullOrEmpty (example_text))
                                    PathEntry.ExampleText = null;
                                else
                                    PathEntry.ExampleText = example_text;

                                if (string.IsNullOrEmpty (text))
                                    PathEntry.ExampleTextActive = true;
                                else
                                    PathEntry.ExampleTextActive = false;
                            });
                        };

                        // Update the address field text when the selection changes
                        tree.CursorChanged += delegate (object sender, EventArgs e) {
                            TreeIter iter;
                            TreeModel model;

                            TreeSelection selection = (sender as TreeView).Selection;
                            selection.GetSelected (out model, out iter);

                            SparklePlugin plugin = (SparklePlugin) model.GetValue (iter, 2);
                            int selected_path = int.Parse (model.GetPath (iter).ToString ());

                            Controller.SelectedPluginChanged (selected_path);

                            // TODO: Scroll to selected row when using arrow keys
                        };

                        tree.Model.Foreach (new TreeModelForeachFunc (delegate (TreeModel model,
                            TreePath path, TreeIter iter) {

                            string address;

                            try {
                                address = (model.GetValue (iter, 2) as SparklePlugin).Address;

                            } catch (NullReferenceException) {
                                address = "";
                            }

                            if (!string.IsNullOrEmpty (address) &&
                                address.Equals (Controller.PreviousAddress)) {

                                tree.SetCursor (path, service_column, false);
                                SparklePlugin plugin = (SparklePlugin) model.GetValue (iter, 2);

                                if (plugin.Address != null) {
                                    AddressEntry.Sensitive = false;}

                                if (plugin.Path != null)
                                    PathEntry.Sensitive = false;

                                // TODO: Scroll to the selection

                                return true;
                            } else {
                                return false;
                            }
                        }));

                        AddressEntry.Completion = new EntryCompletion();
                        ListStore server_store = new ListStore (typeof (string));

                        foreach (string host in Program.Controller.PreviousHosts)
                            server_store.AppendValues (host);

                        AddressEntry.Completion.Model      = server_store;
                        AddressEntry.Completion.TextColumn = 0;

                        AddressEntry.Changed += delegate {
                            CheckAddPage ();
                        };

                                layout_address.PackStart (new Label () {
                                    Markup = "<b>" + _("Address") + "</b>",
                                    Xalign = 0
                                }, true, true, 0);

                                layout_address.PackStart (AddressEntry, true, true, 0);

                                    PathEntry.Completion  = new EntryCompletion();

                                    ListStore folder_store = new ListStore (typeof (string));

                                    //foreach (string host in Program.Controller.FolderPaths)
                                    //    folder_store.AppendValues (host);

                                    PathEntry.Completion.Model      = folder_store;
                                    PathEntry.Completion.TextColumn = 0;

                                    PathEntry.Changed += delegate {
                                        CheckAddPage ();
                                    };

                                layout_path.PackStart (new Label () { Markup = "<b>" + _("Remote Path") + "</b>", Xalign = 0 },
                                    true, true, 0);
                                layout_path.PackStart (PathEntry, true, true, 0);

                            layout_fields.PackStart (layout_address);
                            layout_fields.PackStart (layout_path);

                        layout_vertical.PackStart (new Label (""), false, false, 0);
                        layout_vertical.PackStart (scrolled_window, true, true, 0);
                        layout_vertical.PackStart (layout_fields, false, false, 0);

                        Add (layout_vertical);

                            // Cancel button
                            Button cancel_button = new Button (_("Cancel"));

                            cancel_button.Clicked += delegate {
                                Close ();
                            };

                            // Sync button
                            SyncButton = new Button (_("Add"));

                            SyncButton.Clicked += delegate {
                                string server         = AddressEntry.Text;
                                string folder_name    = PathEntry.Text;

                                Controller.AddPageCompleted (server, folder_name);
                            };

                        AddButton (cancel_button);
                        AddButton (SyncButton);

                        CheckAddPage ();

                        break;
                    }

                    case PageType.Syncing: {

                        Header      = String.Format (_("Adding project ‘{0}’…"), Controller.SyncingFolder);
                        Description = _("This may take a while." + Environment.NewLine) +
                                      _("Are you sure it’s not coffee o'clock?");

                        Button finish_button = new Button () {
                            Sensitive = false,
                            Label = _("Finish")
                        };

                        Button cancel_button = new Button () {
                            Label = _("Cancel")
                        };

                        cancel_button.Clicked += delegate {
                            Controller.SyncingCancelled ();
                        };

                        AddButton (cancel_button);
                        AddButton (finish_button);

                        Controller.UpdateProgressBarEvent += delegate (double percentage) {
                            Application.Invoke (delegate {
                                this.progress_bar.Fraction = percentage / 100;
                            });
                        };

                        if (this.progress_bar.Parent != null)
                           (this.progress_bar.Parent as Container).Remove (this.progress_bar);

                        VBox bar_wrapper = new VBox (false , 0);
                        bar_wrapper.PackStart (this.progress_bar, false, false, 0);

                        Add (bar_wrapper);

                        break;
                    }

                    case PageType.Error: {

                        Header      = _("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)) {  };

                        Label label_one = new Label () {
                            Text   = "First, have you tried turning it off and on again?",
                            Wrap   = true,
                            Xalign = 0
                        };

                        Label label_two = new Label () {
                            Markup = "<b>" + Controller.PreviousUrl + "</b> is the address we've compiled. " +
                                     "Does this look alright?",
                            Wrap   = true,
                            Xalign = 0
                        };

                        Label label_three = new Label () {
                            Text   = "The host needs to know who you are. Did you upload the key that's in " +
                                     "your SparkleShare folder?",
                            Wrap   = true,
                            Xalign = 0
                        };

                        points.PackStart (new Label ("Please check the following:") { Xalign = 0 }, false, false, 6);

                        HBox point_one = new HBox (false, 0);
                        point_one.PackStart (list_point_one, false, false, 0);
                        point_one.PackStart (label_one, true, true, 12);
                        points.PackStart (point_one, false, false, 12);

                        HBox point_two = new HBox (false, 0);
                        point_two.PackStart (list_point_two, false, false, 0);
                        point_two.PackStart (label_two, true, true, 12);
                        points.PackStart (point_two, false, false, 12);

                        HBox point_three = new HBox (false, 0);
                        point_three.PackStart (list_point_three, false, false, 0);
                        point_three.PackStart (label_three, true, true, 12);
                        points.PackStart (point_three, false, false, 12);

                        points.PackStart (new Label (""), true, true, 0);

                        Button try_again_button = new Button (_("Try Again…")) {
                            Sensitive = true
                        };

                        try_again_button.Clicked += delegate {
                            Controller.ErrorPageCompleted ();
                        };

                        AddButton (try_again_button);
                        Add (points);

                        break;
                    }

                    case PageType.Finished: {

                        UrgencyHint = true;

                        if (!HasToplevelFocus) {
                            string title   = String.Format (_("‘{0}’ has been successfully added"), Controller.SyncingFolder);
                            string subtext = "";

                            SparkleUI.Bubbles.Controller.ShowBubble (title, subtext, null);
                        }

                        Header      = _("Project successfully added!");
                        Description = _("Access the files from your SparkleShare folder.");

                        // A button that opens the synced folder
                        Button open_folder_button = new Button (_("Open Folder"));

                        open_folder_button.Clicked += delegate {
                            Program.Controller.OpenSparkleShareFolder (Controller.SyncingFolder);
                        };

                        Button finish_button = new Button (_("Finish"));

                        finish_button.Clicked += delegate {
                            Controller.FinishedPageCompleted ();
                            Close ();
                        };

                        Add (null);

                        AddButton (open_folder_button);
                        AddButton (finish_button);

                        break;
                    }

                    case PageType.Tutorial: {

                        switch (Controller.TutorialPageNumber) {
                        case 1: {
                            Header      = _("What's happening next?");
                            Description = _("SparkleShare creates a special folder in your personal folder " +
                                "that will keep track of your projects.");

                            Button skip_tutorial_button = new Button (_("Skip Tutorial"));
                            skip_tutorial_button.Clicked += delegate {
                                Controller.TutorialSkipped ();
                            };

                            Button continue_button = new Button (_("Continue"));
                            continue_button.Clicked += delegate {
                                Controller.TutorialPageCompleted ();
                            };

                            Image slide = SparkleUIHelpers.GetImage ("tutorial-slide-1.png");

                            Add (slide);

                            AddButton (skip_tutorial_button);
                            AddButton (continue_button);

                            break;
                        }

                        case 2: {
                            Header      = _("Sharing files with others");
                            Description = _("All files added to your project folders are synced with the host " +
                                "automatically, as well as with your collaborators.");

                            Button continue_button = new Button (_("Continue"));
                            continue_button.Clicked += delegate {
                                Controller.TutorialPageCompleted ();
                            };

                            Image slide = SparkleUIHelpers.GetImage ("tutorial-slide-2.png");

                            Add (slide);
                            AddButton (continue_button);

                            break;
                        }

                        case 3: {
                            Header      = _("The status icon is here to help");
                            Description = _("It shows the syncing process status, " +
                                "and contains links to your projects and the event log.");

                            Button continue_button = new Button (_("Continue"));
                            continue_button.Clicked += delegate {
                                Controller.TutorialPageCompleted ();
                            };

                            Image slide = SparkleUIHelpers.GetImage ("tutorial-slide-3.png");

                            Add (slide);
                            AddButton (continue_button);

                            break;
                        }

                        case 4: {
                            Header      = _("Adding projects to SparkleShare");
                            Description = _("Just click this button when you see it on the web, and " +
                                "the project will be automatically added:");

                            Label label = new Label (_("…or select <b>‘Add Project…’</b> from the status icon menu " +
                                "to add one by hand.")) {
                                Wrap   = true,
                                Xalign = 0,
                                UseMarkup = true
                            };

                            Image slide = SparkleUIHelpers.GetImage ("tutorial-slide-4.png");

                            Button add_project_button = new Button (_("Add Project…"));
                            add_project_button.Clicked += delegate {
                                Controller.TutorialPageCompleted ();
                            };

                            Button finish_button = new Button (_("Finish"));
                            finish_button.Clicked += delegate {
                                Close ();
                            };

                            VBox box = new VBox (false, 0);
                            box.Add (slide);
                            box.Add (label);

                            Add (box);

                            AddButton (add_project_button);
                            AddButton (finish_button);

                            break;
                        }
                        }

                        break;
                    }
                    }

                    ShowAll ();
                });
            };
        }
Exemple #5
0
        public SparkleSetup()
            : base()
        {
            SecondaryTextColor = SparkleUIHelpers.GdkColorToHex (Style.Foreground (StateType.Insensitive));

            Controller.ChangePageEvent += delegate (PageType type) {
                Application.Invoke (delegate {
                    Reset ();

                    switch (type) {
                    case PageType.Setup: {

                        Header = _("Welcome to SparkleShare!");
                        Description = _("Before we can create a SparkleShare folder on this " +
                                        "computer, we need a few bits of information from you.");

                        Table = new Table (4, 2, true) {
                            RowSpacing = 6
                        };

                            Label name_label = new Label ("<b>" + _("Full Name:") + "</b>") {
                                UseMarkup = true,
                                Xalign    = 0
                            };

                            NameEntry = new Entry (Controller.GuessedUserName);
                            NameEntry.Changed += delegate {
                                CheckSetupPage ();
                            };

                            EmailEntry = new Entry (Controller.GuessedUserEmail);
                            EmailEntry.Changed += delegate {
                                CheckSetupPage ();
                            };

                            Label email_label = new Label ("<b>" + _("Email:") + "</b>") {
                                UseMarkup = true,
                                Xalign    = 0
                            };

                        Table.Attach (name_label, 0, 1, 0, 1);
                        Table.Attach (NameEntry, 1, 2, 0, 1);
                        Table.Attach (email_label, 0, 1, 1, 2);
                        Table.Attach (EmailEntry, 1, 2, 1, 2);

                            NextButton = new Button (_("Next")) {
                                Sensitive = false
                            };

                            NextButton.Clicked += delegate (object o, EventArgs args) {
                                string full_name = NameEntry.Text;
                                string email     = EmailEntry.Text;

                                Controller.SetupPageCompleted (full_name, email);
                            };

                        AddButton (NextButton);
                        Add (Table);

                        CheckSetupPage ();

                        break;
                    }

                    case PageType.Add: {

                        Header = _("Where is your project?");

                        Table = new Table (6, 2, false) {
                            RowSpacing = 0
                        };

                            HBox layout_server = new HBox (true, 0);

                                // Own server radiobutton
                                RadioButton radio_button = new RadioButton ("<b>" + _("On my own server:") + "</b>");
                                (radio_button.Child as Label).UseMarkup = true;

                                radio_button.Toggled += delegate {
                                    if (radio_button.Active) {
                                        FolderEntry.ExampleText = _("Folder");
                                        ServerEntry.Sensitive   = true;
                                        CheckAddPage ();
                                    } else {
                                        ServerEntry.Sensitive = false;
                                        CheckAddPage ();
                                    }

                                    ShowAll ();
                                };

                                // Own server entry
                                ServerEntry = new SparkleEntry () { };
                                ServerEntry.Completion = new EntryCompletion();

                                ListStore server_store = new ListStore (typeof (string));

                                foreach (string host in Program.Controller.PreviousHosts)
                                    server_store.AppendValues (host);

                                ServerEntry.Completion.Model = server_store;
                                ServerEntry.Completion.TextColumn = 0;

                                if (!string.IsNullOrEmpty (Controller.PreviousServer)) {
                                    ServerEntry.Text = Controller.PreviousServer;
                                    ServerEntry.ExampleTextActive = false;
                                } else {
                                    ServerEntry.ExampleText = _("address-to-server.com");
                                }

                                ServerEntry.Changed += delegate {
                                    CheckAddPage ();
                                };

                            layout_server.Add (radio_button);
                            layout_server.Add (ServerEntry);

                        Table.Attach (layout_server,          0, 2, 1, 2);

                            // Github radiobutton
                            string github_text = "<b>" + "Github" + "</b>";

                            RadioButton radio_button_github = new RadioButton (radio_button, github_text);
                            (radio_button_github.Child as Label).UseMarkup = true;
                            (radio_button_github.Child as Label).Wrap      = true;

                            radio_button_github.Toggled += delegate {
                                if (radio_button_github.Active)
                                    FolderEntry.ExampleText = _("Username/Folder");
                            };

                            // Gitorious radiobutton
                            string gitorious_text = "<b>" + _("Gitorious") + "</b>";

                            RadioButton radio_button_gitorious = new RadioButton (radio_button, gitorious_text);
                            (radio_button_gitorious.Child as Label).UseMarkup = true;
                            (radio_button_gitorious.Child as Label).Wrap      = true;

                            radio_button_gitorious.Toggled += delegate {
                                if (radio_button_gitorious.Active)
                                    FolderEntry.ExampleText = _("Project/Folder");
                            };

                            // GNOME radiobutton
                            string gnome_text = "<b>" + _("The GNOME Project") + "</b>";

                            RadioButton radio_button_gnome = new RadioButton (radio_button, gnome_text);
                            (radio_button_gnome.Child as Label).UseMarkup = true;
                            (radio_button_gnome.Child as Label).Wrap      = true;

                            radio_button_gnome.Toggled += delegate {
                                if (radio_button_gnome.Active)
                                    FolderEntry.ExampleText = _("Project");
                            };

                        Table.Attach (radio_button_github,    0, 2, 2, 3);
                        Table.Attach (radio_button_gitorious, 0, 2, 3, 4);
                        Table.Attach (radio_button_gnome,     0, 2, 4, 5);

                            // Folder label and entry
                            HBox layout_folder = new HBox (true, 0);

                                Label folder_label = new Label (_("Folder Name:")) {
                                    UseMarkup = true,
                                    Xalign    = 1
                                };

                                FolderEntry             = new SparkleEntry ();
                                FolderEntry.ExampleText = _("Folder");
                                FolderEntry.Completion = new EntryCompletion();

                                ListStore folder_store = new ListStore (typeof (string));

                                //foreach (string host in Program.Controller.FolderPaths)
                                //    folder_store.AppendValues (host);

                                FolderEntry.Completion.Model = folder_store;
                                FolderEntry.Completion.TextColumn = 0;

                                FolderEntry.Changed += delegate {
                                    CheckAddPage ();
                                };

                            layout_folder.PackStart (folder_label, true, true, 12);
                            layout_folder.PackStart (FolderEntry, true, true, 0);

                        Table.Attach (layout_folder, 0, 2, 5, 6);

                        VBox box = new VBox (false, 0);
                        box.PackStart (Table, false, false, 0);
                        Add (box);

                            // Cancel button
                            Button cancel_button = new Button (_("Cancel"));

                            cancel_button.Clicked += delegate {
                                Close ();
                            };

                            // Sync button
                            SyncButton = new Button (_("Add"));

                            SyncButton.Clicked += delegate {
                                string server         = ServerEntry.Text;
                                string folder_name    = FolderEntry.Text;

                                if (radio_button_gitorious.Active)
                                    server = "gitorious.org";

                                if (radio_button_github.Active)
                                    server = "github.com";

                                if (radio_button_gnome.Active)
                                    server = "gnome.org";

                                Controller.AddPageCompleted (server, folder_name);
                            };

                        AddButton (cancel_button);
                        AddButton (SyncButton);

                        CheckAddPage ();

                        break;
                    }

                    case PageType.Syncing: {

                        Header      = String.Format (_("Adding project ‘{0}’…"), Controller.SyncingFolder);
                        Description = _("This may take a while." + Environment.NewLine) +
                                      _("Are you sure it’s not coffee o'clock?");

                        Button finish_button = new Button () {
                            Sensitive = false,
                            Label = _("Finish")
                        };

                        Button cancel_button = new Button () {
                            Label = _("Cancel")
                        };

                        cancel_button.Clicked += delegate {
                            Controller.SyncingCancelled ();
                        };

                        AddButton (cancel_button);
                        AddButton (finish_button);

                        Controller.UpdateProgressBarEvent += delegate (double percentage) {
                            Application.Invoke (delegate {
                                this.progress_bar.Fraction = percentage / 100;
                            });
                        };

                        if (this.progress_bar.Parent != null)
                           (this.progress_bar.Parent as Container).Remove (this.progress_bar);

                        VBox bar_wrapper = new VBox (false , 0);
                        bar_wrapper.PackStart (this.progress_bar, false, false, 0);

                        Add (bar_wrapper);

                        break;
                    }

                    case PageType.Error: {

                        Header      = _("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)) {  };

                        Label label_one = new Label () {
                            Text   = "First, have you tried turning it off and on again?",
                            Wrap   = true,
                            Xalign = 0
                        };

                        Label label_two = new Label () {
                            Markup = "<b>" + Controller.PreviousUrl + "</b> is the address we've compiled. " +
                                     "Does this look alright?",
                            Wrap   = true,
                            Xalign = 0
                        };

                        Label label_three = new Label () {
                            Text   = "The host needs to know who you are. Did you upload the key that's in " +
                                     "your SparkleShare folder?",
                            Wrap   = true,
                            Xalign = 0
                        };

                        points.PackStart (new Label ("Please check the following:") { Xalign = 0 }, false, false, 6);

                        HBox point_one = new HBox (false, 0);
                        point_one.PackStart (list_point_one, false, false, 0);
                        point_one.PackStart (label_one, true, true, 12);
                        points.PackStart (point_one, false, false, 12);

                        HBox point_two = new HBox (false, 0);
                        point_two.PackStart (list_point_two, false, false, 0);
                        point_two.PackStart (label_two, true, true, 12);
                        points.PackStart (point_two, false, false, 12);

                        HBox point_three = new HBox (false, 0);
                        point_three.PackStart (list_point_three, false, false, 0);
                        point_three.PackStart (label_three, true, true, 12);
                        points.PackStart (point_three, false, false, 12);

                        points.PackStart (new Label (""), true, true, 0);

                        Button try_again_button = new Button (_("Try Again…")) {
                            Sensitive = true
                        };

                        try_again_button.Clicked += delegate {
                            Controller.ErrorPageCompleted ();
                        };

                        AddButton (try_again_button);
                        Add (points);

                        break;
                    }

                    case PageType.Finished: {

                        UrgencyHint = true;

                        if (!HasToplevelFocus) {
                            string title   = String.Format (_("‘{0}’ has been successfully added"), Controller.SyncingFolder);
                            string subtext = "";

                            SparkleUI.Bubbles.Controller.ShowBubble (title, subtext, null);
                        }

                        Header      = _("Project successfully added!");
                        Description = _("Access the files from your SparkleShare folder.");

                        // A button that opens the synced folder
                        Button open_folder_button = new Button (_("Open Folder"));

                        open_folder_button.Clicked += delegate {
                            Program.Controller.OpenSparkleShareFolder (Controller.SyncingFolder);
                        };

                        Button finish_button = new Button (_("Finish"));

                        finish_button.Clicked += delegate {
                            Controller.FinishedPageCompleted ();
                            Close ();
                        };

                        Add (null);

                        AddButton (open_folder_button);
                        AddButton (finish_button);

                        break;
                    }

                    case PageType.Tutorial: {

                        switch (Controller.TutorialPageNumber) {
                        case 1: {
                            Header      = _("What's happening next?");
                            Description = _("SparkleShare creates a special folder in your personal folder " +
                                "that will keep track of your projects.");

                            Button skip_tutorial_button = new Button (_("Skip Tutorial"));
                            skip_tutorial_button.Clicked += delegate {
                                Controller.TutorialSkipped ();
                            };

                            Button continue_button = new Button (_("Continue"));
                            continue_button.Clicked += delegate {
                                Controller.TutorialPageCompleted ();
                            };

                            Image slide = SparkleUIHelpers.GetImage ("tutorial-slide-1.png");

                            Add (slide);

                            AddButton (skip_tutorial_button);
                            AddButton (continue_button);

                            break;
                        }

                        case 2: {
                            Header      = _("Sharing files with others");
                            Description = _("All files added to your project folders are synced with the host " +
                                "automatically, as well as with your collaborators.");

                            Button continue_button = new Button (_("Continue"));
                            continue_button.Clicked += delegate {
                                Controller.TutorialPageCompleted ();
                            };

                            Image slide = SparkleUIHelpers.GetImage ("tutorial-slide-2.png");

                            Add (slide);
                            AddButton (continue_button);

                            break;
                        }

                        case 3: {
                            Header      = _("The status icon is here to help");
                            Description = _("It shows the syncing process status, " +
                                "and contains links to your projects and the event log.");

                            Button continue_button = new Button (_("Continue"));
                            continue_button.Clicked += delegate {
                                Controller.TutorialPageCompleted ();
                            };

                            Image slide = SparkleUIHelpers.GetImage ("tutorial-slide-3.png");

                            Add (slide);
                            AddButton (continue_button);

                            break;
                        }

                        case 4: {
                            Header      = _("Adding projects to SparkleShare");
                            Description = _("Just click this button when you see it on the web, and " +
                                "the project will be automatically added:");

                            Label label = new Label (_("…or select <b>‘Add Project…’</b> from the status icon menu " +
                                "to add one by hand.")) {
                                Wrap   = true,
                                Xalign = 0,
                                UseMarkup = true
                            };

                            Image slide = SparkleUIHelpers.GetImage ("tutorial-slide-4.png");

                            Button add_project_button = new Button (_("Add Project…"));
                            add_project_button.Clicked += delegate {
                                Controller.TutorialPageCompleted ();
                            };

                            Button finish_button = new Button (_("Finish"));
                            finish_button.Clicked += delegate {
                                Close ();
                            };

                            VBox box = new VBox (false, 0);
                            box.Add (slide);
                            box.Add (label);

                            Add (box);

                            AddButton (add_project_button);
                            AddButton (finish_button);

                            break;
                        }
                        }

                        break;
                    }
                    }

                    ShowAll ();
                });
            };
        }
        public SparkleSetup()
            : base()
        {
            SecondaryTextColor = SparkleUIHelpers.GdkColorToHex (Style.Foreground (StateType.Insensitive));

            Controller.ChangePageEvent += delegate (PageType type) {
                Application.Invoke (delegate {
                    Reset ();

                    switch (type) {
                    case PageType.Setup:

                        Header = _("Welcome to SparkleShare!");
                        Description = _("Before we can create a SparkleShare folder on this " +
                                        "computer, we need a few bits of information from you.");

                        Table = new Table (4, 2, true) {
                            RowSpacing = 6
                        };

                            Label name_label = new Label ("<b>" + _("Full Name:") + "</b>") {
                                UseMarkup = true,
                                Xalign    = 0
                            };

                            NameEntry = new Entry (SparkleShare.Controller.UserName);
                            NameEntry.Changed += delegate {
                                CheckSetupPage ();
                            };

                            EmailEntry = new Entry ();
                            EmailEntry.Changed += delegate {
                                CheckSetupPage ();
                            };

                            Label email_label = new Label ("<b>" + _("Email:") + "</b>") {
                                UseMarkup = true,
                                Xalign    = 0
                            };

                        Table.Attach (name_label, 0, 1, 0, 1);
                        Table.Attach (NameEntry, 1, 2, 0, 1);
                        Table.Attach (email_label, 0, 1, 1, 2);
                        Table.Attach (EmailEntry, 1, 2, 1, 2);

                            NextButton = new Button (_("Next")) {
                                Sensitive = false
                            };

                            NextButton.Clicked += delegate (object o, EventArgs args) {
                                string full_name = NameEntry.Text;
                                string email     = EmailEntry.Text;

                                Controller.SetupPageCompleted (full_name, email);
                            };

                        AddButton (NextButton);
                        Add (Table);

                        CheckSetupPage ();

                        break;

                    case PageType.Add:

                        Header = _("Where is your remote folder?");

                        Table = new Table (6, 2, false) {
                            RowSpacing = 12
                        };

                            HBox layout_server = new HBox (true, 0);

                                // Own server radiobutton
                                RadioButton radio_button = new RadioButton ("<b>" + _("On my own server:") + "</b>");
                                (radio_button.Child as Label).UseMarkup = true;

                                radio_button.Toggled += delegate {
                                    if (radio_button.Active) {
                                        FolderEntry.ExampleText = _("Folder");
                                        ServerEntry.Sensitive   = true;
                                        CheckAddPage ();
                                    } else {
                                        ServerEntry.Sensitive = false;
                                        CheckAddPage ();
                                    }

                                    ShowAll ();
                                };

                                // Own server entry
                                ServerEntry = new SparkleEntry () { };
                                ServerEntry.Completion = new EntryCompletion();

                                ListStore server_store = new ListStore (typeof (string));

                                //TODO foreach (string host in SparkleShare.Controller.PreviousHosts)
                                  //  server_store.AppendValues (host);

                                ServerEntry.Completion.Model = server_store;
                                ServerEntry.Completion.TextColumn = 0;

                                if (!string.IsNullOrEmpty (Controller.PreviousServer)) {
                                    ServerEntry.Text = Controller.PreviousServer;
                                    ServerEntry.ExampleTextActive = false;
                                } else {
                                    ServerEntry.ExampleText = _("address-to-server.com");
                                }

                                ServerEntry.Changed += delegate {
                                    CheckAddPage ();
                                };

                            layout_server.Add (radio_button);
                            layout_server.Add (ServerEntry);

                        Table.Attach (layout_server,          0, 2, 1, 2);

                            // Github radiobutton
                            string github_text = "<b>" + "Github" + "</b>\n" +
                                  "<span fgcolor='" + SecondaryTextColor + "' size='small'>" +
                                _("Free hosting for Free and Open Source Software projects.") + "\n" +
                                _("Also has paid accounts for extra private space and bandwidth.") +
                                  "</span>";

                            RadioButton radio_button_github = new RadioButton (radio_button, github_text);
                            (radio_button_github.Child as Label).UseMarkup = true;
                            (radio_button_github.Child as Label).Wrap      = true;

                            radio_button_github.Toggled += delegate {
                                if (radio_button_github.Active)
                                    FolderEntry.ExampleText = _("Username/Folder");
                            };

                            // Gitorious radiobutton
                            string gitorious_text = "<b>" + _("Gitorious") + "</b>\n" +
                                  "<span fgcolor='" + SecondaryTextColor + "' size='small'>" +
                                _("Completely Free as in Freedom infrastructure.") + "\n" +
                                _("Free accounts for Free and Open Source projects.") +
                                  "</span>";

                            RadioButton radio_button_gitorious = new RadioButton (radio_button, gitorious_text);
                            (radio_button_gitorious.Child as Label).UseMarkup = true;
                            (radio_button_gitorious.Child as Label).Wrap      = true;

                            radio_button_gitorious.Toggled += delegate {
                                if (radio_button_gitorious.Active)
                                    FolderEntry.ExampleText = _("Project/Folder");
                            };

                            // GNOME radiobutton
                            string gnome_text = "<b>" + _("The GNOME Project") + "</b>\n"+
                                 "<span fgcolor='" + SecondaryTextColor + "' size='small'>" +
                                _("GNOME is an easy to understand interface to your computer.") + "\n" +
                                _("Select this option if you’re a developer or designer working on GNOME.") +
                                  "</span>";

                            RadioButton radio_button_gnome = new RadioButton (radio_button, gnome_text);
                            (radio_button_gnome.Child as Label).UseMarkup = true;
                            (radio_button_gnome.Child as Label).Wrap      = true;

                            radio_button_gnome.Toggled += delegate {
                                if (radio_button_gnome.Active)
                                    FolderEntry.ExampleText = _("Project");
                            };

                        Table.Attach (radio_button_github,    0, 2, 2, 3);
                        Table.Attach (radio_button_gitorious, 0, 2, 3, 4);
                        Table.Attach (radio_button_gnome,     0, 2, 4, 5);

                            // Folder label and entry
                            HBox layout_folder = new HBox (true, 0);

                                Label folder_label = new Label (_("Folder Name:")) {
                                    UseMarkup = true,
                                    Xalign    = 1
                                };

                                FolderEntry             = new SparkleEntry ();
                                FolderEntry.ExampleText = _("Folder");

                                FolderEntry.Changed += delegate {
                                    CheckAddPage ();
                                };

                            layout_folder.PackStart (folder_label, true, true, 12);
                            layout_folder.PackStart (FolderEntry, true, true, 0);

                        Table.Attach (layout_folder, 0, 2, 5, 6);
                        Add (Table);

                            // Cancel button
                            Button cancel_button = new Button (_("Cancel"));

                            cancel_button.Clicked += delegate {
                                Close ();
                            };

                            // Sync button
                            SyncButton = new Button (_("Sync"));

                            SyncButton.Clicked += delegate {
                                string server         = ServerEntry.Text;
                                string folder_name    = FolderEntry.Text;

                                if (radio_button_gitorious.Active)
                                    server = "gitorious.org";

                                if (radio_button_github.Active)
                                    server = "github.com";

                                if (radio_button_gnome.Active)
                                    server = "gnome.org";

                                Controller.AddPageCompleted (server, folder_name);
                            };

                        AddButton (cancel_button);
                        AddButton (SyncButton);

                        CheckAddPage ();

                        break;

                    case PageType.Syncing:

                        Header      = String.Format (_("Syncing folder ‘{0}’…"), Controller.SyncingFolder);
                        Description = _("This may take a while." + Environment.NewLine) +
                                      _("Are you sure it’s not coffee o'clock?");

                        Button button = new Button () {
                            Sensitive = false,
                            Label = _("Finish")
                        };

                        button.Clicked += delegate {
                            Close ();
                        };

                        AddButton (button);

                        this.progress_bar_pulse_timer.Elapsed += delegate {
                            Application.Invoke (delegate {
                                progress_bar.Pulse ();
                            });
                        };

                        if (this.progress_bar.Parent != null)
                           (this.progress_bar.Parent as Container).Remove (this.progress_bar);

                        VBox bar_wrapper = new VBox (false , 0);
                        bar_wrapper.PackStart (this.progress_bar, false, false, 0);

                        Add (bar_wrapper);

                        break;

                    case PageType.Error:

                        string n = Environment.NewLine;

                        Header      = _("Something went wrong") + "…";
                        Description = "We don't know exactly what the problem is, " +
                                      "but we can try to help you pinpoint it.";

                          Label l = new Label (
                          "First, have you tried turning it off and on again?" + n +
                          n +
                          Controller.SyncingFolder +" is the address we've compiled from the information " +
                          "you entered. Does this look correct?" + n +
                          n +
                          "The host needs to know who you are. Have you uploaded the key that sits in your SparkleShare folder?");

                        l.Xpad = 12;
                        l.Wrap = true;

                        Button try_again_button = new Button (_("Try Again")) {
                            Sensitive = true
                        };

                        try_again_button.Clicked += delegate {
                            Controller.ErrorPageCompleted ();
                        };

                        AddButton (try_again_button);
                        Add (l);

                        break;

                    case PageType.Finished:

                        UrgencyHint = true;

                        if (!HasToplevelFocus) {
                            string title   = String.Format (_("‘{0}’ has been successfully added"), Controller.SyncingFolder);
                            string subtext = _("");

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

                        Header      = _("Folder synced successfully!");
                        Description = _("Access the synced files from your SparkleShare folder.");

                        // A button that opens the synced folder
                        Button open_folder_button = new Button (_("Open Folder"));

                        open_folder_button.Clicked += delegate {
                          SparkleShare.Controller.OpenSparkleShareFolder (Controller.SyncingFolder);
                        };

                        Button finish_button = new Button (_("Finish"));

                        finish_button.Clicked += delegate {
                            Close ();
                        };

                        Add (null);

                        AddButton (open_folder_button);
                        AddButton (finish_button);

                        break;
                    }

                    ShowAll ();
                });
            };
        }
Exemple #7
0
        public SparkleSetup() : base()
        {
            SecondaryTextColor         = SparkleUIHelpers.GdkColorToHex(Style.Foreground(StateType.Insensitive));
            SecondaryTextColorSelected =
                SparkleUIHelpers.GdkColorToHex(
                    MixColors(
                        new TreeView().Style.Foreground(StateType.Selected),
                        new TreeView().Style.Background(StateType.Selected),
                        0.15
                        )
                    );

            Controller.ChangePageEvent += delegate(PageType type, string [] warnings) {
                Application.Invoke(delegate {
                    Reset();

                    switch (type)
                    {
                    case PageType.Setup: {
                        Header      = _("Welcome to SparkleShare!");
                        Description = "We'll need some info to mark your changes in the event log. " +
                                      "Don't worry, this stays between you and your peers.";


                        Table table = new Table(2, 3, true)
                        {
                            RowSpacing    = 6,
                            ColumnSpacing = 6
                        };

                        Label name_label = new Label("<b>" + _("Full Name:") + "</b>")
                        {
                            UseMarkup = true,
                            Xalign    = 1
                        };

                        Entry name_entry = new Entry(Controller.GuessedUserName)
                        {
                            Xalign = 0
                        };

                        Entry email_entry = new Entry(Controller.GuessedUserEmail)
                        {
                            Xalign = 0
                        };

                        name_entry.Changed += delegate {
                            Controller.CheckSetupPage(name_entry.Text, email_entry.Text);
                        };

                        email_entry.Changed += delegate {
                            Controller.CheckSetupPage(name_entry.Text, email_entry.Text);
                        };

                        Label email_label = new Label("<b>" + _("Email:") + "</b>")
                        {
                            UseMarkup = true,
                            Xalign    = 1
                        };

                        table.Attach(name_label, 0, 1, 0, 1);
                        table.Attach(name_entry, 1, 2, 0, 1);
                        table.Attach(email_label, 0, 1, 1, 2);
                        table.Attach(email_entry, 1, 2, 1, 2);

                        VBox wrapper = new VBox(false, 9);
                        wrapper.PackStart(table, true, false, 0);

                        Button continue_button = new Button(_("Continue"))
                        {
                            Sensitive = false
                        };

                        continue_button.Clicked += delegate(object o, EventArgs args) {
                            string full_name = name_entry.Text;
                            string email     = email_entry.Text;

                            Controller.SetupPageCompleted(full_name, email);
                        };

                        AddButton(continue_button);
                        Add(wrapper);


                        Controller.UpdateSetupContinueButtonEvent += delegate(bool button_enabled) {
                            Application.Invoke(delegate {
                                    continue_button.Sensitive = button_enabled;
                                });
                        };

                        Controller.CheckSetupPage(name_entry.Text, email_entry.Text);

                        break;
                    }

                    case PageType.Add: {
                        Header = _("Where's your project hosted?");

                        VBox layout_vertical = new VBox(false, 12);
                        HBox layout_fields   = new HBox(true, 12);
                        VBox layout_address  = new VBox(true, 0);
                        VBox layout_path     = new VBox(true, 0);


                        ListStore store = new ListStore(typeof(Gdk.Pixbuf),
                                                        typeof(string), typeof(SparklePlugin));

                        SparkleTreeView tree = new SparkleTreeView(store)
                        {
                            HeadersVisible = false
                        };
                        ScrolledWindow scrolled_window = new ScrolledWindow();
                        scrolled_window.AddWithViewport(tree);

                        // Icon column
                        tree.AppendColumn("Icon", new Gtk.CellRendererPixbuf(), "pixbuf", 0);
                        tree.Columns [0].Cells [0].Xpad = 6;

                        // Service column
                        TreeViewColumn service_column = new TreeViewColumn()
                        {
                            Title = "Service"
                        };
                        CellRendererText service_cell = new CellRendererText()
                        {
                            Ypad = 4
                        };
                        service_column.PackStart(service_cell, true);
                        service_column.SetCellDataFunc(service_cell, new TreeCellDataFunc(RenderServiceColumn));

                        foreach (SparklePlugin plugin in Controller.Plugins)
                        {
                            store.AppendValues(
                                new Gdk.Pixbuf(plugin.ImagePath),
                                "<span size=\"small\"><b>" + plugin.Name + "</b>\n" +
                                "<span fgcolor=\"" + SecondaryTextColorSelected + "\">" +
                                plugin.Description + "</span>" +
                                "</span>",
                                plugin);
                        }

                        tree.AppendColumn(service_column);

                        SparkleEntry path_entry    = new SparkleEntry();
                        SparkleEntry address_entry = new SparkleEntry();


                        // Select the first plugin by default
                        TreeSelection default_selection = tree.Selection;
                        TreePath default_path           = new TreePath("0");
                        default_selection.SelectPath(default_path);
                        Controller.SelectedPluginChanged(0);

                        Controller.ChangeAddressFieldEvent += delegate(string text,
                                                                       string example_text, FieldState state) {
                            Application.Invoke(delegate {
                                    address_entry.Text      = text;
                                    address_entry.Sensitive = (state == FieldState.Enabled);

                                    if (string.IsNullOrEmpty(example_text))
                                    {
                                        address_entry.ExampleText = null;
                                    }
                                    else
                                    {
                                        address_entry.ExampleText = example_text;
                                    }

                                    if (string.IsNullOrEmpty(text))
                                    {
                                        address_entry.ExampleTextActive = true;
                                    }
                                    else
                                    {
                                        address_entry.ExampleTextActive = false;
                                    }
                                });
                        };

                        Controller.ChangePathFieldEvent += delegate(string text,
                                                                    string example_text, FieldState state) {
                            Application.Invoke(delegate {
                                    path_entry.Text      = text;
                                    path_entry.Sensitive = (state == FieldState.Enabled);

                                    if (string.IsNullOrEmpty(example_text))
                                    {
                                        path_entry.ExampleText = null;
                                    }
                                    else
                                    {
                                        path_entry.ExampleText = example_text;
                                    }

                                    if (string.IsNullOrEmpty(text))
                                    {
                                        path_entry.ExampleTextActive = true;
                                    }
                                    else
                                    {
                                        path_entry.ExampleTextActive = false;
                                    }
                                });
                        };

                        // Update the address field text when the selection changes
                        tree.CursorChanged += delegate(object sender, EventArgs e) {
                            Controller.SelectedPluginChanged(tree.SelectedRow);
                            // TODO: Scroll to selected row when using arrow keys
                        };

                        tree.Model.Foreach(new TreeModelForeachFunc(delegate(TreeModel model,
                                                                             TreePath path, TreeIter iter) {
                                string address;

                                try {
                                    address = (model.GetValue(iter, 2) as SparklePlugin).Address;
                                } catch (NullReferenceException) {
                                    address = "";
                                }

                                if (!string.IsNullOrEmpty(address) &&
                                    address.Equals(Controller.PreviousAddress))
                                {
                                    tree.SetCursor(path, service_column, false);
                                    SparklePlugin plugin = (SparklePlugin)model.GetValue(iter, 2);

                                    if (plugin.Address != null)
                                    {
                                        address_entry.Sensitive = false;
                                    }

                                    if (plugin.Path != null)
                                    {
                                        path_entry.Sensitive = false;
                                    }

                                    // TODO: Scroll to the selection

                                    return(true);
                                }
                                else
                                {
                                    return(false);
                                }
                            }));

                        address_entry.Completion = new EntryCompletion();
                        ListStore server_store   = new ListStore(typeof(string));

                        foreach (string host in Program.Controller.PreviousHosts)
                        {
                            server_store.AppendValues(host);
                        }

                        address_entry.Completion.Model      = server_store;
                        address_entry.Completion.TextColumn = 0;

                        address_entry.Changed += delegate {
                            Controller.CheckAddPage(address_entry.Text, path_entry.Text, tree.SelectedRow);
                        };

                        layout_address.PackStart(new Label()
                            {
                                Markup = "<b>" + _("Address") + "</b>",
                                Xalign = 0
                            }, true, true, 0);

                        layout_address.PackStart(address_entry, true, true, 0);

                        path_entry.Completion = new EntryCompletion();

                        ListStore folder_store = new ListStore(typeof(string));

                        //foreach (string host in Program.Controller.FolderPaths)
                        //    folder_store.AppendValues (host);

                        path_entry.Completion.Model      = folder_store;
                        path_entry.Completion.TextColumn = 0;

                        path_entry.Changed += delegate {
                            Controller.CheckAddPage(address_entry.Text, path_entry.Text, tree.SelectedRow);
                        };

                        layout_path.PackStart(new Label()
                            {
                                Markup = "<b>" + _("Remote Path") + "</b>",
                                Xalign = 0
                            }, true, true, 0);

                        layout_path.PackStart(path_entry, true, true, 0);

                        layout_fields.PackStart(layout_address);
                        layout_fields.PackStart(layout_path);

                        layout_vertical.PackStart(new Label(""), false, false, 0);
                        layout_vertical.PackStart(scrolled_window, true, true, 0);
                        layout_vertical.PackStart(layout_fields, false, false, 0);

                        Add(layout_vertical);

                        // Cancel button
                        Button cancel_button = new Button(_("Cancel"));

                        cancel_button.Clicked += delegate {
                            Close();
                        };

                        // Sync button
                        Button add_button = new Button(_("Add"));

                        add_button.Clicked += delegate {
                            string server      = address_entry.Text;
                            string folder_name = path_entry.Text;

                            Controller.AddPageCompleted(server, folder_name);
                        };

                        AddButton(cancel_button);
                        AddButton(add_button);

                        Controller.CheckAddPage(address_entry.Text, path_entry.Text, tree.SelectedRow);

                        break;
                    }

                    case PageType.Syncing: {
                        Header      = String.Format(_("Adding project ‘{0}’…"), Controller.SyncingFolder);
                        Description = _("This may take a while.") + Environment.NewLine +
                                      _("Are you sure it’s not coffee o'clock?");

                        Button finish_button = new Button()
                        {
                            Sensitive = false,
                            Label     = _("Finish")
                        };

                        Button cancel_button = new Button()
                        {
                            Label = _("Cancel")
                        };

                        cancel_button.Clicked += delegate {
                            Controller.SyncingCancelled();
                        };

                        AddButton(cancel_button);
                        AddButton(finish_button);

                        Controller.UpdateProgressBarEvent += delegate(double percentage) {
                            Application.Invoke(delegate {
                                    this.progress_bar.Fraction = percentage / 100;
                                });
                        };

                        if (this.progress_bar.Parent != null)
                        {
                            (this.progress_bar.Parent as Container).Remove(this.progress_bar);
                        }

                        VBox bar_wrapper = new VBox(false, 0);
                        bar_wrapper.PackStart(this.progress_bar, false, false, 0);

                        Add(bar_wrapper);

                        break;
                    }

                    case PageType.Error: {
                        Header = _("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))
                        {
                        };

                        Label label_one = new Label()
                        {
                            Text   = "First, have you tried turning it off and on again?",
                            Wrap   = true,
                            Xalign = 0
                        };

                        Label label_two = new Label()
                        {
                            Markup = "<b>" + Controller.PreviousUrl + "</b> is the address we've compiled. " +
                                     "Does this look alright?",
                            Wrap   = true,
                            Xalign = 0
                        };

                        Label label_three = new Label()
                        {
                            Text = "The host needs to know who you are. Did you upload the key that's in " +
                                   "your SparkleShare folder?",
                            Wrap   = true,
                            Xalign = 0
                        };


                        points.PackStart(new Label("Please check the following:")
                            {
                                Xalign = 0
                            }, false, false, 6);

                        HBox point_one = new HBox(false, 0);
                        point_one.PackStart(list_point_one, false, false, 0);
                        point_one.PackStart(label_one, true, true, 12);
                        points.PackStart(point_one, false, false, 12);

                        HBox point_two = new HBox(false, 0);
                        point_two.PackStart(list_point_two, false, false, 0);
                        point_two.PackStart(label_two, true, true, 12);
                        points.PackStart(point_two, false, false, 12);

                        HBox point_three = new HBox(false, 0);
                        point_three.PackStart(list_point_three, false, false, 0);
                        point_three.PackStart(label_three, true, true, 12);
                        points.PackStart(point_three, false, false, 12);

                        points.PackStart(new Label(""), true, true, 0);


                        Button try_again_button = new Button(_("Try Again…"))
                        {
                            Sensitive = true
                        };

                        try_again_button.Clicked += delegate {
                            Controller.ErrorPageCompleted();
                        };

                        AddButton(try_again_button);
                        Add(points);

                        break;
                    }

                    case PageType.Finished: {
                        UrgencyHint = true;

                        if (!HasToplevelFocus)
                        {
                            string title   = String.Format(_("‘{0}’ has been successfully added"), Controller.SyncingFolder);
                            string subtext = "";

                            SparkleUI.Bubbles.Controller.ShowBubble(title, subtext, null);
                        }

                        Header      = _("Project successfully added!");
                        Description = _("Access the files from your SparkleShare folder.");

                        // A button that opens the synced folder
                        Button open_folder_button = new Button(_("Open Folder"));

                        open_folder_button.Clicked += delegate {
                            Program.Controller.OpenSparkleShareFolder(Controller.SyncingFolder);
                        };

                        Button finish_button = new Button(_("Finish"));

                        finish_button.Clicked += delegate {
                            Controller.FinishedPageCompleted();
                            Close();
                        };


                        if (warnings != null)
                        {
                            Image warning_image = new Image(
                                SparkleUIHelpers.GetIcon("dialog-warning", 24)
                                );

                            Label warning_label = new Label(warnings [0])
                            {
                                Xalign = 0,
                                Wrap   = true
                            };

                            HBox warning_layout = new HBox(false, 0);
                            warning_layout.PackStart(warning_image, false, false, 0);
                            warning_layout.PackStart(warning_label, true, true, 15);

                            VBox warning_wrapper = new VBox(false, 0);
                            warning_wrapper.PackStart(warning_layout, false, false, 0);

                            Add(warning_wrapper);
                        }
                        else
                        {
                            Add(null);
                        }


                        AddButton(open_folder_button);
                        AddButton(finish_button);

                        break;
                    }


                    case PageType.Tutorial: {
                        switch (Controller.TutorialPageNumber)
                        {
                        case 1: {
                            Header      = _("What's happening next?");
                            Description = _("SparkleShare creates a special folder in your personal folder " +
                                            "that will keep track of your projects.");

                            Button skip_tutorial_button   = new Button(_("Skip Tutorial"));
                            skip_tutorial_button.Clicked += delegate {
                                Controller.TutorialSkipped();
                            };

                            Button continue_button   = new Button(_("Continue"));
                            continue_button.Clicked += delegate {
                                Controller.TutorialPageCompleted();
                            };

                            Image slide = SparkleUIHelpers.GetImage("tutorial-slide-1.png");

                            Add(slide);

                            AddButton(skip_tutorial_button);
                            AddButton(continue_button);

                            break;
                        }

                        case 2: {
                            Header      = _("Sharing files with others");
                            Description = _("All files added to your project folders are synced with the host " +
                                            "automatically, as well as with your collaborators.");

                            Button continue_button   = new Button(_("Continue"));
                            continue_button.Clicked += delegate {
                                Controller.TutorialPageCompleted();
                            };

                            Image slide = SparkleUIHelpers.GetImage("tutorial-slide-2.png");

                            Add(slide);
                            AddButton(continue_button);

                            break;
                        }

                        case 3: {
                            Header      = _("The status icon is here to help");
                            Description = _("It shows the syncing process status, " +
                                            "and contains links to your projects and the event log.");

                            Button continue_button   = new Button(_("Continue"));
                            continue_button.Clicked += delegate {
                                Controller.TutorialPageCompleted();
                            };

                            Image slide = SparkleUIHelpers.GetImage("tutorial-slide-3.png");

                            Add(slide);
                            AddButton(continue_button);

                            break;
                        }

                        case 4: {
                            Header      = _("Adding projects to SparkleShare");
                            Description = _("Just click this button when you see it on the web, and " +
                                            "the project will be automatically added:");

                            Label label = new Label(_("…or select <b>‘Add Hosted Project…’</b> from the status icon menu " +
                                                      "to add one by hand."))
                            {
                                Wrap      = true,
                                Xalign    = 0,
                                UseMarkup = true
                            };

                            Image slide = SparkleUIHelpers.GetImage("tutorial-slide-4.png");

                            Button finish_button   = new Button(_("Finish"));
                            finish_button.Clicked += delegate {
                                Close();
                            };


                            VBox box = new VBox(false, 0);
                            box.Add(slide);
                            box.Add(label);

                            Add(box);
                            AddButton(finish_button);

                            break;
                        }
                        }

                        break;
                    }
                    }

                    ShowAll();
                });
            };
        }