Add a switch button to exchange points of arrival and departure
authorPhilipp Zabel <philipp.zabel@gmail.com>
Sat, 1 May 2010 08:57:40 +0000 (10:57 +0200)
committerPhilipp Zabel <philipp.zabel@gmail.com>
Sat, 1 May 2010 09:04:56 +0000 (11:04 +0200)
src/query-window.vala

index 8756b70..3ec6488 100644 (file)
@@ -67,7 +67,7 @@ public class QueryWindow : StackableWindow {
                for (int days = 0; days <= 4; days += 1)
                        tolerance_selector.append_text (_("+/- %d days").printf (days));
 
-               var table = new Table (4, 2, false);
+               var table = new Table (5, 2, false);
 
                var button = new PickerButton (SizeType.FINGER_HEIGHT,
                                               ButtonArrangement.VERTICAL);
@@ -111,10 +111,15 @@ public class QueryWindow : StackableWindow {
                button.set_alignment (0.0f, 0.0f, 0.5f, 0.5f);
                table.attach (button, 1, 2, 1, 2, AttachOptions.FILL, AttachOptions.FILL, 0, 0);
 
+               var switch_button = new Gtk.Button.with_label (_("Switch departure and arrival"));
+               Hildon.gtk_widget_set_theme_size (switch_button, SizeType.FINGER_HEIGHT);
+               switch_button.set_alignment (0.0f, 0.5f);
+               table.attach (switch_button, 0, 1, 2, 3, AttachOptions.FILL, AttachOptions.FILL, 0, 0);
+
                date = new DateButton (SizeType.FINGER_HEIGHT,
                                       ButtonArrangement.VERTICAL);
                date.set_alignment (0.0f, 0.0f, 0.5f, 0.5f);
-               table.attach (date, 0, 1, 2, 3, AttachOptions.FILL | AttachOptions.EXPAND, AttachOptions.FILL, 0, 0);
+               table.attach (date, 0, 1, 3, 4, AttachOptions.FILL | AttachOptions.EXPAND, AttachOptions.FILL, 0, 0);
 
                button = new PickerButton (SizeType.FINGER_HEIGHT,
                                           ButtonArrangement.VERTICAL);
@@ -122,14 +127,15 @@ public class QueryWindow : StackableWindow {
                button.set_title (_("Tolerance"));
                button.set_value (_("+/- 0 days"));
                button.set_alignment (0.0f, 0.0f, 0.5f, 0.5f);
-               table.attach (button, 1, 2, 2, 3, AttachOptions.FILL, AttachOptions.FILL, 0, 0);
+               table.attach (button, 1, 2, 3, 4, AttachOptions.FILL, AttachOptions.FILL, 0, 0);
 
                var search_button = new Gtk.Button.with_label (_("Search"));
                Hildon.gtk_widget_set_theme_size (search_button, SizeType.FINGER_HEIGHT);
-               table.attach (search_button, 0, 2, 3, 4, AttachOptions.FILL, AttachOptions.FILL, 0, 0);
+               table.attach (search_button, 0, 2, 4, 5, AttachOptions.FILL, AttachOptions.FILL, 0, 0);
 
                add (table);
 
+               switch_button.clicked.connect (on_switch_button_clicked);
                search_button.clicked.connect (on_search_button_clicked);
                settings.clicked.connect (on_settings_clicked);
 
@@ -244,6 +250,16 @@ public class QueryWindow : StackableWindow {
                window.find_lifts.begin (city_from, city_to, date, tolerance);
        }
 
+       // Switch departure and arrival
+       void on_switch_button_clicked () {
+               int n = city_from_selector.get_active (0);
+               city_from_selector.set_active (0, city_to_selector.get_active (0));
+               city_to_selector.set_active (0, n);
+               n = umkreis_from_selector.get_active (0);
+               umkreis_from_selector.set_active (0, umkreis_to_selector.get_active (0));
+               umkreis_to_selector.set_active (0, n);
+       }
+
        void on_settings_clicked () {
                var dialog = new SettingsDialog (this);
                dialog.response.connect (on_settings_response);