<html><head></head><body style="zoom: 0%;"><div dir="auto">Nice feature 👍<br><br></div>
<div dir="auto"><!-- tmjah_g_1299s -->Hent <!-- tmjah_g_1299e --><a href="https://bluemail.me"><!-- tmjah_g_1299s -->BlueMail til Android<!-- tmjah_g_1299e --></a><!-- tmjah_g_1299s --> <!-- tmjah_g_1299e --></div>
<div class="gmail_quote" >Den 8. sep. 2021, fra 14.08, <a href="mailto:wwp@claws-mail.org" target="_blank">wwp@claws-mail.org</a> skrev:<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<pre class="blue">The branch, gtk3 has been updated<br> via d4e2645d82e74b9a24c34ec2edb2430529ef4354 (commit)<br> from 2478af427a8a8e95cdd4562d4403aea4ef7a1807 (commit)<br><br>Summary of changes:<br> src/textview.c | 197 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--<br> 1 file changed, 190 insertions(+), 7 deletions(-)<br><br><br>- Log<hr><br>commit d4e2645d82e74b9a24c34ec2edb2430529ef4354<br>Author: wwp <subscript@free.fr><br>Date: Wed Sep 8 14:08:27 2021 +0200<br><br> Allow zooming in/out a message body text view. Zoom level is applied to<br> any further message viewed, and reset at next start-up. Only applies to<br> text font. Zoom is changed by using CTRL+mouse wheel up/down, or with<br> text view's right-click menu.<br><br>diff --git a/src/textview.c b/src/textview.c<br>index cf33d779d..5fb20e858 100644<br>--- a/src/textview.c<br>+++ b/src/textview.c<br>@@ -118,6 +118,18 @@ static GdkCursor *hand_cursor = NULL;<br> static GdkCursor *text_cursor = NULL;<br> static GdkCursor *watch_cursor= NULL;<br> <br>+#define TEXTVIEW_FONT_SIZE_STEP 15 /* pango font zoom level change granularity in % */<br>+#define TEXTVIEW_FONT_SIZE_MIN -75 /* this gives 5 zoom out steps at 15% */<br>+#define TEXTVIEW_FONT_SIZE_MAX 3100 /* this gives 200 zoom in steps at 15% */<br>+#define TEXTVIEW_FONT_SIZE_UNSET -666 /* default value when unset (must be lower than TEXTVIEW_FONT_SIZE_MIN */<br>+<br>+/* font size in session (will apply to next message views we open */<br>+/* must be lower than TEXTVIEW_FONT_SIZE_MIN */<br>+static gint textview_font_size_percent = TEXTVIEW_FONT_SIZE_UNSET;<br>+static gint textview_font_size_default = TEXTVIEW_FONT_SIZE_UNSET;<br>+<br>+static void textview_set_font_zoom(TextView *textview);<br>+<br> #define TEXTVIEW_STATUSBAR_PUSH(textview, str) \<br> { if (textview->messageview->statusbar) \<br> gtk_statusbar_push(GTK_STATUSBAR(textview->messageview->statusbar), \<br>@@ -157,9 +169,20 @@ static GPtrArray *textview_scan_header (TextView *textview,<br> static void textview_show_header (TextView *textview,<br> GPtrArray *headers);<br> <br>+static void textview_zoom(GtkWidget *widget, gboolean zoom_in);<br>+static void textview_zoom_in(GtkWidget *widget, gpointer data);<br>+static void textview_zoom_out(GtkWidget *widget, gpointer data);<br>+static void textview_zoom_reset(GtkWidget *widget, gpointer data);<br>+<br> static gint textview_key_pressed (GtkWidget *widget,<br> GdkEventKey *event,<br> TextView *textview);<br>+static gboolean textview_scrolled(GtkWidget *widget,<br>+ GdkEvent *_event,<br>+ gpointer user_data);<br>+static void textview_populate_popup(GtkTextView *self,<br>+ GtkMenu *menu,<br>+ gpointer user_data);<br> static gboolean textview_motion_notify (GtkWidget *widget,<br> GdkEventMotion *motion,<br> TextView *textview);<br>@@ -324,6 +347,10 @@ TextView *textview_create(void)<br> g_signal_connect(G_OBJECT(text), "size_allocate",<br> G_CALLBACK(textview_size_allocate_cb),<br> textview);<br>+ g_signal_connect(G_OBJECT(text), "scroll-event",<br>+ G_CALLBACK(textview_scrolled), textview);<br>+ g_signal_connect(G_OBJECT(text), "populate-popup",<br>+ G_CALLBACK(textview_populate_popup), textview);<br> <br> <br> gtk_widget_show(scrolledwin);<br>@@ -426,7 +453,7 @@ static void textview_create_tags(GtkTextView *text, TextView *textview)<br> "foreground-rgba", &uri_color,<br> NULL);<br> g_signal_connect(G_OBJECT(tag), "event",<br>- G_CALLBACK(textview_uri_button_pressed), textview);<br>+ G_CALLBACK(textview_uri_button_pressed), textview);<br> if (prefs_common.enable_bgcolor) {<br> gtk_text_buffer_create_tag(buffer, "quote0",<br> "foreground-rgba", "e_colors[0],<br>@@ -488,14 +515,14 @@ static void textview_create_tags(GtkTextView *text, TextView *textview)<br> "weight", PANGO_WEIGHT_BOLD,<br> NULL);<br> g_signal_connect(G_OBJECT(qtag), "event",<br>- G_CALLBACK(textview_uri_button_pressed), textview);<br>+ G_CALLBACK(textview_uri_button_pressed), textview);<br> g_signal_connect(G_OBJECT(tag), "event",<br>- G_CALLBACK(textview_uri_button_pressed), textview);<br>+ G_CALLBACK(textview_uri_button_pressed), textview);<br> /* if (font_desc)<br> pango_font_description_free(font_desc);<br> if (bold_font_desc)<br> pango_font_description_free(bold_font_desc);*/<br>- }<br>+}<br> <br> void textview_init(TextView *textview)<br> {<br>@@ -510,15 +537,14 @@ void textview_init(TextView *textview)<br> gtk_widget_get_display(textview->vbox), GDK_WATCH);<br> <br> textview_reflect_prefs(textview);<br>- textview_set_font(textview, NULL);<br> textview_create_tags(GTK_TEXT_VIEW(textview->text), textview);<br> }<br> <br>- #define CHANGE_TAG_COLOR(tagname, colorfg, colorbg) { \<br>+#define CHANGE_TAG_COLOR(tagname, colorfg, colorbg) { \<br> tag = gtk_text_tag_table_lookup(tags, tagname); \<br> if (tag) \<br> g_object_set(G_OBJECT(tag), "foreground-rgba", colorfg, "paragraph-background-rgba", colorbg, NULL); \<br>- }<br>+}<br> <br> static void textview_update_message_colors(TextView *textview)<br> {<br>@@ -1007,6 +1033,7 @@ static void textview_write_body(TextView *textview, MimeInfo *mimeinfo)<br> }<br> <br> textview_set_font(textview, charset);<br>+ textview_set_font_zoom(textview);<br> <br> conv = conv_code_converter_new(charset);<br> <br>@@ -2573,6 +2600,162 @@ static void textview_uri_update(TextView *textview, gint x, gint y)<br> }<br> }<br> <br>+static void textview_set_font_zoom(TextView *textview)<br>+{<br>+ PangoFontDescription *font;<br>+ gint size;<br>+<br>+ font = pango_font_description_from_string<br>+ (prefs_common.textfont);<br>+ cm_return_if_fail(font);<br>+<br>+ /* do nothing is no zoom level has been set */<br>+ if (textview_font_size_percent == TEXTVIEW_FONT_SIZE_UNSET)<br>+ return;<br>+<br>+ if (textview_font_size_default == TEXTVIEW_FONT_SIZE_UNSET)<br>+ textview_font_size_default = pango_font_description_get_size(font);<br>+<br>+ size = textview_font_size_default + ( textview_font_size_default / 100 * textview_font_size_percent );<br>+<br>+ pango_font_description_set_size(font, size);<br>+ gtk_widget_override_font(textview->text, font);<br>+}<br>+<br>+static void textview_zoom(GtkWidget *widget, gboolean zoom_in)<br>+{<br>+ PangoContext *pctx;<br>+ PangoFontDescription *font;<br>+ gint size;<br>+<br>+ pctx = gtk_widget_get_pango_context(widget);<br>+ font = pango_context_get_font_description(pctx);<br>+ size = pango_font_description_get_size(font);<br>+<br>+ /* save the default font size first time before zooming */<br>+ if (textview_font_size_default == TEXTVIEW_FONT_SIZE_UNSET)<br>+ textview_font_size_default = size;<br>+<br>+ if (textview_font_size_percent == TEXTVIEW_FONT_SIZE_UNSET)<br>+ textview_font_size_percent = 0;<br>+<br>+ if (zoom_in) {<br>+ if ((textview_font_size_percent + TEXTVIEW_FONT_SIZE_STEP ) <= TEXTVIEW_FONT_SIZE_MAX)<br>+ textview_font_size_percent += TEXTVIEW_FONT_SIZE_STEP;<br>+ } else {<br>+ if ((textview_font_size_percent - TEXTVIEW_FONT_SIZE_STEP ) >= TEXTVIEW_FONT_SIZE_MIN)<br>+ textview_font_size_percent -= TEXTVIEW_FONT_SIZE_STEP;<br>+ }<br>+ size = textview_font_size_default + ( textview_font_size_default / 100 * textview_font_size_percent );<br>+<br>+ pango_font_description_set_size(font, size);<br>+ gtk_widget_override_font(widget, font);<br>+ gtk_widget_show(widget);<br>+}<br>+<br>+static void textview_zoom_in(GtkWidget *widget, gpointer data)<br>+{<br>+ textview_zoom(GTK_WIDGET(data), TRUE);<br>+}<br>+<br>+static void textview_zoom_out(GtkWidget *widget, gpointer data)<br>+{<br>+ textview_zoom(GTK_WIDGET(data), FALSE);<br>+}<br>+<br>+static void textview_zoom_reset(GtkWidget *widget, gpointer data)<br>+{<br>+ PangoContext *pctx;<br>+ PangoFontDescription *font;<br>+ gint size;<br>+<br>+ pctx = gtk_widget_get_pango_context(GTK_WIDGET(data));<br>+ font = pango_context_get_font_description(pctx);<br>+<br>+ /* reset and save the value for current session */<br>+ if (textview_font_size_default == TEXTVIEW_FONT_SIZE_UNSET || textview_font_size_percent == TEXTVIEW_FONT_SIZE_UNSET) <br>+ return;<br>+<br>+ textview_font_size_percent = 0;<br>+ size = textview_font_size_default + ( textview_font_size_default / 100 * textview_font_size_percent );<br>+<br>+ pango_font_description_set_size(font, size);<br>+ gtk_widget_override_font(GTK_WIDGET(data), font);<br>+ gtk_widget_show(GTK_WIDGET(data));<br>+}<br>+<br>+static void textview_populate_popup(GtkTextView* textview,<br>+ GtkMenu *menu,<br>+ gpointer user_data)<br>+{<br>+ GtkWidget *menuitem;<br>+ <br>+ cm_return_if_fail(menu != NULL);<br>+ cm_return_if_fail(GTK_IS_MENU_SHELL(menu));<br>+<br>+ menuitem = gtk_separator_menu_item_new();<br>+ gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);<br>+ gtk_widget_show(menuitem);<br>+<br>+ menuitem = gtk_menu_item_new_with_mnemonic(_("Zoom _In"));<br>+ g_signal_connect(G_OBJECT(menuitem), "activate",<br>+ G_CALLBACK(textview_zoom_in), textview);<br>+ gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);<br>+ gtk_widget_set_sensitive(menuitem,<br>+ textview_font_size_percent == TEXTVIEW_FONT_SIZE_UNSET ||<br>+ ((textview_font_size_percent + TEXTVIEW_FONT_SIZE_STEP ) <= TEXTVIEW_FONT_SIZE_MAX));<br>+ gtk_widget_show(menuitem);<br>+<br>+ menuitem = gtk_menu_item_new_with_mnemonic(_("Zoom _Out"));<br>+ g_signal_connect(G_OBJECT(menuitem), "activate",<br>+ G_CALLBACK(textview_zoom_out), textview);<br>+ gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);<br>+ gtk_widget_set_sensitive(menuitem,<br>+ textview_font_size_percent == TEXTVIEW_FONT_SIZE_UNSET ||<br>+ ((textview_font_size_percent - TEXTVIEW_FONT_SIZE_STEP ) >= TEXTVIEW_FONT_SIZE_MIN));<br>+ gtk_widget_show(menuitem);<br>+<br>+ menuitem = gtk_menu_item_new_with_mnemonic(_("Reset _zoom"));<br>+ g_signal_connect(G_OBJECT(menuitem), "activate",<br>+ G_CALLBACK(textview_zoom_reset), textview);<br>+ gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);<br>+ gtk_widget_set_sensitive(menuitem,<br>+ (textview_font_size_percent != TEXTVIEW_FONT_SIZE_UNSET && textview_font_size_percent != 0));<br>+ gtk_widget_show(menuitem);<br>+}<br>+<br>+static gboolean textview_scrolled(GtkWidget *widget,<br>+ GdkEvent *_event,<br>+ gpointer user_data)<br>+{<br>+ GdkEventScroll *event = (GdkEventScroll *)_event;<br>+<br>+ /* Ctrl+mousewheel changes font size */<br>+ if (event->state & GDK_CONTROL_MASK || event->state & GDK_SHIFT_MASK) {<br>+<br>+ if (event->direction == GDK_SCROLL_UP) {<br>+ textview_zoom(widget, TRUE);<br>+ } else if (event->direction == GDK_SCROLL_DOWN) {<br>+ textview_zoom(widget, FALSE);<br>+ } else {<br>+ gdouble x, y;<br>+<br>+ if ((event->direction == GDK_SCROLL_SMOOTH) &&<br>+ gdk_event_get_scroll_deltas(_event, &x, &y)) {<br>+ if (y < 0)<br>+ textview_zoom(widget, TRUE);<br>+ else<br>+ if (y >0)<br>+ textview_zoom(widget, FALSE);<br>+ } else<br>+ return FALSE; /* Scrolling left or right */<br>+ }<br>+ return TRUE;<br>+ }<br>+<br>+ return FALSE;<br>+}<br>+<br> static gboolean textview_get_uri_range(TextView *textview,<br> GtkTextIter *iter,<br> GtkTextTag *tag,<br><br><hr><br><br><br>hooks/post-receive</pre></blockquote></div></body></html>