rework image viewer
[claws.git] / src / prefs_image_viewer.c
index dce5fc79a8d9455664c44b648dd91b8abd355965..d7748db54c15e518cd2a371aa31fda84614b59a5 100644 (file)
@@ -1,10 +1,10 @@
 /*
- * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2006 Hiroyuki Yamamoto and the Sylpheed-Claws Team
+ * 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
- * the Free Software Foundation; either version 2 of the License, or
+ * the Free Software Foundation; either version 3 of the License, or
  * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * 
  */
 
 #ifdef HAVE_CONFIG_H
 #  include "config.h"
+#include "claws-features.h"
 #endif
 
 #include "defs.h"
@@ -43,7 +44,10 @@ 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;
 
 static void imageviewer_create_widget_func(PrefsPage * _page,
@@ -55,10 +59,15 @@ 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;
-       GtkTooltips *resize_tooltip;
+       GtkWidget *print_imgs;
 
-       table = gtk_table_new(3, 1, FALSE);
+       table = gtk_table_new(4, 1, FALSE);
        gtk_widget_show(table);
        gtk_container_set_border_width(GTK_CONTAINER(table), VBOX_BORDER);
        gtk_table_set_row_spacings(GTK_TABLE(table), 4);
@@ -70,31 +79,68 @@ static void imageviewer_create_widget_func(PrefsPage * _page,
                         (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
                         (GtkAttachOptions) (0), 0, 0);
 
-       resize_tooltip = gtk_tooltips_new();
-
        resize_img = gtk_check_button_new_with_label(_("Resize attached images by default"));
        gtk_widget_show(resize_img);
-       gtk_tooltips_set_tip(GTK_TOOLTIPS(resize_tooltip), resize_img,
-                            _("Clicking image toggles scaling"),
-                            NULL);
+       CLAWS_SET_TIP(resize_img,
+                            _("Clicking image toggles scaling"));
        gtk_table_attach(GTK_TABLE(table), resize_img, 0, 1, 1, 2,
                         (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
                         (GtkAttachOptions) (0), 0, 0);
 
+       vbox = gtk_vbox_new(FALSE, VSPACING);
+       hbox = gtk_hbox_new(FALSE, 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_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_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_table_attach(GTK_TABLE(table), vbox, 0, 1, 2, 3,
+                        (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
+                        (GtkAttachOptions) (0), 0, 0);
+
        inline_img = gtk_check_button_new_with_label(_("Display images inline"));
        gtk_widget_show(inline_img);
-       gtk_table_attach(GTK_TABLE(table), inline_img, 0, 1, 2, 3,
+       gtk_table_attach(GTK_TABLE(table), inline_img, 0, 1, 3, 4,
+                        (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
+                        (GtkAttachOptions) (0), 0, 0);
+       
+       print_imgs = gtk_check_button_new_with_label(_("Print images"));
+       gtk_widget_show(print_imgs);
+       gtk_table_attach(GTK_TABLE(table), print_imgs, 0, 1, 4, 5,
                         (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
                         (GtkAttachOptions) (0), 0, 0);
        
        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;
 
        prefs_imageviewer->page.widget = table;
 }
@@ -113,9 +159,15 @@ 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));
+       prefs_common.print_imgs =
+           gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
+                                        (imageviewer->print_imgs));
 }
 
 ImageViewerPage *prefs_imageviewer;