1 /* -*- Mode: C; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 3 -*- */
2 
3 /*
4  * Profile
5  * copyright (c) 2002-2003 Kazuki IWAMOTO http://www.maid.org/ iwm@maid.org
6  *
7  *  This program is free software; you can redistribute it and/or modify
8  *  it under the terms of the GNU General Public License as published by
9  *  the Free Software Foundation; either version 2 of the License, or
10  *  (at your option) any later version.
11  *
12  *  This program is distributed in the hope that it will be useful,
13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *  GNU General Public License for more details.
16  *
17  *  You should have received a copy of the GNU General Public License
18  *  along with this program; if not, write to the Free Software
19  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20  */
21 
22 /*
23  *  2004-02-24 Takuro Ashie <ashie@homa.ne.jp>
24  *      Adapt to GImageView.
25  *
26  *  2003-09-03 Takuro Ashie <ashie@homa.ne.jp>
27  *      Added Kz and kz_ prefix.
28  *      GObjectize.
29  *      Added const keyword for value field of KzPrrofileList.
30  *
31  *  2003-08-28 Takuro Ashie <ashie@homa.ne.jp>
32  *      Translated comments into English.
33  *
34  *  2003-08-27 Takuro Ashie <ashie@homa.ne.jp>
35  *      Modified coding style.
36  *      Changed interface of profile_open().
37  */
38 
39 #ifndef __GIMV_PREFS_H__
40 #define __GIMV_PREFS_H__
41 
42 #ifdef HAVE_CONFIG_H
43 #  include "config.h"
44 #endif
45 
46 #include <gtk/gtk.h>
47 
48 #define GIMV_TYPE_PREFS		        (gimv_prefs_get_type ())
49 #define GIMV_PREFS(obj)            (GTK_CHECK_CAST (obj, gimv_prefs_get_type (), GimvPrefs))
50 #define GIMV_PREFS_CLASS(klass)    (GTK_CHECK_CLASS_CAST (klass, gimv_prefs_get_type, GimvPrefsClass))
51 #define GIMV_IS_PREFS(obj)         (GTK_CHECK_TYPE (obj, gimv_prefs_get_type ()))
52 #define GIMV_IS_PREFS_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMV_TYPE_PREFS))
53 
54 
55 typedef struct GimvPrefs_Tag      GimvPrefs;
56 typedef struct GimvPrefsClass_Tag GimvPrefsClass;
57 typedef struct GimvPrefsList_Tag  GimvPrefsList;
58 
59 
60 #define GIMV_PREFS_DATA_TYPE_UNKNOW 0
61 #define GIMV_PREFS_DATA_TYPE_SPACE 1
62 #define GIMV_PREFS_DATA_TYPE_COMMENT 2
63 #define GIMV_PREFS_DATA_TYPE_SECTION 3
64 #define GIMV_PREFS_DATA_TYPE_KEY 4
65 
66 #define GIMV_PREFS_VALUE_TYPE_BOOL 0
67 #define GIMV_PREFS_VALUE_TYPE_INT 1
68 #define GIMV_PREFS_VALUE_TYPE_STRING 2
69 #define GIMV_PREFS_VALUE_TYPE_ARRAY 3
70 
71 
72 struct GimvPrefs_Tag
73 {
74    GtkObject parent;
75 
76    gboolean edit;
77    gchar *file, *subfile;
78    GimvPrefsList *list, *sublist;
79 };
80 
81 
82 struct GimvPrefsList_Tag
83 {
84    gchar *data, *section, *key;
85    const gchar *value;
86    guint type;
87    struct GimvPrefsList_Tag *prev, *next;
88 };
89 
90 
91 struct GimvPrefsClass_Tag
92 {
93    GtkObjectClass parent_class;
94 
95 	/* -- signals -- */
96    void (*section_added)   (GimvPrefs *profile,
97                             const gchar *section);
98    void (*section_deleted) (GimvPrefs *profile,
99                             const gchar *section);
100    void (*key_added)       (GimvPrefs *profile,
101                             const gchar *section,
102                             const gchar *key);
103    void (*key_deleted)     (GimvPrefs *profile,
104                             const gchar *section,
105                             const gchar *key);
106    void (*changed)         (GimvPrefs *profile,
107                             const gchar *section,
108                             const gchar *key,
109                             const gchar *old_value);
110 };
111 
112 
113 GtkType    gimv_prefs_get_type (void);
114 GimvPrefs *gimv_prefs_new      (void);
115 
116 
117 /*
118  * Open the initialize file.
119  * @file,file name
120  * @RET,the GimvPrefs struct
121  */
122 GimvPrefs *gimv_prefs_open (const gchar *file,
123                             const gchar *subfile);
124 
125 /*
126  * Close the initialize file.
127  * @profile,the GimvPrefs struct
128  * @RET,TRUE:normal exit,FALSE:error
129  */
130 gboolean gimv_prefs_close (GimvPrefs *profile);
131 
132 
133 /*
134  * Save the initialize file.
135  * @profile,the GimvPrefs struct
136  * @RET,TRUE:normal exit,FALSE:error
137  */
138 gboolean gimv_prefs_save (GimvPrefs *profile);
139 
140 
141 /*
142  * Get a string from the initialize file.
143  * @profile,the GimvPrefs struct
144  * @section,name of the section
145  * @key,name of the key
146  * @RET,string,NULL:error
147  */
148 gchar *gimv_prefs_get_string (GimvPrefs *profile,
149                               const gchar *section,
150                               const gchar *key);
151 
152 
153 /*
154  * Get size of a value.
155  * @profile,the GimvPrefs struct
156  * @section,name of the section
157  * @key,name of the key
158  * @type,value type
159  * @RET,bytes,0:error
160  */
161 gint gimv_prefs_get_size (GimvPrefs *profile,
162                           const gchar *section,
163                           const gchar *key,
164                           const guint type);
165 
166 
167 /*
168  * Get a value from the initialize file.
169  * @profile,the GimvPrefs struct
170  * @section,name of the section
171  * @key,name of the key
172  * @value,buffer to store value.
173  * @size,size of buffer to store value.
174  * @type,value type
175  * @RET,TRUE:normal exit,FALSE:error
176  */
177 gboolean gimv_prefs_get_value (GimvPrefs *profile,
178                                const gchar *section,
179                                const gchar *key,
180                                gpointer value,
181                                const gint size,
182                                const guint type);
183 
184 
185 /*
186  * Set a value into the initialize file.
187  * @profile,the GimvPrefs struct
188  * @section,name of the section
189  * @key,name of the key
190  * @value,buffer which store the value.
191  * @size,size of buffer which store the value.
192  * @type,value type
193  * @RET,TRUE:normal exit,FALSE:error
194  */
195 gboolean gimv_prefs_set_value (GimvPrefs *profile,
196                                const gchar *section,
197                                const gchar *key,
198                                gconstpointer value,
199                                const gint size,
200                                const guint type);
201 
202 
203 /*
204  * Delete a section from the initialize file.
205  * @profile,the GimvPrefs struct
206  * @section,name of the section
207  * @RET,TRUE:normal exit,FALSE:error
208  */
209 gboolean gimv_prefs_delete_section (GimvPrefs *profile,
210                                     const gchar *section);
211 
212 
213 /*
214  * Delete a key from the initialize file.
215  * @profile,the GimvPrefs struct
216  * @section,name of the section
217  * @key,key
218  * @RET,TRUE:normal exit,FALSE:error
219  */
220 gboolean gimv_prefs_delete_key (GimvPrefs *profile,
221                                 const gchar *section,
222                                 const gchar *key);
223 
224 
225 /*
226  * Enumerate sections in the initialize file.
227  * @profile,the GimvPrefs struct
228  * @RET,list of sections,NULL:error
229  */
230 GList *gimv_prefs_enum_section (GimvPrefs *profile);
231 
232 
233 /*
234  * Enumelate keys in the initialize file.
235  * @profile,the GimvPrefs struct
236  * @section,name of the section
237  * @RET,list of keys,NULL:error
238 */
239 GList *gimv_prefs_enum_key (GimvPrefs *profile,
240                             const gchar *section);
241 
242 #endif /* __GIMV_PREFS_H__ */
243