2
* This file is autogenerated with bcop:
3
* The Compiz option code generator
5
* This program is distributed in the hope that it will be useful,
6
* but WITHOUT ANY WARRANTY; without even the implied warranty of
7
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8
* GNU General Public License for more details.
18
#define _IMGJPEG_OPTIONS_INTERNAL
19
#include "imgjpeg_options.h"
21
static int displayPrivateIndex;
23
static CompMetadata imgjpegOptionsMetadata;
25
static CompPluginVTable *imgjpegPluginVTable = NULL;
26
CompPluginVTable imgjpegOptionsVTable;
28
#define GET_IMGJPEG_OPTIONS_DISPLAY(d) \
29
((ImgjpegOptionsDisplay *) (d)->privates[displayPrivateIndex].ptr)
31
#define IMGJPEG_OPTIONS_DISPLAY(d) \
32
ImgjpegOptionsDisplay *od = GET_IMGJPEG_OPTIONS_DISPLAY (d)
34
#define GET_IMGJPEG_OPTIONS_SCREEN(s, od) \
35
((ImgjpegOptionsScreen *) (s)->privates[(od)->screenPrivateIndex].ptr)
37
#define IMGJPEG_OPTIONS_SCREEN(s) \
38
ImgjpegOptionsScreen *os = GET_IMGJPEG_OPTIONS_SCREEN (s, GET_IMGJPEG_OPTIONS_DISPLAY (s->display))
40
typedef struct _ImgjpegOptionsDisplay
42
int screenPrivateIndex;
44
CompOption opt[ImgjpegDisplayOptionNum];
45
imgjpegDisplayOptionChangeNotifyProc notify[ImgjpegDisplayOptionNum];
46
} ImgjpegOptionsDisplay;
48
typedef struct _ImgjpegOptionsScreen
50
} ImgjpegOptionsScreen;
52
int imgjpegGetQuality (CompDisplay *d)
54
IMGJPEG_OPTIONS_DISPLAY(d);
55
return od->opt[ImgjpegDisplayOptionQuality].value.i;
58
CompOption * imgjpegGetQualityOption (CompDisplay *d)
60
IMGJPEG_OPTIONS_DISPLAY(d);
61
return &od->opt[ImgjpegDisplayOptionQuality];
64
void imgjpegSetQualityNotify (CompDisplay *d, imgjpegDisplayOptionChangeNotifyProc notify)
66
IMGJPEG_OPTIONS_DISPLAY(d);
67
od->notify[ImgjpegDisplayOptionQuality] = notify;
70
CompOption * imgjpegGetDisplayOption (CompDisplay *d, ImgjpegDisplayOptions num)
72
IMGJPEG_OPTIONS_DISPLAY(d);
76
static const CompMetadataOptionInfo imgjpegOptionsDisplayOptionInfo[] = {
77
{ "quality", "int", "<min>0</min><max>100</max>", 0, 0 },
80
static Bool imgjpegOptionsSetDisplayOption (CompPlugin *plugin, CompDisplay *d, char *name, CompOptionValue *value)
82
IMGJPEG_OPTIONS_DISPLAY(d);
86
o = compFindOption (od->opt, ImgjpegDisplayOptionNum, name, &index);
93
case ImgjpegDisplayOptionQuality:
94
if (compSetDisplayOption (d, o, value))
96
if (od->notify[ImgjpegDisplayOptionQuality])
97
(*od->notify[ImgjpegDisplayOptionQuality]) (d, o, ImgjpegDisplayOptionQuality);
107
static CompOption * imgjpegOptionsGetDisplayOptions (CompPlugin *plugin, CompDisplay *d, int *count)
109
IMGJPEG_OPTIONS_DISPLAY(d);
110
*count = ImgjpegDisplayOptionNum;
114
static Bool imgjpegOptionsInitScreen (CompPlugin *p, CompScreen *s)
116
ImgjpegOptionsScreen *os;
118
IMGJPEG_OPTIONS_DISPLAY (s->display);
120
os = calloc (1, sizeof(ImgjpegOptionsScreen));
124
s->privates[od->screenPrivateIndex].ptr = os;
126
if (imgjpegPluginVTable && imgjpegPluginVTable->initScreen)
127
return imgjpegPluginVTable->initScreen (p, s);
131
static void imgjpegOptionsFiniScreen (CompPlugin *p, CompScreen *s)
133
if (imgjpegPluginVTable && imgjpegPluginVTable->finiScreen)
134
return imgjpegPluginVTable->finiScreen (p, s);
136
IMGJPEG_OPTIONS_SCREEN (s);
141
static Bool imgjpegOptionsInitDisplay (CompPlugin *p, CompDisplay *d)
143
ImgjpegOptionsDisplay *od;
146
od = calloc (1, sizeof(ImgjpegOptionsDisplay));
150
od->screenPrivateIndex = allocateScreenPrivateIndex(d);
151
if (od->screenPrivateIndex < 0)
157
d->privates[displayPrivateIndex].ptr = od;
159
if (!compInitDisplayOptionsFromMetadata (d, &imgjpegOptionsMetadata, imgjpegOptionsDisplayOptionInfo, od->opt, ImgjpegDisplayOptionNum))
164
if (imgjpegPluginVTable && imgjpegPluginVTable->initDisplay)
165
return imgjpegPluginVTable->initDisplay (p, d);
169
static void imgjpegOptionsFiniDisplay (CompPlugin *p, CompDisplay *d)
171
if (imgjpegPluginVTable && imgjpegPluginVTable->finiDisplay)
172
return imgjpegPluginVTable->finiDisplay (p, d);
174
IMGJPEG_OPTIONS_DISPLAY (d);
176
freeScreenPrivateIndex(d, od->screenPrivateIndex);
178
compFiniDisplayOptions (d, od->opt, ImgjpegDisplayOptionNum);
183
static Bool imgjpegOptionsInit (CompPlugin *p)
185
displayPrivateIndex = allocateDisplayPrivateIndex();
186
if (displayPrivateIndex < 0)
189
if (!compInitPluginMetadataFromInfo (&imgjpegOptionsMetadata, "imgjpeg",imgjpegOptionsDisplayOptionInfo, ImgjpegDisplayOptionNum, 0, 0))
192
compAddMetadataFromFile (&imgjpegOptionsMetadata, "imgjpeg");
193
if (imgjpegPluginVTable && imgjpegPluginVTable->init)
194
return imgjpegPluginVTable->init (p);
198
static void imgjpegOptionsFini (CompPlugin *p)
200
if (imgjpegPluginVTable && imgjpegPluginVTable->fini)
201
return imgjpegPluginVTable->fini (p);
203
if (displayPrivateIndex >= 0)
204
freeDisplayPrivateIndex(displayPrivateIndex);
206
compFiniMetadata (&imgjpegOptionsMetadata);
209
static CompMetadata *
210
imgjpegOptionsGetMetadata (CompPlugin *plugin)
212
return &imgjpegOptionsMetadata;
215
CompPluginVTable *getCompPluginInfo (void)
217
if (!imgjpegPluginVTable)
219
imgjpegPluginVTable = imgjpegOptionsGetCompPluginInfo ();
220
memcpy(&imgjpegOptionsVTable, imgjpegPluginVTable, sizeof(CompPluginVTable));
221
imgjpegOptionsVTable.getMetadata = imgjpegOptionsGetMetadata;
222
imgjpegOptionsVTable.init = imgjpegOptionsInit;
223
imgjpegOptionsVTable.fini = imgjpegOptionsFini;
224
imgjpegOptionsVTable.initDisplay = imgjpegOptionsInitDisplay;
225
imgjpegOptionsVTable.finiDisplay = imgjpegOptionsFiniDisplay;
226
imgjpegOptionsVTable.initScreen = imgjpegOptionsInitScreen;
227
imgjpegOptionsVTable.finiScreen = imgjpegOptionsFiniScreen;
228
imgjpegOptionsVTable.getDisplayOptions = imgjpegOptionsGetDisplayOptions;
229
imgjpegOptionsVTable.setDisplayOption = imgjpegOptionsSetDisplayOption;
232
return &imgjpegOptionsVTable;