Debian Codegraph @

fontforgeexe/pluginui.cpp

raw
1 /* Copyright (C) 2000-2012 by George Williams */
2 /*
3 * Redistribution and use in source and binary forms, with or without
4 * modification, are permitted provided that the following conditions are met:
5
6 * Redistributions of source code must retain the above copyright notice, this
7 * list of conditions and the following disclaimer.
8
9 * Redistributions in binary form must reproduce the above copyright notice,
10 * this list of conditions and the following disclaimer in the documentation
11 * and/or other materials provided with the distribution.
12
13 * The name of the author may not be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
19 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28 #include <fontforge-config.h>
29
30 #ifndef _NO_PYTHON
31
32 extern "C" {
33 #include "fontforgeui.h"
34 #include "gkeysym.h"
35 }
36 #include "plugin.h"
37 #include "gtk/simple_dialogs.hpp"
38
39 #include "assert.h"
40
41 extern "C" GTextInfo *GTextInfoCopy(GTextInfo *ti);
42
43 #define CID_SmOn 1000
44 #define CID_SmOff 1001
45 #define CID_SmAsk 1002
46 #define CID_Top 1003
47 #define CID_Up 1004
48 #define CID_Down 1005
49 #define CID_Bottom 1006
50 #define CID_Enable 1007
51 #define CID_Disable 1008
52 #define CID_Delete 1009
53 #define CID_MoreInfo 1010
54 #define CID_Load 1011
55 #define CID_Web 1012
56 #define CID_Conf 1013
57 #define CID_Revert 1014
58 #define CID_PluginList 1015
59 #define CID_OK 1016
60 #define CID_Cancel 1017
61
62 static void PluginInfoDlg(GWindow parent, PluginEntry* pe) {
63 if (no_windowing_ui) {
64 return;
65 }
66
67 PropertyVec properties = {
68 {_("Name:"), pe->name},
69 {_("Package Name:"),
70 pe->package_name == NULL ? _("[Unknown]") : pe->package_name},
71 {_("Module Name:"),
72 pe->module_name == NULL ? _("[Unknown]") : pe->module_name},
73 {_("'attrs' (if any):"), pe->attrs == NULL ? "" : pe->attrs},
74 {_("Package URL:"),
75 pe->package_url == NULL ? _("[Unknown]") : pe->package_url},
76 {_("Summary:"), pe->summary == NULL ? _("[Unknown]") : pe->summary},
77 };
78 show_properties_dialog(parent, _("Plugin Information"), properties);
79 }
80
81 struct plg_data {
82 GWindow gw;
83 int done;
84 };
85
86 static int PLUG_OK(GGadget *g, GEvent *e) {
87 int len, i;
88 FFList *l;
89 struct plg_data *d = (struct plg_data *) GDrawGetUserData(GGadgetGetWindow(g));
90
91 if (e->type != et_controlevent || e->u.control.subtype != et_buttonactivate) {
92 return true;
93 }
94
95 for (l = plugin_data; l != NULL; l = l->next) {
96 PluginEntry *pe = (PluginEntry *) l->data;
97 if (!pe->is_present && pe->new_mode == sm_ask) {
98 FreePluginEntry(pe);
99 }
100 }
101
102 ff_list_free(ff_steal_pointer(&plugin_data)); // Won't free ->data elements
103 GGadget *list = GWidgetGetControl(d->gw, CID_PluginList);
104 GTextInfo **ti = GGadgetGetList(list, &len);
105 for (i = 0; i < len; ++i) {
106 PluginEntry *pe = (PluginEntry *) ti[i]->userdata;
107 pe->startup_mode = pe->new_mode;
108 plugin_data = ff_list_append(plugin_data, pe);
109 }
110 SavePluginConfig();
111
112 enum plugin_startup_mode_type sm = sm_ask;
113 if (GGadgetIsChecked(GWidgetGetControl(d->gw, CID_SmOn))) {
114 sm = sm_on;
115 } else if (GGadgetIsChecked(GWidgetGetControl(d->gw, CID_SmOff))) {
116 sm = sm_off;
117 }
118 if (sm != plugin_startup_mode) {
119 plugin_startup_mode = sm;
120 SavePrefs(true);
121 }
122
123 d->done = true;
124 return true;
125 }
126
127 static int PLUG_Cancel(GGadget *g, GEvent *e) {
128 struct plg_data *d = (struct plg_data *) GDrawGetUserData(GGadgetGetWindow(g));
129 if (e->type == et_controlevent && e->u.control.subtype == et_buttonactivate) {
130 d->done = true;
131 }
132 return true;
133 }
134
135 static int plug_e_h(GWindow gw, GEvent *e) {
136 struct plg_data *d = (struct plg_data *) GDrawGetUserData(gw);
137 if (e->type == et_close) {
138 d->done = true;
139 } else if (e->type == et_char) {
140 if ( e->u.chr.keysym == GK_F1 || e->u.chr.keysym == GK_Help ) {
141 help("techref/plugin.html", NULL);
142 return( true );
143 }
144 }
145 return true;
146 }
147
148 static unichar_t *pluginDescString(PluginEntry *pe, int *has_err) {
149 char *str, *csm, *nsm = NULL, *info = NULL;
150
151 csm = _(PluginStartupModeString(pe->startup_mode, false));
152 if (pe->startup_mode != pe->new_mode) {
153 nsm = _(PluginStartupModeString(pe->new_mode, false));
154 }
155 info = _(PluginInfoString(pe, true, has_err));
156
157 if (info != NULL && nsm != NULL) {
158 str = smprintf("%s (%s -> %s) [%s]", pe->name, csm, nsm, info);
159 } else if (info != NULL && nsm == NULL) {
160 str = smprintf("%s (%s) [%s]", pe->name, csm, info);
161 } else if (info == NULL && nsm != NULL) {
162 str = smprintf("%s (%s -> %s)", pe->name, csm, nsm);
163 } else {
164 str = smprintf("%s (%s)", pe->name, csm);
165 }
166 unichar_t *r = utf82u_copy(str);
167 free(str);
168 return r;
169 }
170
171 static void FigurePluginList(struct plg_data *d) {
172 GGadget *list = GWidgetGetControl(d->gw, CID_PluginList);
173 FFList *p;
174 int l = ff_list_length(plugin_data), i, has_err;
175
176 GGadgetClearList(list);
177
178 if (l == 0) {
179 return;
180 }
181
182 GTextInfo **ti = (GTextInfo **)malloc((l + 1) * sizeof(GTextInfo *));
183 for (i = 0, p = plugin_data; p != NULL; ++i, p = p->next) {
184 PluginEntry *pe = (PluginEntry *) p->data;
185 pe->new_mode = pe->startup_mode;
186 ti[i] = (GTextInfo *)calloc(1, sizeof(GTextInfo));
187 ti[i]->text = pluginDescString(pe, &has_err);
188 ti[i]->fg = ti[i]->bg = COLOR_DEFAULT;
189 if (has_err) {
190 ti[i]->fg = GDrawGetWarningForeground(GDrawGetDisplayOfWindow(d->gw));
191 }
192 ti[i]->userdata = pe;
193 }
194 ti[i] = (GTextInfo *)calloc(1, sizeof(GTextInfo));
195 GGadgetSetList(list, ti, false);
196 }
197
198 static void PLUG_EnableButtons(struct plg_data *d) {
199 GGadget *list = GWidgetGetControl(d->gw, CID_PluginList);
200 int pos = GGadgetGetFirstListSelectedItem(list), len;
201 GTextInfo **ti = GGadgetGetList(list, &len);
202 PluginEntry *pe = pos == -1 ? NULL : (PluginEntry *) ti[pos]->userdata;
203
204 GGadgetSetEnabled(GWidgetGetControl(d->gw, CID_Top), pe && pos > 0);
205 GGadgetSetEnabled(GWidgetGetControl(d->gw, CID_Up), pe && pos > 0);
206 GGadgetSetEnabled(GWidgetGetControl(d->gw, CID_Down), pe && pos < len - 1);
207 GGadgetSetEnabled(GWidgetGetControl(d->gw, CID_Bottom), pe && pos < len - 1);
208 GGadgetSetEnabled(GWidgetGetControl(d->gw, CID_Enable), pe && pe->new_mode != sm_on);
209 GGadgetSetEnabled(GWidgetGetControl(d->gw, CID_Disable), pe && pe->new_mode != sm_off);
210 GGadgetSetEnabled(GWidgetGetControl(d->gw, CID_Delete), pe && !pe->is_present);
211 GGadgetSetEnabled(GWidgetGetControl(d->gw, CID_MoreInfo), pe != NULL);
212 GGadgetSetEnabled(GWidgetGetControl(d->gw, CID_Load), pe && pe->entrypoint != NULL);
213 GGadgetSetEnabled(GWidgetGetControl(d->gw, CID_Web), pe && pe->package_url != NULL);
214 GGadgetSetEnabled(GWidgetGetControl(d->gw, CID_Conf), pe && pe->has_prefs);
215 }
216
217 static int PLUG_PluginListChange(GGadget *g, GEvent *e) {
218 struct plg_data *d = (struct plg_data *)GDrawGetUserData(GGadgetGetWindow(g));
219 PLUG_EnableButtons(d);
220 return true;
221 }
222
223 void GListMoveOneSelected(GGadget *list, int offset) {
224 int32_t len;
225 int i, pos = -1;
226 GTextInfo **old, **new_ti, *tmp;
227
228 old = GGadgetGetList(list, &len);
229 new_ti = (GTextInfo **)calloc(len + 1, sizeof(GTextInfo *));
230 for (i = 0; i < len; i++) {
231 if (old[i]->selected) {
232 pos = i;
233 }
234 new_ti[i] = GTextInfoCopy(old[i]);
235 }
236 new_ti[len] = (GTextInfo *)calloc(1, sizeof(GTextInfo));
237 if (pos == -1 || pos == offset) {
238 GGadgetSetList(list, new_ti, false);
239 return;
240 }
241 if (offset > pos) {
242 tmp = new_ti[pos];
243 for (i = pos; i < offset; ++i) {
244 new_ti[i] = new_ti[i + 1];
245 }
246 new_ti[offset] = tmp;
247 } else {
248 tmp = new_ti[pos];
249 for (i = pos; i > offset; --i) {
250 new_ti[i] = new_ti[i - 1];
251 }
252 new_ti[offset] = tmp;
253 }
254 GGadgetSetList(list, new_ti, false);
255 }
256
257 static int PLUG_PluginListOrder(GGadget *g, GEvent *e) {
258 if ( e->type!=et_controlevent || e->u.control.subtype!=et_buttonactivate)
259 return true;
260
261 struct plg_data *d = (struct plg_data *)GDrawGetUserData(GGadgetGetWindow(g));
262 GGadget *list = GWidgetGetControl(d->gw, CID_PluginList);
263 int cid = GGadgetGetCid(g);
264 int pos = GGadgetGetFirstListSelectedItem(list), newpos, len;
265 GGadgetGetList(list, &len);
266 (void)len; //only used in asserts
267
268 if (pos == -1) {
269 return true; // Shouldn't happen
270 }
271 assert(pos >= 0 && pos < len);
272
273 if (cid == CID_Top) {
274 assert(pos > 0);
275 GListMoveOneSelected(list, newpos = 0);
276 } else if (cid == CID_Up) {
277 assert(pos > 0);
278 GListMoveOneSelected(list, newpos = pos - 1);
279 } else if (cid == CID_Down) {
280 assert(pos < len - 1);
281 GListMoveOneSelected(list, newpos = pos + 1);
282 } else if (cid == CID_Bottom) {
283 assert(pos < len - 1);
284 GListMoveOneSelected(list, newpos = len - 1);
285 }
286 GGadgetSelectOneListItem(list, newpos);
287 PLUG_EnableButtons(d);
288 return true;
289 }
290
291 static void ResetPluginText(GTextInfo *i) {
292 free(i->text);
293 i->text = pluginDescString((PluginEntry *) i->userdata, NULL);
294 }
295
296 static int PLUG_PluginOp(GGadget *g, GEvent *e) {
297 if (e->type != et_controlevent || e->u.control.subtype != et_buttonactivate) {
298 return true;
299 }
300
301 struct plg_data *d = (struct plg_data *)GDrawGetUserData(GGadgetGetWindow(g));
302 GGadget *list = GWidgetGetControl(d->gw, CID_PluginList);
303 GTextInfo *i = GGadgetGetListItemSelected(list);
304 if (i == NULL) {
305 return true;
306 }
307 PluginEntry *pe = (PluginEntry *) i->userdata;
308 int cid = GGadgetGetCid(g);
309
310 if (cid == CID_Enable) {
311 static char *buts[4];
312 buts[0] = _("_Yes");
313 buts[1] = _("_No");
314 buts[2] = _("_Cancel");
315 buts[3] = NULL;
316 int ans = ff_ask(_("Load Plugin?"), (const char **) buts, 0, 2, _("The plugin will be loaded in the order at the next restart\nof FontForge. You can also load it now. Would you like to?"));
317 if ( ans==0 || ans==1)
318 pe->new_mode = sm_on;
319 if ( ans==0 )
320 LoadPlugin(pe);
321 ResetPluginText(i);
322 PLUG_EnableButtons(d);
323 } else if (cid == CID_Disable) {
324 pe->new_mode = sm_off;
325 ResetPluginText(i);
326 PLUG_EnableButtons(d);
327 } else if (cid == CID_Delete) {
328 pe->new_mode = sm_ask;
329 if (!pe->is_present)
330 GListDelSelected(list);
331 PLUG_EnableButtons(d);
332 } else if (cid == CID_MoreInfo) {
333 PluginInfoDlg(GGadgetGetWindow(g), pe);
334 } else if (cid == CID_Load) {
335 if (pe->entrypoint != NULL) {
336 LoadPlugin(pe);
337 ResetPluginText(i);
338 PLUG_EnableButtons(d);
339 }
340 } else if (cid == CID_Web) {
341 if (pe->package_url != NULL) {
342 help(pe->package_url, NULL);
343 }
344 } else if (cid == CID_Conf) {
345 PluginDoPreferences(pe);
346 } else if (cid == CID_Revert) {
347 FigurePluginList(d);
348 }
349 GGadgetRedraw(list);
350 return true;
351 }
352
353 void _PluginDlg(void) {
354 GRect pos;
355 GWindow gw;
356 GWindowAttrs wattrs;
357 GGadgetCreateData gcd[24], boxes[6], *vert[5], *horiz[3], *tradio[6], *sbuttons[17],
358 *bbuttons[9];
359 GTextInfo label[24];
360 int k, msg;
361 struct plg_data d = { NULL, false };
362
363 if (no_windowing_ui) {
364 return;
365 }
366
367 if (!attempted_plugin_load) {
368 static char *buts[3];
369 if (!use_plugins) {
370 buts[0] = _("_Ok");
371 buts[1] = NULL;
372 ff_ask(_("Plugins off in preferences"), (const char **) buts, 0, 0, _("The UsePlugins preferences option is currently off.\nFontForge will not load plugin configuration or\nattempt discovery unless that option is on."));
373 } else {
374 buts[0] = _("_Yes");
375 buts[1] = _("_No");
376 buts[2] = NULL;
377 int ans = ff_ask(_("Initialize Plugins?"), (const char **) buts, 0, 1, _("FontForge has not yet attempted to load Plugins\nDo you want it to do that now?"));
378 if (ans == 0) {
379 PyFF_ProcessInitFiles(false, true);
380 }
381 }
382 }
383
384 memset(&wattrs, 0, sizeof(wattrs));
385 wattrs.mask = (window_attr_mask)(wam_events | wam_cursor | wam_utf8_wtitle | wam_undercursor | wam_isdlg | wam_restrict);
386 wattrs.event_masks = ~(1 << et_charup);
387 wattrs.restrict_input_to_me = 1;
388 wattrs.undercursor = 1;
389 wattrs.cursor = ct_pointer;
390 wattrs.utf8_window_title = _("Plugin Configuration");
391 wattrs.is_dlg = true;
392 pos.x = pos.y = 0;
393 pos.width = pos.height = 0;
394 d.gw = gw = GDrawCreateTopWindow(NULL, &pos, plug_e_h, &d, &wattrs);
395
396 memset(&label, 0, sizeof(label));
397 memset(&gcd, 0, sizeof(gcd));
398 memset(&vert, 0, sizeof(vert));
399 memset(&tradio, 0, sizeof(tradio));
400 memset(&horiz, 0, sizeof(horiz));
401 memset(&sbuttons, 0, sizeof(sbuttons));
402 memset(&bbuttons, 0, sizeof(bbuttons));
403 memset(&boxes, 0, sizeof(boxes));
404
405 k = 0;
406 label[k].text = (unichar_t *) _("PluginStartupMode:");
407 label[k].text_is_1byte = true;
408 label[k].text_in_resource = true;
409 gcd[k].gd.label = &label[k];
410 gcd[k].gd.pos.x = 10;
411 gcd[k].gd.pos.y = 6;
412 gcd[k].gd.flags = gg_enabled | gg_visible;
413 gcd[k++].creator = GLabelCreate;
414 tradio[0] = &gcd[k - 1];
415 tradio[1] = GCD_Glue;
416
417 label[k].text = (unichar_t *) _("O_n");
418 label[k].text_is_1byte = true;
419 label[k].text_in_resource = true;
420 gcd[k].gd.label = &label[k];
421 gcd[k].gd.flags = gg_visible | gg_enabled | (gg_flags)(plugin_startup_mode == sm_on ? gg_cb_on : 0);
422 gcd[k].gd.u.radiogroup = 1;
423 gcd[k].gd.popup_msg = _("When a new plugin is discovered it is recorded and activated");
424 gcd[k].gd.cid = CID_SmOn;
425 gcd[k++].creator = GRadioCreate;
426 tradio[2] = &gcd[k - 1];
427
428 label[k].text = (unichar_t *) _("O_ff");
429 label[k].text_is_1byte = true;
430 label[k].text_in_resource = true;
431 gcd[k].gd.label = &label[k];
432 gcd[k].gd.flags = gg_visible | gg_enabled | (gg_flags)(plugin_startup_mode == sm_off ? gg_cb_on : 0);
433 gcd[k].gd.u.radiogroup = 1;
434 gcd[k].gd.popup_msg = _("When a new plugin is discovered it is recorded but not activated");
435 gcd[k].gd.cid = CID_SmOff;
436 gcd[k++].creator = GRadioCreate;
437 tradio[3] = &gcd[k - 1];
438
439 label[k].text = (unichar_t *) _("_Ask");
440 label[k].text_is_1byte = true;
441 label[k].text_in_resource = true;
442 gcd[k].gd.label = &label[k];
443 gcd[k].gd.flags = gg_visible | gg_enabled | (gg_flags)(plugin_startup_mode == sm_ask ? gg_cb_on : 0);
444 gcd[k].gd.u.radiogroup = 1;
445 gcd[k].gd.popup_msg = _("When a new plugin is discovered it is left unrecorded\nuntil configured in this dialog.");
446 gcd[k].gd.cid = CID_SmAsk;
447 gcd[k++].creator = GRadioCreate;
448 tradio[4] = &gcd[k - 1];
449 tradio[5] = NULL;
450
451 boxes[2].gd.flags = gg_enabled | gg_visible;
452 boxes[2].gd.u.boxelements = tradio;
453 boxes[2].creator = GHBoxCreate;
454
455 msg = k;
456 label[k].text = (unichar_t *) _("Plugins can be Loaded and Configured now.\nOther changes will take effect at next restart.");
457 label[k].text_is_1byte = true;
458 gcd[k].gd.label = &label[k];
459 gcd[k].gd.pos.x = 10;
460 gcd[k].gd.pos.y = 6;
461 gcd[k].gd.flags = gg_enabled | gg_visible;
462 gcd[k++].creator = GLabelCreate;
463
464 label[k].text = (unichar_t *) _("_Top");
465 label[k].text_is_1byte = true;
466 label[k].text_in_resource = true;
467 gcd[k].gd.label = &label[k];
468 gcd[k].gd.flags = gg_visible | gg_enabled;
469 gcd[k].gd.cid = CID_Top;
470 gcd[k].gd.handle_controlevent = PLUG_PluginListOrder;
471 gcd[k++].creator = GButtonCreate;
472 sbuttons[0] = &gcd[k - 1];
473
474 label[k].text = (unichar_t *) _("_Up");
475 label[k].text_is_1byte = true;
476 label[k].text_in_resource = true;
477 gcd[k].gd.label = &label[k];
478 gcd[k].gd.flags = gg_visible | gg_enabled;
479 gcd[k].gd.cid = CID_Up;
480 gcd[k].gd.handle_controlevent = PLUG_PluginListOrder;
481 gcd[k++].creator = GButtonCreate;
482 sbuttons[1] = &gcd[k - 1];
483
484 label[k].text = (unichar_t *) _("_Down");
485 label[k].text_is_1byte = true;
486 label[k].text_in_resource = true;
487 gcd[k].gd.label = &label[k];
488 gcd[k].gd.flags = gg_visible | gg_enabled;
489 gcd[k].gd.cid = CID_Down;
490 gcd[k].gd.handle_controlevent = PLUG_PluginListOrder;
491 gcd[k++].creator = GButtonCreate;
492 sbuttons[2] = &gcd[k - 1];
493
494 label[k].text = (unichar_t *) _("_Bottom");
495 label[k].text_is_1byte = true;
496 label[k].text_in_resource = true;
497 gcd[k].gd.label = &label[k];
498 gcd[k].gd.flags = gg_visible | gg_enabled;
499 gcd[k].gd.cid = CID_Bottom;
500 gcd[k].gd.handle_controlevent = PLUG_PluginListOrder;
501 gcd[k++].creator = GButtonCreate;
502 sbuttons[3] = &gcd[k - 1];
503
504 gcd[k].gd.flags = gg_visible | gg_enabled;
505 gcd[k++].creator = GLineCreate;
506 sbuttons[4] = &gcd[k - 1];
507
508 label[k].text = (unichar_t *) _("_Enable");
509 label[k].text_is_1byte = true;
510 label[k].text_in_resource = true;
511 gcd[k].gd.label = &label[k];
512 gcd[k].gd.flags = gg_visible | gg_enabled;
513 gcd[k].gd.cid = CID_Enable;
514 gcd[k].gd.handle_controlevent = PLUG_PluginOp;
515 gcd[k++].creator = GButtonCreate;
516 sbuttons[5] = &gcd[k - 1];
517
518 label[k].text = (unichar_t *) _("_Disable");
519 label[k].text_is_1byte = true;
520 label[k].text_in_resource = true;
521 gcd[k].gd.label = &label[k];
522 gcd[k].gd.flags = gg_visible | gg_enabled;
523 gcd[k].gd.cid = CID_Disable;
524 gcd[k].gd.handle_controlevent = PLUG_PluginOp;
525 gcd[k++].creator = GButtonCreate;
526 sbuttons[6] = &gcd[k - 1];
527
528 label[k].text = (unichar_t *) _("_Delete");
529 label[k].text_is_1byte = true;
530 label[k].text_in_resource = true;
531 gcd[k].gd.label = &label[k];
532 gcd[k].gd.flags = gg_visible | gg_enabled;
533 gcd[k].gd.cid = CID_Delete;
534 gcd[k].gd.handle_controlevent = PLUG_PluginOp;
535 gcd[k++].creator = GButtonCreate;
536 sbuttons[7] = &gcd[k - 1];
537
538 gcd[k].gd.flags = gg_visible | gg_enabled;
539 gcd[k++].creator = GLineCreate;
540 sbuttons[8] = &gcd[k - 1];
541
542 label[k].text = (unichar_t *) _("_More Info");
543 label[k].text_is_1byte = true;
544 label[k].text_in_resource = true;
545 gcd[k].gd.label = &label[k];
546 gcd[k].gd.flags = gg_visible | gg_enabled;
547 gcd[k].gd.cid = CID_MoreInfo;
548 gcd[k].gd.handle_controlevent = PLUG_PluginOp;
549 gcd[k++].creator = GButtonCreate;
550 sbuttons[9] = &gcd[k - 1];
551
552 label[k].text = (unichar_t *) _("_Load");
553 label[k].text_is_1byte = true;
554 label[k].text_in_resource = true;
555 gcd[k].gd.label = &label[k];
556 gcd[k].gd.flags = gg_visible | gg_enabled;
557 gcd[k].gd.cid = CID_Load;
558 gcd[k].gd.handle_controlevent = PLUG_PluginOp;
559 gcd[k++].creator = GButtonCreate;
560 sbuttons[10] = &gcd[k - 1];
561
562 label[k].text = (unichar_t *) _("Open _Web Page");
563 label[k].text_is_1byte = true;
564 label[k].text_in_resource = true;
565 gcd[k].gd.label = &label[k];
566 gcd[k].gd.flags = gg_visible | gg_enabled;
567 gcd[k].gd.cid = CID_Web;
568 gcd[k].gd.handle_controlevent = PLUG_PluginOp;
569 gcd[k++].creator = GButtonCreate;
570 sbuttons[11] = &gcd[k - 1];
571
572 label[k].text = (unichar_t *) _("_Configure");
573 label[k].text_is_1byte = true;
574 label[k].text_in_resource = true;
575 gcd[k].gd.label = &label[k];
576 gcd[k].gd.flags = gg_visible | gg_enabled;
577 gcd[k].gd.cid = CID_Conf;
578 gcd[k].gd.handle_controlevent = PLUG_PluginOp;
579 gcd[k++].creator = GButtonCreate;
580 sbuttons[12] = &gcd[k - 1];
581
582 gcd[k].gd.flags = gg_visible | gg_enabled;
583 gcd[k++].creator = GLineCreate;
584 sbuttons[13] = &gcd[k - 1];
585
586 label[k].text = (unichar_t *) _("Re_vert List");
587 label[k].text_is_1byte = true;
588 label[k].text_in_resource = true;
589 gcd[k].gd.label = &label[k];
590 gcd[k].gd.flags = gg_visible | gg_enabled;
591 gcd[k].gd.cid = CID_Revert;
592 gcd[k].gd.handle_controlevent = PLUG_PluginOp;
593 gcd[k++].creator = GButtonCreate;
594 sbuttons[14] = &gcd[k - 1];
595
596 sbuttons[15] = GCD_Glue;
597 sbuttons[16] = NULL;
598
599 boxes[3].gd.flags = gg_enabled | gg_visible;
600 boxes[3].gd.u.boxelements = sbuttons;
601 boxes[3].creator = GVBoxCreate;
602
603 gcd[k].gd.flags = gg_visible | gg_enabled | gg_list_exactlyone;
604 gcd[k].gd.handle_controlevent = PLUG_PluginListChange;
605 gcd[k].gd.cid = CID_PluginList;
606 gcd[k].gd.pos.width = 200;
607 gcd[k++].creator = GListCreate;
608
609 horiz[0] = &gcd[k - 1];
610 horiz[1] = &boxes[3];
611 horiz[2] = NULL;
612
613 boxes[4].gd.flags = gg_enabled | gg_visible;
614 boxes[4].gd.u.boxelements = horiz;
615 boxes[4].creator = GHBoxCreate;
616
617 label[k].text = (unichar_t *) _("_OK");
618 label[k].text_is_1byte = true;
619 label[k].text_in_resource = true;
620 gcd[k].gd.label = &label[k];
621 gcd[k].gd.flags = gg_visible | gg_enabled;
622 gcd[k].gd.cid = CID_OK;
623 gcd[k].gd.handle_controlevent = PLUG_OK;
624 gcd[k++].creator = GButtonCreate;
625 bbuttons[0] = GCD_Glue;
626 bbuttons[1] = &gcd[k - 1];
627 bbuttons[2] = GCD_Glue;
628 bbuttons[3] = GCD_Glue;
629
630 label[k].text = (unichar_t *) _("_Cancel");
631 label[k].text_is_1byte = true;
632 label[k].text_in_resource = true;
633 gcd[k].gd.label = &label[k];
634 gcd[k].gd.flags = gg_visible | gg_enabled;
635 gcd[k].gd.cid = CID_Cancel;
636 gcd[k].gd.handle_controlevent = PLUG_Cancel;
637 gcd[k++].creator = GButtonCreate;
638 bbuttons[4] = GCD_Glue;
639 bbuttons[5] = &gcd[k - 1];
640 bbuttons[6] = GCD_Glue;
641 bbuttons[7] = GCD_Glue;
642 bbuttons[8] = NULL;
643
644 boxes[5].gd.flags = gg_enabled | gg_visible;
645 boxes[5].gd.u.boxelements = bbuttons;
646 boxes[5].creator = GHBoxCreate;
647
648 vert[0] = &boxes[2];
649 vert[1] = &gcd[msg];
650 vert[2] = &boxes[4];
651 vert[3] = &boxes[5];
652 vert[4] = NULL;
653
654 boxes[0].gd.flags = gg_enabled | gg_visible;
655 boxes[0].gd.u.boxelements = vert;
656 boxes[0].creator = GVBoxCreate;
657
658 GGadgetsCreate(gw, boxes);
659 GHVBoxSetExpandableRow(boxes[0].ret, 2);
660 GHVBoxSetExpandableRow(boxes[3].ret, 15);
661 GHVBoxSetExpandableCol(boxes[4].ret, 0);
662 GHVBoxSetPadding(boxes[0].ret, 0, 10);
663 GHVBoxSetPadding(boxes[4].ret, 10, 0);
664 GHVBoxFitWindow(boxes[0].ret);
665
666 FigurePluginList(&d);
667 PLUG_EnableButtons(&d);
668
669 GDrawSetVisible(gw, true);
670
671 while (!d.done) {
672 GDrawProcessOneEvent(NULL);
673 }
674
675 GDrawDestroyWindow(gw);
676 }
677
678 void MenuPlug(GWindow UNUSED(base), struct gmenuitem *UNUSED(mi), GEvent *UNUSED(e)) {
679 PluginDlg();
680 }
681
682 #endif // _NO_PYTHON