2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 2003-2009 Hiroyuki Yamamoto & 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/>.
30 #include <glib/gi18n.h>
32 #include <gdk/gdkkeysyms.h>
34 #include "prefs_common.h"
35 #include "prefs_gtk.h"
37 #include "gtk/prefswindow.h"
39 typedef struct _FontsPage
43 GtkWidget *window; /* do not modify */
45 GtkWidget *entry_folderview_smallfont;
46 GtkWidget *entry_folderview_normalfont;
47 GtkWidget *entry_folderview_boldfont;
48 GtkWidget *entry_messageviewfont;
49 GtkWidget *derive_from_normalfont_checkbutton;
50 GtkWidget *print_checkbutton;
51 GtkWidget *entry_messageprintfont;
54 static void prefs_fonts_create_widget(PrefsPage *_page, GtkWindow *window,
57 FontsPage *prefs_fonts = (FontsPage *) _page;
60 GtkWidget *entry_folderview_smallfont;
61 GtkWidget *entry_folderview_normalfont;
62 GtkWidget *entry_folderview_boldfont;
63 GtkWidget *entry_messageviewfont;
65 GtkWidget *entry_messageprintfont;
66 GtkWidget *print_checkbutton;
67 GtkWidget *derive_from_normalfont_checkbutton;
71 table = gtk_table_new(10, 2, FALSE);
72 gtk_widget_show(table);
73 gtk_container_set_border_width(GTK_CONTAINER(table), VBOX_BORDER);
74 gtk_table_set_row_spacings(GTK_TABLE(table), 4);
75 gtk_table_set_col_spacings(GTK_TABLE(table), 8);
77 /* normal font label */
78 tmplabel = gtk_label_new (_("Folder and Message Lists"));
79 gtk_widget_show (tmplabel);
80 gtk_table_attach (GTK_TABLE (table), tmplabel, 0, 1, row, row+1,
81 (GtkAttachOptions) GTK_FILL,
82 (GtkAttachOptions) (0), 0, 0);
83 gtk_label_set_justify(GTK_LABEL(tmplabel), GTK_JUSTIFY_RIGHT);
84 gtk_misc_set_alignment(GTK_MISC(tmplabel), 1, 0.5);
86 /* normal font button */
87 entry_folderview_normalfont = gtk_font_button_new_with_font (prefs_common.normalfont);
88 g_object_set(G_OBJECT(entry_folderview_normalfont),
91 gtk_widget_show (entry_folderview_normalfont);
92 gtk_table_attach (GTK_TABLE (table), entry_folderview_normalfont, 1, 2, row, row+1,
93 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
94 (GtkAttachOptions) (0), 0, 0);
97 /* message font label */
98 tmplabel = gtk_label_new (_("Message"));
99 gtk_widget_show (tmplabel);
100 gtk_table_attach (GTK_TABLE (table), tmplabel, 0, 1, row, row+1,
101 (GtkAttachOptions) GTK_FILL,
102 (GtkAttachOptions) (0), 0, 0);
103 gtk_label_set_justify(GTK_LABEL(tmplabel), GTK_JUSTIFY_RIGHT);
104 gtk_misc_set_alignment(GTK_MISC(tmplabel), 1, 0.5);
106 /* message font button */
107 entry_messageviewfont = gtk_font_button_new_with_font (prefs_common.textfont);
108 g_object_set(G_OBJECT(entry_messageviewfont),
111 gtk_widget_show (entry_messageviewfont);
112 gtk_table_attach (GTK_TABLE (table), entry_messageviewfont, 1, 2, row, row+1,
113 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
114 (GtkAttachOptions) (0), 0, 0);
117 vbox = gtk_vbox_new(FALSE, VSPACING_NARROW);
118 gtk_widget_show(vbox);
119 gtk_table_attach (GTK_TABLE (table), vbox, 0, 4, row, row+1,
120 (GtkAttachOptions) GTK_FILL,
121 (GtkAttachOptions) (0), 0, 0);
124 /* derive from normal font check button */
125 derive_from_normalfont_checkbutton = gtk_check_button_new_with_label(_("Derive small and bold fonts from Folder and Message Lists font"));
126 gtk_widget_show(derive_from_normalfont_checkbutton);
127 gtk_table_attach (GTK_TABLE (table), derive_from_normalfont_checkbutton, 0, 2, row, row+1,
128 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
129 (GtkAttachOptions) (0), 0, 0);
130 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(derive_from_normalfont_checkbutton),
131 prefs_common.derive_from_normal_font);
134 /* small font label */
135 tmplabel = gtk_label_new (_("Small"));
136 gtk_widget_show (tmplabel);
137 gtk_table_attach (GTK_TABLE (table), tmplabel, 0, 1, row, row+1,
138 (GtkAttachOptions) GTK_FILL,
139 (GtkAttachOptions) (0), 0, 0);
140 gtk_label_set_justify(GTK_LABEL(tmplabel), GTK_JUSTIFY_RIGHT);
141 gtk_misc_set_alignment(GTK_MISC(tmplabel), 1, 0.5);
142 SET_TOGGLE_SENSITIVITY_REVERSE (derive_from_normalfont_checkbutton, tmplabel);
144 /* small font button */
145 entry_folderview_smallfont = gtk_font_button_new_with_font (prefs_common.smallfont);
146 g_object_set(G_OBJECT(entry_folderview_smallfont),
149 gtk_widget_show (entry_folderview_smallfont);
150 gtk_table_attach (GTK_TABLE (table), entry_folderview_smallfont, 1, 2, row, row+1,
151 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
152 (GtkAttachOptions) (0), 0, 0);
153 SET_TOGGLE_SENSITIVITY_REVERSE (derive_from_normalfont_checkbutton, entry_folderview_smallfont);
156 /* bold font label */
157 tmplabel = gtk_label_new (_("Bold"));
158 gtk_widget_show (tmplabel);
159 gtk_table_attach (GTK_TABLE (table), tmplabel, 0, 1, row, row+1,
160 (GtkAttachOptions) GTK_FILL,
161 (GtkAttachOptions) (0), 0, 0);
162 gtk_label_set_justify(GTK_LABEL(tmplabel), GTK_JUSTIFY_RIGHT);
163 gtk_misc_set_alignment(GTK_MISC(tmplabel), 1, 0.5);
164 SET_TOGGLE_SENSITIVITY_REVERSE (derive_from_normalfont_checkbutton, tmplabel);
166 /* bold font button */
167 entry_folderview_boldfont = gtk_font_button_new_with_font (prefs_common.boldfont);
168 g_object_set(G_OBJECT(entry_folderview_boldfont),
171 gtk_widget_show (entry_folderview_boldfont);
172 gtk_table_attach (GTK_TABLE (table), entry_folderview_boldfont, 1, 2, row, row+1,
173 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
174 (GtkAttachOptions) (0), 0, 0);
175 SET_TOGGLE_SENSITIVITY_REVERSE (derive_from_normalfont_checkbutton, entry_folderview_boldfont);
178 /* print check button */
179 print_checkbutton = gtk_check_button_new_with_label(_("Use different font for printing"));
180 gtk_widget_show(print_checkbutton);
181 gtk_table_attach (GTK_TABLE (table), print_checkbutton, 0, 2, row, row+1,
182 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
183 (GtkAttachOptions) (0), 0, 0);
184 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(print_checkbutton),
185 prefs_common.use_different_print_font);
188 /* print font label */
189 tmplabel = gtk_label_new (_("Message Printing"));
190 gtk_widget_show (tmplabel);
191 gtk_table_attach (GTK_TABLE (table), tmplabel, 0, 1, row, row+1,
192 (GtkAttachOptions) GTK_FILL,
193 (GtkAttachOptions) (0), 0, 0);
194 gtk_label_set_justify(GTK_LABEL(tmplabel), GTK_JUSTIFY_RIGHT);
195 gtk_misc_set_alignment(GTK_MISC(tmplabel), 1, 0.5);
196 SET_TOGGLE_SENSITIVITY (print_checkbutton, tmplabel);
198 /* print font button */
199 entry_messageprintfont = gtk_font_button_new_with_font (prefs_common.printfont);
200 g_object_set(G_OBJECT(entry_messageprintfont),
203 gtk_widget_show (entry_messageprintfont);
204 gtk_table_attach (GTK_TABLE (table), entry_messageprintfont, 1, 2, row, row+1,
205 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
206 (GtkAttachOptions) (0), 0, 0);
207 SET_TOGGLE_SENSITIVITY (print_checkbutton, entry_messageprintfont);
210 prefs_fonts->window = GTK_WIDGET(window);
211 prefs_fonts->entry_folderview_smallfont = entry_folderview_smallfont;
212 prefs_fonts->entry_folderview_normalfont = entry_folderview_normalfont;
213 prefs_fonts->entry_folderview_boldfont = entry_folderview_boldfont;
214 prefs_fonts->entry_messageviewfont = entry_messageviewfont;
215 prefs_fonts->derive_from_normalfont_checkbutton = derive_from_normalfont_checkbutton;
216 prefs_fonts->entry_messageprintfont = entry_messageprintfont;
217 prefs_fonts->print_checkbutton = print_checkbutton;
219 prefs_fonts->page.widget = table;
222 static void prefs_fonts_save(PrefsPage *_page)
224 FontsPage *fonts = (FontsPage *) _page;
226 g_free(prefs_common.boldfont);
227 prefs_common.boldfont = g_strdup(gtk_font_button_get_font_name
228 (GTK_FONT_BUTTON(fonts->entry_folderview_boldfont)));
230 g_free(prefs_common.normalfont);
231 prefs_common.normalfont = g_strdup(gtk_font_button_get_font_name
232 (GTK_FONT_BUTTON(fonts->entry_folderview_normalfont)));
234 g_free(prefs_common.smallfont);
235 prefs_common.smallfont = g_strdup(gtk_font_button_get_font_name
236 (GTK_FONT_BUTTON(fonts->entry_folderview_smallfont)));
238 g_free(prefs_common.textfont);
239 prefs_common.textfont = g_strdup(gtk_font_button_get_font_name
240 (GTK_FONT_BUTTON(fonts->entry_messageviewfont)));
242 prefs_common.derive_from_normal_font = gtk_toggle_button_get_active
243 (GTK_TOGGLE_BUTTON(fonts->derive_from_normalfont_checkbutton));
245 g_free(prefs_common.printfont);
246 prefs_common.printfont = g_strdup(gtk_font_button_get_font_name
247 (GTK_FONT_BUTTON(fonts->entry_messageprintfont)));
248 prefs_common.use_different_print_font = gtk_toggle_button_get_active
249 (GTK_TOGGLE_BUTTON(fonts->print_checkbutton));
251 main_window_reflect_prefs_all();
254 static void prefs_fonts_destroy_widget(PrefsPage *_page)
256 /* FontsPage *fonts = (FontsPage *) _page; */
260 FontsPage *prefs_fonts;
262 void prefs_fonts_init(void)
265 static gchar *path[3];
267 path[0] = _("Display");
268 path[1] = _("Fonts");
271 page = g_new0(FontsPage, 1);
272 page->page.path = path;
273 page->page.create_widget = prefs_fonts_create_widget;
274 page->page.destroy_widget = prefs_fonts_destroy_widget;
275 page->page.save_page = prefs_fonts_save;
276 page->page.weight = 135.0;
277 prefs_gtk_register_page((PrefsPage *) page);
281 void prefs_fonts_done(void)
283 prefs_gtk_unregister_page((PrefsPage *) prefs_fonts);