Skip to content
This repository was archived by the owner on Oct 1, 2024. It is now read-only.

Commit c15a1d1

Browse files
committed
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/.
1 parent e52ff66 commit c15a1d1

File tree

3 files changed

+75
-0
lines changed

3 files changed

+75
-0
lines changed

sample/GtkDemo/DemoSpinner.cs

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/* Spinner
2+
*
3+
* GtkSpinner allows to show that background activity is on-going.
4+
*
5+
*/
6+
7+
using System;
8+
using Gtk;
9+
10+
namespace GtkDemo
11+
{
12+
[Demo ("Spinner", "DemoSpinner.cs")]
13+
public class DemoSpinner : Dialog
14+
{
15+
Spinner spinner_sensitive;
16+
Spinner spinner_unsensitive;
17+
18+
public DemoSpinner () : base ("Spinner", null, DialogFlags.DestroyWithParent)
19+
{
20+
Resizable = false;
21+
22+
VBox vbox = new VBox (false, 5);
23+
vbox.BorderWidth = 5;
24+
ContentArea.PackStart (vbox, true, true, 0);
25+
26+
/* Sensitive */
27+
HBox hbox = new HBox (false, 5);
28+
spinner_sensitive = new Spinner ();
29+
hbox.Add (spinner_sensitive);
30+
hbox.Add (new Entry ());
31+
vbox.Add (hbox);
32+
33+
/* Disabled */
34+
hbox = new HBox (false, 5);
35+
spinner_unsensitive = new Spinner ();
36+
spinner_unsensitive.Sensitive = false;
37+
hbox.Add (spinner_unsensitive);
38+
hbox.Add (new Entry ());
39+
vbox.Add (hbox);
40+
41+
Button btn_play = new Button ();
42+
btn_play.Label = "Play";
43+
btn_play.Clicked += OnPlayClicked;
44+
vbox.Add (btn_play);
45+
46+
Button btn_stop = new Button ();
47+
btn_stop.Label = "Stop";
48+
btn_stop.Clicked += OnStopClicked;
49+
vbox.Add (btn_stop);
50+
51+
AddButton (Stock.Close, ResponseType.Close);
52+
53+
OnPlayClicked (null, null);
54+
55+
ShowAll ();
56+
Run ();
57+
Destroy ();
58+
}
59+
60+
private void OnPlayClicked (object sender, EventArgs e)
61+
{
62+
spinner_sensitive.Start ();
63+
spinner_unsensitive.Start ();
64+
}
65+
66+
private void OnStopClicked (object sender, EventArgs e)
67+
{
68+
spinner_sensitive.Stop ();
69+
spinner_unsensitive.Stop ();
70+
}
71+
}
72+
}
73+

sample/GtkDemo/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ sources = \
3636
DemoPixbuf.cs \
3737
DemoRotatedText.cs \
3838
DemoSizeGroup.cs \
39+
DemoSpinner.cs \
3940
DemoStockBrowser.cs \
4041
DemoTextView.cs \
4142
DemoTreeStore.cs \

sample/sample.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@
109109
<Compile Include="gtk-gio\MountOperation.cs" />
110110
<Compile Include="CairoPng.cs" />
111111
<Compile Include="valtest\Gtksharp\Valobj.cs" />
112+
<Compile Include="GtkDemo\DemoSpinner.cs" />
112113
</ItemGroup>
113114
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
114115
<ItemGroup>

0 commit comments

Comments
 (0)