2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2003 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, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 # include "claws-features.h"
30 #include <glib/gi18n.h>
36 #include "prefs_gtk.h"
38 #include "fetchinfo_plugin.h"
44 GtkWidget *fetchinfo_enable;
45 GtkWidget *fetchinfo_uidl;
46 GtkWidget *fetchinfo_account;
47 GtkWidget *fetchinfo_server;
48 GtkWidget *fetchinfo_userid;
49 GtkWidget *fetchinfo_time;
52 static void fetchinfo_set_sensitive(struct FetchinfoPage *page, gboolean enable)
54 gtk_widget_set_sensitive(GTK_WIDGET(page->fetchinfo_uidl), enable);
55 gtk_widget_set_sensitive(GTK_WIDGET(page->fetchinfo_account), enable);
56 gtk_widget_set_sensitive(GTK_WIDGET(page->fetchinfo_server), enable);
57 gtk_widget_set_sensitive(GTK_WIDGET(page->fetchinfo_userid), enable);
58 gtk_widget_set_sensitive(GTK_WIDGET(page->fetchinfo_time), enable);
61 static void fetchinfo_enable_cb(GtkWidget *widget, gpointer data)
63 struct FetchinfoPage *page = (struct FetchinfoPage *) data;
65 fetchinfo_set_sensitive(page, gtk_toggle_button_get_active(
66 GTK_TOGGLE_BUTTON(page->fetchinfo_enable)));
69 #define ADD_NEW_CHECKBOX(line, button, text) \
70 button = gtk_check_button_new_with_label (text); \
71 gtk_widget_show (button); \
72 gtk_table_attach (GTK_TABLE (table), button, 1, 2, line, line+1, \
73 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), \
74 (GtkAttachOptions) (0), 0, 0);
76 static void fetchinfo_create_widget_func(PrefsPage * _page, GtkWindow *window, gpointer data)
78 struct FetchinfoPage *page = (struct FetchinfoPage *) _page;
79 FetchinfoConfig *config;
81 GtkWidget *fetchinfo_enable;
82 GtkWidget *fetchinfo_uidl;
83 GtkWidget *fetchinfo_account;
84 GtkWidget *fetchinfo_server;
85 GtkWidget *fetchinfo_userid;
86 GtkWidget *fetchinfo_time;
88 table = gtk_table_new (6, 3, FALSE);
89 gtk_widget_show(table);
90 gtk_table_set_row_spacings(GTK_TABLE(table), 4);
91 gtk_table_set_col_spacings(GTK_TABLE(table), 8);
93 /* i18n: Heading of a preferences section determining which headers to add */
94 fetchinfo_enable = gtk_check_button_new_with_label (_("Add fetchinfo headers"));
95 gtk_widget_show (fetchinfo_enable);
96 gtk_table_attach (GTK_TABLE (table), fetchinfo_enable, 0, 2, 0, 1,
97 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
98 (GtkAttachOptions) (0), 0, 0);
100 /* i18n: Description of a header to be added */
101 ADD_NEW_CHECKBOX(1, fetchinfo_uidl, _("UIDL"));
102 /* i18n: Description of a header to be added */
103 ADD_NEW_CHECKBOX(2, fetchinfo_account, _("Account name"));
104 /* i18n: Description of a header to be added */
105 ADD_NEW_CHECKBOX(3, fetchinfo_server, _("Receive server"));
106 /* i18n: Description of a header to be added */
107 ADD_NEW_CHECKBOX(4, fetchinfo_userid, _("UserID"));
108 /* i18n: Description of a header to be added */
109 ADD_NEW_CHECKBOX(5, fetchinfo_time, _("Fetch time"));
111 config = fetchinfo_get_config();
113 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(fetchinfo_enable),
114 config->fetchinfo_enable);
115 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(fetchinfo_uidl),
116 config->fetchinfo_uidl);
117 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(fetchinfo_account),
118 config->fetchinfo_account);
119 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(fetchinfo_server),
120 config->fetchinfo_server);
121 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(fetchinfo_userid),
122 config->fetchinfo_userid);
123 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(fetchinfo_time),
124 config->fetchinfo_time);
126 g_signal_connect(G_OBJECT(fetchinfo_enable), "released",
127 G_CALLBACK(fetchinfo_enable_cb), page);
129 page->fetchinfo_enable = fetchinfo_enable;
130 page->fetchinfo_uidl = fetchinfo_uidl;
131 page->fetchinfo_account = fetchinfo_account;
132 page->fetchinfo_server = fetchinfo_server;
133 page->fetchinfo_userid = fetchinfo_userid;
134 page->fetchinfo_time = fetchinfo_time;
136 page->page.widget = table;
138 fetchinfo_set_sensitive(page, config->fetchinfo_enable);
140 #undef ADD_NEW_CHECKBOX
142 static void fetchinfo_destroy_widget_func(PrefsPage *_page)
144 debug_print("Destroying Fetchinfo widget\n");
147 static void fetchinfo_save_func(PrefsPage *_page)
149 struct FetchinfoPage *page = (struct FetchinfoPage *) _page;
150 FetchinfoConfig *config;
152 debug_print("Saving Fetchinfo Page\n");
154 config = fetchinfo_get_config();
156 config->fetchinfo_enable = gtk_toggle_button_get_active(
157 GTK_TOGGLE_BUTTON(page->fetchinfo_enable) );
158 config->fetchinfo_uidl = gtk_toggle_button_get_active(
159 GTK_TOGGLE_BUTTON(page->fetchinfo_uidl) );
160 config->fetchinfo_account = gtk_toggle_button_get_active(
161 GTK_TOGGLE_BUTTON(page->fetchinfo_account));
162 config->fetchinfo_server = gtk_toggle_button_get_active(
163 GTK_TOGGLE_BUTTON(page->fetchinfo_server) );
164 config->fetchinfo_userid = gtk_toggle_button_get_active(
165 GTK_TOGGLE_BUTTON(page->fetchinfo_userid) );
166 config->fetchinfo_time = gtk_toggle_button_get_active(
167 GTK_TOGGLE_BUTTON(page->fetchinfo_time) );
169 fetchinfo_save_config();
172 static struct FetchinfoPage fetchinfo_page;
174 gint fetchinfo_gtk_init(void)
176 static gchar *path[3];
178 path[0] = _("Plugins");
179 path[1] = _("Fetchinfo");
182 fetchinfo_page.page.path = path;
183 fetchinfo_page.page.create_widget = fetchinfo_create_widget_func;
184 fetchinfo_page.page.destroy_widget = fetchinfo_destroy_widget_func;
185 fetchinfo_page.page.save_page = fetchinfo_save_func;
187 prefs_gtk_register_page((PrefsPage *) &fetchinfo_page);
189 debug_print("Fetchinfo GTK plugin loaded\n");
193 void fetchinfo_gtk_done(void)
195 prefs_gtk_unregister_page((PrefsPage *) &fetchinfo_page);
197 debug_print("Fetchinfo GTK plugin unloaded\n");