2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 2003-2012 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/>.
22 #include "claws-features.h"
31 #include <glib/gi18n.h>
33 #include <gdk/gdkkeysyms.h>
35 #include "prefs_common.h"
36 #include "prefs_gtk.h"
38 #include "gtk/prefswindow.h"
40 typedef struct _FontsPage
44 GtkWidget
*window
; /* do not modify */
46 GtkWidget
*entry_folderview_smallfont
;
47 GtkWidget
*entry_folderview_normalfont
;
48 GtkWidget
*entry_folderview_boldfont
;
49 GtkWidget
*entry_messageviewfont
;
50 GtkWidget
*derive_from_normalfont_checkbutton
;
51 GtkWidget
*print_checkbutton
;
52 GtkWidget
*entry_messageprintfont
;
55 static void prefs_fonts_create_widget(PrefsPage
*_page
, GtkWindow
*window
,
58 FontsPage
*prefs_fonts
= (FontsPage
*) _page
;
61 GtkWidget
*entry_folderview_smallfont
;
62 GtkWidget
*entry_folderview_normalfont
;
63 GtkWidget
*entry_folderview_boldfont
;
64 GtkWidget
*entry_messageviewfont
;
66 GtkWidget
*entry_messageprintfont
;
67 GtkWidget
*print_checkbutton
;
68 GtkWidget
*derive_from_normalfont_checkbutton
;
72 table
= gtk_table_new(10, 2, FALSE
);
73 gtk_widget_show(table
);
74 gtk_container_set_border_width(GTK_CONTAINER(table
), VBOX_BORDER
);
75 gtk_table_set_row_spacings(GTK_TABLE(table
), 4);
76 gtk_table_set_col_spacings(GTK_TABLE(table
), 8);
78 /* normal font label */
79 tmplabel
= gtk_label_new (_("Folder and Message Lists"));
80 gtk_widget_show (tmplabel
);
81 gtk_table_attach (GTK_TABLE (table
), tmplabel
, 0, 1, row
, row
+1,
82 (GtkAttachOptions
) GTK_FILL
,
83 (GtkAttachOptions
) (0), 0, 0);
84 gtk_label_set_justify(GTK_LABEL(tmplabel
), GTK_JUSTIFY_RIGHT
);
85 gtk_misc_set_alignment(GTK_MISC(tmplabel
), 1, 0.5);
87 /* normal font button */
88 entry_folderview_normalfont
= gtk_font_button_new_with_font (prefs_common
.normalfont
);
89 g_object_set(G_OBJECT(entry_folderview_normalfont
),
92 gtk_widget_show (entry_folderview_normalfont
);
93 gtk_table_attach (GTK_TABLE (table
), entry_folderview_normalfont
, 1, 2, row
, row
+1,
94 (GtkAttachOptions
) (GTK_EXPAND
| GTK_FILL
),
95 (GtkAttachOptions
) (0), 0, 0);
98 /* message font label */
99 tmplabel
= gtk_label_new (_("Message"));
100 gtk_widget_show (tmplabel
);
101 gtk_table_attach (GTK_TABLE (table
), tmplabel
, 0, 1, row
, row
+1,
102 (GtkAttachOptions
) GTK_FILL
,
103 (GtkAttachOptions
) (0), 0, 0);
104 gtk_label_set_justify(GTK_LABEL(tmplabel
), GTK_JUSTIFY_RIGHT
);
105 gtk_misc_set_alignment(GTK_MISC(tmplabel
), 1, 0.5);
107 /* message font button */
108 entry_messageviewfont
= gtk_font_button_new_with_font (prefs_common
.textfont
);
109 g_object_set(G_OBJECT(entry_messageviewfont
),
112 gtk_widget_show (entry_messageviewfont
);
113 gtk_table_attach (GTK_TABLE (table
), entry_messageviewfont
, 1, 2, row
, row
+1,
114 (GtkAttachOptions
) (GTK_EXPAND
| GTK_FILL
),
115 (GtkAttachOptions
) (0), 0, 0);
118 vbox
= gtk_vbox_new(FALSE
, VSPACING_NARROW
);
119 gtk_widget_show(vbox
);
120 gtk_table_attach (GTK_TABLE (table
), vbox
, 0, 4, row
, row
+1,
121 (GtkAttachOptions
) GTK_FILL
,
122 (GtkAttachOptions
) (0), 0, 0);
125 /* derive from normal font check button */
126 derive_from_normalfont_checkbutton
= gtk_check_button_new_with_label(_("Derive small and bold fonts from Folder and Message Lists font"));
127 gtk_widget_show(derive_from_normalfont_checkbutton
);
128 gtk_table_attach (GTK_TABLE (table
), derive_from_normalfont_checkbutton
, 0, 2, row
, row
+1,
129 (GtkAttachOptions
) (GTK_EXPAND
| GTK_FILL
),
130 (GtkAttachOptions
) (0), 0, 0);
131 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(derive_from_normalfont_checkbutton
),
132 prefs_common
.derive_from_normal_font
);
135 /* small font label */
136 tmplabel
= gtk_label_new (_("Small"));
137 gtk_widget_show (tmplabel
);
138 gtk_table_attach (GTK_TABLE (table
), tmplabel
, 0, 1, row
, row
+1,
139 (GtkAttachOptions
) GTK_FILL
,
140 (GtkAttachOptions
) (0), 0, 0);
141 gtk_label_set_justify(GTK_LABEL(tmplabel
), GTK_JUSTIFY_RIGHT
);
142 gtk_misc_set_alignment(GTK_MISC(tmplabel
), 1, 0.5);
143 SET_TOGGLE_SENSITIVITY_REVERSE (derive_from_normalfont_checkbutton
, tmplabel
);
145 /* small font button */
146 entry_folderview_smallfont
= gtk_font_button_new_with_font (prefs_common
.smallfont
);
147 g_object_set(G_OBJECT(entry_folderview_smallfont
),
150 gtk_widget_show (entry_folderview_smallfont
);
151 gtk_table_attach (GTK_TABLE (table
), entry_folderview_smallfont
, 1, 2, row
, row
+1,
152 (GtkAttachOptions
) (GTK_EXPAND
| GTK_FILL
),
153 (GtkAttachOptions
) (0), 0, 0);
154 SET_TOGGLE_SENSITIVITY_REVERSE (derive_from_normalfont_checkbutton
, entry_folderview_smallfont
);
157 /* bold font label */
158 tmplabel
= gtk_label_new (_("Bold"));
159 gtk_widget_show (tmplabel
);
160 gtk_table_attach (GTK_TABLE (table
), tmplabel
, 0, 1, row
, row
+1,
161 (GtkAttachOptions
) GTK_FILL
,
162 (GtkAttachOptions
) (0), 0, 0);
163 gtk_label_set_justify(GTK_LABEL(tmplabel
), GTK_JUSTIFY_RIGHT
);
164 gtk_misc_set_alignment(GTK_MISC(tmplabel
), 1, 0.5);
165 SET_TOGGLE_SENSITIVITY_REVERSE (derive_from_normalfont_checkbutton
, tmplabel
);
167 /* bold font button */
168 entry_folderview_boldfont
= gtk_font_button_new_with_font (prefs_common
.boldfont
);
169 g_object_set(G_OBJECT(entry_folderview_boldfont
),
172 gtk_widget_show (entry_folderview_boldfont
);
173 gtk_table_attach (GTK_TABLE (table
), entry_folderview_boldfont
, 1, 2, row
, row
+1,
174 (GtkAttachOptions
) (GTK_EXPAND
| GTK_FILL
),
175 (GtkAttachOptions
) (0), 0, 0);
176 SET_TOGGLE_SENSITIVITY_REVERSE (derive_from_normalfont_checkbutton
, entry_folderview_boldfont
);
179 /* print check button */
180 print_checkbutton
= gtk_check_button_new_with_label(_("Use different font for printing"));
181 gtk_widget_show(print_checkbutton
);
182 gtk_table_attach (GTK_TABLE (table
), print_checkbutton
, 0, 2, row
, row
+1,
183 (GtkAttachOptions
) (GTK_EXPAND
| GTK_FILL
),
184 (GtkAttachOptions
) (0), 0, 0);
185 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(print_checkbutton
),
186 prefs_common
.use_different_print_font
);
189 /* print font label */
190 tmplabel
= gtk_label_new (_("Message Printing"));
191 gtk_widget_show (tmplabel
);
192 gtk_table_attach (GTK_TABLE (table
), tmplabel
, 0, 1, row
, row
+1,
193 (GtkAttachOptions
) GTK_FILL
,
194 (GtkAttachOptions
) (0), 0, 0);
195 gtk_label_set_justify(GTK_LABEL(tmplabel
), GTK_JUSTIFY_RIGHT
);
196 gtk_misc_set_alignment(GTK_MISC(tmplabel
), 1, 0.5);
197 SET_TOGGLE_SENSITIVITY (print_checkbutton
, tmplabel
);
199 /* print font button */
200 entry_messageprintfont
= gtk_font_button_new_with_font (prefs_common
.printfont
);
201 g_object_set(G_OBJECT(entry_messageprintfont
),
204 gtk_widget_show (entry_messageprintfont
);
205 gtk_table_attach (GTK_TABLE (table
), entry_messageprintfont
, 1, 2, row
, row
+1,
206 (GtkAttachOptions
) (GTK_EXPAND
| GTK_FILL
),
207 (GtkAttachOptions
) (0), 0, 0);
208 SET_TOGGLE_SENSITIVITY (print_checkbutton
, entry_messageprintfont
);
211 prefs_fonts
->window
= GTK_WIDGET(window
);
212 prefs_fonts
->entry_folderview_smallfont
= entry_folderview_smallfont
;
213 prefs_fonts
->entry_folderview_normalfont
= entry_folderview_normalfont
;
214 prefs_fonts
->entry_folderview_boldfont
= entry_folderview_boldfont
;
215 prefs_fonts
->entry_messageviewfont
= entry_messageviewfont
;
216 prefs_fonts
->derive_from_normalfont_checkbutton
= derive_from_normalfont_checkbutton
;
217 prefs_fonts
->entry_messageprintfont
= entry_messageprintfont
;
218 prefs_fonts
->print_checkbutton
= print_checkbutton
;
220 prefs_fonts
->page
.widget
= table
;
223 static void prefs_fonts_save(PrefsPage
*_page
)
225 FontsPage
*fonts
= (FontsPage
*) _page
;
227 g_free(prefs_common
.boldfont
);
228 prefs_common
.boldfont
= g_strdup(gtk_font_button_get_font_name
229 (GTK_FONT_BUTTON(fonts
->entry_folderview_boldfont
)));
231 g_free(prefs_common
.normalfont
);
232 prefs_common
.normalfont
= g_strdup(gtk_font_button_get_font_name
233 (GTK_FONT_BUTTON(fonts
->entry_folderview_normalfont
)));
235 g_free(prefs_common
.smallfont
);
236 prefs_common
.smallfont
= g_strdup(gtk_font_button_get_font_name
237 (GTK_FONT_BUTTON(fonts
->entry_folderview_smallfont
)));
239 g_free(prefs_common
.textfont
);
240 prefs_common
.textfont
= g_strdup(gtk_font_button_get_font_name
241 (GTK_FONT_BUTTON(fonts
->entry_messageviewfont
)));
243 prefs_common
.derive_from_normal_font
= gtk_toggle_button_get_active
244 (GTK_TOGGLE_BUTTON(fonts
->derive_from_normalfont_checkbutton
));
246 g_free(prefs_common
.printfont
);
247 prefs_common
.printfont
= g_strdup(gtk_font_button_get_font_name
248 (GTK_FONT_BUTTON(fonts
->entry_messageprintfont
)));
249 prefs_common
.use_different_print_font
= gtk_toggle_button_get_active
250 (GTK_TOGGLE_BUTTON(fonts
->print_checkbutton
));
252 main_window_reflect_prefs_all();
255 static void prefs_fonts_destroy_widget(PrefsPage
*_page
)
257 /* FontsPage *fonts = (FontsPage *) _page; */
261 FontsPage
*prefs_fonts
;
263 void prefs_fonts_init(void)
266 static gchar
*path
[3];
268 path
[0] = _("Display");
269 path
[1] = _("Fonts");
272 page
= g_new0(FontsPage
, 1);
273 page
->page
.path
= path
;
274 page
->page
.create_widget
= prefs_fonts_create_widget
;
275 page
->page
.destroy_widget
= prefs_fonts_destroy_widget
;
276 page
->page
.save_page
= prefs_fonts_save
;
277 page
->page
.weight
= 135.0;
278 prefs_gtk_register_page((PrefsPage
*) page
);
282 void prefs_fonts_done(void)
284 prefs_gtk_unregister_page((PrefsPage
*) prefs_fonts
);