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:
parent
e52ff66c9d
commit
c15a1d18b5
3 changed files with 75 additions and 0 deletions
73
sample/GtkDemo/DemoSpinner.cs
Normal file
73
sample/GtkDemo/DemoSpinner.cs
Normal 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 ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -36,6 +36,7 @@ sources = \
|
||||||
DemoPixbuf.cs \
|
DemoPixbuf.cs \
|
||||||
DemoRotatedText.cs \
|
DemoRotatedText.cs \
|
||||||
DemoSizeGroup.cs \
|
DemoSizeGroup.cs \
|
||||||
|
DemoSpinner.cs \
|
||||||
DemoStockBrowser.cs \
|
DemoStockBrowser.cs \
|
||||||
DemoTextView.cs \
|
DemoTextView.cs \
|
||||||
DemoTreeStore.cs \
|
DemoTreeStore.cs \
|
||||||
|
|
|
@ -109,6 +109,7 @@
|
||||||
<Compile Include="gtk-gio\MountOperation.cs" />
|
<Compile Include="gtk-gio\MountOperation.cs" />
|
||||||
<Compile Include="CairoPng.cs" />
|
<Compile Include="CairoPng.cs" />
|
||||||
<Compile Include="valtest\Gtksharp\Valobj.cs" />
|
<Compile Include="valtest\Gtksharp\Valobj.cs" />
|
||||||
|
<Compile Include="GtkDemo\DemoSpinner.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
Loading…
Reference in a new issue