intro statusicon: fix coding style and whitespace
This commit is contained in:
parent
9707481f42
commit
cbe9979324
|
@ -48,16 +48,13 @@ namespace SparkleShare {
|
|||
|
||||
public SparkleIntro () : base ()
|
||||
{
|
||||
|
||||
ServerFormOnly = false;
|
||||
SecondaryTextColor = SparkleUIHelpers.GdkColorToHex (Style.Foreground (StateType.Insensitive));
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void ShowAccountForm ()
|
||||
{
|
||||
|
||||
Reset ();
|
||||
|
||||
VBox layout_vertical = new VBox (false, 0);
|
||||
|
@ -117,7 +114,6 @@ namespace SparkleShare {
|
|||
};
|
||||
|
||||
NextButton.Clicked += delegate (object o, EventArgs args) {
|
||||
|
||||
NextButton.Remove (NextButton.Child);
|
||||
NextButton.Add (new Label (_("Configuring…")));
|
||||
|
||||
|
@ -136,7 +132,6 @@ namespace SparkleShare {
|
|||
|
||||
Deletable = true;
|
||||
ShowServerForm ();
|
||||
|
||||
};
|
||||
|
||||
AddButton (NextButton);
|
||||
|
@ -147,26 +142,20 @@ namespace SparkleShare {
|
|||
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);
|
||||
|
@ -230,44 +219,31 @@ namespace SparkleShare {
|
|||
(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);
|
||||
|
@ -296,7 +272,6 @@ namespace SparkleShare {
|
|||
SyncButton = new Button (_("Sync"));
|
||||
|
||||
SyncButton.Clicked += delegate {
|
||||
|
||||
string name = FolderEntry.Text;
|
||||
|
||||
// Remove the starting slash if there is one
|
||||
|
@ -327,22 +302,17 @@ namespace SparkleShare {
|
|||
// 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)
|
||||
|
@ -359,35 +329,24 @@ namespace SparkleShare {
|
|||
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 {
|
||||
|
@ -395,10 +354,7 @@ namespace SparkleShare {
|
|||
};
|
||||
|
||||
AddButton (cancel_button);
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
Button skip_button = new Button (_("Skip"));
|
||||
|
||||
skip_button.Clicked += delegate {
|
||||
|
@ -406,7 +362,6 @@ namespace SparkleShare {
|
|||
};
|
||||
|
||||
AddButton (skip_button);
|
||||
|
||||
}
|
||||
|
||||
AddButton (SyncButton);
|
||||
|
@ -417,17 +372,13 @@ namespace SparkleShare {
|
|||
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 ("<span size='large'><b>" +
|
||||
|
@ -483,26 +434,20 @@ namespace SparkleShare {
|
|||
};
|
||||
|
||||
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);
|
||||
|
@ -516,16 +461,13 @@ namespace SparkleShare {
|
|||
layout_vertical.PackStart (question, false, false, 21);
|
||||
|
||||
Add (layout_vertical);
|
||||
|
||||
ShowAll ();
|
||||
|
||||
}
|
||||
|
||||
|
||||
// The page shown when syncing has failed
|
||||
private void ShowErrorPage ()
|
||||
{
|
||||
|
||||
Reset ();
|
||||
|
||||
UrgencyHint = true;
|
||||
|
@ -552,27 +494,22 @@ namespace SparkleShare {
|
|||
layout_vertical.PackStart (header, false, false, 0);
|
||||
|
||||
Add (layout_vertical);
|
||||
|
||||
ShowAll ();
|
||||
|
||||
}
|
||||
|
||||
|
||||
// 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);
|
||||
|
@ -596,9 +533,7 @@ namespace SparkleShare {
|
|||
Button open_folder_button = new Button (_("Open Folder"));
|
||||
|
||||
open_folder_button.Clicked += delegate {
|
||||
|
||||
SparkleShare.Controller.OpenSparkleShareFolder (System.IO.Path.GetFileNameWithoutExtension(folder_name));
|
||||
|
||||
SparkleShare.Controller.OpenSparkleShareFolder (Path.GetFileNameWithoutExtension(folder_name));
|
||||
};
|
||||
|
||||
Button finish_button = new Button (_("Finish"));
|
||||
|
@ -614,16 +549,13 @@ namespace SparkleShare {
|
|||
layout_vertical.PackStart (information, false, false, 21);
|
||||
|
||||
Add (layout_vertical);
|
||||
|
||||
ShowAll ();
|
||||
|
||||
}
|
||||
|
||||
|
||||
// The page shown whilst syncing
|
||||
private void ShowSyncingPage (string name)
|
||||
{
|
||||
|
||||
Reset ();
|
||||
|
||||
Deletable = false;
|
||||
|
@ -644,7 +576,6 @@ namespace SparkleShare {
|
|||
Xalign = 0
|
||||
};
|
||||
|
||||
|
||||
Button button = new Button () {
|
||||
Sensitive = false,
|
||||
Label = _("Finish")
|
||||
|
@ -674,16 +605,13 @@ namespace SparkleShare {
|
|||
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);
|
||||
|
@ -723,9 +651,7 @@ namespace SparkleShare {
|
|||
AddButton (finish_button);
|
||||
|
||||
Add (layout_vertical);
|
||||
|
||||
ShowAll ();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -733,18 +659,13 @@ namespace SparkleShare {
|
|||
// entries filled in by the user
|
||||
private void CheckAccountForm ()
|
||||
{
|
||||
|
||||
if (NameEntry.Text.Length > 0 &&
|
||||
IsValidEmail (EmailEntry.Text)) {
|
||||
|
||||
NextButton.Sensitive = true;
|
||||
|
||||
} else {
|
||||
|
||||
NextButton.Sensitive = false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -752,9 +673,7 @@ namespace SparkleShare {
|
|||
// filled in correctly
|
||||
public void CheckServerForm (object o, EventArgs args)
|
||||
{
|
||||
|
||||
CheckServerForm ();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -762,7 +681,6 @@ namespace SparkleShare {
|
|||
// filled in correctly
|
||||
public void CheckServerForm ()
|
||||
{
|
||||
|
||||
SyncButton.Sensitive = false;
|
||||
|
||||
if (FolderEntry.ExampleTextActive ||
|
||||
|
@ -773,28 +691,19 @@ namespace SparkleShare {
|
|||
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);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,12 +14,14 @@
|
|||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
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
|
||||
|
@ -41,7 +43,6 @@ namespace SparkleShare {
|
|||
|
||||
public SparkleStatusIcon () : base ()
|
||||
{
|
||||
|
||||
AnimationFrames = CreateAnimationFrames ();
|
||||
Animation = CreateAnimation ();
|
||||
|
||||
|
@ -51,15 +52,12 @@ namespace SparkleShare {
|
|||
SetNormalState ();
|
||||
CreateMenu ();
|
||||
|
||||
|
||||
SparkleShare.Controller.FolderSizeChanged += delegate {
|
||||
Application.Invoke (delegate {
|
||||
|
||||
if (!Animation.Enabled)
|
||||
SetNormalState ();
|
||||
|
||||
UpdateMenu ();
|
||||
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -98,7 +96,6 @@ namespace SparkleShare {
|
|||
// animation frames.
|
||||
private Gdk.Pixbuf [] CreateAnimationFrames ()
|
||||
{
|
||||
|
||||
Gdk.Pixbuf [] animation_frames = new Gdk.Pixbuf [5];
|
||||
Gdk.Pixbuf frames_pixbuf = SparkleUIHelpers.GetIcon ("process-syncing-sparkleshare", 24);
|
||||
|
||||
|
@ -106,14 +103,12 @@ namespace SparkleShare {
|
|||
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 () {
|
||||
|
@ -121,7 +116,6 @@ namespace SparkleShare {
|
|||
};
|
||||
|
||||
Animation.Elapsed += delegate {
|
||||
|
||||
if (FrameNumber < AnimationFrames.Length - 1)
|
||||
FrameNumber++;
|
||||
else
|
||||
|
@ -130,11 +124,9 @@ namespace SparkleShare {
|
|||
Application.Invoke (delegate {
|
||||
Pixbuf = AnimationFrames [FrameNumber];
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
return Animation;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -142,7 +134,6 @@ namespace SparkleShare {
|
|||
// user clicks the status icon
|
||||
public void CreateMenu ()
|
||||
{
|
||||
|
||||
Menu = new Menu ();
|
||||
|
||||
// The menu item showing the status and size of the SparkleShare folder
|
||||
|
@ -181,17 +172,13 @@ namespace SparkleShare {
|
|||
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
|
||||
|
@ -204,10 +191,8 @@ namespace SparkleShare {
|
|||
Application.Invoke (delegate {
|
||||
|
||||
if (SparkleUI.Intro == null) {
|
||||
|
||||
SparkleUI.Intro = new SparkleIntro ();
|
||||
SparkleUI.Intro.ShowServerForm (true);
|
||||
|
||||
}
|
||||
|
||||
if (!SparkleUI.Intro.Visible)
|
||||
|
@ -215,7 +200,6 @@ namespace SparkleShare {
|
|||
|
||||
SparkleUI.Intro.ShowAll ();
|
||||
SparkleUI.Intro.Present ();
|
||||
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -230,10 +214,8 @@ namespace SparkleShare {
|
|||
notify_item = new MenuItem (_("Turn Notifications On"));
|
||||
|
||||
notify_item.Activated += delegate {
|
||||
|
||||
SparkleShare.Controller.ToggleNotifications ();
|
||||
CreateMenu ();
|
||||
|
||||
};
|
||||
|
||||
Menu.Add (notify_item);
|
||||
|
@ -243,10 +225,8 @@ namespace SparkleShare {
|
|||
MenuItem about_item = new MenuItem (_("About SparkleShare"));
|
||||
|
||||
about_item.Activated += delegate {
|
||||
|
||||
SparkleAbout about = new SparkleAbout ();
|
||||
about.ShowAll ();
|
||||
|
||||
};
|
||||
|
||||
Menu.Add (about_item);
|
||||
|
@ -260,9 +240,7 @@ namespace SparkleShare {
|
|||
};
|
||||
|
||||
Menu.Add (quit_item);
|
||||
|
||||
Menu.ShowAll ();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -270,19 +248,14 @@ namespace SparkleShare {
|
|||
// 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) {
|
||||
|
@ -293,95 +266,73 @@ namespace SparkleShare {
|
|||
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));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue