1 /* This file is part of Beifahrer.
3 * Copyright (C) 2010 Philipp Zabel
5 * Beifahrer is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * Beifahrer is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with Beifahrer. If not, see <http://www.gnu.org/licenses/>.
22 public class OfferEditDialog : Gtk.Dialog {
23 TimeButton time_button;
24 DateButton date_button;
25 CityButton departure_button;
26 CityButton arrival_button;
27 Hildon.TextView comment_entry;
28 Hildon.CheckButton cell;
29 Hildon.CheckButton phone;
30 Hildon.CheckButton email;
32 public OfferEditDialog (Gtk.Window window, AdacMitfahrclub adac, Lift lift) {
33 set_title (_("Edit offer"));
34 set_transient_for (window);
36 var vbox = (VBox) get_content_area ();
37 vbox.set_size_request (-1, 5*70);
38 var pannable = new PannableArea ();
39 vbox.pack_start (pannable, true, true, 0);
40 vbox = new Gtk.VBox (false, 0);
41 pannable.add_with_viewport (vbox);
43 var title_size = new SizeGroup (SizeGroupMode.HORIZONTAL);
45 time_button = new Hildon.TimeButton (SizeType.FINGER_HEIGHT, ButtonArrangement.HORIZONTAL);
46 time_button.add_title_size_group (title_size);
47 time_button.set_alignment (0.0f, 0.5f, 0.5f, 0.5f);
48 time_button.set_time (lift.time.hour, lift.time.minute);
49 date_button = new Hildon.DateButton (SizeType.FINGER_HEIGHT, ButtonArrangement.HORIZONTAL);
50 date_button.add_title_size_group (title_size);
51 date_button.set_alignment (0.0f, 0.5f, 0.5f, 0.5f);
52 date_button.set_date (lift.time.year, lift.time.month - DateMonth.JANUARY, lift.time.day);
53 departure_button = new CityButton (SizeType.FINGER_HEIGHT, ButtonArrangement.HORIZONTAL, adac.get_city_list (), false);
54 departure_button.set_title (_("Departure"));
55 departure_button.set_value (_("Please select"));
56 departure_button.add_title_size_group (title_size);
57 departure_button.set_alignment (0.0f, 0.5f, 0.5f, 0.5f);
58 departure_button.set_city (lift.city_from);
59 arrival_button = new CityButton (SizeType.FINGER_HEIGHT, ButtonArrangement.HORIZONTAL, adac.get_city_list (), false);
60 arrival_button.set_title (_("Arrival"));
61 arrival_button.set_value (_("Please select"));
62 arrival_button.add_title_size_group (title_size);
63 arrival_button.set_alignment (0.0f, 0.5f, 0.5f, 0.5f);
64 arrival_button.set_city (lift.city_to);
66 var comment_hbox = new Gtk.HBox (false, Hildon.MARGIN_DOUBLE);
67 var comment_label = new Label (_("Comment"));
68 comment_label.set_alignment (0.0f, 0.5f);
69 title_size.add_widget (comment_label);
70 comment_entry = new Hildon.TextView (); // 1000 chars
71 comment_entry.set_wrap_mode (Gtk.WrapMode.WORD_CHAR);
72 cell = new Hildon.CheckButton (SizeType.FINGER_HEIGHT);
73 cell.set_label (_("Show cell number"));
74 phone = new Hildon.CheckButton (SizeType.FINGER_HEIGHT);
75 phone.set_label (_("Show phone number"));
76 email = new Hildon.CheckButton (SizeType.FINGER_HEIGHT);
77 email.set_label (_("Show E-mail address"));
79 comment_hbox.pack_start (comment_label, false, false, 0);
80 comment_hbox.pack_start (comment_entry, true, true, 0);
82 vbox.pack_start (time_button, true, true, 0);
83 vbox.pack_start (date_button, true, true, 0);
84 vbox.pack_start (departure_button, true, true, 0);
85 vbox.pack_start (arrival_button, true, true, 0);
86 vbox.pack_start (comment_hbox, true, false, 0);
87 vbox.pack_start (cell, true, true, 0);
88 vbox.pack_start (phone, true, true, 0);
89 vbox.pack_start (email, true, true, 0);
92 add_button (_("Save"), ResponseType.APPLY);
94 response.connect (on_response);
97 void on_response (int response_id) {
98 if (response_id == ResponseType.APPLY) try {