GtkDemo: Add a Spinner demo

As the other samples in GtkDemo, this is straight translation of the C
demos in the GTK+ source tree under demos/gtk-demo/.
This commit is contained in:
Bertrand Lorentz 2014-05-29 18:25:42 +02:00
parent e52ff66c9d
commit c15a1d18b5
3 changed files with 75 additions and 0 deletions

View file

@ -0,0 +1,73 @@
/* Spinner
*
* GtkSpinner allows to show that background activity is on-going.
*
*/
using System;
using Gtk;
namespace GtkDemo
{
[Demo ("Spinner", "DemoSpinner.cs")]
public class DemoSpinner : Dialog
{
Spinner spinner_sensitive;
Spinner spinner_unsensitive;
public DemoSpinner () : base ("Spinner", null, DialogFlags.DestroyWithParent)
{
Resizable = false;
VBox vbox = new VBox (false, 5);
vbox.BorderWidth = 5;
ContentArea.PackStart (vbox, true, true, 0);
/* Sensitive */
HBox hbox = new HBox (false, 5);
spinner_sensitive = new Spinner ();
hbox.Add (spinner_sensitive);
hbox.Add (new Entry ());
vbox.Add (hbox);
/* Disabled */
hbox = new HBox (false, 5);
spinner_unsensitive = new Spinner ();
spinner_unsensitive.Sensitive = false;
hbox.Add (spinner_unsensitive);
hbox.Add (new Entry ());
vbox.Add (hbox);
Button btn_play = new Button ();
btn_play.Label = "Play";
btn_play.Clicked += OnPlayClicked;
vbox.Add (btn_play);
Button btn_stop = new Button ();
btn_stop.Label = "Stop";
btn_stop.Clicked += OnStopClicked;
vbox.Add (btn_stop);
AddButton (Stock.Close, ResponseType.Close);
OnPlayClicked (null, null);
ShowAll ();
Run ();
Destroy ();
}
private void OnPlayClicked (object sender, EventArgs e)
{
spinner_sensitive.Start ();
spinner_unsensitive.Start ();
}
private void OnStopClicked (object sender, EventArgs e)
{
spinner_sensitive.Stop ();
spinner_unsensitive.Stop ();
}
}
}

View file

@ -36,6 +36,7 @@ sources = \
DemoPixbuf.cs \
DemoRotatedText.cs \
DemoSizeGroup.cs \
DemoSpinner.cs \
DemoStockBrowser.cs \
DemoTextView.cs \
DemoTreeStore.cs \

View file

@ -109,6 +109,7 @@
<Compile Include="gtk-gio\MountOperation.cs" />
<Compile Include="CairoPng.cs" />
<Compile Include="valtest\Gtksharp\Valobj.cs" />
<Compile Include="GtkDemo\DemoSpinner.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>