2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2003 Hiroyuki Yamamoto and the Sylpheed-Claws 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 2 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, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
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;
49 static void imageviewer_create_widget_func(PrefsPage * _page,
53 ImageViewerPage *prefs_imageviewer = (ImageViewerPage *) _page;
57 GtkWidget *autoload_img;
58 GtkWidget *resize_img;
59 GtkWidget *inline_img;
61 table = gtk_table_new(2, 2, FALSE);
62 gtk_widget_show(table);
63 gtk_container_set_border_width(GTK_CONTAINER(table), 8);
64 gtk_table_set_row_spacings(GTK_TABLE(table), 4);
65 gtk_table_set_col_spacings(GTK_TABLE(table), 8);
68 gtk_label_new(_("Automatically display attached images"));
69 gtk_widget_show(label);
70 gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1,
71 (GtkAttachOptions) (GTK_FILL),
72 (GtkAttachOptions) (0), 0, 0);
73 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
75 label = gtk_label_new(_("Resize attached images by default\n(Clicking image toggles scaling)"));
76 gtk_widget_show(label);
77 gtk_table_attach(GTK_TABLE(table), label, 0, 1, 1, 2,
78 (GtkAttachOptions) (GTK_FILL),
79 (GtkAttachOptions) (0), 0, 0);
80 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
82 label = gtk_label_new(_("Display images inline"));
83 gtk_widget_show(label);
84 gtk_table_attach(GTK_TABLE(table), label, 0, 1, 2, 3,
85 (GtkAttachOptions) (GTK_FILL),
86 (GtkAttachOptions) (0), 0, 0);
87 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
89 autoload_img = gtk_check_button_new_with_label("");
90 gtk_widget_show(autoload_img);
91 gtk_table_attach(GTK_TABLE(table), autoload_img, 1, 2, 0, 1,
92 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
93 (GtkAttachOptions) (0), 0, 0);
95 resize_img = gtk_check_button_new_with_label("");
96 gtk_widget_show(resize_img);
97 gtk_table_attach(GTK_TABLE(table), resize_img, 1, 2, 1, 2,
98 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
99 (GtkAttachOptions) (0), 0, 0);
101 inline_img = gtk_check_button_new_with_label("");
102 gtk_widget_show(inline_img);
103 gtk_table_attach(GTK_TABLE(table), inline_img, 1, 2, 2, 3,
104 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
105 (GtkAttachOptions) (0), 0, 0);
107 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(resize_img), prefs_common.resize_img);
108 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(autoload_img), prefs_common.display_img);
109 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(inline_img), prefs_common.inline_img);
111 prefs_imageviewer->window = GTK_WIDGET(window);
112 prefs_imageviewer->autoload_img = autoload_img;
113 prefs_imageviewer->resize_img = resize_img;
114 prefs_imageviewer->inline_img = inline_img;
116 prefs_imageviewer->page.widget = table;
119 static void imageviewer_destroy_widget_func(PrefsPage *_page)
123 static void imageviewer_save_func(PrefsPage * _page)
125 ImageViewerPage *imageviewer = (ImageViewerPage *) _page;
127 prefs_common.display_img =
128 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
129 (imageviewer->autoload_img));
130 prefs_common.resize_img =
131 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
132 (imageviewer->resize_img));
133 prefs_common.inline_img =
134 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
135 (imageviewer->inline_img));
138 ImageViewerPage *prefs_imageviewer;
140 void prefs_image_viewer_init(void)
142 ImageViewerPage *page;
143 static gchar *path[3];
145 path[0] = _("Message View");
146 path[1] = _("Image Viewer");
149 page = g_new0(ImageViewerPage, 1);
150 page->page.path = path;
151 page->page.create_widget = imageviewer_create_widget_func;
152 page->page.destroy_widget = imageviewer_destroy_widget_func;
153 page->page.save_page = imageviewer_save_func;
154 page->page.weight = 160.0;
155 prefs_gtk_register_page((PrefsPage *) page);
156 prefs_imageviewer = page;
159 void prefs_image_viewer_done(void)
161 prefs_gtk_unregister_page((PrefsPage *) prefs_imageviewer);
162 g_free(prefs_imageviewer);