make gtkspinner clone work
This commit is contained in:
parent
f720d2beda
commit
6325e9f8b4
|
@ -27,7 +27,6 @@ namespace SparkleShare {
|
|||
|
||||
public static void Main (string [] args) {
|
||||
|
||||
|
||||
// Check if git is installed
|
||||
Process Process = new Process();
|
||||
Process.StartInfo.RedirectStandardOutput = true;
|
||||
|
@ -67,6 +66,8 @@ namespace SparkleShare {
|
|||
SparkleUI = new SparkleUI (HideUI);
|
||||
SparkleUI.StartMonitoring ();
|
||||
|
||||
|
||||
|
||||
// The main loop
|
||||
Gtk.Application.Run ();
|
||||
|
||||
|
|
|
@ -15,39 +15,63 @@
|
|||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
using Gtk;
|
||||
using System;
|
||||
using System.Timers;
|
||||
|
||||
namespace SparkleShare {
|
||||
|
||||
// This is a close implementation of GtkSpinner
|
||||
public class SparkleSpinner : Gdk.Pixbuf {
|
||||
public class SparkleSpinner : Image {
|
||||
|
||||
private int CycleDuration;
|
||||
private int NumSteps;
|
||||
private bool Active;
|
||||
public bool Active;
|
||||
|
||||
private Gdk.Pixbuf [] Images;
|
||||
private Timer Timer;
|
||||
private int CycleDuration;
|
||||
private int CurrentStep;
|
||||
private int NumSteps;
|
||||
private int Size;
|
||||
|
||||
public SparkleSpinner () : base ("") {
|
||||
Timer = new Timer ();
|
||||
CycleDuration = 1000;
|
||||
public SparkleSpinner () : base () {
|
||||
|
||||
Size = 48;
|
||||
Gdk.Pixbuf SpinnerGallery = new Gdk.Pixbuf ("/usr/share/icons/" +
|
||||
"gnome/" + Size + "x" +
|
||||
Size + "/animations/" +
|
||||
"process-working.png");
|
||||
CycleDuration = 750;
|
||||
CurrentStep = 0;
|
||||
NumSteps = 20;
|
||||
|
||||
int FramesInWidth = SpinnerGallery.Width / Size;
|
||||
int FramesInHeight = SpinnerGallery.Height / Size;
|
||||
NumSteps = FramesInWidth * FramesInHeight;
|
||||
Images = new Gdk.Pixbuf [NumSteps - 1];
|
||||
|
||||
int i = 0;
|
||||
for (int y = 0; y < FramesInHeight; y++) {
|
||||
for (int x = 0; x < FramesInWidth; x++) {
|
||||
if (!(y == 0 && x == 0)) {
|
||||
Images [i] = new Gdk.Pixbuf (SpinnerGallery,
|
||||
x * Size, y * Size, Size, Size);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Timer = new Timer ();
|
||||
Timer.Interval = CycleDuration / NumSteps;
|
||||
Timer.Elapsed += delegate { NextImage (); };
|
||||
Start ();
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void NextImage () {
|
||||
Console.WriteLine (CurrentStep);
|
||||
if (CurrentStep < NumSteps)
|
||||
CurrentStep++;
|
||||
else
|
||||
CurrentStep = 0;
|
||||
CurrentStep = 1;
|
||||
Pixbuf = Images [CurrentStep];
|
||||
}
|
||||
|
||||
|
||||
public bool IsActive () {
|
||||
return Active;
|
||||
}
|
||||
|
|
|
@ -36,18 +36,16 @@ namespace SparkleShare {
|
|||
Process.StartInfo.RedirectStandardOutput = true;
|
||||
Process.StartInfo.UseShellExecute = false;
|
||||
|
||||
// Get home folder, example: "/home/user/"
|
||||
string UserHome = Environment.GetEnvironmentVariable("HOME") + "/";
|
||||
string ReposPath = UserHome + "SparkleShare";
|
||||
string SparkleDir = SparklePaths.SparkleDir;
|
||||
|
||||
// Create 'SparkleShare' folder in the user's home folder
|
||||
// if it's not there already
|
||||
if (!Directory.Exists (ReposPath)) {
|
||||
Directory.CreateDirectory (ReposPath);
|
||||
Console.WriteLine ("[Config] Created '" + ReposPath + "'");
|
||||
if (!Directory.Exists (SparkleDir)) {
|
||||
Directory.CreateDirectory (SparkleDir);
|
||||
Console.WriteLine ("[Config] Created '" + SparkleDir + "'");
|
||||
|
||||
Process.StartInfo.FileName = "gvfs-set-attribute";
|
||||
Process.StartInfo.Arguments = ReposPath +
|
||||
Process.StartInfo.Arguments = SparkleDir +
|
||||
" metadata::custom-icon " +
|
||||
"file:///usr/share/icons/hicolor/" +
|
||||
"48x48/places/" +
|
||||
|
@ -57,24 +55,21 @@ namespace SparkleShare {
|
|||
}
|
||||
|
||||
// Create place to store configuration user's home folder
|
||||
string ConfigPath = UserHome + ".config/sparkleshare/";
|
||||
if (!Directory.Exists (ConfigPath)) {
|
||||
string ConfigDir = SparklePaths.SparkleConfigDir;
|
||||
string AvatarDir = SparklePaths.SparkleAvatarsDir;
|
||||
if (!Directory.Exists (ConfigDir)) {
|
||||
|
||||
Directory.CreateDirectory (ConfigPath);
|
||||
Console.WriteLine ("[Config] Created '" + ConfigPath + "'");
|
||||
|
||||
// Create a first run file to show the intro message
|
||||
File.Create (ConfigPath + "firstrun");
|
||||
Console.WriteLine ("[Config] Created '" + ConfigPath + "firstrun'");
|
||||
Directory.CreateDirectory (ConfigDir);
|
||||
Console.WriteLine ("[Config] Created '" + ConfigDir + "'");
|
||||
|
||||
// Create a place to store the avatars
|
||||
Directory.CreateDirectory (ConfigPath + "avatars/");
|
||||
Console.WriteLine ("[Config] Created '" + ConfigPath + "avatars'");
|
||||
Directory.CreateDirectory (AvatarDir);
|
||||
Console.WriteLine ("[Config] Created '" + AvatarDir + "avatars'");
|
||||
|
||||
}
|
||||
|
||||
// Get all the repos in ~/SparkleShare
|
||||
string [] Repos = Directory.GetDirectories (ReposPath);
|
||||
string [] Repos = Directory.GetDirectories (SparkleDir);
|
||||
Repositories = new SparkleRepo [Repos.Length];
|
||||
|
||||
int i = 0;
|
||||
|
|
|
@ -200,6 +200,7 @@ namespace SparkleShare {
|
|||
CreateAddDialog ();
|
||||
};
|
||||
|
||||
|
||||
AddRemoveButtons.PackStart (AddButton, true, true, 0);
|
||||
|
||||
Image RemoveImage = new Image ("/usr/share/icons/gnome/16x16/actions/list-remove.png");
|
||||
|
@ -492,7 +493,13 @@ namespace SparkleShare {
|
|||
AddButton.Clicked += delegate {
|
||||
|
||||
AddDialog.Remove (AddDialog.Child);
|
||||
AddDialog.Add (new Label ("Downloading files...\nPlease wait."));
|
||||
VBox Box = new VBox (false, 24);
|
||||
SparkleSpinner Spinner = new SparkleSpinner ();
|
||||
Label Label = new Label ("Downloading files,\nthis may take a while...");
|
||||
Box.PackStart (Spinner, false, false, 0);
|
||||
Box.PackStart (Label, false, false, 0);
|
||||
AddDialog.BorderWidth = 30;
|
||||
AddDialog.Add (Box);
|
||||
AddDialog.ShowAll ();
|
||||
|
||||
string RepoRemoteUrl = RemoteUrlCombo.Entry.Text;
|
||||
|
@ -518,6 +525,7 @@ namespace SparkleShare {
|
|||
};
|
||||
|
||||
};
|
||||
|
||||
ButtonBox.Add (CancelButton);
|
||||
ButtonBox.Add (AddButton);
|
||||
|
||||
|
|
Loading…
Reference in a new issue