[balsa/61-citation-bars] balsa-mime-widget-text: Hide quote prefix



commit 907cc3f5e368af11b53d444f5e504f2e51d8b6b7
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Sun Oct 10 17:49:27 2021 -0400

    balsa-mime-widget-text: Hide quote prefix
    
    Revert the previous commit and try a different approach. As Albrecht pointed out at
    https://gitlab.gnome.org/GNOME/balsa/-/merge_requests/45#note_1286766, it resulted
    in copied text not containing the quoting prefix, which is an undesirable change
    in behavior.
    
    We can fix the problem by using gtk_text_view_get_line_yrange() instead of
    gtk_text_view_get_iter_location(). The former looks across the whole line, whereas
    the latter looks at only a single character; if it is one that has been made smaller
    to hide it, the location and height are not what we want.

 src/balsa-mime-widget-text.c | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)
---
diff --git a/src/balsa-mime-widget-text.c b/src/balsa-mime-widget-text.c
index 930cf4a1d..9a5a81987 100644
--- a/src/balsa-mime-widget-text.c
+++ b/src/balsa-mime-widget-text.c
@@ -150,6 +150,7 @@ struct _BalsaMimeWidgetText {
     GList               *cite_bar_list;
     gint                 cite_bar_dimension;
     gint                 phrase_hl;
+    GtkTextTag          *invisible;
 };
 
 G_DEFINE_TYPE(BalsaMimeWidgetText, balsa_mime_widget_text, BALSA_TYPE_MIME_WIDGET)
@@ -977,8 +978,7 @@ draw_cite_bar_real(gpointer data, gpointer user_data)
     GtkTextView * view;
     GtkTextBuffer * buffer;
     gint dimension;
-    GdkRectangle location;
-    gint x_pos;
+    gint buffer_y;
     gint y_pos;
     gint height;
 
@@ -997,14 +997,14 @@ draw_cite_bar_real(gpointer data, gpointer user_data)
     }
 
     /* get the locations */
-    gtk_text_view_get_iter_location(view, &bar->start_iter, &location);
+    gtk_text_view_get_line_yrange(view, &bar->start_iter, &buffer_y, NULL);
     gtk_text_view_buffer_to_window_coords(view, GTK_TEXT_WINDOW_TEXT,
-                                          location.x, location.y,
-                                          &x_pos, &y_pos);
-    gtk_text_view_get_iter_location(view, &bar->end_iter, &location);
+                                          0, buffer_y,
+                                          NULL, &y_pos);
+    gtk_text_view_get_line_yrange(view, &bar->end_iter, &buffer_y, NULL);
     gtk_text_view_buffer_to_window_coords(view, GTK_TEXT_WINDOW_TEXT,
-                                          location.x, location.y,
-                                          &x_pos, &height);
+                                          0, buffer_y,
+                                          NULL, &height);
     height -= y_pos;
 
     /* add a new widget if necessary */
@@ -1411,7 +1411,6 @@ fill_text_buf_cited(BalsaMimeWidgetText *mwt,
     GdkScreen *screen;
     GtkTextBuffer *buffer;
     GdkRGBA *rgba;
-    GtkTextTag *invisible;
     LibBalsaUrlInsertInfo url_info;
     guint cite_level;
     guint cite_start;
@@ -1440,11 +1439,11 @@ fill_text_buf_cited(BalsaMimeWidgetText *mwt,
                                NULL);
 
     if (rex != NULL) {
-        invisible = gtk_text_buffer_create_tag(buffer, "hide-cite",
-                                               "invisible", TRUE,
-                                               NULL);
+        mwt->invisible = gtk_text_buffer_create_tag(buffer, "hide-cite",
+                                                    "size-points", (gdouble) 0.0,
+                                                    NULL);
     } else {
-        invisible = NULL;
+        mwt->invisible = NULL;
     }
 
     mwt->url_list = NULL;
@@ -1497,11 +1496,12 @@ fill_text_buf_cited(BalsaMimeWidgetText *mwt,
                 gtk_text_buffer_insert_with_tags(buffer, &cite_iter,
                                                  text_body,
                                                  cite_idx,
-                                                 tag, invisible, NULL);
+                                                 tag, mwt->invisible, NULL);
                 text_body += cite_idx;
 
                 /* append a zero-width space if the remainder of the line is
-                 * empty, as otherwise the line is not visible */
+                 * empty, as otherwise the line is not visible (i.e.
+                 * completely 0.01 pts high)... */
                 if (text_body == line_end || *text_body == '\r')
                     gtk_text_buffer_insert_at_cursor(buffer, "\xE2\x80\x8B", 3);
             }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]