2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2007 Hiroyuki Yamamoto and the Claws Mail Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
27 #include <glib/gi18n.h>
30 #include "common/utils.h"
32 #include "prefs_gtk.h"
33 #include "prefswindow.h"
35 #include "prefs_common.h"
36 #include "prefs_gtk.h"
38 typedef struct _ImageViewerPage
42 GtkWidget *window; /* do not modify */
44 GtkWidget *autoload_img;
45 GtkWidget *resize_img;
46 GtkWidget *inline_img;
47 GtkWidget *print_imgs;
50 static void imageviewer_create_widget_func(PrefsPage * _page,
54 ImageViewerPage *prefs_imageviewer = (ImageViewerPage *) _page;
57 GtkWidget *autoload_img;
58 GtkWidget *resize_img;
59 GtkWidget *inline_img;
60 GtkWidget *print_imgs;
61 GtkTooltips *resize_tooltip;
63 table = gtk_table_new(4, 1, FALSE);
64 gtk_widget_show(table);
65 gtk_container_set_border_width(GTK_CONTAINER(table), VBOX_BORDER);
66 gtk_table_set_row_spacings(GTK_TABLE(table), 4);
67 gtk_table_set_col_spacings(GTK_TABLE(table), 8);
69 autoload_img = gtk_check_button_new_with_label(_("Automatically display attached images"));
70 gtk_widget_show(autoload_img);
71 gtk_table_attach(GTK_TABLE(table), autoload_img, 0, 1, 0, 1,
72 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
73 (GtkAttachOptions) (0), 0, 0);
75 resize_tooltip = gtk_tooltips_new();
77 resize_img = gtk_check_button_new_with_label(_("Resize attached images by default"));
78 gtk_widget_show(resize_img);
79 gtk_tooltips_set_tip(GTK_TOOLTIPS(resize_tooltip), resize_img,
80 _("Clicking image toggles scaling"),
82 gtk_table_attach(GTK_TABLE(table), resize_img, 0, 1, 1, 2,
83 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
84 (GtkAttachOptions) (0), 0, 0);
86 inline_img = gtk_check_button_new_with_label(_("Display images inline"));
87 gtk_widget_show(inline_img);
88 gtk_table_attach(GTK_TABLE(table), inline_img, 0, 1, 2, 3,
89 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
90 (GtkAttachOptions) (0), 0, 0);
92 print_imgs = gtk_check_button_new_with_label(_("Print images"));
93 #if !defined(USE_GNOMEPRINT) && GTK_CHECK_VERSION(2,10,0)
94 gtk_widget_show(print_imgs);
96 gtk_table_attach(GTK_TABLE(table), print_imgs, 0, 1, 3, 4,
97 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
98 (GtkAttachOptions) (0), 0, 0);
100 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(resize_img), prefs_common.resize_img);
101 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(autoload_img), prefs_common.display_img);
102 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(inline_img), prefs_common.inline_img);
103 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(print_imgs), prefs_common.print_imgs);
105 prefs_imageviewer->window = GTK_WIDGET(window);
106 prefs_imageviewer->autoload_img = autoload_img;
107 prefs_imageviewer->resize_img = resize_img;
108 prefs_imageviewer->inline_img = inline_img;
109 prefs_imageviewer->print_imgs = print_imgs;
111 prefs_imageviewer->page.widget = table;
114 static void imageviewer_destroy_widget_func(PrefsPage *_page)
118 static void imageviewer_save_func(PrefsPage * _page)
120 ImageViewerPage *imageviewer = (ImageViewerPage *) _page;
122 prefs_common.display_img =
123 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
124 (imageviewer->autoload_img));
125 prefs_common.resize_img =
126 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
127 (imageviewer->resize_img));
128 prefs_common.inline_img =
129 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
130 (imageviewer->inline_img));
131 prefs_common.print_imgs =
132 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
133 (imageviewer->print_imgs));
136 ImageViewerPage *prefs_imageviewer;
138 void prefs_image_viewer_init(void)
140 ImageViewerPage *page;
141 static gchar *path[3];
143 path[0] = _("Message View");
144 path[1] = _("Image Viewer");
147 page = g_new0(ImageViewerPage, 1);
148 page->page.path = path;
149 page->page.create_widget = imageviewer_create_widget_func;
150 page->page.destroy_widget = imageviewer_destroy_widget_func;
151 page->page.save_page = imageviewer_save_func;
152 page->page.weight = 160.0;
153 prefs_gtk_register_page((PrefsPage *) page);
154 prefs_imageviewer = page;
157 void prefs_image_viewer_done(void)
159 prefs_gtk_unregister_page((PrefsPage *) prefs_imageviewer);
160 g_free(prefs_imageviewer);