* began work on quoting html messages. I use an ugly hack to get the text from the...
authorArne Zellentin <arne@kernelconcepts.de>
Fri, 26 May 2006 12:38:55 +0000 (12:38 +0000)
committerArne Zellentin <arne@kernelconcepts.de>
Fri, 26 May 2006 12:38:55 +0000 (12:38 +0000)
pmo-trunk-r116

src/gtk-glade/modest-ui.c
src/modest-tny-msg-view.c
src/modest-tny-msg-view.h

index 5bcf1e2..219be19 100644 (file)
@@ -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;
index 9bb4944..5cc8f63 100644 (file)
@@ -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"));
 }
-
-
-
index 3f53c0e..6dfa856 100644 (file)
@@ -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__ */
-