From 66eb6b3842cd4288e6835b5fd7d3e4ca83401b10 Mon Sep 17 00:00:00 2001 From: Philipp Zabel Date: Sat, 1 May 2010 10:57:40 +0200 Subject: [PATCH] Add a switch button to exchange points of arrival and departure --- src/query-window.vala | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/query-window.vala b/src/query-window.vala index 8756b70..3ec6488 100644 --- a/src/query-window.vala +++ b/src/query-window.vala @@ -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); -- 1.7.9.5