Initial commit
[fillmore] / src / fillmore / trackinformation.vala
1 /* Copyright 2009 Yorba Foundation
2  *
3  * This software is licensed under the GNU Lesser General Public License
4  * (version 2.1 or later).  See the COPYING file in this distribution. 
5  */
6
7 namespace UI {
8     class TrackInformation : Hildon.Dialog {
9
10         Hildon.Entry entry;
11
12         construct {
13             set_title("New Track");
14             set_modal(true);
15             add_buttons(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
16                         Gtk.STOCK_OK, Gtk.ResponseType.OK,
17                         null);
18             Gtk.Label label = new Gtk.Label("Track name:");
19             entry = new Hildon.Entry(Hildon.SizeType.HALFSCREEN_WIDTH | Hildon.SizeType.FINGER_HEIGHT);
20             entry.set_activates_default(true);
21             entry.changed.connect(on_entry_changed);
22
23             Gtk.Table table = new Gtk.Table(1, 2, false);
24             table.attach_defaults(label, 0, 1, 0, 1);
25             table.attach_defaults(entry, 1, 2, 0, 1);
26             table.set_col_spacing(0, 12);
27             table.set_border_width(12);
28
29             vbox.pack_start(table, true, true, 0);
30             show_all();
31             set_default_response(Gtk.ResponseType.OK);
32         }
33
34         public void set_track_name(string new_name) {
35             entry.set_text(new_name);
36             entry.select_region(0, -1);
37         }
38
39         public string get_track_name() {
40             return entry.get_text().strip();
41         }
42
43         private void on_entry_changed() {
44             bool is_valid = get_track_name().length > 0;
45             set_response_sensitive(Gtk.ResponseType.OK, is_valid);
46         }
47     }
48 }