2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 2003-2007 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 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
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_folderviewfont;
46 GtkWidget *entry_messageviewfont;
48 GtkWidget *print_checkbutton;
49 GtkWidget *entry_messageprintfont;
53 static void prefs_fonts_create_widget(PrefsPage *_page, GtkWindow *window,
56 FontsPage *prefs_fonts = (FontsPage *) _page;
59 GtkWidget *entry_folderviewfont;
60 GtkWidget *entry_messageviewfont;
63 GtkWidget *entry_messageprintfont;
64 GtkWidget *print_checkbutton;
68 table = gtk_table_new(7, 2, FALSE);
69 gtk_widget_show(table);
70 gtk_container_set_border_width(GTK_CONTAINER(table), VBOX_BORDER);
71 gtk_table_set_row_spacings(GTK_TABLE(table), 4);
72 gtk_table_set_col_spacings(GTK_TABLE(table), 8);
74 tmplabel = gtk_label_new (_("Folder and Message Lists"));
75 gtk_widget_show (tmplabel);
76 gtk_table_attach (GTK_TABLE (table), tmplabel, 0, 1, 0, 1,
77 (GtkAttachOptions) GTK_FILL,
78 (GtkAttachOptions) (0), 0, 0);
79 gtk_label_set_justify(GTK_LABEL(tmplabel), GTK_JUSTIFY_RIGHT);
80 gtk_misc_set_alignment(GTK_MISC(tmplabel), 1, 0.5);
82 entry_folderviewfont = gtk_font_button_new_with_font (prefs_common.normalfont);
83 g_object_set(G_OBJECT(entry_folderviewfont),
86 gtk_widget_show (entry_folderviewfont);
87 gtk_table_attach (GTK_TABLE (table), entry_folderviewfont, 1, 2, 0, 1,
88 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
89 (GtkAttachOptions) (0), 0, 0);
91 tmplabel = gtk_label_new (_("Message"));
92 gtk_widget_show (tmplabel);
93 gtk_table_attach (GTK_TABLE (table), tmplabel, 0, 1, 2, 3,
94 (GtkAttachOptions) GTK_FILL,
95 (GtkAttachOptions) (0), 0, 0);
96 gtk_label_set_justify(GTK_LABEL(tmplabel), GTK_JUSTIFY_RIGHT);
97 gtk_misc_set_alignment(GTK_MISC(tmplabel), 1, 0.5);
99 entry_messageviewfont = gtk_font_button_new_with_font (prefs_common.textfont);
100 g_object_set(G_OBJECT(entry_messageviewfont),
103 gtk_widget_show (entry_messageviewfont);
104 gtk_table_attach (GTK_TABLE (table), entry_messageviewfont, 1, 2, 2, 3,
105 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
106 (GtkAttachOptions) (0), 0, 0);
108 #ifdef USE_GNOMEPRINT
109 /* print check button */
110 print_checkbutton = gtk_check_button_new_with_label(_("Use different font for printing"));
111 gtk_widget_show(print_checkbutton);
112 gtk_table_attach (GTK_TABLE (table), print_checkbutton, 0, 2, 4, 5,
113 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
114 (GtkAttachOptions) (0), 0, 0);
115 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(print_checkbutton),
116 prefs_common.use_different_print_font);
118 /* print font label */
119 tmplabel = gtk_label_new (_("Message Printing"));
120 gtk_widget_show (tmplabel);
121 gtk_table_attach (GTK_TABLE (table), tmplabel, 0, 1, 6, 7,
122 (GtkAttachOptions) GTK_FILL,
123 (GtkAttachOptions) (0), 0, 0);
124 gtk_label_set_justify(GTK_LABEL(tmplabel), GTK_JUSTIFY_RIGHT);
125 gtk_misc_set_alignment(GTK_MISC(tmplabel), 1, 0.5);
126 SET_TOGGLE_SENSITIVITY (print_checkbutton, tmplabel);
128 /* print font button */
129 entry_messageprintfont = gtk_font_button_new_with_font (prefs_common.printfont);
130 g_object_set(G_OBJECT(entry_messageprintfont),
133 gtk_widget_show (entry_messageprintfont);
134 gtk_table_attach (GTK_TABLE (table), entry_messageprintfont, 1, 2, 6, 7,
135 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
136 (GtkAttachOptions) (0), 0, 0);
137 SET_TOGGLE_SENSITIVITY (print_checkbutton, entry_messageprintfont);
140 vbox = gtk_vbox_new(FALSE, VSPACING_NARROW);
141 gtk_widget_show(vbox);
142 gtk_table_attach (GTK_TABLE (table), vbox, 0, 4, 4, 5,
143 (GtkAttachOptions) GTK_FILL,
144 (GtkAttachOptions) (0), 0, 0);
146 prefs_fonts->window = GTK_WIDGET(window);
147 prefs_fonts->entry_folderviewfont = entry_folderviewfont;
148 prefs_fonts->entry_messageviewfont = entry_messageviewfont;
149 #ifdef USE_GNOMEPRINT
150 prefs_fonts->entry_messageprintfont = entry_messageprintfont;
151 prefs_fonts->print_checkbutton = print_checkbutton;
154 prefs_fonts->page.widget = table;
157 static void prefs_fonts_save(PrefsPage *_page)
159 FontsPage *fonts = (FontsPage *) _page;
161 g_free(prefs_common.normalfont);
162 prefs_common.normalfont = g_strdup(gtk_font_button_get_font_name
163 (GTK_FONT_BUTTON(fonts->entry_folderviewfont)));
165 g_free(prefs_common.smallfont);
166 prefs_common.smallfont = g_strdup(gtk_font_button_get_font_name
167 (GTK_FONT_BUTTON(fonts->entry_folderviewfont)));
169 g_free(prefs_common.textfont);
170 prefs_common.textfont = g_strdup(gtk_font_button_get_font_name
171 (GTK_FONT_BUTTON(fonts->entry_messageviewfont)));
173 #ifdef USE_GNOMEPRINT
174 g_free(prefs_common.printfont);
175 prefs_common.printfont = g_strdup(gtk_font_button_get_font_name
176 (GTK_FONT_BUTTON(fonts->entry_messageprintfont)));
177 prefs_common.use_different_print_font = gtk_toggle_button_get_active
178 (GTK_TOGGLE_BUTTON(fonts->print_checkbutton));
181 main_window_reflect_prefs_all();
184 static void prefs_fonts_destroy_widget(PrefsPage *_page)
186 /* FontsPage *fonts = (FontsPage *) _page; */
190 FontsPage *prefs_fonts;
192 void prefs_fonts_init(void)
195 static gchar *path[3];
197 path[0] = _("Display");
198 path[1] = _("Fonts");
201 page = g_new0(FontsPage, 1);
202 page->page.path = path;
203 page->page.create_widget = prefs_fonts_create_widget;
204 page->page.destroy_widget = prefs_fonts_destroy_widget;
205 page->page.save_page = prefs_fonts_save;
206 page->page.weight = 135.0;
207 prefs_gtk_register_page((PrefsPage *) page);
211 void prefs_fonts_done(void)
213 prefs_gtk_unregister_page((PrefsPage *) prefs_fonts);