added missing line
[claws.git] / src / prefs.h
1 /*
2  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3  * Copyright (C) 1999,2000 Hiroyuki Yamamoto
4  *
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.
9  *
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.
14  *
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.
18  */
19
20 #ifndef __PREFS_H__
21 #define __PREFS_H__
22
23 #include <glib.h>
24 #include <gtk/gtkwidget.h>
25 #include <gtk/gtksignal.h>
26 #include <gtk/gtklabel.h>
27 #include <gtk/gtknotebook.h>
28 #include <gtk/gtkcheckbutton.h>
29 #include <gtk/gtkbox.h>
30 #include <stdio.h>
31
32 typedef struct _PrefParam       PrefParam;
33 typedef struct _PrefFile        PrefFile;
34 typedef struct _PrefsDialog     PrefsDialog;
35
36 #include "account.h"
37
38 typedef enum
39 {
40         P_STRING,
41         P_INT,
42         P_BOOL,
43         P_ENUM,
44         P_USHORT,
45         P_OTHER
46 } PrefType;
47
48 typedef void (*DataSetFunc)   (PrefParam *pparam);
49 typedef void (*WidgetSetFunc) (PrefParam *pparam);
50
51 struct _PrefParam {
52         gchar         *name;
53         gchar         *defval;
54         gpointer       data;
55         PrefType       type;
56         GtkWidget    **widget;
57         DataSetFunc    data_set_func;
58         WidgetSetFunc  widget_set_func;
59 };
60
61 struct _PrefFile {
62         FILE *fp;
63         gchar *path;
64 };
65
66 struct _PrefsDialog 
67 {
68         GtkWidget *window;
69         GtkWidget *notebook;
70
71         GtkWidget *ok_btn;
72         GtkWidget *cancel_btn;
73         GtkWidget *apply_btn;
74 };
75
76 #define SET_NOTEBOOK_LABEL(notebook, str, page_num) \
77 { \
78         GtkWidget *label; \
79  \
80         label = gtk_label_new (str); \
81         gtk_widget_show (label); \
82         gtk_notebook_set_tab_label \
83                 (GTK_NOTEBOOK (notebook), \
84                  gtk_notebook_get_nth_page \
85                         (GTK_NOTEBOOK (notebook), page_num), \
86                  label); \
87 }
88
89 #define PACK_CHECK_BUTTON(box, chkbtn, label) \
90 { \
91         chkbtn = gtk_check_button_new_with_label(label); \
92         gtk_widget_show(chkbtn); \
93         gtk_box_pack_start(GTK_BOX(box), chkbtn, FALSE, TRUE, 0); \
94 }
95
96 #define PACK_END_CHECK_BUTTON(box, chkbtn, label) \
97 { \
98         chkbtn = gtk_check_button_new_with_label(label); \
99         gtk_widget_show(chkbtn); \
100         gtk_box_pack_end(GTK_BOX(box), chkbtn, FALSE, TRUE, 0); \
101 }
102
103 #define PACK_FRAME(box, frame, label) \
104 { \
105         frame = gtk_frame_new(label); \
106         gtk_widget_show(frame); \
107         gtk_box_pack_start(GTK_BOX(box), frame, FALSE, TRUE, 0); \
108         gtk_frame_set_label_align(GTK_FRAME(frame), 0.01, 0.5); \
109 }
110
111 #define SET_TOGGLE_SENSITIVITY(togglewid, targetwid) \
112 { \
113         gtk_widget_set_sensitive(targetwid, FALSE); \
114         gtk_signal_connect(GTK_OBJECT(togglewid), "toggled", \
115                            GTK_SIGNAL_FUNC(prefs_button_toggled), targetwid); \
116 }
117
118 void prefs_read_config          (PrefParam      *param,
119                                  const gchar    *label,
120                                  const gchar    *rcfile);
121 void prefs_config_parse_one_line(PrefParam      *param,
122                                  const gchar    *buf);
123 void prefs_save_config          (PrefParam      *param,
124                                  const gchar    *label,
125                                  const gchar    *rcfile);
126 gint prefs_write_param          (PrefParam      *param,
127                                  FILE           *fp);
128
129 PrefFile *prefs_write_open      (const gchar    *path);
130 gint prefs_write_close          (PrefFile       *pfile);
131 gint prefs_write_close_revert   (PrefFile       *pfile);
132
133 void prefs_set_default          (PrefParam      *param);
134 void prefs_free                 (PrefParam      *param);
135
136 void prefs_dialog_create        (PrefsDialog    *dialog);
137
138 void prefs_button_toggled       (GtkToggleButton        *toggle_btn,
139                                  GtkWidget              *widget);
140
141 void prefs_set_dialog           (PrefParam      *param);
142 void prefs_set_data_from_dialog (PrefParam      *param);
143 void prefs_set_dialog_to_default(PrefParam      *param);
144
145 void prefs_set_data_from_entry  (PrefParam      *pparam);
146 void prefs_set_entry            (PrefParam      *pparam);
147 void prefs_set_data_from_text   (PrefParam      *pparam);
148 void prefs_set_text             (PrefParam      *pparam);
149 void prefs_set_data_from_toggle (PrefParam      *pparam);
150 void prefs_set_toggle           (PrefParam      *pparam);
151 void prefs_set_data_from_spinbtn(PrefParam      *pparam);
152 void prefs_set_spinbtn          (PrefParam      *pparam);
153 gboolean prefs_is_readonly(const gchar * path);
154 gboolean prefs_rc_is_readonly(const gchar * rcfile);
155
156 #endif /* __PREFS_H__ */