2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 2003-2004 Hiroyuki Yamamoto & 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.
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;
47 GtkWidget *entry_boldfont;
50 void prefs_fonts_create_widget(PrefsPage *_page, GtkWindow *window,
53 FontsPage *prefs_fonts = (FontsPage *) _page;
56 GtkWidget *entry_folderviewfont;
57 GtkWidget *entry_messageviewfont;
58 GtkWidget *entry_boldfont;
61 GtkWidget *hint_label;
63 table = gtk_table_new(7, 2, FALSE);
64 gtk_widget_show(table);
65 gtk_container_set_border_width(GTK_CONTAINER(table), 8);
66 gtk_table_set_row_spacings(GTK_TABLE(table), 4);
67 gtk_table_set_col_spacings(GTK_TABLE(table), 8);
69 tmplabel = gtk_label_new (_("Folder and Message Lists"));
70 gtk_widget_show (tmplabel);
71 gtk_table_attach (GTK_TABLE (table), tmplabel, 0, 1, 0, 1,
72 (GtkAttachOptions) GTK_FILL,
73 (GtkAttachOptions) (0), 0, 0);
74 gtk_label_set_justify(GTK_LABEL(tmplabel), GTK_JUSTIFY_RIGHT);
75 gtk_misc_set_alignment(GTK_MISC(tmplabel), 1, 0.5);
77 entry_folderviewfont = gtk_font_button_new_with_font (prefs_common.normalfont);
78 g_object_set(G_OBJECT(entry_folderviewfont),
81 gtk_widget_show (entry_folderviewfont);
82 gtk_table_attach (GTK_TABLE (table), entry_folderviewfont, 1, 2, 0, 1,
83 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
84 (GtkAttachOptions) (0), 0, 0);
86 tmplabel = gtk_label_new (_("Message"));
87 gtk_widget_show (tmplabel);
88 gtk_table_attach (GTK_TABLE (table), tmplabel, 0, 1, 2, 3,
89 (GtkAttachOptions) GTK_FILL,
90 (GtkAttachOptions) (0), 0, 0);
91 gtk_label_set_justify(GTK_LABEL(tmplabel), GTK_JUSTIFY_RIGHT);
92 gtk_misc_set_alignment(GTK_MISC(tmplabel), 1, 0.5);
94 entry_messageviewfont = gtk_font_button_new_with_font (prefs_common.textfont);
95 g_object_set(G_OBJECT(entry_messageviewfont),
98 gtk_widget_show (entry_messageviewfont);
99 gtk_table_attach (GTK_TABLE (table), entry_messageviewfont, 1, 2, 2, 3,
100 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
101 (GtkAttachOptions) (0), 0, 0);
103 tmplabel = gtk_label_new (_("Bold"));
104 gtk_widget_show (tmplabel);
105 gtk_table_attach (GTK_TABLE (table), tmplabel, 0, 1, 3, 4,
106 (GtkAttachOptions) GTK_FILL,
107 (GtkAttachOptions) (0), 0, 0);
108 gtk_label_set_justify(GTK_LABEL(tmplabel), GTK_JUSTIFY_RIGHT);
109 gtk_misc_set_alignment(GTK_MISC(tmplabel), 1, 0.5);
111 entry_boldfont = gtk_font_button_new_with_font (prefs_common.boldfont);
112 g_object_set(G_OBJECT(entry_boldfont),
115 gtk_widget_show (entry_boldfont);
116 gtk_table_attach (GTK_TABLE (table), entry_boldfont, 1, 2, 3, 4,
117 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
118 (GtkAttachOptions) (0), 0, 0);
120 vbox = gtk_vbox_new(FALSE, VSPACING_NARROW);
121 gtk_widget_show(vbox);
122 gtk_table_attach (GTK_TABLE (table), vbox, 0, 4, 4, 5,
123 (GtkAttachOptions) GTK_FILL,
124 (GtkAttachOptions) (0), 0, 0);
126 hint_label = gtk_label_new (_("You will need to restart for the "
127 "changes to take effect"));
128 gtk_label_set_justify (GTK_LABEL (hint_label), GTK_JUSTIFY_LEFT);
129 gtkut_widget_set_small_font_size (hint_label);
130 gtk_widget_show (hint_label);
131 gtk_box_pack_start (GTK_BOX (vbox),
132 hint_label, FALSE, FALSE, 0);
133 gtk_misc_set_alignment(GTK_MISC(hint_label), 0.5, 0.5);
135 prefs_fonts->window = GTK_WIDGET(window);
136 prefs_fonts->entry_folderviewfont = entry_folderviewfont;
137 prefs_fonts->entry_messageviewfont = entry_messageviewfont;
138 prefs_fonts->entry_boldfont = entry_boldfont;
140 prefs_fonts->page.widget = table;
143 void prefs_fonts_save(PrefsPage *_page)
145 FontsPage *fonts = (FontsPage *) _page;
147 g_free(prefs_common.normalfont);
148 prefs_common.normalfont = g_strdup(gtk_font_button_get_font_name
149 (GTK_FONT_BUTTON(fonts->entry_folderviewfont)));
151 g_free(prefs_common.smallfont);
152 prefs_common.smallfont = g_strdup(gtk_font_button_get_font_name
153 (GTK_FONT_BUTTON(fonts->entry_folderviewfont)));
155 g_free(prefs_common.textfont);
156 prefs_common.textfont = g_strdup(gtk_font_button_get_font_name
157 (GTK_FONT_BUTTON(fonts->entry_messageviewfont)));
159 g_free(prefs_common.boldfont);
160 prefs_common.boldfont = g_strdup(gtk_font_button_get_font_name
161 (GTK_FONT_BUTTON(fonts->entry_boldfont)));
164 static void prefs_fonts_destroy_widget(PrefsPage *_page)
166 /* FontsPage *fonts = (FontsPage *) _page; */
170 FontsPage *prefs_fonts;
172 void prefs_fonts_init(void)
175 static gchar *path[3];
177 path[0] = _("Display");
178 path[1] = _("Fonts");
181 page = g_new0(FontsPage, 1);
182 page->page.path = path;
183 page->page.create_widget = prefs_fonts_create_widget;
184 page->page.destroy_widget = prefs_fonts_destroy_widget;
185 page->page.save_page = prefs_fonts_save;
186 page->page.weight = 135.0;
187 prefs_gtk_register_page((PrefsPage *) page);
191 void prefs_fonts_done(void)
193 prefs_gtk_unregister_page((PrefsPage *) prefs_fonts);