~ubuntu-branches/ubuntu/gutsy/compiz-fusion-plugins-main/gutsy

« back to all changes in this revision

Viewing changes to src/jpeg/imgjpeg_options.c

  • Committer: Bazaar Package Importer
  • Author(s): Michael Vogt
  • Date: 2007-06-25 14:53:30 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20070625145330-279imp4j31n39ybp
Tags: 0.0.0+git20070625-0ubuntu1
new git snapshot (fixes animation plugin breakage)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * This file is autogenerated with bcop:
 
3
 * The Compiz option code generator
 
4
 *
 
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.
 
9
 *
 
10
 */
 
11
 
 
12
#include <stdio.h>
 
13
#include <stdlib.h>
 
14
#include <string.h>
 
15
 
 
16
#include <compiz.h>
 
17
 
 
18
#define _IMGJPEG_OPTIONS_INTERNAL
 
19
#include "imgjpeg_options.h"
 
20
 
 
21
static int displayPrivateIndex;
 
22
 
 
23
static CompMetadata imgjpegOptionsMetadata;
 
24
 
 
25
static CompPluginVTable *imgjpegPluginVTable = NULL;
 
26
CompPluginVTable imgjpegOptionsVTable;
 
27
 
 
28
#define GET_IMGJPEG_OPTIONS_DISPLAY(d) \
 
29
        ((ImgjpegOptionsDisplay *) (d)->privates[displayPrivateIndex].ptr)
 
30
 
 
31
#define IMGJPEG_OPTIONS_DISPLAY(d) \
 
32
        ImgjpegOptionsDisplay *od = GET_IMGJPEG_OPTIONS_DISPLAY (d)
 
33
 
 
34
#define GET_IMGJPEG_OPTIONS_SCREEN(s, od) \
 
35
        ((ImgjpegOptionsScreen *) (s)->privates[(od)->screenPrivateIndex].ptr)
 
36
 
 
37
#define IMGJPEG_OPTIONS_SCREEN(s) \
 
38
        ImgjpegOptionsScreen *os = GET_IMGJPEG_OPTIONS_SCREEN (s, GET_IMGJPEG_OPTIONS_DISPLAY (s->display))
 
39
 
 
40
typedef struct _ImgjpegOptionsDisplay
 
41
{
 
42
    int screenPrivateIndex;
 
43
 
 
44
    CompOption opt[ImgjpegDisplayOptionNum];
 
45
    imgjpegDisplayOptionChangeNotifyProc notify[ImgjpegDisplayOptionNum];
 
46
} ImgjpegOptionsDisplay;
 
47
 
 
48
typedef struct _ImgjpegOptionsScreen
 
49
{
 
50
} ImgjpegOptionsScreen;
 
51
 
 
52
int imgjpegGetQuality (CompDisplay *d)
 
53
{
 
54
    IMGJPEG_OPTIONS_DISPLAY(d);
 
55
    return od->opt[ImgjpegDisplayOptionQuality].value.i;
 
56
}
 
57
 
 
58
CompOption * imgjpegGetQualityOption (CompDisplay *d)
 
59
{
 
60
    IMGJPEG_OPTIONS_DISPLAY(d);
 
61
    return &od->opt[ImgjpegDisplayOptionQuality];
 
62
}
 
63
 
 
64
void imgjpegSetQualityNotify (CompDisplay *d, imgjpegDisplayOptionChangeNotifyProc notify)
 
65
{
 
66
    IMGJPEG_OPTIONS_DISPLAY(d);
 
67
    od->notify[ImgjpegDisplayOptionQuality] = notify;
 
68
}
 
69
 
 
70
CompOption * imgjpegGetDisplayOption (CompDisplay *d, ImgjpegDisplayOptions num)
 
71
{
 
72
    IMGJPEG_OPTIONS_DISPLAY(d);
 
73
    return &od->opt[num];
 
74
}
 
75
 
 
76
static const CompMetadataOptionInfo imgjpegOptionsDisplayOptionInfo[] = {
 
77
    { "quality", "int", "<min>0</min><max>100</max>", 0, 0 },
 
78
};
 
79
 
 
80
static Bool imgjpegOptionsSetDisplayOption (CompPlugin *plugin, CompDisplay *d, char *name, CompOptionValue *value)
 
81
{
 
82
    IMGJPEG_OPTIONS_DISPLAY(d);
 
83
    CompOption *o;
 
84
    int        index;
 
85
 
 
86
    o = compFindOption (od->opt, ImgjpegDisplayOptionNum, name, &index);
 
87
 
 
88
    if (!o)
 
89
        return FALSE;
 
90
 
 
91
    switch (index)
 
92
    {
 
93
     case ImgjpegDisplayOptionQuality:
 
94
        if (compSetDisplayOption (d, o, value))
 
95
        {
 
96
            if (od->notify[ImgjpegDisplayOptionQuality])
 
97
                (*od->notify[ImgjpegDisplayOptionQuality]) (d, o, ImgjpegDisplayOptionQuality);
 
98
            return TRUE;
 
99
        }
 
100
        break;
 
101
    default:
 
102
        break;
 
103
    }
 
104
    return FALSE;
 
105
}
 
106
 
 
107
static CompOption * imgjpegOptionsGetDisplayOptions (CompPlugin *plugin, CompDisplay *d, int *count)
 
108
{
 
109
    IMGJPEG_OPTIONS_DISPLAY(d);
 
110
    *count = ImgjpegDisplayOptionNum;
 
111
    return od->opt;
 
112
}
 
113
 
 
114
static Bool imgjpegOptionsInitScreen (CompPlugin *p, CompScreen *s)
 
115
{
 
116
    ImgjpegOptionsScreen *os;
 
117
    
 
118
    IMGJPEG_OPTIONS_DISPLAY (s->display);
 
119
 
 
120
    os = calloc (1, sizeof(ImgjpegOptionsScreen));
 
121
    if (!os)
 
122
        return FALSE;
 
123
 
 
124
    s->privates[od->screenPrivateIndex].ptr = os;
 
125
 
 
126
        if (imgjpegPluginVTable && imgjpegPluginVTable->initScreen)
 
127
        return imgjpegPluginVTable->initScreen (p, s);
 
128
    return TRUE;
 
129
}
 
130
 
 
131
static void imgjpegOptionsFiniScreen (CompPlugin *p, CompScreen *s)
 
132
{
 
133
    if (imgjpegPluginVTable && imgjpegPluginVTable->finiScreen)
 
134
        return imgjpegPluginVTable->finiScreen (p, s);
 
135
 
 
136
    IMGJPEG_OPTIONS_SCREEN (s);
 
137
 
 
138
    free (os);
 
139
}
 
140
 
 
141
static Bool imgjpegOptionsInitDisplay (CompPlugin *p, CompDisplay *d)
 
142
{
 
143
    ImgjpegOptionsDisplay *od;
 
144
   
 
145
    
 
146
    od = calloc (1, sizeof(ImgjpegOptionsDisplay));
 
147
    if (!od)
 
148
        return FALSE;
 
149
 
 
150
    od->screenPrivateIndex = allocateScreenPrivateIndex(d);
 
151
    if (od->screenPrivateIndex < 0)
 
152
    {
 
153
        free(od);
 
154
        return FALSE;
 
155
    }
 
156
 
 
157
    d->privates[displayPrivateIndex].ptr = od;
 
158
 
 
159
    if (!compInitDisplayOptionsFromMetadata (d, &imgjpegOptionsMetadata, imgjpegOptionsDisplayOptionInfo, od->opt, ImgjpegDisplayOptionNum))
 
160
    {
 
161
        free (od);
 
162
        return FALSE;
 
163
    }
 
164
    if (imgjpegPluginVTable && imgjpegPluginVTable->initDisplay)
 
165
        return imgjpegPluginVTable->initDisplay (p, d);
 
166
    return TRUE;
 
167
}
 
168
 
 
169
static void imgjpegOptionsFiniDisplay (CompPlugin *p, CompDisplay *d)
 
170
{
 
171
    if (imgjpegPluginVTable && imgjpegPluginVTable->finiDisplay)
 
172
        return imgjpegPluginVTable->finiDisplay (p, d);
 
173
 
 
174
    IMGJPEG_OPTIONS_DISPLAY (d);
 
175
 
 
176
    freeScreenPrivateIndex(d, od->screenPrivateIndex);
 
177
 
 
178
    compFiniDisplayOptions (d, od->opt, ImgjpegDisplayOptionNum);
 
179
 
 
180
    free (od);
 
181
}
 
182
 
 
183
static Bool imgjpegOptionsInit (CompPlugin *p)
 
184
{
 
185
    displayPrivateIndex = allocateDisplayPrivateIndex();
 
186
    if (displayPrivateIndex < 0)
 
187
        return FALSE;
 
188
 
 
189
    if (!compInitPluginMetadataFromInfo (&imgjpegOptionsMetadata, "imgjpeg",imgjpegOptionsDisplayOptionInfo, ImgjpegDisplayOptionNum, 0, 0))
 
190
        return FALSE;
 
191
 
 
192
    compAddMetadataFromFile (&imgjpegOptionsMetadata, "imgjpeg");
 
193
    if (imgjpegPluginVTable && imgjpegPluginVTable->init)
 
194
        return imgjpegPluginVTable->init (p);
 
195
    return TRUE;
 
196
}
 
197
 
 
198
static void imgjpegOptionsFini (CompPlugin *p)
 
199
{
 
200
    if (imgjpegPluginVTable && imgjpegPluginVTable->fini)
 
201
        return imgjpegPluginVTable->fini (p);
 
202
 
 
203
    if (displayPrivateIndex >= 0)
 
204
        freeDisplayPrivateIndex(displayPrivateIndex);
 
205
 
 
206
    compFiniMetadata (&imgjpegOptionsMetadata);
 
207
}
 
208
 
 
209
static CompMetadata *
 
210
imgjpegOptionsGetMetadata (CompPlugin *plugin)
 
211
{
 
212
    return &imgjpegOptionsMetadata;
 
213
}
 
214
 
 
215
CompPluginVTable *getCompPluginInfo (void)
 
216
{
 
217
    if (!imgjpegPluginVTable)
 
218
    {
 
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;
 
230
        
 
231
    }
 
232
    return &imgjpegOptionsVTable;
 
233
}
 
234