iceWing
Main Page
Namespaces
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
gui
Goptions.h
Go to the documentation of this file.
1
/* -*- mode: C; tab-width: 4; c-basic-offset: 4; -*- */
2
3
/*
4
* Author: Frank Loemker
5
*
6
* Copyright (C) 1999-2009
7
* Frank Loemker, Applied Computer Science, Faculty of Technology,
8
* Bielefeld University, Germany
9
*
10
* This file is part of iceWing, a graphical plugin shell.
11
*
12
* iceWing is free software; you can redistribute it and/or modify
13
* it under the terms of the GNU General Public License as published by
14
* the Free Software Foundation; either version 2 of the License, or
15
* (at your option) any later version.
16
*
17
* iceWing is distributed in the hope that it will be useful,
18
* but WITHOUT ANY WARRANTY; without even the implied warranty of
19
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
* GNU General Public License for more details.
21
*
22
* You should have received a copy of the GNU General Public License
23
* along with this program; if not, write to the Free Software
24
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
25
*/
26
27
#ifndef iw_Goptions_H
28
#define iw_Goptions_H
29
30
#include <gtk/gtk.h>
31
32
/* Return value for opts_value_set() if error occurs */
33
#define OPTS_SET_ERROR (-9999)
34
35
/* Flags for a list widget: */
36
typedef
enum
{
37
OPTS_SELECT
= 1 << 0,
/* Toggle entries (otherwise only one entry is selected) */
38
OPTS_REORDER
= 1 << 1,
/* Entries can be reordered */
39
OPTS_ADD
= 1 << 2,
/* Entries can be added/removed */
40
OPTS_DATA
= 1 << 3
/* For every entry a string can be entered */
41
}
optsListFlags
;
42
43
/* Data type identifier for opts_variable_add() */
44
typedef
enum
{
45
OPTS_BOOL
,
46
OPTS_INT
,
47
OPTS_LONG
,
48
OPTS_FLOAT
,
49
OPTS_DOUBLE
,
50
OPTS_STRING
51
}
optsType
;
52
53
/* Both optsListEntry and optsListData can be passed to opts_value_set() */
54
55
/* Entries of the list widget, can be passed to opts_value_set() */
56
typedef
struct
optsListEntry
{
57
int
oldindex
;
/* Index of the entry before reordering, -1 marks last entry */
58
gboolean
selected
;
/* Is the entry selected ? */
59
char
*
data
;
/* Any data entered for this entry (see OPTS_DATA) */
60
}
optsListEntry
;
61
62
/* Data for a list entry, can be passed to opts_value_set() */
63
typedef
struct
optsListData
{
64
optsListEntry
*
entries
;
/* Array of all entries */
65
int
current
;
/* Currently selected entry */
66
}
optsListData
;
67
68
typedef
struct
optsWidget
{
69
char
*
title
;
/* Full qualified name */
70
char
*
wtitle
;
/* Pointer inside title, widget name part */
71
void
*
value
;
/* Pointer to the widgets current value/variable */
72
}
optsWidget
;
73
74
/* Signal for a widget, see opts_signal_connect() */
75
typedef
enum
{
76
OPTS_SIG_CHANGED
= 1 << 0,
/* The value of the widget has changed */
77
OPTS_SIG_REMOVE
= 1 << 1
/* The widget is removed */
78
}
optsSignal
;
79
80
typedef
gboolean (*
optsLoadFunc
) (
void
*data,
char
*buffer,
int
size);
81
typedef
gboolean (*
optsSaveFunc
) (
void
*data,
char
*string);
82
83
typedef
void (*
optsCbackFunc
) (GtkWidget *widget,
int
number,
void
*data);
84
85
typedef
gboolean (*
optsSetFunc
) (
void
*value,
void
*newValue,
void
*data);
86
typedef
void (*
optsSignalFunc
) (
optsWidget
*widget,
void
*newValue,
void
*data);
87
88
#ifdef __cplusplus
89
extern
"C"
{
90
#endif
91
92
/*********************************************************************
93
Return name of the default rcFile. Returned value is a pointer to a
94
static variable.
95
*********************************************************************/
96
char
*
opts_get_default_file
(
void
);
97
98
/*********************************************************************
99
Call cback with data as last argument if one of the signals
100
specified with sigset occured for the widget referenced by title.
101
page: - Return value of opts_page_append() or
102
- Return value of prev_get_page() or
103
- Partly a pointer to a prevBuffer or
104
- -1 -> title must have the form 'pageTitle.widgetTitle'
105
title: Name of a widget or 'pageTitle.widgetTitle'
106
Return TRUE on success.
107
*********************************************************************/
108
gboolean
opts_signal_connect
(
long
page,
const
char
*title,
optsSignal
sigset,
109
optsSignalFunc
cback,
void
*data);
110
111
/*********************************************************************
112
Remove widget with title 'title' from options tab.
113
Use 'pageTitle.widgetTitle' for the title argument.
114
Return: Did the widget exist?
115
*********************************************************************/
116
gboolean
opts_widget_remove
(
const
char
*title);
117
118
/*********************************************************************
119
Prevent any values, which are loaded from default config files to
120
be set for the widget referenced by title.
121
*********************************************************************/
122
void
opts_defvalue_remove
(
const
char
*title);
123
124
/*********************************************************************
125
Return a pointer to the current value from the widget referenced by
126
title.
127
title: 'pageTitle.widgetTitle'
128
*********************************************************************/
129
void
*
opts_value_get
(
const
char
*title);
130
131
/*********************************************************************
132
Set new value and display it in widget referenced by title.
133
title: 'pageTitle.widgetTitle'
134
value: strings, floats, list: a pointer to the value
135
otherwise : the value itself
136
Return: Old value on sucess, OPTS_SET_ERROR otherwise (no widget
137
found or value does not fit into one long(e.g. a string)).
138
*********************************************************************/
139
long
opts_value_set
(
const
char
*title,
void
*value);
140
141
/*********************************************************************
142
Add a non graphical value, which gets loaded/saved in the same way
143
as the graphical values. If the value should be set to a new value,
144
setval() is called with the old value, the new value and data as
145
arguments. If setval() returns TRUE or if setval()==NULL the value
146
is set automatically in the background.
147
*********************************************************************/
148
void
opts_variable_add
(
const
char
*title,
optsSetFunc
setval,
void
*data,
149
optsType
type,
void
*value);
150
void
opts_varstring_add
(
const
char
*title,
optsSetFunc
setval,
void
*data,
151
void
*value,
int
length);
152
153
/*
154
* For all opts_..._create() functions:
155
* - page: - return value of opts_page_append() or
156
* - return value of prev_get_page() or
157
* - partly a pointer to a prevBuffer
158
* -> widget is added to the context menu or
159
* - -1 -> title must have the form 'pageTitle.widgetTitle'
160
* - title: Name for the widget or 'pageTitle.widgetTitle'
161
* - If a widget with the name 'pageTitle.widgetTitle' already exists,
162
* the newly created one replaces the old one.
163
*/
164
165
/*********************************************************************
166
Create a new separator with a label.
167
page can be a pointer to a prevBuffer (-> new menu separator).
168
*********************************************************************/
169
void
opts_separator_create
(
long
page,
const
char
*title);
170
171
/*********************************************************************
172
Create new button widgets. On button click value is set to the
173
button number starting at 1. title and ttip are '|'-separated for
174
the single buttons, e.g. "title1|title2" for two buttons.
175
page can be a pointer to a prevBuffer (-> new menu items).
176
*********************************************************************/
177
void
opts_button_create
(
long
page,
const
char
*title,
const
char
*ttip,
178
gint *value);
179
180
/*********************************************************************
181
Create new button widgets. On button click cback is called with the
182
button number starting at 1 and 'data'. title and ttip are
183
'|'-separated for the single buttons, e.g. "title1|title2" for
184
two buttons.
185
page can be a pointer to a prevBuffer (-> new menu items).
186
*********************************************************************/
187
void
opts_buttoncb_create
(
long
page,
const
char
*title,
const
char
*ttip,
188
optsCbackFunc
cback,
void
*data);
189
190
/*********************************************************************
191
Create new string widget. Max allowed length of string is length.
192
*********************************************************************/
193
void
opts_string_create
(
long
page,
const
char
*title,
const
char
*ttip,
194
char
*value,
int
length);
195
196
/*********************************************************************
197
Create new string widget with an "enter" button. The string is
198
updated only on enter press or button click. Max allowed length of
199
string is length.
200
*********************************************************************/
201
void
opts_stringenter_create
(
long
page,
const
char
*title,
const
char
*ttip,
202
char
*value,
int
length);
203
204
/*********************************************************************
205
Create new string widget with an attached button to open a file
206
selection widget. Max allowed length of string is length.
207
*********************************************************************/
208
void
opts_filesel_create
(
long
page,
const
char
*title,
const
char
*ttip,
209
char
*value,
int
length);
210
211
/*********************************************************************
212
Create new integer scale widget with an attached entry widget.
213
*********************************************************************/
214
void
opts_entscale_create
(
long
page,
const
char
*title,
const
char
*ttip,
215
gint *value, gint left, gint right);
216
217
/*********************************************************************
218
Create new scale widget with an attached entry widget (for floats).
219
*********************************************************************/
220
void
opts_float_create
(
long
page,
const
char
*title,
const
char
*ttip,
221
gfloat *value, gfloat left, gfloat right);
222
223
/*********************************************************************
224
Create new toggle widget.
225
page can be a pointer to a prevBuffer (-> new check menu item).
226
*********************************************************************/
227
void
opts_toggle_create
(
long
page,
const
char
*title,
const
char
*ttip,
228
gboolean *value);
229
230
/*********************************************************************
231
Create new option-menu widget with selectable values from label.
232
The const array label must be terminated with NULL.
233
*********************************************************************/
234
void
opts_option_create
(
long
page,
const
char
*title,
const
char
*ttip,
235
char
**label, gint *value);
236
237
/*********************************************************************
238
Create new radio widget with selectable values from label.
239
The const array label must be terminated with NULL.
240
page can be a pointer to a prevBuffer (-> new radio menu item).
241
*********************************************************************/
242
void
opts_radio_create
(
long
page,
const
char
*title,
const
char
*ttip,
243
char
**label, gint *value);
244
245
/*********************************************************************
246
Create new list widget with selectable values from label. The const
247
array label must be terminated with NULL. Allowed meta characters
248
at start of label (for 'Add entry' menu, only usefull if flags
249
contain OPTS_ADD):
250
'>': label is a sub menu
251
'<': Back one hierarchy
252
In label (only usefull if flags contain OPTS_DATA):
253
'|': Separator between label and string help.
254
e.g. {"> Sub1", "Entry1|Help1", "<> Sub2", "Entry2|Help2", NULL}
255
-> Two submenues with two entries, these two can be added to
256
the list widget.
257
value->entries can be NULL (-> list is filled with default values).
258
If not, oldindex of last entry must be -1.
259
*********************************************************************/
260
void
opts_list_create
(
long
page,
const
char
*title,
const
char
*ttip,
261
char
**label,
optsListFlags
flags,
optsListData
*value);
262
263
/*********************************************************************
264
fkt!=NULL: Get settings for widgets and display them by periodically
265
calling fkt(data,buffer,buf_len).
266
fkt==NULL: Load settings of all widgets from file data (a file name
267
of type char*) and display them.
268
*********************************************************************/
269
void
opts_load
(
optsLoadFunc
fkt,
void
*data);
270
271
/*********************************************************************
272
If opts_save() is called, do not save the settings for the widget
273
referenced by title.
274
*********************************************************************/
275
void
opts_save_remove
(
const
char
*title);
276
277
/*********************************************************************
278
fkt!=NULL: Save settings of all widgets by periodically calling
279
fkt(data,string) for all to be saved strings.
280
fkt==NULL: Save settings of all widgets to file data (a file name
281
of type char*).
282
Return: TRUE if no error occurred.
283
*********************************************************************/
284
gboolean
opts_save
(
optsSaveFunc
fkt,
void
*data);
285
286
/*********************************************************************
287
Append a new page to the options notebook. If title contains '.' or
288
' ' (a'.'b or a' 'b) the page is shown in the categories list under
289
node a with entry b.
290
Return: the number of the new page
291
*********************************************************************/
292
int
opts_page_append
(
const
char
*title);
293
294
#ifdef __cplusplus
295
}
296
#endif
297
298
#endif
/* iw_Goptions_H */
Generated by
1.8.1