From d5531e7a10d8058db8850a5ebe6054bfcb0f6df3 Mon Sep 17 00:00:00 2001 From: Philipp Zabel Date: Mon, 3 May 2010 18:47:55 +0200 Subject: [PATCH] Add E-mail button --- src/adac-mitfahrclub.vala | 3 ++- src/lift-detail-window.vala | 42 +++++++++++++++++++++++++++++++++++++++--- src/lift-list-window.vala | 2 +- 3 files changed, 42 insertions(+), 5 deletions(-) diff --git a/src/adac-mitfahrclub.vala b/src/adac-mitfahrclub.vala index b359e05..a9a8ace 100644 --- a/src/adac-mitfahrclub.vala +++ b/src/adac-mitfahrclub.vala @@ -62,6 +62,7 @@ public class Lift : Object { public string phone; public string phone2; public string email; + public string email_image_uri; public string description; public string modified; @@ -417,7 +418,7 @@ public class AdacMitfahrclub { if (n2->children->name == "img") { // FIXME: email image - // n2->children->get_prop ("src")) + lift.email_image_uri = n2->children->get_prop ("src"); continue; } diff --git a/src/lift-detail-window.vala b/src/lift-detail-window.vala index 163da15..346b1fc 100644 --- a/src/lift-detail-window.vala +++ b/src/lift-detail-window.vala @@ -38,6 +38,7 @@ public class LiftDetailWindow : StackableWindow { Label label_driver; OssoABook.Button button_phone; OssoABook.Button button_sms; + OssoABook.Button button_email; Image image_smoke; Label label; Label label_changed; @@ -88,7 +89,7 @@ public class LiftDetailWindow : StackableWindow { hbox.pack_start (button_route, true, true, 0); hbox.pack_start (image_eventbox, false, false, MARGIN_DEFAULT); - table = new Table (6, 2, false); + table = new Table (7, 2, false); button_calendar = new OssoABook.Button (SizeType.FINGER_HEIGHT); button_calendar.set_icon_name ("general_calendar"); @@ -109,6 +110,11 @@ public class LiftDetailWindow : StackableWindow { button_sms.set_icon_visible (true); button_sms.title = _("SMS"); + button_email = new OssoABook.Button (SizeType.FINGER_HEIGHT); + button_email.set_icon_name ("general_email"); + button_email.set_icon_visible (true); + button_email.title = _("E-mail"); + label = new Label (""); label.set_alignment (0.0f, 0.5f); label.set_line_wrap (true); @@ -123,14 +129,16 @@ public class LiftDetailWindow : StackableWindow { table.attach (label_driver, 0, 2, 1, 2, AttachOptions.FILL | AttachOptions.EXPAND, AttachOptions.FILL, MARGIN_DEFAULT, 0); table.attach (button_phone, 0, 2, 2, 3, AttachOptions.FILL | AttachOptions.EXPAND, AttachOptions.FILL, 0, 0); table.attach (button_sms, 0, 2, 3, 4, AttachOptions.FILL | AttachOptions.EXPAND, AttachOptions.FILL, 0, 0); + table.attach (button_email, 0, 2, 4, 5, AttachOptions.FILL | AttachOptions.EXPAND, AttachOptions.FILL, 0, 0); } else { table.attach (button_calendar, 1, 2, 0, 1, AttachOptions.FILL | AttachOptions.EXPAND, AttachOptions.FILL, 0, 0); table.attach (label_driver, 0, 1, 1, 2, AttachOptions.FILL | AttachOptions.EXPAND, AttachOptions.FILL, MARGIN_DEFAULT, 0); table.attach (button_phone, 1, 2, 1, 2, AttachOptions.FILL | AttachOptions.EXPAND, AttachOptions.FILL, 0, 0); table.attach (button_sms, 1, 2, 2, 3, AttachOptions.FILL | AttachOptions.EXPAND, AttachOptions.FILL, 0, 0); + table.attach (button_email, 1, 2, 3, 4, AttachOptions.FILL | AttachOptions.EXPAND, AttachOptions.FILL, 0, 0); } - table.attach (label, 0, 2, 4, 5, AttachOptions.FILL | AttachOptions.EXPAND, AttachOptions.FILL, MARGIN_DEFAULT, 0); - table.attach (label_changed, 0, 2, 5, 6, AttachOptions.FILL | AttachOptions.EXPAND, AttachOptions.FILL, MARGIN_DEFAULT, 0); + table.attach (label, 0, 2, 5, 6, AttachOptions.FILL | AttachOptions.EXPAND, AttachOptions.FILL, MARGIN_DEFAULT, 0); + table.attach (label_changed, 0, 2, 6, 7, AttachOptions.FILL | AttachOptions.EXPAND, AttachOptions.FILL, MARGIN_DEFAULT, 0); vbox.pack_start (hbox, true, true, 0); vbox.pack_start (table, true, true, 0); @@ -139,6 +147,7 @@ public class LiftDetailWindow : StackableWindow { alignment.add (pannable); alignment.show_all (); + button_email.hide (); add (alignment); BeifahrerProgram.orientation.changed.connect (on_orientation_changed); @@ -148,6 +157,7 @@ public class LiftDetailWindow : StackableWindow { button_calendar.clicked.connect (on_button_calendar_clicked); button_phone.clicked.connect (on_button_phone_clicked); button_sms.clicked.connect (on_button_sms_clicked); + button_email.clicked.connect (on_button_email_clicked); destroy.connect (on_destroy); map_event.connect (on_map_event); } @@ -186,6 +196,11 @@ public class LiftDetailWindow : StackableWindow { button_sms.value = phone_number; } + if (lift.email_image_uri != null) { + button_email.value = _("Click to view E-mail image"); + button_email.show (); + } + string lift_text = _("Free places: %d\n").printf (lift.places); lift_text += (lift.price != null) ? _("Price: %s\n").printf (lift.price) : _("(no price given)\n"); if (LiftFlags.SMOKER in lift.flags) try { @@ -294,6 +309,24 @@ public class LiftDetailWindow : StackableWindow { } } + void on_button_email_clicked () { + var uri = "http://mitfahrclub.adac.de"; + uri += lift.email_image_uri; + try { + var action = URIAction.get_default_action_by_uri (uri); + if (action != null) { + action.open (uri); + } else { + + Banner.show_information (this, null, _("Couldn't open %s URI").printf (uri)); + } + } catch (Error e) { + if (e is URIError) { + Banner.show_information (this, null, _("Error: %s").printf (e.message)); + } + } + } + void on_add_contact_clicked () { var contact = new OssoABook.Contact (); var attr_fn = new E.VCardAttribute (null, E.EVC_FN); @@ -347,16 +380,19 @@ public class LiftDetailWindow : StackableWindow { table.remove (label_driver); table.remove (button_phone); table.remove (button_sms); + table.remove (button_email); if (BeifahrerProgram.orientation.portrait) { table.attach (button_calendar, 0, 2, 0, 1, AttachOptions.FILL | AttachOptions.EXPAND, AttachOptions.FILL, 0, 0); table.attach (label_driver, 0, 2, 1, 2, AttachOptions.FILL | AttachOptions.EXPAND, AttachOptions.FILL, MARGIN_DEFAULT, 0); table.attach (button_phone, 0, 2, 2, 3, AttachOptions.FILL | AttachOptions.EXPAND, AttachOptions.FILL, 0, 0); table.attach (button_sms, 0, 2, 3, 4, AttachOptions.FILL | AttachOptions.EXPAND, AttachOptions.FILL, 0, 0); + table.attach (button_email, 0, 2, 4, 5, AttachOptions.FILL | AttachOptions.EXPAND, AttachOptions.FILL, 0, 0); } else { table.attach (button_calendar, 1, 2, 0, 1, AttachOptions.FILL | AttachOptions.EXPAND, AttachOptions.FILL, 0, 0); table.attach (label_driver, 0, 1, 1, 2, AttachOptions.FILL | AttachOptions.EXPAND, AttachOptions.FILL, MARGIN_DEFAULT, 0); table.attach (button_phone, 1, 2, 1, 2, AttachOptions.FILL | AttachOptions.EXPAND, AttachOptions.FILL, 0, 0); table.attach (button_sms, 1, 2, 2, 3, AttachOptions.FILL | AttachOptions.EXPAND, AttachOptions.FILL, 0, 0); + table.attach (button_email, 1, 2, 3, 4, AttachOptions.FILL | AttachOptions.EXPAND, AttachOptions.FILL, 0, 0); } } } diff --git a/src/lift-list-window.vala b/src/lift-list-window.vala index 59831b5..6cf87c3 100644 --- a/src/lift-list-window.vala +++ b/src/lift-list-window.vala @@ -171,7 +171,7 @@ public class LiftListWindow : StackableWindow { model.get (iter, 5, out lift); var window = new LiftDetailWindow (adac, lift); - window.show_all (); + window.show (); } } -- 1.7.9.5