From bcafa7c94f8b935d53aac8edb6cf21ea1f8fb1de Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Tue, 10 Aug 2010 22:22:51 +0100 Subject: [PATCH] [statusicon] code cleanup --- SparkleShare/SparkleStatusIcon.cs | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/SparkleShare/SparkleStatusIcon.cs b/SparkleShare/SparkleStatusIcon.cs index 69aed34f..067a2601 100644 --- a/SparkleShare/SparkleStatusIcon.cs +++ b/SparkleShare/SparkleStatusIcon.cs @@ -52,8 +52,9 @@ namespace SparkleShare { FolderSize = GetFolderSize (new DirectoryInfo (SparklePaths.SparklePath)); - CreateAnimationFrames (); - CreateTimer (); + FrameNumber = 0; + AnimationFrames = CreateAnimationFrames (); + Timer = CreateTimer (); SyncingReposCount = 0; @@ -61,7 +62,11 @@ namespace SparkleShare { StatusMenuItem = new MenuItem (); CreateMenu (); + + // Primary mouse button Activate += ShowMenu; + + // Secondary mouse button PopupMenu += ShowMenu; SetIdleState (); @@ -70,29 +75,29 @@ namespace SparkleShare { } - private void CreateAnimationFrames () + private Gdk.Pixbuf [] CreateAnimationFrames () { - FrameNumber = 0; - - AnimationFrames = new Gdk.Pixbuf [5]; + Gdk.Pixbuf [] animation_frames = new Gdk.Pixbuf [5]; Gdk.Pixbuf frames_pixbuf = SparkleHelpers.GetIcon ("process-syncing-sparkleshare", 24); - for (int i = 0; i < AnimationFrames.Length; i++) - AnimationFrames [i] = new Gdk.Pixbuf (frames_pixbuf, (i * 24), 0, 24, 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 timer that handles the syncing animation - private void CreateTimer () + private Timer CreateTimer () { - Timer = new Timer () { + Timer timer = new Timer () { Interval = 35 }; - Timer.Elapsed += delegate { + timer.Elapsed += delegate { if (FrameNumber < AnimationFrames.Length - 1) FrameNumber++; @@ -103,6 +108,8 @@ namespace SparkleShare { }; + return timer; + }