[Commits] [SCM] claws branch, gtk3, updated. 3.99.0-18-g00fd8f76f
paul at claws-mail.org
paul at claws-mail.org
Tue Dec 29 13:23:42 CET 2020
The branch, gtk3 has been updated
via 00fd8f76fb6dba06837a4189600d943f20211808 (commit)
from 959585854644ebb831e74e1dd8afa969a05984a9 (commit)
Summary of changes:
src/gtk/gtkutils.c | 21 +++++++++++++++-----
src/gtk/gtkutils.h | 7 ++++---
src/image_viewer.c | 18 ++++++++++++-----
src/prefs_common.c | 2 ++
src/prefs_common.h | 1 +
src/prefs_image_viewer.c | 51 ++++++++++++++++++++++++++++++++++++++++++++----
src/textview.c | 4 ++--
7 files changed, 85 insertions(+), 19 deletions(-)
- Log -----------------------------------------------------------------
commit 00fd8f76fb6dba06837a4189600d943f20211808
Author: paul <paul at claws-mail.org>
Date: Tue Dec 29 12:23:37 2020 +0000
rework image viewer
add options, when resizing images, to either fit the image width or fit the image height. image height is the default. regardless of this setting, when displaying images inline they will fit the height
diff --git a/src/gtk/gtkutils.c b/src/gtk/gtkutils.c
index 035584af6..4db881b0b 100644
--- a/src/gtk/gtkutils.c
+++ b/src/gtk/gtkutils.c
@@ -1734,8 +1734,8 @@ claws_input_add (gint source,
*
* @return a GdkPixbuf
*/
-GdkPixbuf *claws_load_pixbuf_fitting(GdkPixbuf *src_pixbuf, int box_width,
- int box_height)
+GdkPixbuf *claws_load_pixbuf_fitting(GdkPixbuf *src_pixbuf, gboolean inline_img,
+ gboolean fit_img_height, int box_width, int box_height)
{
gint w, h, orientation, angle;
gint avail_width, avail_height;
@@ -1806,9 +1806,20 @@ GdkPixbuf *claws_load_pixbuf_fitting(GdkPixbuf *src_pixbuf, int box_width,
avail_height = box_height;
if (box_width != -1 && box_height != -1 && avail_width - 100 > 0) {
- if (w > avail_width || h > avail_height) {
- h = (avail_width * h) / w;
- w = avail_width;
+ if (inline_img || fit_img_height) {
+ if (w > avail_width) {
+ h = (avail_width * h) / w;
+ w = avail_width;
+ }
+ if (h > avail_height) {
+ w = (avail_height * w) / h;
+ h = avail_height;
+ }
+ } else {
+ if (w > avail_width || h > avail_height) {
+ h = (avail_width * h) / w;
+ w = avail_width;
+ }
}
t_pixbuf = gdk_pixbuf_scale_simple(pixbuf,
w, h, GDK_INTERP_BILINEAR);
diff --git a/src/gtk/gtkutils.h b/src/gtk/gtkutils.h
index f4b6a686c..6ff0db7e4 100644
--- a/src/gtk/gtkutils.h
+++ b/src/gtk/gtkutils.h
@@ -1,6 +1,6 @@
/*
* Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2019 the Claws Mail team and Hiroyuki Yamamoto
+ * Copyright (C) 1999-2020 the Claws Mail team and Hiroyuki Yamamoto
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -203,8 +203,9 @@ gboolean gtkut_list_view_select_row(GtkWidget *list, gint row);
GtkUIManager *gtkut_create_ui_manager(void);
GtkUIManager *gtkut_ui_manager(void);
-GdkPixbuf *claws_load_pixbuf_fitting(GdkPixbuf *pixbuf, int box_width,
- int box_height);
+GdkPixbuf *claws_load_pixbuf_fitting(GdkPixbuf *pixbuf, gboolean inline_img,
+ gboolean fit_img_height,
+ int box_width, int box_height);
GtkWidget *gtkut_time_select_combo_new();
void gtkut_time_select_select_by_time(GtkComboBox *combo, int hour, int minute);
diff --git a/src/image_viewer.c b/src/image_viewer.c
index c97826368..a4273e9f2 100644
--- a/src/image_viewer.c
+++ b/src/image_viewer.c
@@ -1,6 +1,6 @@
/*
* Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2018 Hiroyuki Yamamoto and the Claws Mail team
+ * Copyright (C) 1999-2020 the Claws Mail team and Hiroyuki Yamamoto
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -47,6 +47,7 @@ struct _ImageViewer
gchar *file;
MimeInfo *mimeinfo;
gboolean resize_img;
+ gboolean fit_img_height;
GtkWidget *scrolledwin;
GtkWidget *image;
@@ -102,23 +103,24 @@ static void image_viewer_load_image(ImageViewer *imageviewer)
#if GDK_PIXBUF_MINOR >= 28
if (gdk_pixbuf_animation_is_static_image(animation)
- || imageviewer->resize_img) {
+ || imageviewer->resize_img || imageviewer->fit_img_height) {
pixbuf = gdk_pixbuf_animation_get_static_image(animation);
g_object_ref(pixbuf);
g_object_unref(animation);
animation = NULL;
#else
- if (imageviewer->resize_img) {
+ if (imageviewer->resize_img || imageviewer->fit_img_height) {
#endif
if (imageviewer->resize_img) {
gtk_widget_get_allocation(imageviewer->scrolledwin, &allocation);
- pixbuf = claws_load_pixbuf_fitting(pixbuf,
+ pixbuf = claws_load_pixbuf_fitting(pixbuf, FALSE,
+ imageviewer->fit_img_height,
allocation.width,
allocation.height);
}
else
- pixbuf = claws_load_pixbuf_fitting(pixbuf, -1, -1);
+ pixbuf = claws_load_pixbuf_fitting(pixbuf, FALSE, imageviewer->fit_img_height, -1, -1);
}
if (error && !pixbuf && !animation) {
@@ -214,6 +216,7 @@ static void image_viewer_clear_viewer(MimeViewer *_mimeviewer)
imageviewer->file = NULL;
imageviewer->mimeinfo = NULL;
imageviewer->resize_img = prefs_common.resize_img;
+ imageviewer->fit_img_height = prefs_common.fit_img_height;
}
static void image_viewer_destroy_viewer(MimeViewer *_mimeviewer)
@@ -264,6 +267,10 @@ static gboolean image_button_cb(GtkWidget *scrolledwin, GdkEventButton *event,
imageviewer->resize_img = !imageviewer->resize_img;
image_viewer_load_image(imageviewer);
return TRUE;
+ } else if (event->button == 3 && imageviewer->image) {
+ imageviewer->fit_img_height = !imageviewer->fit_img_height;
+ image_viewer_load_image(imageviewer);
+ return TRUE;
}
return FALSE;
}
@@ -387,6 +394,7 @@ static MimeViewer *image_viewer_create(void)
imageviewer->mimeviewer.get_selection = NULL;
imageviewer->resize_img = prefs_common.resize_img;
+ imageviewer->fit_img_height = prefs_common.fit_img_height;
imageviewer->scrolledwin = scrolledwin;
imageviewer->image = image;
diff --git a/src/prefs_common.c b/src/prefs_common.c
index 7d3e39e43..a257f5d90 100644
--- a/src/prefs_common.c
+++ b/src/prefs_common.c
@@ -428,6 +428,8 @@ static PrefParam param[] = {
NULL, NULL, NULL},
{"inline_image", "TRUE", &prefs_common.inline_img, P_BOOL,
NULL, NULL, NULL},
+ {"fit_image_height", "TRUE", &prefs_common.fit_img_height, P_BOOL,
+ NULL, NULL, NULL},
{"display_folder_unread_num", "0",
&prefs_common.display_folder_unread, P_INT,
diff --git a/src/prefs_common.h b/src/prefs_common.h
index 48de0a2ce..90de7de6c 100644
--- a/src/prefs_common.h
+++ b/src/prefs_common.h
@@ -246,6 +246,7 @@ struct _PrefsCommon
gboolean display_img;
gboolean resize_img;
gboolean inline_img;
+ gboolean fit_img_height;
gboolean trans_hdr;
gint display_folder_unread;
diff --git a/src/prefs_image_viewer.c b/src/prefs_image_viewer.c
index 165ededa9..6c21f1224 100644
--- a/src/prefs_image_viewer.c
+++ b/src/prefs_image_viewer.c
@@ -1,6 +1,6 @@
/*
- * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2019 the Claws Mail Team and Hiroyuki Yamamoto
+ * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
+ * Copyright (C) 1999-2020 the Claws Mail Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -44,6 +44,8 @@ typedef struct _ImageViewerPage
GtkWidget *autoload_img;
GtkWidget *resize_img;
+ GtkWidget *fit_img_height_radiobtn;
+ GtkWidget *fit_img_width_radiobtn;
GtkWidget *inline_img;
GtkWidget *print_imgs;
}ImageViewerPage;
@@ -57,10 +59,16 @@ static void imageviewer_create_widget_func(PrefsPage * _page,
GtkWidget *table;
GtkWidget *autoload_img;
GtkWidget *resize_img;
+ GtkWidget *vbox;
+ GtkWidget *hbox;
+ GtkWidget *fit_img_label;
+ GtkWidget *fit_img_height_radiobtn;
+ GtkWidget *fit_img_width_radiobtn;
GtkWidget *inline_img;
GtkWidget *print_imgs;
table = gtk_grid_new();
+ gtk_grid_set_column_homogeneous(GTK_GRID(table), FALSE);
gtk_widget_show(table);
gtk_container_set_border_width(GTK_CONTAINER(table), VBOX_BORDER);
gtk_grid_set_row_spacing(GTK_GRID(table), 4);
@@ -76,22 +84,54 @@ static void imageviewer_create_widget_func(PrefsPage * _page,
_("Clicking image toggles scaling"));
gtk_grid_attach(GTK_GRID(table), resize_img, 0, 1, 1, 1);
+ vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, VSPACING);
+ hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8);
+ gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
+ gtk_widget_show(vbox);
+ gtk_widget_show(hbox);
+
+ fit_img_label = gtk_label_new (_("Fit image"));
+ gtk_widget_set_halign(fit_img_label, GTK_ALIGN_END);
+ gtk_widget_show(fit_img_label);
+ CLAWS_SET_TIP(fit_img_label,
+ _("Right-clicking image toggles fitting height/width"));
+ gtk_box_pack_start(GTK_BOX(hbox), fit_img_label, FALSE, FALSE, 0);
+
+ fit_img_height_radiobtn = gtk_radio_button_new_with_label(NULL, _("Height"));
+ gtk_widget_set_halign(fit_img_height_radiobtn, GTK_ALIGN_START);
+ gtk_widget_show(fit_img_height_radiobtn);
+ gtk_box_pack_start(GTK_BOX(hbox), fit_img_height_radiobtn, FALSE, FALSE, 0);
+
+ fit_img_width_radiobtn = gtk_radio_button_new_with_label_from_widget(
+ GTK_RADIO_BUTTON(fit_img_height_radiobtn), _("Width"));
+ gtk_widget_show(fit_img_width_radiobtn);
+ gtk_box_pack_start(GTK_BOX(hbox), fit_img_width_radiobtn, FALSE, FALSE, 0);
+ gtk_grid_attach(GTK_GRID(table), vbox, 0, 2, 1, 1);
+
inline_img = gtk_check_button_new_with_label(_("Display images inline"));
gtk_widget_show(inline_img);
- gtk_grid_attach(GTK_GRID(table), inline_img, 0, 2, 1, 1);
+ gtk_grid_attach(GTK_GRID(table), inline_img, 0, 3, 1, 1);
print_imgs = gtk_check_button_new_with_label(_("Print images"));
gtk_widget_show(print_imgs);
- gtk_grid_attach(GTK_GRID(table), print_imgs, 0, 3, 1, 1);
+ gtk_grid_attach(GTK_GRID(table), print_imgs, 0, 4, 1, 1);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(resize_img), prefs_common.resize_img);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(autoload_img), prefs_common.display_img);
+ if (prefs_common.fit_img_height)
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(fit_img_height_radiobtn), TRUE);
+ else
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(fit_img_width_radiobtn), TRUE);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(inline_img), prefs_common.inline_img);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(print_imgs), prefs_common.print_imgs);
+
+ SET_TOGGLE_SENSITIVITY(resize_img, vbox);
prefs_imageviewer->window = GTK_WIDGET(window);
prefs_imageviewer->autoload_img = autoload_img;
prefs_imageviewer->resize_img = resize_img;
+ prefs_imageviewer->fit_img_height_radiobtn = fit_img_height_radiobtn;
+ prefs_imageviewer->fit_img_width_radiobtn = fit_img_width_radiobtn;
prefs_imageviewer->inline_img = inline_img;
prefs_imageviewer->print_imgs = print_imgs;
@@ -112,6 +152,9 @@ static void imageviewer_save_func(PrefsPage * _page)
prefs_common.resize_img =
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
(imageviewer->resize_img));
+ prefs_common.fit_img_height =
+ gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
+ (imageviewer->fit_img_height_radiobtn));
prefs_common.inline_img =
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
(imageviewer->inline_img));
diff --git a/src/textview.c b/src/textview.c
index c68611dd5..c63c5d9c1 100644
--- a/src/textview.c
+++ b/src/textview.c
@@ -699,8 +699,8 @@ static void textview_add_part(TextView *textview, MimeInfo *mimeinfo)
}
gtk_widget_get_allocation(textview->scrolledwin, &allocation);
- pixbuf = claws_load_pixbuf_fitting(pixbuf,
- allocation.width,
+ pixbuf = claws_load_pixbuf_fitting(pixbuf, prefs_common.inline_img,
+ prefs_common.fit_img_height, allocation.width,
allocation.height);
if (textview->stop_loading) {
-----------------------------------------------------------------------
hooks/post-receive
--
Claws Mail
More information about the Commits
mailing list