Remove uses of deprecated HBox/VBox
[libprolooks.git] / demos / TransportButtonDemo.vala
blobc1c184d2e500f19df7bf1a1aa9230606146482e1
1 /*
2 Copyright 2009 by Hans Baier
3 License: LGPLv2+
4 */
6 using Gtk;
7 using Gdk;
9 namespace Prolooks {
11 public class TransportButtons : TransportButton {
13 public TransportButtons () {
14 // Set favored widget size
15 set_size_request (280, 40);
16 draw.connect(on_draw);
19 /* Widget is asked to draw itself */
20 public new bool on_draw (Cairo.Context cr) {
21 Gtk.Allocation allocation;
22 get_allocation(out allocation);
24 cr.translate (10.0, 10.0);
25 paint_stop_icon (cr);
27 cr.translate (20.0, 0.0);
28 paint_play_icon (cr);
30 cr.translate (20.0, 0.0);
31 paint_rec_icon (cr);
33 cr.translate (20.0, 0.0);
34 paint_fast_forward_icon (cr);
36 cr.translate (20.0, 0.0);
37 paint_fast_to_end_icon (cr);
39 cr.translate (20.0, 0.0);
40 paint_fast_backward_icon (cr);
42 cr.translate (20.0, 0.0);
43 paint_fast_to_start_icon (cr);
46 return false;
49 static int main (string[] args) {
50 Gtk.init (ref args);
51 var window = new Gtk.Window (Gtk.WindowType.TOPLEVEL);
52 var vbox = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
53 var hbox = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
54 var widget = new TransportButtons ();
55 vbox.add (widget);
57 var button = new TransportButton();
58 button.icon_type = IconType.STOP;
59 hbox.add (button);
60 button = new TransportButton();
61 button.icon_type = IconType.PLAY;
62 hbox.add (button);
63 button = new TransportButton();
64 button.icon_type = IconType.REC;
65 hbox.add (button);
66 button = new TransportButton();
67 button.icon_type = IconType.FAST_BACKWARD;
68 hbox.add (button);
69 button = new TransportButton();
70 button.icon_type = IconType.FAST_FORWARD;
71 hbox.add (button);
72 button = new TransportButton();
73 button.icon_type = IconType.TO_START;
74 hbox.add (button);
75 button = new TransportButton();
76 button.icon_type = IconType.TO_END;
77 hbox.add (button);
79 vbox.add (hbox);
81 int[] sizes = {16, 22, 24, 28, 32, 48};
82 foreach (var size in sizes) {
83 hbox = new Gtk.HBox (true, 100);
85 button = new TransportButton();
86 button.icon_type = IconType.STOP;
87 button.set_size_request (size, size);
88 hbox.add (button);
89 hbox.set_child_packing (button, false, false, 0, PackType.END);
91 button = new TransportButton();
92 button.icon_type = IconType.PLAY;
93 button.set_size_request (size, size);
94 hbox.add (button);
95 hbox.set_child_packing (button, false, false, 0, PackType.END);
97 button = new TransportButton();
98 button.icon_type = IconType.REC;
99 button.set_size_request (size, size);
100 hbox.add (button);
101 hbox.set_child_packing (button, false, false, 0, PackType.END);
103 button = new TransportButton();
104 button.icon_type = IconType.FAST_BACKWARD;
105 button.set_size_request (size, size);
106 hbox.add (button);
107 hbox.set_child_packing (button, false, false, 0, PackType.END);
109 button = new TransportButton();
110 button.icon_type = IconType.FAST_FORWARD;
111 button.set_size_request (size, size);
112 hbox.add (button);
113 hbox.set_child_packing (button, false, false, 0, PackType.END);
115 button = new TransportButton();
116 button.icon_type = IconType.TO_START;
117 button.set_size_request (size, size);
118 hbox.add (button);
119 hbox.set_child_packing (button, false, false, 0, PackType.END);
121 button = new TransportButton();
122 button.icon_type = IconType.TO_END;
123 button.set_size_request (size, size);
124 hbox.add (button);
125 hbox.set_child_packing (button, false, false, 0, PackType.END);
127 vbox.add (hbox);
130 window.add (vbox);
132 window.destroy.connect(Gtk.main_quit);
133 window.show_all ();
134 Gtk.main ();
135 return 0;
139 } // namespace Prolooks