+
+
+static void
+on_new_mail_clicked (GtkWidget *widget, ModestUI *modest_ui)
+{
+ g_return_if_fail (modest_ui);
+ modest_ui_show_edit_window (modest_ui, "", "", "", "", "", NULL);
+}
+
+
+/* FIXME: truly evil --> we cannot really assume that
+ * there is only one edit window open...
+ */
+static void
+on_send_button_clicked (GtkWidget *widget, ModestUI *modest_ui)
+{
+ ModestTnyTransportActions *actions;
+ ModestUIPrivate *priv;
+ GtkWidget *to_entry, *subject_entry, *body_view;
+ const gchar *to, *subject;
+ gchar *body;
+ GtkTextIter start, end;
+ GtkTextBuffer *buf;
+ TnyAccountStoreIface *account_store;
+ const GList *transport_accounts;
+ TnyTransportAccountIface *transport_account;
+
+ g_return_if_fail (modest_ui);
+
+ actions = MODEST_TNY_TRANSPORT_ACTIONS
+ (modest_tny_transport_actions_new ());
+ priv = MODEST_UI_GET_PRIVATE(modest_ui);
+
+ account_store = priv->account_store;
+ transport_accounts =
+ tny_account_store_iface_get_transport_accounts (account_store);
+ if (!transport_accounts) {
+ g_message ("cannot send message: no transport account defined");
+ return;
+ } else /* take the first one! */
+ transport_account =
+ TNY_TRANSPORT_ACCOUNT_IFACE(transport_accounts->data);
+
+ to_entry = glade_xml_get_widget (priv->glade_xml, "to_entry");
+ subject_entry = glade_xml_get_widget (priv->glade_xml, "subject_entry");
+ body_view = glade_xml_get_widget (priv->glade_xml, "body_view");
+
+ to = gtk_entry_get_text (GTK_ENTRY(to_entry));
+ subject = gtk_entry_get_text (GTK_ENTRY(subject_entry));
+
+ buf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(body_view));
+ gtk_text_buffer_get_bounds (buf, &start, &end);
+ body = gtk_text_buffer_get_text (buf, &start, &end, FALSE);
+
+ g_message ("sending %s ==> %s", subject, to);
+ modest_tny_transport_actions_send_message (actions,
+ transport_account,
+ "dirk-jan.binnema@nokia.com",
+ to, "", "", subject,
+ body);
+ g_free (body);
+ g_object_unref (G_OBJECT(actions));
+
+ gtk_entry_set_text (GTK_ENTRY(to_entry), "");
+ gtk_entry_set_text (GTK_ENTRY(subject_entry), "");
+ gtk_text_buffer_set_text (buf, "", 0);
+
+ gtk_widget_hide (glade_xml_get_widget (priv->glade_xml, "new_mail"));
+}