[balsa] mime: Remove unused libbalsa_wrap_view()
- From: Peter Bloomfield <peterb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [balsa] mime: Remove unused libbalsa_wrap_view()
- Date: Thu, 14 Apr 2022 14:38:01 +0000 (UTC)
commit 72069366cdf99cd7d4006f2ae5d585b5c658bf73
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date: Thu Apr 14 10:32:38 2022 -0400
mime: Remove unused libbalsa_wrap_view()
modified: libbalsa/mime.c
modified: libbalsa/misc.h
libbalsa/mime.c | 148 --------------------------------------------------------
libbalsa/misc.h | 1 -
2 files changed, 149 deletions(-)
---
diff --git a/libbalsa/mime.c b/libbalsa/mime.c
index 1abf4b18e..fae3d3918 100644
--- a/libbalsa/mime.c
+++ b/libbalsa/mime.c
@@ -471,144 +471,6 @@ libbalsa_wrap_rfc2646(gchar * par, gint width, gboolean from_screen,
return g_string_free(result, FALSE);
}
-/*
- * libbalsa_wrap_view(GtkTextView * view, gint length)
- *
- * Wrap the text in a GtkTextView to the given line length.
- */
-
-/* Forward references: */
-static GtkTextTag *get_quote_tag(GtkTextIter * iter);
-static gint get_quote_depth(GtkTextIter * iter, gchar ** quote_string);
-static gchar *get_line(GtkTextBuffer * buffer, GtkTextIter * iter);
-static gboolean is_in_url(GtkTextIter * iter, gint offset,
- GtkTextTag * url_tag);
-
-void
-libbalsa_wrap_view(GtkTextView * view, gint length)
-{
- GtkTextBuffer *buffer = gtk_text_view_get_buffer(view);
- GtkTextTagTable *table = gtk_text_buffer_get_tag_table(buffer);
- GtkTextTag *url_tag = gtk_text_tag_table_lookup(table, "url");
- GtkTextIter iter;
- PangoContext *context = gtk_widget_get_pango_context(GTK_WIDGET(view));
- PangoLanguage *language = pango_context_get_language(context);
- PangoLogAttr *log_attrs = NULL;
-
- gtk_text_buffer_get_start_iter(buffer, &iter);
-
- /* Loop over original lines. */
- while (!gtk_text_iter_is_end(&iter)) {
- GtkTextTag *quote_tag;
- gchar *quote_string;
- gint quote_len;
-
- quote_tag = get_quote_tag(&iter);
- quote_len = get_quote_depth(&iter, "e_string);
- if (quote_string) {
- if (quote_string[quote_len])
- quote_len++;
- else {
- gchar *tmp = g_strconcat(quote_string, " ", NULL);
- g_free(quote_string);
- quote_string = tmp;
- }
- }
-
- /* Loop over breaks within the original line. */
- while (!gtk_text_iter_ends_line(&iter)) {
- gchar *line;
- gint num_chars;
- gint attrs_len;
- gint offset;
- gint len;
- gint brk_offset = 0;
- gunichar c = 0;
- gboolean in_space = FALSE;
-
- line = get_line(buffer, &iter);
- num_chars = g_utf8_strlen(line, -1);
- attrs_len = num_chars + 1;
- log_attrs = g_renew(PangoLogAttr, log_attrs, attrs_len);
- pango_get_log_attrs(line, -1, -1, language, log_attrs, attrs_len);
- g_free(line);
-
- for (len = offset = quote_len;
- len < length && offset < num_chars; offset++) {
- gtk_text_iter_set_line_offset(&iter, offset);
- c = gtk_text_iter_get_char(&iter);
- if (c == '\t')
- len = ((len + 8) / 8) * 8;
- else if (g_unichar_isprint(c))
- len++;
-
- if (log_attrs[offset].is_line_break
- && !is_in_url(&iter, offset, url_tag))
- brk_offset = offset;
- }
-
- if (len < length)
- break;
-
- in_space = g_unichar_isspace(c);
- if (brk_offset > quote_len && !in_space)
- /* Break at the last break we saw. */
- gtk_text_iter_set_line_offset(&iter, brk_offset);
- else {
- GtkTextIter start = iter;
- /* Break at the next line break. */
- if (offset <= quote_len)
- offset = quote_len + 1;
- while (offset < num_chars
- && (is_in_url(&iter, offset, url_tag)
- || !log_attrs[offset].is_line_break))
- offset++;
-
- if (offset >= num_chars)
- /* No next line break. */
- break;
-
- /* Trim extra trailing whitespace */
- gtk_text_iter_forward_char(&start);
- gtk_text_buffer_delete(buffer, &start, &iter);
- }
-
- gtk_text_buffer_insert(buffer, &iter, "\n", 1);
- if (quote_string)
- gtk_text_buffer_insert_with_tags(buffer, &iter,
- quote_string, -1,
- quote_tag, NULL);
- }
- g_free(quote_string);
- gtk_text_iter_forward_line(&iter);
- }
- g_free(log_attrs);
-}
-
-/* Find the quote tag, if any, at iter; doesn't move iter; returns tag
- * or NULL. */
-static GtkTextTag *
-get_quote_tag(GtkTextIter * iter)
-{
- GtkTextTag *quote_tag = NULL;
- GSList *list;
- GSList *tag_list = gtk_text_iter_get_tags(iter);
-
- for (list = tag_list; list; list = list->next) {
- GtkTextTag *tag = list->data;
- gchar *name;
- g_object_get(tag, "name", &name, NULL);
- if (name) {
- if (!strncmp(name, "quote-", 6))
- quote_tag = tag_list->data;
- g_free(name);
- }
- }
- g_slist_free(tag_list);
-
- return quote_tag;
-}
-
/* Move the iter over a string of consecutive '>' characters, and an
* optional ' ' character; returns the number of '>'s, and, if
* quote_string is not NULL, stores an allocated copy of the string
@@ -653,16 +515,6 @@ get_line(GtkTextBuffer * buffer, GtkTextIter * iter)
return gtk_text_buffer_get_slice(buffer, iter, &end, TRUE);
}
-/* Move the iter to position offset in the current line, and test
- * whether it's in an URL. */
-static gboolean
-is_in_url(GtkTextIter * iter, gint offset, GtkTextTag * url_tag)
-{
- gtk_text_iter_set_line_offset(iter, offset);
- return url_tag ? (gtk_text_iter_has_tag(iter, url_tag)
- && !gtk_text_iter_starts_tag(iter, url_tag)) : FALSE;
-}
-
/* Remove soft newlines and associated quote strings from num_paras
* paragraphs in the buffer, starting at the line before iter; if
* num_paras < 0, process the whole buffer. */
diff --git a/libbalsa/misc.h b/libbalsa/misc.h
index bbc7f9dbe..7ef58b576 100644
--- a/libbalsa/misc.h
+++ b/libbalsa/misc.h
@@ -104,7 +104,6 @@ GString *libbalsa_process_text_rfc2646(gchar * par, gint width,
gchar *libbalsa_wrap_rfc2646(gchar * par, gint width,
gboolean from_screen, gboolean to_screen,
gboolean delsp);
-void libbalsa_wrap_view(GtkTextView * view, gint length);
void libbalsa_unwrap_buffer(GtkTextBuffer * buffer, GtkTextIter * iter,
gint lines);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]