2 * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2007 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/>.
21 * The structure of this file has been borrowed from the structure of
22 * the image_viewer plugin file. I also used it as an example of how to
23 * build the preferences for the dillo plugin.
33 #include <glib/gi18n.h>
39 #include "prefs_gtk.h"
40 #include "prefswindow.h"
42 #include "dillo_prefs.h"
44 #define PREFS_BLOCK_NAME "Dillo"
46 DilloBrowserPrefs dillo_prefs;
48 typedef struct _DilloBrowserPage DilloBrowserPage;
50 struct _DilloBrowserPage {
56 static PrefParam param[] = {
57 {"local_browse", "TRUE", &dillo_prefs.local, P_BOOL, NULL, NULL, NULL},
58 {"full_window", "TRUE", &dillo_prefs.full, P_BOOL, NULL, NULL, NULL},
62 static DilloBrowserPage prefs_page;
64 static void create_dillo_prefs_page (PrefsPage *page,
67 static void destroy_dillo_prefs_page (PrefsPage *page);
68 static void save_dillo_prefs (PrefsPage *page);
70 void dillo_prefs_init(void)
72 static gchar *path[3];
75 path[0] = _("Plugins");
76 path[1] = _("Dillo Browser");
79 prefs_set_default(param);
80 rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, COMMON_RC, NULL);
81 prefs_read_config(param, PREFS_BLOCK_NAME, rcpath, NULL);
84 prefs_page.page.path = path;
85 prefs_page.page.create_widget = create_dillo_prefs_page;
86 prefs_page.page.destroy_widget = destroy_dillo_prefs_page;
87 prefs_page.page.save_page = save_dillo_prefs;
89 prefs_gtk_register_page((PrefsPage *) &prefs_page);
92 void dillo_prefs_done(void)
94 prefs_gtk_unregister_page((PrefsPage *) &prefs_page);
97 static void create_dillo_prefs_page(PrefsPage *page,
101 DilloBrowserPage *prefs_page = (DilloBrowserPage *) page;
104 GtkWidget *local_checkbox;
105 GtkWidget *full_checkbox;
107 GtkTooltips *local_tooltip;
108 GtkTooltips *full_tooltip;
110 vbox = gtk_vbox_new(FALSE, 3);
111 gtk_container_set_border_width(GTK_CONTAINER(vbox), VBOX_BORDER);
112 gtk_widget_show(vbox);
114 local_tooltip = gtk_tooltips_new();
115 local_checkbox = gtk_check_button_new_with_label
116 (_("Do not load remote links in mails"));
117 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(local_checkbox),
119 gtk_box_pack_start(GTK_BOX(vbox), local_checkbox, FALSE, FALSE, 0);
120 gtk_widget_show(local_checkbox);
121 gtk_tooltips_set_tip(GTK_TOOLTIPS(local_tooltip), local_checkbox,
122 _("Equivalent to Dillo's '--local' option"), NULL);
124 label = gtk_label_new(_("You can still load remote links "
125 "by reloading the page"));
126 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
127 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
128 gtkut_widget_set_small_font_size (label);
129 gtk_widget_show(label);
131 full_tooltip = gtk_tooltips_new();
132 full_checkbox = gtk_check_button_new_with_label
133 (_("Full window mode (hide controls)"));
134 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(full_checkbox),
136 gtk_box_pack_start(GTK_BOX(vbox), full_checkbox, FALSE, FALSE, 0);
137 gtk_widget_show(full_checkbox);
138 gtk_tooltips_set_tip(GTK_TOOLTIPS(full_tooltip), full_checkbox,
139 _("Equivalent to Dillo's '--fullwindow' option"),
142 prefs_page->local = local_checkbox;
143 prefs_page->full = full_checkbox;
144 prefs_page->page.widget = vbox;
147 static void destroy_dillo_prefs_page(PrefsPage *page)
152 static void save_dillo_prefs(PrefsPage *page)
154 DilloBrowserPage *prefs_page = (DilloBrowserPage *) page;
156 gchar *rc_file_path = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
159 dillo_prefs.local = gtk_toggle_button_get_active
160 (GTK_TOGGLE_BUTTON(prefs_page->local));
161 dillo_prefs.full = gtk_toggle_button_get_active
162 (GTK_TOGGLE_BUTTON(prefs_page->full));
164 pref_file = prefs_write_open(rc_file_path);
165 g_free(rc_file_path);
168 (prefs_set_block_label(pref_file, PREFS_BLOCK_NAME) < 0))
171 if (prefs_write_param(param, pref_file->fp) < 0) {
172 g_warning("failed to write Dillo Plugin configuration\n");
173 prefs_file_close_revert(pref_file);
176 fprintf(pref_file->fp, "\n");
177 prefs_file_close(pref_file);