spinner: fix coding style and whitespace
This commit is contained in:
parent
632c57da13
commit
aed1c9fa2d
|
@ -14,112 +14,98 @@
|
|||
// 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 System.Timers;
|
||||
using Gtk;
|
||||
|
||||
namespace SparkleShare {
|
||||
|
||||
// This is a close implementation of GtkSpinner
|
||||
public class SparkleSpinner : Image
|
||||
{
|
||||
|
||||
// This is a close implementation of GtkSpinner
|
||||
public class SparkleSpinner : Image {
|
||||
|
||||
public bool Active;
|
||||
public bool Active;
|
||||
|
||||
private Gdk.Pixbuf [] Images;
|
||||
private Timer Timer;
|
||||
private int CycleDuration;
|
||||
private int CurrentStep;
|
||||
private int NumSteps;
|
||||
private int Size;
|
||||
private Gdk.Pixbuf [] Images;
|
||||
private Timer Timer;
|
||||
private int CycleDuration;
|
||||
private int CurrentStep;
|
||||
private int NumSteps;
|
||||
private int Size;
|
||||
|
||||
public SparkleSpinner (int size) : base ()
|
||||
{
|
||||
|
||||
Size = size;
|
||||
public SparkleSpinner (int size) : base ()
|
||||
{
|
||||
Size = size;
|
||||
|
||||
CycleDuration = 600;
|
||||
CurrentStep = 0;
|
||||
CycleDuration = 600;
|
||||
CurrentStep = 0;
|
||||
|
||||
Gdk.Pixbuf spinner_gallery = SparkleUIHelpers.GetIcon ("process-working", Size);
|
||||
Gdk.Pixbuf spinner_gallery = SparkleUIHelpers.GetIcon ("process-working", Size);
|
||||
|
||||
int frames_in_width = spinner_gallery.Width / Size;
|
||||
int frames_in_height = spinner_gallery.Height / Size;
|
||||
int frames_in_width = spinner_gallery.Width / Size;
|
||||
int frames_in_height = spinner_gallery.Height / Size;
|
||||
|
||||
NumSteps = frames_in_width * frames_in_height;
|
||||
Images = new Gdk.Pixbuf [NumSteps - 1];
|
||||
NumSteps = frames_in_width * frames_in_height;
|
||||
Images = new Gdk.Pixbuf [NumSteps - 1];
|
||||
|
||||
int i = 0;
|
||||
int i = 0;
|
||||
|
||||
for (int y = 0; y < frames_in_height; y++) {
|
||||
for (int y = 0; y < frames_in_height; y++) {
|
||||
for (int x = 0; x < frames_in_width; x++) {
|
||||
if (!(y == 0 && x == 0)) {
|
||||
Images [i] = new Gdk.Pixbuf (spinner_gallery, x * Size, y * Size, Size, Size);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int x = 0; x < frames_in_width; x++) {
|
||||
Timer = new Timer () {
|
||||
Interval = CycleDuration / NumSteps
|
||||
};
|
||||
|
||||
if (!(y == 0 && x == 0)) {
|
||||
|
||||
Images [i] = new Gdk.Pixbuf (spinner_gallery, x * Size, y * Size, Size, Size);
|
||||
i++;
|
||||
Timer.Elapsed += delegate {
|
||||
NextImage ();
|
||||
};
|
||||
|
||||
}
|
||||
Start ();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
private void NextImage ()
|
||||
{
|
||||
if (CurrentStep < NumSteps - 2)
|
||||
CurrentStep++;
|
||||
else
|
||||
CurrentStep = 0;
|
||||
|
||||
Timer = new Timer () {
|
||||
Interval = CycleDuration / NumSteps
|
||||
};
|
||||
Application.Invoke (delegate { SetImage (); });
|
||||
}
|
||||
|
||||
Timer.Elapsed += delegate {
|
||||
NextImage ();
|
||||
};
|
||||
|
||||
Start ();
|
||||
private void SetImage ()
|
||||
{
|
||||
Pixbuf = Images [CurrentStep];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void NextImage ()
|
||||
{
|
||||
public bool IsActive ()
|
||||
{
|
||||
return Active;
|
||||
}
|
||||
|
||||
if (CurrentStep < NumSteps - 2)
|
||||
CurrentStep++;
|
||||
else
|
||||
CurrentStep = 0;
|
||||
|
||||
Application.Invoke (delegate { SetImage (); });
|
||||
public void Start ()
|
||||
{
|
||||
CurrentStep = 0;
|
||||
Active = true;
|
||||
Timer.Start ();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void SetImage ()
|
||||
{
|
||||
|
||||
Pixbuf = Images [CurrentStep];
|
||||
|
||||
}
|
||||
|
||||
public bool IsActive ()
|
||||
{
|
||||
|
||||
return Active;
|
||||
|
||||
}
|
||||
|
||||
public void Start ()
|
||||
{
|
||||
|
||||
CurrentStep = 0;
|
||||
Active = true;
|
||||
Timer.Start ();
|
||||
|
||||
}
|
||||
|
||||
public void Stop ()
|
||||
{
|
||||
|
||||
Active = false;
|
||||
Timer.Stop ();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void Stop ()
|
||||
{
|
||||
Active = false;
|
||||
Timer.Stop ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue