From 930220a904e260345f8b6ab7d65d6ec61076d9bf Mon Sep 17 00:00:00 2001 From: Arne Zellentin Date: Fri, 26 May 2006 12:38:55 +0000 Subject: [PATCH] * began work on quoting html messages. I use an ugly hack to get the text from the GtkHTML; I need help to do it right. -> mailing list pmo-trunk-r116 --- src/gtk-glade/modest-ui.c | 10 +++++- src/modest-tny-msg-view.c | 78 +++++++++++++++++++++++++++++++++++++++++++-- src/modest-tny-msg-view.h | 3 +- 3 files changed, 86 insertions(+), 5 deletions(-) diff --git a/src/gtk-glade/modest-ui.c b/src/gtk-glade/modest-ui.c index 5bcf1e2..219be19 100644 --- a/src/gtk-glade/modest-ui.c +++ b/src/gtk-glade/modest-ui.c @@ -718,6 +718,7 @@ modest_ui_reply_to_msg (ModestUI *modest_ui, TnyMsgHeaderIface *header, const TnyMsgFolderIface *folder; GString *re_sub; const gchar *subject, *from; + GtkTextBuffer *unquoted; gchar *quoted; time_t sent_date; @@ -740,7 +741,14 @@ modest_ui_reply_to_msg (ModestUI *modest_ui, TnyMsgHeaderIface *header, /* FIXME: honor replyto, cc */ from = tny_msg_header_iface_get_from(header); sent_date = tny_msg_header_iface_get_date_sent(header); - quoted = modest_ui_quote_msg(msg, from, sent_date); + + unquoted = modest_tny_msg_view_get_selected(msg_view); + + if (unquoted != NULL) { + quoted = modest_text_utils_quote (unquoted, from, sent_date, 66); + } else { + quoted = modest_ui_quote_msg(msg, from, sent_date); + } } else { g_warning("no header"); return; diff --git a/src/modest-tny-msg-view.c b/src/modest-tny-msg-view.c index 9bb4944..5cc8f63 100644 --- a/src/modest-tny-msg-view.c +++ b/src/modest-tny-msg-view.c @@ -509,7 +509,82 @@ set_text_message (ModestTnyMsgView *self, TnyMsgMimePartIface *tny_body) return TRUE; } +/* WIP (az), unused */ +char * +get_all_text(ModestTnyMsgView *self) +{ + GtkWidget *html; + ModestTnyMsgViewPrivate *priv; + GSList *list; + GString *str = g_string_new (""); + gchar *ptr; + gint id = 0; + GObject *obj; + //HtmlBoxText *text; + + g_return_if_fail (self); + priv = MODEST_TNY_MSG_VIEW_GET_PRIVATE(self); + html = priv->gtkhtml; + + //list = view->sel_list; + + //if (view->sel_list == NULL) + // return NULL; + + while (obj = gtk_html_get_object_by_id(GTK_HTML(html), id)) { + //text = HTML_BOX_TEXT (obj->data); + + //list = list->next; + /* + * Some boxes may not have any text + */ + //if (text->canon_text == NULL) + // continue; + //ptr = (gchar *)text->canon_text; + //g_string_append_len (str, ptr, text->length); + printf("obj#%d\n", id); + id++; + + } + ptr = str->str; + g_string_free (str, FALSE); + return ptr; +} + + +GtkTextBuffer * +modest_tny_msg_view_get_selected (ModestTnyMsgView *self) +{ + ModestTnyMsgViewPrivate *priv; + gchar *sel; + GtkWidget *html; + int len; + GtkClipboard *clip; + gchar *text; + GtkTextBuffer *buf; + + g_return_if_fail (self); + priv = MODEST_TNY_MSG_VIEW_GET_PRIVATE(self); + html = priv->gtkhtml; + + /* I'm sure there is a better way to check for selected text */ + sel = gtk_html_get_selection_html(GTK_HTML(html), &len); + + /* and I hope we can get rid of this hack soon: */ + if (sel == NULL) + gtk_html_select_all(GTK_HTML(html)); + + clip = gtk_widget_get_clipboard(html, GDK_SELECTION_PRIMARY); + text = gtk_clipboard_wait_for_text(clip); + if (text == NULL) + return NULL; + + buf = gtk_text_buffer_new(NULL); + gtk_text_buffer_set_text(buf, text, -1); + g_free(text); + return buf; +} void modest_tny_msg_view_set_message (ModestTnyMsgView *self, TnyMsgIface *msg) @@ -544,6 +619,3 @@ modest_tny_msg_view_set_message (ModestTnyMsgView *self, TnyMsgIface *msg) fill_gtkhtml_with_txt (GTK_HTML(priv->gtkhtml), _("Unsupported message type")); } - - - diff --git a/src/modest-tny-msg-view.h b/src/modest-tny-msg-view.h index 3f53c0e..6dfa856 100644 --- a/src/modest-tny-msg-view.h +++ b/src/modest-tny-msg-view.h @@ -65,8 +65,9 @@ GtkWidget* modest_tny_msg_view_new (TnyMsgIface *tny_msg); * */ void modest_tny_msg_view_set_message (ModestTnyMsgView *self, TnyMsgIface *tny_msg); + +GtkTextBuffer * modest_tny_msg_view_get_selected (ModestTnyMsgView *self); G_END_DECLS #endif /* __MODEST_TNY_MSG_VIEW_H__ */ - -- 1.7.9.5