add user specified stylesheet option
[claws.git] / src / prefs_image_viewer.c
blob0edf109d844637c69afa753a85d20fbbe537a029
1 /*
2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2012 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/>.
20 #ifdef HAVE_CONFIG_H
21 # include "config.h"
22 #include "claws-features.h"
23 #endif
25 #include "defs.h"
27 #include <glib.h>
28 #include <glib/gi18n.h>
29 #include <gtk/gtk.h>
31 #include "common/utils.h"
32 #include "prefs.h"
33 #include "prefs_gtk.h"
34 #include "prefswindow.h"
36 #include "prefs_common.h"
37 #include "prefs_gtk.h"
39 typedef struct _ImageViewerPage
41 PrefsPage page;
43 GtkWidget *window; /* do not modify */
45 GtkWidget *autoload_img;
46 GtkWidget *resize_img;
47 GtkWidget *inline_img;
48 GtkWidget *print_imgs;
49 }ImageViewerPage;
51 static void imageviewer_create_widget_func(PrefsPage * _page,
52 GtkWindow * window,
53 gpointer data)
55 ImageViewerPage *prefs_imageviewer = (ImageViewerPage *) _page;
57 GtkWidget *table;
58 GtkWidget *autoload_img;
59 GtkWidget *resize_img;
60 GtkWidget *inline_img;
61 GtkWidget *print_imgs;
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_img = gtk_check_button_new_with_label(_("Resize attached images by default"));
76 gtk_widget_show(resize_img);
77 CLAWS_SET_TIP(resize_img,
78 _("Clicking image toggles scaling"));
79 gtk_table_attach(GTK_TABLE(table), resize_img, 0, 1, 1, 2,
80 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
81 (GtkAttachOptions) (0), 0, 0);
83 inline_img = gtk_check_button_new_with_label(_("Display images inline"));
84 gtk_widget_show(inline_img);
85 gtk_table_attach(GTK_TABLE(table), inline_img, 0, 1, 2, 3,
86 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
87 (GtkAttachOptions) (0), 0, 0);
89 print_imgs = gtk_check_button_new_with_label(_("Print images"));
90 gtk_widget_show(print_imgs);
91 gtk_table_attach(GTK_TABLE(table), print_imgs, 0, 1, 3, 4,
92 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
93 (GtkAttachOptions) (0), 0, 0);
95 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(resize_img), prefs_common.resize_img);
96 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(autoload_img), prefs_common.display_img);
97 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(inline_img), prefs_common.inline_img);
98 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(print_imgs), prefs_common.print_imgs);
100 prefs_imageviewer->window = GTK_WIDGET(window);
101 prefs_imageviewer->autoload_img = autoload_img;
102 prefs_imageviewer->resize_img = resize_img;
103 prefs_imageviewer->inline_img = inline_img;
104 prefs_imageviewer->print_imgs = print_imgs;
106 prefs_imageviewer->page.widget = table;
109 static void imageviewer_destroy_widget_func(PrefsPage *_page)
113 static void imageviewer_save_func(PrefsPage * _page)
115 ImageViewerPage *imageviewer = (ImageViewerPage *) _page;
117 prefs_common.display_img =
118 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
119 (imageviewer->autoload_img));
120 prefs_common.resize_img =
121 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
122 (imageviewer->resize_img));
123 prefs_common.inline_img =
124 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
125 (imageviewer->inline_img));
126 prefs_common.print_imgs =
127 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
128 (imageviewer->print_imgs));
131 ImageViewerPage *prefs_imageviewer;
133 void prefs_image_viewer_init(void)
135 ImageViewerPage *page;
136 static gchar *path[3];
138 path[0] = _("Message View");
139 path[1] = _("Image Viewer");
140 path[2] = NULL;
142 page = g_new0(ImageViewerPage, 1);
143 page->page.path = path;
144 page->page.create_widget = imageviewer_create_widget_func;
145 page->page.destroy_widget = imageviewer_destroy_widget_func;
146 page->page.save_page = imageviewer_save_func;
147 page->page.weight = 160.0;
148 prefs_gtk_register_page((PrefsPage *) page);
149 prefs_imageviewer = page;
152 void prefs_image_viewer_done(void)
154 prefs_gtk_unregister_page((PrefsPage *) prefs_imageviewer);
155 g_free(prefs_imageviewer);