2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2003 Hiroyuki Yamamoto and 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.
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.
38 #include "prefs_gtk.h"
39 #include "prefswindow.h"
41 #include "dillo_prefs.h"
43 #define PREFS_BLOCK_NAME "Dillo"
45 DilloBrowserPrefs dillo_prefs;
47 typedef struct _DilloBrowserPage DilloBrowserPage;
49 struct _DilloBrowserPage {
55 static PrefParam param[] = {
56 {"local_browse", "TRUE", &dillo_prefs.local, P_BOOL, NULL, NULL, NULL},
57 {"full_window", "TRUE", &dillo_prefs.full, P_BOOL, NULL, NULL, NULL},
61 DilloBrowserPage prefs_page;
63 static void create_dillo_prefs_page (PrefsPage *page,
66 static void destroy_dillo_prefs_page (PrefsPage *page);
67 static void save_dillo_prefs (PrefsPage *page);
69 void dillo_prefs_init(void)
71 prefs_set_default(param);
72 prefs_read_config(param, PREFS_BLOCK_NAME, COMMON_RC);
74 prefs_page.page.path = "Message View/Dillo Browser";
75 prefs_page.page.create_widget = create_dillo_prefs_page;
76 prefs_page.page.destroy_widget = destroy_dillo_prefs_page;
77 prefs_page.page.save_page = save_dillo_prefs;
79 prefs_gtk_register_page((PrefsPage *) &prefs_page);
82 void dillo_prefs_done(void)
84 prefs_gtk_unregister_page((PrefsPage *) &prefs_page);
87 static void create_dillo_prefs_page(PrefsPage *page,
91 DilloBrowserPage *prefs_page = (DilloBrowserPage *) page;
94 GtkWidget *local_checkbox;
95 GtkWidget *full_checkbox;
97 GtkTooltips *local_tooltip;
98 GtkTooltips *full_tooltip;
100 vbox = gtk_vbox_new(FALSE, 3);
101 gtk_container_set_border_width(GTK_CONTAINER(vbox), 3);
102 gtk_widget_show(vbox);
104 local_tooltip = gtk_tooltips_new();
105 local_checkbox = gtk_check_button_new_with_label
106 (_("Do not load remote links in mails"));
107 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(local_checkbox),
109 gtk_box_pack_start(GTK_BOX(vbox), local_checkbox, FALSE, FALSE, 0);
110 gtk_widget_show(local_checkbox);
111 gtk_tooltips_set_tip(GTK_TOOLTIPS(local_tooltip), local_checkbox,
112 _("Equivalent to Dillo's '--local' option"), NULL);
114 label = gtk_label_new(_("You can still load remote links "
115 "by reloading the page"));
116 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
117 gtk_widget_show(label);
119 full_tooltip = gtk_tooltips_new();
120 full_checkbox = gtk_check_button_new_with_label
121 (_("Full window mode (hide controls)"));
122 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(full_checkbox),
124 gtk_box_pack_start(GTK_BOX(vbox), full_checkbox, FALSE, FALSE, 0);
125 gtk_widget_show(full_checkbox);
126 gtk_tooltips_set_tip(GTK_TOOLTIPS(full_tooltip), full_checkbox,
127 _("Equivalent to Dillo's '--fullwindow' option"),
130 prefs_page->local = local_checkbox;
131 prefs_page->full = full_checkbox;
132 prefs_page->page.widget = vbox;
135 static void destroy_dillo_prefs_page(PrefsPage *page)
140 static void save_dillo_prefs(PrefsPage *page)
142 DilloBrowserPage *prefs_page = (DilloBrowserPage *) page;
144 gchar *rc_file_path = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
147 dillo_prefs.local = gtk_toggle_button_get_active
148 (GTK_TOGGLE_BUTTON(prefs_page->local));
149 dillo_prefs.full = gtk_toggle_button_get_active
150 (GTK_TOGGLE_BUTTON(prefs_page->full));
152 pref_file = prefs_write_open(rc_file_path);
153 g_free(rc_file_path);
156 (prefs_set_block_label(pref_file, PREFS_BLOCK_NAME) < 0))
159 if (prefs_write_param(param, pref_file->fp) < 0) {
160 g_warning("failed to write Dillo Plugin configuration\n");
161 prefs_file_close_revert(pref_file);
164 fprintf(pref_file->fp, "\n");
165 prefs_file_close(pref_file);