diff --git a/SparkleShare/SparkleIntro.cs b/SparkleShare/SparkleIntro.cs
index ebb15056..bab4178b 100644
--- a/SparkleShare/SparkleIntro.cs
+++ b/SparkleShare/SparkleIntro.cs
@@ -27,774 +27,683 @@ using Notifications;
namespace SparkleShare {
- public class SparkleIntro : SparkleWindow {
+ public class SparkleIntro : SparkleWindow {
+
+ private Entry NameEntry;
+ private Entry EmailEntry;
+ private SparkleEntry ServerEntry;
+ private SparkleEntry FolderEntry;
+ private Button NextButton;
+ private Button SyncButton;
+ private bool ServerFormOnly;
+ private string SecondaryTextColor;
+
+
+ // Short alias for the translations
+ public static string _ (string s)
+ {
+ return Catalog.GetString (s);
+ }
+
+
+ public SparkleIntro () : base ()
+ {
+ ServerFormOnly = false;
+ SecondaryTextColor = SparkleUIHelpers.GdkColorToHex (Style.Foreground (StateType.Insensitive));
+ }
+
+
+ public void ShowAccountForm ()
+ {
+ Reset ();
+
+ VBox layout_vertical = new VBox (false, 0);
+
+ Deletable = false;
+
+ Label header = new Label ("" +
+ _("Welcome to SparkleShare!") +
+ "") {
+ UseMarkup = true,
+ Xalign = 0
+ };
+
+ Label information = new Label (_("Before we can create a SparkleShare folder on this " +
+ "computer, we need a few bits of information from you.")) {
+ Xalign = 0,
+ Wrap = true
+ };
+
+ Table table = new Table (4, 2, true) {
+ RowSpacing = 6
+ };
+
+ string full_name = new UnixUserInfo (UnixEnvironment.UserName).RealName;
+ if (string.IsNullOrEmpty (full_name))
+ full_name = "";
+
+ Label name_label = new Label ("" + _("Full Name:") + "") {
+ UseMarkup = true,
+ Xalign = 0
+ };
+
+ NameEntry = new Entry (full_name.TrimEnd (",".ToCharArray()));
+ NameEntry.Changed += delegate {
+ CheckAccountForm ();
+ };
+
+
+ EmailEntry = new Entry (SparkleShare.Controller.UserEmail);
+ EmailEntry.Changed += delegate {
+ CheckAccountForm ();
+ };
+
+ Label email_label = new Label ("" + _("Email:") + "") {
+ 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) {
+ NextButton.Remove (NextButton.Child);
+ NextButton.Add (new Label (_("Configuring…")));
+
+ NextButton.Sensitive = false;
+ table.Sensitive = false;
+
+ NextButton.ShowAll ();
+
+ SparkleShare.Controller.UserName = NameEntry.Text;
+ SparkleShare.Controller.UserEmail = EmailEntry.Text;
+
+ SparkleShare.Controller.GenerateKeyPair ();
+ SparkleShare.Controller.AddKey ();
+
+ SparkleShare.Controller.FirstRun = false;
+
+ Deletable = true;
+ ShowServerForm ();
+ };
+
+ AddButton (NextButton);
+
+ layout_vertical.PackStart (header, false, false, 0);
+ layout_vertical.PackStart (information, false, false, 21);
+ layout_vertical.PackStart (new Label (""), false, false, 0);
+ layout_vertical.PackStart (table, false, false, 0);
+
+ Add (layout_vertical);
+ CheckAccountForm ();
+ ShowAll ();
+ }
+
+
+ public void ShowServerForm (bool server_form_only)
+ {
+ ServerFormOnly = server_form_only;
+ ShowServerForm ();
+ }
+
+
+ public void ShowServerForm ()
+ {
+ Reset ();
+
+ VBox layout_vertical = new VBox (false, 0);
+
+ Label header = new Label ("" +
+ _("Where is your remote folder?") +
+ "") {
+ 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 ("" + _("On my own server:") + "");
+
+ layout_server.Add (radio_button);
+ layout_server.Add (ServerEntry);
+
+ string github_text = "" + "Github" + "\n" +
+ "" +
+ _("Free hosting for Free and Open Source Software projects.") + "\n" +
+ _("Also has paid accounts for extra private space and bandwidth.") +
+ "";
+
+ 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 = "" + _("The GNOME Project") + "\n" +
+ "" +
+ _("GNOME is an easy to understand interface to your computer.") + "\n" +
+ _("Select this option if you’re a developer or designer working on GNOME.") +
+ "";
+
+ 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 = "" + _("Gitorious") + "\n" +
+ "" +
+ _("Completely Free as in Freedom infrastructure.") + "\n" +
+ _("Free accounts for Free and Open Source projects.") +
+ "";
+ 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 ();
+ };
- private Entry NameEntry;
- private Entry EmailEntry;
- private SparkleEntry ServerEntry;
- private SparkleEntry FolderEntry;
- private Button NextButton;
- private Button SyncButton;
- private bool ServerFormOnly;
- private string SecondaryTextColor;
-
-
- // Short alias for the translations
- public static string _ (string s)
- {
- return Catalog.GetString (s);
- }
-
-
- public SparkleIntro () : base ()
- {
-
- ServerFormOnly = false;
- SecondaryTextColor = SparkleUIHelpers.GdkColorToHex (Style.Foreground (StateType.Insensitive));
-
- }
+ 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);
-
- public void ShowAccountForm ()
- {
+ 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;
- Reset ();
+ 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);
- VBox layout_vertical = new VBox (false, 0);
-
- Deletable = false;
+ 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);
- Label header = new Label ("" +
- _("Welcome to SparkleShare!") +
- "") {
- UseMarkup = true,
- Xalign = 0
- };
-
- Label information = new Label (_("Before we can create a SparkleShare folder on this " +
- "computer, we need a few bits of information from you.")) {
- Xalign = 0,
- Wrap = true
- };
-
- Table table = new Table (4, 2, true) {
- RowSpacing = 6
- };
-
- string full_name = new UnixUserInfo (UnixEnvironment.UserName).RealName;
- if (string.IsNullOrEmpty (full_name))
- full_name = "";
-
- Label name_label = new Label ("" + _("Full Name:") + "") {
- UseMarkup = true,
- Xalign = 0
- };
-
- NameEntry = new Entry (full_name.TrimEnd (",".ToCharArray()));
- NameEntry.Changed += delegate {
- CheckAccountForm ();
- };
-
-
- EmailEntry = new Entry (SparkleShare.Controller.UserEmail);
- EmailEntry.Changed += delegate {
- CheckAccountForm ();
- };
-
- Label email_label = new Label ("" + _("Email:") + "") {
- 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) {
-
- NextButton.Remove (NextButton.Child);
- NextButton.Add (new Label (_("Configuring…")));
-
- NextButton.Sensitive = false;
- table.Sensitive = false;
-
- NextButton.ShowAll ();
-
- SparkleShare.Controller.UserName = NameEntry.Text;
- SparkleShare.Controller.UserEmail = EmailEntry.Text;
-
- SparkleShare.Controller.GenerateKeyPair ();
- SparkleShare.Controller.AddKey ();
-
- SparkleShare.Controller.FirstRun = false;
-
- Deletable = true;
- ShowServerForm ();
-
- };
-
- AddButton (NextButton);
-
- layout_vertical.PackStart (header, false, false, 0);
- layout_vertical.PackStart (information, false, false, 21);
- layout_vertical.PackStart (new Label (""), false, false, 0);
- layout_vertical.PackStart (table, false, false, 0);
-
- Add (layout_vertical);
-
- CheckAccountForm ();
-
- ShowAll ();
-
- }
-
-
- public void ShowServerForm (bool server_form_only)
- {
-
- ServerFormOnly = server_form_only;
- ShowServerForm ();
-
- }
-
-
- public void ShowServerForm ()
- {
-
- Reset ();
-
- VBox layout_vertical = new VBox (false, 0);
-
- Label header = new Label ("" +
- _("Where is your remote folder?") +
- "") {
- 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 ("" + _("On my own server:") + "");
-
- layout_server.Add (radio_button);
- layout_server.Add (ServerEntry);
-
- string github_text = "" + "Github" + "\n" +
- "" +
- _("Free hosting for Free and Open Source Software projects.") + "\n" +
- _("Also has paid accounts for extra private space and bandwidth.") +
- "";
-
- 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 = "" + _("The GNOME Project") + "\n" +
- "" +
- _("GNOME is an easy to understand interface to your computer.") + "\n" +
- _("Select this option if you’re a developer or designer working on GNOME.") +
- "";
-
- 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 = "" + _("Gitorious") + "\n" +
- "" +
- _("Completely Free as in Freedom infrastructure.") + "\n" +
- _("Free accounts for Free and Open Source projects.") +
- "";
- 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://git@gitorious.org";
-
- if (!name.EndsWith (".git")) {
-
- if (!name.Contains ("/"))
- name = name + "/" + name;
-
- name += ".git";
-
- }
-
- }
-
- if (radio_button_github.Active)
- server = "ssh://git@github.com";
-
- if (radio_button_gnome.Active)
- server = "ssh://git@gnome.org/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 void ShowInvitationPage (string server, string folder, string token)
- {
-
- VBox layout_vertical = new VBox (false, 0);
-
- Label header = new Label ("" +
- _("Invitation received!") +
- "") {
- UseMarkup = true,
- Xalign = 0
- };
-
- Label information = new Label (_("You've received an invitation to join a shared folder.\n" +
- "We're ready to hook you up immediately if you wish.")) {
- Xalign = 0,
- Wrap = true
- };
-
- Label question = new Label (_("Do you accept this invitation?")) {
- Xalign = 0,
- Wrap = true
- };
-
- Table table = new Table (2, 2, false) {
- RowSpacing = 6
- };
-
- Label server_label = new Label (_("Server Address:")) {
- Xalign = 0
- };
-
- Label server_text = new Label ("" + server + "") {
- UseMarkup = true,
- Xalign = 0
- };
-
- Label folder_label = new Label (_("Folder Name:")) {
- Xalign = 0
- };
-
- Label folder_text = new Label ("" + folder + "") {
- UseMarkup = true,
- Xalign = 0
- };
-
- table.Attach (folder_label, 0, 1, 0, 1);
- table.Attach (folder_text, 1, 2, 0, 1);
- table.Attach (server_label, 0, 1, 1, 2);
- table.Attach (server_text, 1, 2, 1, 2);
-
- Button reject_button = new Button (_("Reject"));
- Button accept_button = new Button (_("Accept and Sync"));
-
- reject_button.Clicked += delegate {
- Close ();
- };
-
- accept_button.Clicked += delegate {
-
- string url = "ssh://git@" + server + "/" + folder;
-
- SparkleShare.Controller.FolderFetched += delegate {
-
- Application.Invoke (delegate {
- ShowSuccessPage (folder);
- });
-
- };
-
- SparkleShare.Controller.FolderFetchError += delegate {
-
- Application.Invoke (delegate { ShowErrorPage (); });
-
- };
-
-
- SparkleShare.Controller.FetchFolder (url, folder);
-
- };
-
- AddButton (reject_button);
- AddButton (accept_button);
-
- layout_vertical.PackStart (header, false, false, 0);
- layout_vertical.PackStart (information, false, false, 21);
- layout_vertical.PackStart (new Label (""), false, false, 0);
- layout_vertical.PackStart (table, false, false, 0);
- layout_vertical.PackStart (new Label (""), false, false, 0);
- layout_vertical.PackStart (question, false, false, 21);
-
- Add (layout_vertical);
-
- ShowAll ();
-
- }
-
-
- // The page shown when syncing has failed
- private void ShowErrorPage ()
- {
-
- Reset ();
-
+ 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://git@gitorious.org";
+
+ if (!name.EndsWith (".git")) {
+ if (!name.Contains ("/"))
+ name = name + "/" + name;
+
+ name += ".git";
+ }
+ }
+
+ if (radio_button_github.Active)
+ server = "ssh://git@github.com";
+
+ if (radio_button_gnome.Active)
+ server = "ssh://git@gnome.org/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 void ShowInvitationPage (string server, string folder, string token)
+ {
+ VBox layout_vertical = new VBox (false, 0);
+
+ Label header = new Label ("" +
+ _("Invitation received!") +
+ "") {
+ UseMarkup = true,
+ Xalign = 0
+ };
+
+ Label information = new Label (_("You've received an invitation to join a shared folder.\n" +
+ "We're ready to hook you up immediately if you wish.")) {
+ Xalign = 0,
+ Wrap = true
+ };
+
+ Label question = new Label (_("Do you accept this invitation?")) {
+ Xalign = 0,
+ Wrap = true
+ };
+
+ Table table = new Table (2, 2, false) {
+ RowSpacing = 6
+ };
+
+ Label server_label = new Label (_("Server Address:")) {
+ Xalign = 0
+ };
+
+ Label server_text = new Label ("" + server + "") {
+ UseMarkup = true,
+ Xalign = 0
+ };
+
+ Label folder_label = new Label (_("Folder Name:")) {
+ Xalign = 0
+ };
+
+ Label folder_text = new Label ("" + folder + "") {
+ UseMarkup = true,
+ Xalign = 0
+ };
+
+ table.Attach (folder_label, 0, 1, 0, 1);
+ table.Attach (folder_text, 1, 2, 0, 1);
+ table.Attach (server_label, 0, 1, 1, 2);
+ table.Attach (server_text, 1, 2, 1, 2);
+
+ Button reject_button = new Button (_("Reject"));
+ Button accept_button = new Button (_("Accept and Sync"));
+
+ reject_button.Clicked += delegate {
+ Close ();
+ };
+
+ accept_button.Clicked += delegate {
+ string url = "ssh://git@" + server + "/" + folder;
+
+ SparkleShare.Controller.FolderFetched += delegate {
+ Application.Invoke (delegate {
+ ShowSuccessPage (folder);
+ });
+ };
+
+ SparkleShare.Controller.FolderFetchError += delegate {
+ Application.Invoke (delegate { ShowErrorPage (); });
+ };
+
+
+ SparkleShare.Controller.FetchFolder (url, folder);
+ };
+
+ AddButton (reject_button);
+ AddButton (accept_button);
+
+ layout_vertical.PackStart (header, false, false, 0);
+ layout_vertical.PackStart (information, false, false, 21);
+ layout_vertical.PackStart (new Label (""), false, false, 0);
+ layout_vertical.PackStart (table, false, false, 0);
+ layout_vertical.PackStart (new Label (""), false, false, 0);
+ layout_vertical.PackStart (question, false, false, 21);
+
+ Add (layout_vertical);
+ ShowAll ();
+ }
+
+
+ // The page shown when syncing has failed
+ private void ShowErrorPage ()
+ {
+ Reset ();
+
UrgencyHint = true;
VBox layout_vertical = new VBox (false, 0);
-
- Label header = new Label ("" +
- _("Something went wrong…") +
- "\n") {
- UseMarkup = true,
- Xalign = 0
- };
+
+ Label header = new Label ("" +
+ _("Something went wrong…") +
+ "\n") {
+ UseMarkup = true,
+ Xalign = 0
+ };
- Button try_again_button = new Button (_("Try Again")) {
- Sensitive = true
- };
-
- try_again_button.Clicked += delegate (object o, EventArgs args) {
- ShowServerForm ();
- };
-
- AddButton (try_again_button);
+ Button try_again_button = new Button (_("Try Again")) {
+ Sensitive = true
+ };
+
+ try_again_button.Clicked += delegate (object o, EventArgs args) {
+ ShowServerForm ();
+ };
+
+ AddButton (try_again_button);
- layout_vertical.PackStart (header, false, false, 0);
+ layout_vertical.PackStart (header, false, false, 0);
- Add (layout_vertical);
-
- ShowAll ();
-
- }
+ Add (layout_vertical);
+ ShowAll ();
+ }
- // The page shown when syncing has succeeded
- private void ShowSuccessPage (string folder_name)
- {
-
- Reset ();
+ // The page shown when syncing has succeeded
+ private void ShowSuccessPage (string folder_name)
+ {
+ Reset ();
UrgencyHint = true;
if (!HasToplevelFocus) {
-
string title = String.Format (_("‘{0}’ has been successfully added"), folder_name);
string subtext = _("");
new SparkleBubble (title, subtext).Show ();
-
}
- VBox layout_vertical = new VBox (false, 0);
+ VBox layout_vertical = new VBox (false, 0);
+
+ Label header = new Label ("" +
+ _("Folder synced successfully!") +
+ "") {
+ UseMarkup = true,
+ Xalign = 0
+ };
+
+ Label information = new Label (
+ String.Format (_("Now you can access the synced files from ‘{0}’ in your SparkleShare folder."),
+ folder_name)) {
+ Xalign = 0,
+ Wrap = true,
+ UseMarkup = true
+ };
+
+ // A button that opens the synced folder
+ Button open_folder_button = new Button (_("Open Folder"));
+
+ open_folder_button.Clicked += delegate {
+ SparkleShare.Controller.OpenSparkleShareFolder (Path.GetFileNameWithoutExtension(folder_name));
+ };
+
+ Button finish_button = new Button (_("Finish"));
+
+ finish_button.Clicked += delegate (object o, EventArgs args) {
+ Close ();
+ };
+
+ AddButton (open_folder_button);
+ AddButton (finish_button);
+
+ layout_vertical.PackStart (header, false, false, 0);
+ layout_vertical.PackStart (information, false, false, 21);
+
+ Add (layout_vertical);
+ ShowAll ();
+ }
+
+
+ // The page shown whilst syncing
+ private void ShowSyncingPage (string name)
+ {
+ Reset ();
- Label header = new Label ("" +
- _("Folder synced successfully!") +
- "") {
- UseMarkup = true,
- Xalign = 0
- };
-
- Label information = new Label (
- String.Format (_("Now you can access the synced files from ‘{0}’ in your SparkleShare folder."),
- folder_name)) {
- Xalign = 0,
- Wrap = true,
- UseMarkup = true
- };
+ Deletable = false;
+
+ VBox layout_vertical = new VBox (false, 0);
- // A button that opens the synced folder
- Button open_folder_button = new Button (_("Open Folder"));
+ Label header = new Label ("" +
+ String.Format (_("Syncing folder ‘{0}’…"), name) +
+ "") {
+ UseMarkup = true,
+ Xalign = 0,
+ Wrap = true
+ };
- open_folder_button.Clicked += delegate {
+ Label information = new Label (_("This may take a while.\n") +
+ _("Are you sure it’s not coffee o'clock?")) {
+ UseMarkup = true,
+ Xalign = 0
+ };
+
+ Button button = new Button () {
+ Sensitive = false,
+ Label = _("Finish")
+ };
+
+ button.Clicked += delegate {
+ Close ();
+ };
+
+ AddButton (button);
- SparkleShare.Controller.OpenSparkleShareFolder (System.IO.Path.GetFileNameWithoutExtension(folder_name));
+// SparkleSpinner spinner = new SparkleSpinner (22);
+
+ Table table = new Table (3, 2, false) {
+ RowSpacing = 12,
+ ColumnSpacing = 9
+ };
+
+ HBox box = new HBox (false, 0);
+
+// table.Attach (spinner, 0, 1, 0, 1);
+ table.Attach (header, 1, 2, 0, 1);
+ table.Attach (information, 1, 2, 1, 2);
+
+ box.PackStart (table, false, false, 0);
+
+ layout_vertical.PackStart (box, false, false, 0);
+
+ Add (layout_vertical);
+ ShowAll ();
+ }
+
+
+ // The page shown when the setup has been completed
+ private void ShowCompletedPage ()
+ {
+ Reset ();
+
+ VBox layout_vertical = new VBox (false, 0);
+
+ Label header = new Label ("" +
+ _("SparkleShare is ready to go!") +
+ "") {
+ UseMarkup = true,
+ Xalign = 0
+ };
+
+ Label information = new Label (_("Now you can start accepting invitations from others. " + "\n" +
+ "Just click on invitations you get by email and " +
+ "we will take care of the rest.")) {
+ UseMarkup = true,
+ Wrap = true,
+ Xalign = 0
+ };
- };
- Button finish_button = new Button (_("Finish"));
-
- finish_button.Clicked += delegate (object o, EventArgs args) {
- Close ();
- };
-
- AddButton (open_folder_button);
- AddButton (finish_button);
+ HBox link_wrapper = new HBox (false, 0);
+ LinkButton link = new LinkButton ("http://www.sparkleshare.org/",
+ _("Learn how to host your own SparkleServer"));
- layout_vertical.PackStart (header, false, false, 0);
- layout_vertical.PackStart (information, false, false, 21);
+ link_wrapper.PackStart (link, false, false, 0);
- Add (layout_vertical);
+ layout_vertical.PackStart (header, false, false, 0);
+ layout_vertical.PackStart (information, false, false, 21);
+ layout_vertical.PackStart (link_wrapper, false, false, 0);
- ShowAll ();
-
- }
+ Button finish_button = new Button (_("Finish"));
+ finish_button.Clicked += delegate (object o, EventArgs args) {
+ Close ();
+ };
- // The page shown whilst syncing
- private void ShowSyncingPage (string name)
- {
+ AddButton (finish_button);
- Reset ();
+ Add (layout_vertical);
+ ShowAll ();
+ }
- Deletable = false;
- VBox layout_vertical = new VBox (false, 0);
+ // Enables or disables the 'Next' button depending on the
+ // entries filled in by the user
+ private void CheckAccountForm ()
+ {
+ if (NameEntry.Text.Length > 0 &&
+ IsValidEmail (EmailEntry.Text)) {
- Label header = new Label ("" +
- String.Format (_("Syncing folder ‘{0}’…"), name) +
- "") {
- UseMarkup = true,
- Xalign = 0,
- Wrap = true
- };
+ NextButton.Sensitive = true;
+ } else {
+ NextButton.Sensitive = false;
+ }
+ }
- Label information = new Label (_("This may take a while.\n") +
- _("Are you sure it’s not coffee o'clock?")) {
- UseMarkup = true,
- Xalign = 0
- };
+ // Enables the Add button when the fields are
+ // filled in correctly
+ public void CheckServerForm (object o, EventArgs args)
+ {
+ CheckServerForm ();
+ }
- Button button = new Button () {
- Sensitive = false,
- Label = _("Finish")
- };
-
- button.Clicked += delegate {
- Close ();
- };
- AddButton (button);
+ // Enables the Add button when the fields are
+ // filled in correctly
+ public void CheckServerForm ()
+ {
+ SyncButton.Sensitive = false;
-// SparkleSpinner spinner = new SparkleSpinner (22);
+ if (FolderEntry.ExampleTextActive ||
+ (ServerEntry.Sensitive && ServerEntry.ExampleTextActive))
+ return;
- Table table = new Table (3, 2, false) {
- RowSpacing = 12,
- ColumnSpacing = 9
- };
+ bool IsFolder = !FolderEntry.Text.Trim ().Equals ("");
+ bool IsServer = !ServerEntry.Text.Trim ().Equals ("");
- HBox box = new HBox (false, 0);
+ if (ServerEntry.Sensitive == true) {
+ if (IsServer && IsFolder)
+ SyncButton.Sensitive = true;
+ } else if (IsFolder) {
+ SyncButton.Sensitive = true;
+ }
+ }
-// table.Attach (spinner, 0, 1, 0, 1);
- table.Attach (header, 1, 2, 0, 1);
- table.Attach (information, 1, 2, 1, 2);
-
- box.PackStart (table, false, false, 0);
-
- layout_vertical.PackStart (box, false, false, 0);
-
- Add (layout_vertical);
-
- ShowAll ();
-
- }
-
-
- // The page shown when the setup has been completed
- private void ShowCompletedPage ()
- {
-
- Reset ();
-
- VBox layout_vertical = new VBox (false, 0);
-
- Label header = new Label ("" +
- _("SparkleShare is ready to go!") +
- "") {
- UseMarkup = true,
- Xalign = 0
- };
-
- Label information = new Label (_("Now you can start accepting invitations from others. " + "\n" +
- "Just click on invitations you get by email and " +
- "we will take care of the rest.")) {
- UseMarkup = true,
- Wrap = true,
- Xalign = 0
- };
-
-
- HBox link_wrapper = new HBox (false, 0);
- LinkButton link = new LinkButton ("http://www.sparkleshare.org/",
- _("Learn how to host your own SparkleServer"));
-
- link_wrapper.PackStart (link, false, false, 0);
-
- layout_vertical.PackStart (header, false, false, 0);
- layout_vertical.PackStart (information, false, false, 21);
- layout_vertical.PackStart (link_wrapper, false, false, 0);
-
- Button finish_button = new Button (_("Finish"));
-
- finish_button.Clicked += delegate (object o, EventArgs args) {
- Close ();
- };
-
- AddButton (finish_button);
-
- Add (layout_vertical);
-
- ShowAll ();
-
- }
-
-
- // Enables or disables the 'Next' button depending on the
- // entries filled in by the user
- private void CheckAccountForm ()
- {
-
- if (NameEntry.Text.Length > 0 &&
- IsValidEmail (EmailEntry.Text)) {
-
- NextButton.Sensitive = true;
-
- } else {
-
- NextButton.Sensitive = false;
-
- }
-
- }
-
-
- // Enables the Add button when the fields are
- // filled in correctly
- public void CheckServerForm (object o, EventArgs args)
- {
-
- CheckServerForm ();
-
- }
-
-
- // Enables the Add button when the fields are
- // filled in correctly
- public void CheckServerForm ()
- {
-
- SyncButton.Sensitive = false;
-
- if (FolderEntry.ExampleTextActive ||
- (ServerEntry.Sensitive && ServerEntry.ExampleTextActive))
- return;
-
- bool IsFolder = !FolderEntry.Text.Trim ().Equals ("");
- bool IsServer = !ServerEntry.Text.Trim ().Equals ("");
-
- if (ServerEntry.Sensitive == true) {
-
- if (IsServer && IsFolder)
- SyncButton.Sensitive = true;
-
- } else if (IsFolder) {
-
- SyncButton.Sensitive = true;
-
- }
-
- }
-
-
- // Checks to see if an email address is valid
- private bool IsValidEmail (string email)
- {
-
- Regex regex = new Regex (@"^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$", RegexOptions.IgnoreCase);
- return regex.IsMatch (email);
-
- }
-
- }
+ // Checks to see if an email address is valid
+ private bool IsValidEmail (string email)
+ {
+ Regex regex = new Regex (@"^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$", RegexOptions.IgnoreCase);
+ return regex.IsMatch (email);
+ }
+ }
}
diff --git a/SparkleShare/SparkleStatusIcon.cs b/SparkleShare/SparkleStatusIcon.cs
index 0c8d22f8..44f3c71f 100644
--- a/SparkleShare/SparkleStatusIcon.cs
+++ b/SparkleShare/SparkleStatusIcon.cs
@@ -14,374 +14,325 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
-using Gtk;
-using Mono.Unix;
+
using System;
using System.IO;
using System.Timers;
+using Gtk;
+using Mono.Unix;
+
namespace SparkleShare {
- // The statusicon that stays in the
- // user's notification area
- public class SparkleStatusIcon : StatusIcon {
+ // The statusicon that stays in the
+ // user's notification area
+ public class SparkleStatusIcon : StatusIcon {
+
+ private Timer Animation;
+ private Gdk.Pixbuf [] AnimationFrames;
+ private int FrameNumber;
+ private string StateText;
+ private Menu Menu;
+
+ // Short alias for the translations
+ public static string _ (string s)
+ {
+ return Catalog.GetString (s);
+ }
+
+
+ public SparkleStatusIcon () : base ()
+ {
+ AnimationFrames = CreateAnimationFrames ();
+ Animation = CreateAnimation ();
+
+ Activate += ShowMenu; // Primary mouse button click
+ PopupMenu += ShowMenu; // Secondary mouse button click
+
+ SetNormalState ();
+ CreateMenu ();
+
+ SparkleShare.Controller.FolderSizeChanged += delegate {
+ Application.Invoke (delegate {
+ if (!Animation.Enabled)
+ SetNormalState ();
+
+ UpdateMenu ();
+ });
+ };
+
+ SparkleShare.Controller.FolderListChanged += delegate {
+ Application.Invoke (delegate {
+ SetNormalState ();
+ CreateMenu ();
+ });
+ };
+
+ SparkleShare.Controller.OnIdle += delegate {
+ Application.Invoke (delegate {
+ SetNormalState ();
+ UpdateMenu ();
+ });
+ };
+
+ SparkleShare.Controller.OnSyncing += delegate {
+ Application.Invoke (delegate {
+ SetAnimationState ();
+ UpdateMenu ();
+ });
+ };
+
+ SparkleShare.Controller.OnError += delegate {
+ Application.Invoke (delegate {
+ SetNormalState (true);
+ UpdateMenu ();
+ });
+ };
+
+ }
+
+
+ // Slices up the graphic that contains the
+ // animation frames.
+ private Gdk.Pixbuf [] CreateAnimationFrames ()
+ {
+ Gdk.Pixbuf [] animation_frames = new Gdk.Pixbuf [5];
+ Gdk.Pixbuf frames_pixbuf = SparkleUIHelpers.GetIcon ("process-syncing-sparkleshare", 24);
+
+ for (int i = 0; i < animation_frames.Length; i++)
+ animation_frames [i] = new Gdk.Pixbuf (frames_pixbuf, (i * 24), 0, 24, 24);
+
+ return animation_frames;
+ }
+
+
+ // Creates the Animation that handles the syncing animation
+ private Timer CreateAnimation ()
+ {
+ FrameNumber = 0;
+
+ Timer Animation = new Timer () {
+ Interval = 35
+ };
+
+ Animation.Elapsed += delegate {
+ if (FrameNumber < AnimationFrames.Length - 1)
+ FrameNumber++;
+ else
+ FrameNumber = 0;
+
+ Application.Invoke (delegate {
+ Pixbuf = AnimationFrames [FrameNumber];
+ });
+ };
+
+ return Animation;
+ }
+
+
+ // Creates the menu that is popped up when the
+ // user clicks the status icon
+ public void CreateMenu ()
+ {
+ Menu = new Menu ();
+
+ // The menu item showing the status and size of the SparkleShare folder
+ MenuItem status_menu_item = new MenuItem (StateText) {
+ Sensitive = false
+ };
+
+ Menu.Add (status_menu_item);
+ Menu.Add (new SeparatorMenuItem ());
+
+ ImageMenuItem folder_item = new SparkleMenuItem ("SparkleShare"){
+ Image = new Image (SparkleUIHelpers.GetIcon ("folder-sparkleshare", 16))
+ };
+
+ folder_item.Activated += delegate {
+ SparkleShare.Controller.OpenSparkleShareFolder ();
+ };
+
+ Menu.Add (folder_item);
+
+ if (SparkleShare.Controller.Folders.Count > 0) {
+
+ // Creates a menu item for each repository with a link to their logs
+ foreach (string path in SparkleShare.Controller.Folders) {
+
+ Gdk.Pixbuf folder_icon = IconTheme.Default.LoadIcon ("folder", 16,
+ IconLookupFlags.GenericFallback);
+
+ ImageMenuItem subfolder_item = new SparkleMenuItem (Path.GetFileName (path)) {
+ Image = new Image (folder_icon)
+ };
+
+// if (repo.HasUnsyncedChanges)
+// folder_action.IconName = "dialog-error";
+
+ subfolder_item.Activated += OpenEventLogDelegate (path);
+
+ Menu.Add (subfolder_item);
+ }
+ } else {
+ MenuItem no_folders_item = new MenuItem (_("No Remote Folders Yet")) {
+ Sensitive = false
+ };
+
+ Menu.Add (no_folders_item);
+ }
+
+ // Opens the wizard to add a new remote folder
+ MenuItem sync_item = new MenuItem (_("Add Remote Folder…"));
+
+ if (SparkleShare.Controller.FirstRun)
+ sync_item.Sensitive = false;
+
+ sync_item.Activated += delegate {
+ Application.Invoke (delegate {
+
+ if (SparkleUI.Intro == null) {
+ SparkleUI.Intro = new SparkleIntro ();
+ SparkleUI.Intro.ShowServerForm (true);
+ }
+
+ if (!SparkleUI.Intro.Visible)
+ SparkleUI.Intro.ShowServerForm (true);
+
+ SparkleUI.Intro.ShowAll ();
+ SparkleUI.Intro.Present ();
+ });
+ };
+
+ Menu.Add (sync_item);
+ Menu.Add (new SeparatorMenuItem ());
+
+ MenuItem notify_item;
+
+ if (SparkleShare.Controller.NotificationsEnabled)
+ notify_item = new MenuItem (_("Turn Notifications Off"));
+ else
+ notify_item = new MenuItem (_("Turn Notifications On"));
+
+ notify_item.Activated += delegate {
+ SparkleShare.Controller.ToggleNotifications ();
+ CreateMenu ();
+ };
+
+ Menu.Add (notify_item);
+ Menu.Add (new SeparatorMenuItem ());
+
+ // A menu item that takes the user to http://www.sparkleshare.org/
+ MenuItem about_item = new MenuItem (_("About SparkleShare"));
+
+ about_item.Activated += delegate {
+ SparkleAbout about = new SparkleAbout ();
+ about.ShowAll ();
+ };
+
+ Menu.Add (about_item);
+ Menu.Add (new SeparatorMenuItem ());
+
+ // A menu item that quits the application
+ MenuItem quit_item = new MenuItem (_("Quit"));
+
+ quit_item.Activated += delegate {
+ SparkleShare.Controller.Quit ();
+ };
+
+ Menu.Add (quit_item);
+ Menu.ShowAll ();
+ }
+
+
+ // A method reference that makes sure that opening the
+ // event log for each repository works correctly
+ private EventHandler OpenEventLogDelegate (string path)
+ {
+ return delegate {
+ SparkleShare.UI.AddEventLog (path);
+ };
+ }
+
+
+ public void UpdateMenu ()
+ {
+ Menu.Remove (Menu.Children [0]);
+
+ MenuItem status_menu_item = new MenuItem (StateText) {
+ Sensitive = false
+ };
+
+ Menu.Add (status_menu_item);
+ Menu.ReorderChild (status_menu_item, 0);
+
+ Menu.ShowAll ();
+ }
+
+
+ // Makes the menu visible
+ private void ShowMenu (object o, EventArgs args)
+ {
+ Menu.Popup (null, null, SetPosition, 0, Global.CurrentEventTime);
+ }
+
+
+ // Makes sure the menu pops up in the right position
+ private void SetPosition (Menu menu, out int x, out int y, out bool push_in)
+ {
+ PositionMenu (menu, out x, out y, out push_in, Handle);
+ }
+
+
+ // The state when there's nothing going on
+ private void SetNormalState ()
+ {
+ SetNormalState (false);
+ }
+
+
+ // The state when there's nothing going on
+ private void SetNormalState (bool error)
+ {
+ Animation.Stop ();
+
+ if (SparkleShare.Controller.Folders.Count == 0) {
+ StateText = _("Welcome to SparkleShare!");
- private Timer Animation;
- private Gdk.Pixbuf [] AnimationFrames;
- private int FrameNumber;
- private string StateText;
- private Menu Menu;
+ Application.Invoke (delegate {
+ Pixbuf = AnimationFrames [0];
+ });
+ } else {
+ if (error) {
+ StateText = _("Not everything is synced");
- // Short alias for the translations
- public static string _ (string s)
- {
- return Catalog.GetString (s);
- }
+ Application.Invoke (delegate {
+ Pixbuf = SparkleUIHelpers.GetIcon ("sparkleshare-syncing-error", 24);
+ });
+ } else {
+ StateText = _("Up to date") + " (" + SparkleShare.Controller.FolderSize + ")";
+ Application.Invoke (delegate {
+ Pixbuf = AnimationFrames [0];
+ });
+ }
+ }
+ }
- public SparkleStatusIcon () : base ()
- {
+ // The state when animating
+ private void SetAnimationState ()
+ {
+ StateText = _("Syncing…");
- AnimationFrames = CreateAnimationFrames ();
- Animation = CreateAnimation ();
+ if (!Animation.Enabled)
+ Animation.Start ();
+ }
+ }
- Activate += ShowMenu; // Primary mouse button click
- PopupMenu += ShowMenu; // Secondary mouse button click
-
- SetNormalState ();
- CreateMenu ();
-
-
- SparkleShare.Controller.FolderSizeChanged += delegate {
- Application.Invoke (delegate {
-
- if (!Animation.Enabled)
- SetNormalState ();
-
- UpdateMenu ();
-
- });
- };
-
- SparkleShare.Controller.FolderListChanged += delegate {
- Application.Invoke (delegate {
- SetNormalState ();
- CreateMenu ();
- });
- };
-
- SparkleShare.Controller.OnIdle += delegate {
- Application.Invoke (delegate {
- SetNormalState ();
- UpdateMenu ();
- });
- };
-
- SparkleShare.Controller.OnSyncing += delegate {
- Application.Invoke (delegate {
- SetAnimationState ();
- UpdateMenu ();
- });
- };
-
- SparkleShare.Controller.OnError += delegate {
- Application.Invoke (delegate {
- SetNormalState (true);
- UpdateMenu ();
- });
- };
-
- }
-
-
- // Slices up the graphic that contains the
- // animation frames.
- private Gdk.Pixbuf [] CreateAnimationFrames ()
- {
-
- Gdk.Pixbuf [] animation_frames = new Gdk.Pixbuf [5];
- Gdk.Pixbuf frames_pixbuf = SparkleUIHelpers.GetIcon ("process-syncing-sparkleshare", 24);
-
- for (int i = 0; i < animation_frames.Length; i++)
- animation_frames [i] = new Gdk.Pixbuf (frames_pixbuf, (i * 24), 0, 24, 24);
-
- return animation_frames;
-
- }
-
-
- // Creates the Animation that handles the syncing animation
- private Timer CreateAnimation ()
- {
-
- FrameNumber = 0;
-
- Timer Animation = new Timer () {
- Interval = 35
- };
-
- Animation.Elapsed += delegate {
-
- if (FrameNumber < AnimationFrames.Length - 1)
- FrameNumber++;
- else
- FrameNumber = 0;
-
- Application.Invoke (delegate {
- Pixbuf = AnimationFrames [FrameNumber];
- });
-
- };
-
- return Animation;
-
- }
-
-
- // Creates the menu that is popped up when the
- // user clicks the status icon
- public void CreateMenu ()
- {
-
- Menu = new Menu ();
-
- // The menu item showing the status and size of the SparkleShare folder
- MenuItem status_menu_item = new MenuItem (StateText) {
- Sensitive = false
- };
-
- Menu.Add (status_menu_item);
- Menu.Add (new SeparatorMenuItem ());
-
- ImageMenuItem folder_item = new SparkleMenuItem ("SparkleShare"){
- Image = new Image (SparkleUIHelpers.GetIcon ("folder-sparkleshare", 16))
- };
-
- folder_item.Activated += delegate {
- SparkleShare.Controller.OpenSparkleShareFolder ();
- };
-
- Menu.Add (folder_item);
-
- if (SparkleShare.Controller.Folders.Count > 0) {
-
- // Creates a menu item for each repository with a link to their logs
- foreach (string path in SparkleShare.Controller.Folders) {
-
- Gdk.Pixbuf folder_icon = IconTheme.Default.LoadIcon ("folder", 16,
- IconLookupFlags.GenericFallback);
-
- ImageMenuItem subfolder_item = new SparkleMenuItem (Path.GetFileName (path)) {
- Image = new Image (folder_icon)
- };
-
-// if (repo.HasUnsyncedChanges)
-// folder_action.IconName = "dialog-error";
-
- subfolder_item.Activated += OpenEventLogDelegate (path);
-
- Menu.Add (subfolder_item);
-
- }
-
- } else {
-
- MenuItem no_folders_item = new MenuItem (_("No Remote Folders Yet")) {
- Sensitive = false
- };
-
- Menu.Add (no_folders_item);
-
- }
-
- // Opens the wizard to add a new remote folder
- MenuItem sync_item = new MenuItem (_("Add Remote Folder…"));
-
- if (SparkleShare.Controller.FirstRun)
- sync_item.Sensitive = false;
-
- sync_item.Activated += delegate {
- Application.Invoke (delegate {
-
- if (SparkleUI.Intro == null) {
-
- SparkleUI.Intro = new SparkleIntro ();
- SparkleUI.Intro.ShowServerForm (true);
-
- }
-
- if (!SparkleUI.Intro.Visible)
- SparkleUI.Intro.ShowServerForm (true);
-
- SparkleUI.Intro.ShowAll ();
- SparkleUI.Intro.Present ();
-
- });
- };
-
- Menu.Add (sync_item);
- Menu.Add (new SeparatorMenuItem ());
-
- MenuItem notify_item;
-
- if (SparkleShare.Controller.NotificationsEnabled)
- notify_item = new MenuItem (_("Turn Notifications Off"));
- else
- notify_item = new MenuItem (_("Turn Notifications On"));
-
- notify_item.Activated += delegate {
-
- SparkleShare.Controller.ToggleNotifications ();
- CreateMenu ();
-
- };
-
- Menu.Add (notify_item);
- Menu.Add (new SeparatorMenuItem ());
-
- // A menu item that takes the user to http://www.sparkleshare.org/
- MenuItem about_item = new MenuItem (_("About SparkleShare"));
-
- about_item.Activated += delegate {
-
- SparkleAbout about = new SparkleAbout ();
- about.ShowAll ();
-
- };
-
- Menu.Add (about_item);
- Menu.Add (new SeparatorMenuItem ());
-
- // A menu item that quits the application
- MenuItem quit_item = new MenuItem (_("Quit"));
-
- quit_item.Activated += delegate {
- SparkleShare.Controller.Quit ();
- };
-
- Menu.Add (quit_item);
-
- Menu.ShowAll ();
-
- }
-
-
- // A method reference that makes sure that opening the
- // event log for each repository works correctly
- private EventHandler OpenEventLogDelegate (string path)
- {
-
- return delegate {
-
- SparkleShare.UI.AddEventLog (path);
-
- };
-
- }
-
-
- public void UpdateMenu ()
- {
-
- Menu.Remove (Menu.Children [0]);
-
- MenuItem status_menu_item = new MenuItem (StateText) {
- Sensitive = false
- };
-
- Menu.Add (status_menu_item);
- Menu.ReorderChild (status_menu_item, 0);
-
- Menu.ShowAll ();
-
- }
-
-
- // Makes the menu visible
- private void ShowMenu (object o, EventArgs args)
- {
-
- Menu.Popup (null, null, SetPosition, 0, Global.CurrentEventTime);
-
- }
-
-
- // Makes sure the menu pops up in the right position
- private void SetPosition (Menu menu, out int x, out int y, out bool push_in)
- {
-
- PositionMenu (menu, out x, out y, out push_in, Handle);
-
- }
-
-
- // The state when there's nothing going on
- private void SetNormalState ()
- {
-
- SetNormalState (false);
-
- }
-
-
- // The state when there's nothing going on
- private void SetNormalState (bool error)
- {
-
- Animation.Stop ();
-
- if (SparkleShare.Controller.Folders.Count == 0) {
-
- StateText = _("Welcome to SparkleShare!");
- Application.Invoke (delegate {
- Pixbuf = AnimationFrames [0];
- });
-
- } else {
-
- if (error) {
-
- StateText = _("Not everything is synced");
- Application.Invoke (delegate {
- Pixbuf = SparkleUIHelpers.GetIcon ("sparkleshare-syncing-error", 24);
- });
-
- } else {
-
- StateText = _("Up to date") + " (" + SparkleShare.Controller.FolderSize + ")";
- Application.Invoke (delegate {
- Pixbuf = AnimationFrames [0];
- });
-
- }
-
- }
-
- }
-
-
- // The state when animating
- private void SetAnimationState ()
- {
-
- StateText = _("Syncing…");
-
- if (!Animation.Enabled)
- Animation.Start ();
-
- }
-
- }
-
- public class SparkleMenuItem : ImageMenuItem {
-
- public SparkleMenuItem (string text) : base (text)
- {
-
- SetProperty ("always-show-image", new GLib.Value (true));
-
- }
-
- }
+ public class SparkleMenuItem : ImageMenuItem {
+ public SparkleMenuItem (string text) : base (text)
+ {
+ SetProperty ("always-show-image", new GLib.Value (true));
+ }
+ }
}