Codebase list dillo / debian/3.0.1-1 src / menu.cc
debian/3.0.1-1

Tree @debian/3.0.1-1 (Download .tar.gz)

menu.cc @debian/3.0.1-1raw · history · blame

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
/*
 * File: menu.cc
 *
 * Copyright (C) 2005-2007 Jorge Arellano Cid <jcid@dillo.org>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 */

// Functions/Methods for menus

#include <FL/Fl.H>
#include <FL/Fl_Menu_Item.H>

#include "lout/misc.hh"    /* SimpleVector */
#include "msg.h"
#include "menu.hh"
#include "uicmd.hh"
#include "history.h"
#include "html.hh"
#include "ui.hh" // for (UI *)
#include "keys.hh"
#include "timeout.hh"

/*
 * Local data
 */

// (This data can be encapsulated inside a class for each popup, but
//  as popups are modal, there's no need).
static DilloUrl *popup_url = NULL;
// Weak reference to the popup's bw
static BrowserWindow *popup_bw = NULL;
static void *popup_form = NULL;
// Where to place the popup
static int popup_x, popup_y;
// History popup direction (-1 = back, 1 = forward).
static int history_direction = -1;
// History popup, list of URL-indexes.
static int *history_list = NULL;


//--------------------------------------------------------------------------
static void Menu_nop_cb(Fl_Widget*, void*)
{
}

/*
 * Static function for File menu callbacks.
 */
static void filemenu_cb(Fl_Widget*, void *data)
{
   if (strcmp((char*)data, "nw") == 0) {
      a_UIcmd_open_url_nw(popup_bw, NULL);
   } else if (strcmp((char*)data, "nt") == 0) {
      a_UIcmd_open_url_nt(popup_bw, NULL, 1);
   } else if (strcmp((char*)data, "of") == 0) {
      a_UIcmd_open_file(popup_bw);
   } else if (strcmp((char*)data, "ou") == 0) {
      a_UIcmd_focus_location(popup_bw);
   } else if (strcmp((char*)data, "cw") == 0) {
      a_Timeout_add(0.0, a_UIcmd_close_bw, popup_bw);
   } else if (strcmp((char*)data, "ed") == 0) {
      a_Timeout_add(0.0, a_UIcmd_close_all_bw, NULL);
   }
}


static void Menu_copy_urlstr_cb(Fl_Widget*, void*)
{
   if (popup_url)
      a_UIcmd_copy_urlstr(popup_bw, URL_STR(popup_url));
}

static void Menu_link_cb(Fl_Widget*, void *user_data)
{
   DilloUrl *url = (DilloUrl *) user_data ;
   _MSG("Menu_link_cb: click! :-)\n");

   if (url)
      a_Menu_link_popup(popup_bw, url);
}

/*
 * Open URL
 */
static void Menu_open_url_cb(Fl_Widget*, void*)
{
   _MSG("Open URL cb: click! :-)\n");
   a_UIcmd_open_url(popup_bw, popup_url);
}

/*
 * Open URL in new window
 */
static void Menu_open_url_nw_cb(Fl_Widget*, void*)
{
   _MSG("Open URL in new window cb: click! :-)\n");
   a_UIcmd_open_url_nw(popup_bw, popup_url);
}

/*
 * Open URL in new Tab
 */
static void Menu_open_url_nt_cb(Fl_Widget*, void*)
{
   int focus = prefs.focus_new_tab ? 1 : 0;
   if (Fl::event_state(FL_SHIFT)) focus = !focus;
   a_UIcmd_open_url_nt(popup_bw, popup_url, focus);
}

/*
 * Add bookmark
 */
static void Menu_add_bookmark_cb(Fl_Widget*, void*)
{
   a_UIcmd_add_bookmark(popup_bw, popup_url);
}

/*
 * Find text
 */
static void Menu_find_text_cb(Fl_Widget*, void*)
{
   ((UI *)popup_bw->ui)->findbar_toggle(1);
}

/*
 * Save link
 */
static void Menu_save_link_cb(Fl_Widget*, void*)
{
   a_UIcmd_save_link(popup_bw, popup_url);
}

/*
 * Save current page
 */
static void Menu_save_page_cb(Fl_Widget*, void*)
{
   a_UIcmd_save(popup_bw);
}

/*
 * View current page source
 */
static void Menu_view_page_source_cb(Fl_Widget*, void*)
{
   a_UIcmd_view_page_source(popup_bw, popup_url);
}

/*
 * View current page's bugs
 */
static void Menu_view_page_bugs_cb(Fl_Widget*, void*)
{
   a_UIcmd_view_page_bugs(popup_bw);
}

/*
 * Load images on current page that match URL pattern
 */
static void Menu_load_images_cb(Fl_Widget*, void *user_data)
{
   DilloUrl *page_url = (DilloUrl *) user_data;
   void *doc = a_Bw_get_url_doc(popup_bw, page_url);

   if (doc)
      a_Html_load_images(doc, popup_url);
}

/*
 * Submit form
 */
static void Menu_form_submit_cb(Fl_Widget*, void*)
{
   void *doc = a_Bw_get_url_doc(popup_bw, popup_url);

   if (doc)
      a_Html_form_submit(doc, popup_form);
}

/*
 * Reset form
 */
static void Menu_form_reset_cb(Fl_Widget*, void*)
{
   void *doc = a_Bw_get_url_doc(popup_bw, popup_url);

   if (doc)
      a_Html_form_reset(doc, popup_form);
}

/*
 * Toggle display of 'hidden' form controls.
 */
static void Menu_form_hiddens_cb(Fl_Widget*, void *user_data)
{
   bool visible = *((bool *) user_data);
   void *doc = a_Bw_get_url_doc(popup_bw, popup_url);

   if (doc)
      a_Html_form_display_hiddens(doc, popup_form, !visible);
}

static void Menu_stylesheet_cb(Fl_Widget*, void *vUrl)
{
   const DilloUrl *url = (const DilloUrl *) vUrl;
   a_UIcmd_open_url(popup_bw, url);
}

/*
 * Validate URL with the W3C
 */
static void Menu_bugmeter_validate_w3c_cb(Fl_Widget*, void*)
{
   Dstr *dstr = dStr_sized_new(128);

   dStr_sprintf(dstr, "http://validator.w3.org/check?uri=%s",
                URL_STR(popup_url));
   a_UIcmd_open_urlstr(popup_bw, dstr->str);
   dStr_free(dstr, 1);
}

/*
 * Validate URL with the WDG
 */
static void Menu_bugmeter_validate_wdg_cb(Fl_Widget*, void*)
{
   Dstr *dstr = dStr_sized_new(128);

   dStr_sprintf(dstr,
      "http://www.htmlhelp.org/cgi-bin/validate.cgi?url=%s&warnings=yes",
      URL_STR(popup_url));
   a_UIcmd_open_urlstr(popup_bw, dstr->str);
   dStr_free(dstr, 1);
}

/*
 * Show info page for the bug meter
 */
static void Menu_bugmeter_about_cb(Fl_Widget*, void*)
{
   a_UIcmd_open_urlstr(popup_bw, "http://www.dillo.org/help/bug_meter.html");
}

/*
 * Navigation History callback.
 * Go to selected URL.
 */
static void Menu_history_cb(Fl_Widget*, void *data)
{
   int mb = Fl::event_button();
   int offset = history_direction * VOIDP2INT(data);
   const DilloUrl *url = a_History_get_url(history_list[VOIDP2INT(data)-1]);

   if (mb == 1) {
      a_UIcmd_nav_jump(popup_bw, offset, 0);
   } else if (mb == 2) {
      // Middle button, open in a new window/tab
      if (prefs.middle_click_opens_new_tab) {
         int focus = prefs.focus_new_tab ? 1 : 0;
         if (Fl::event_state(FL_SHIFT)) focus = !focus;
         a_UIcmd_open_url_nt(popup_bw, url, focus);
      } else {
         a_UIcmd_open_url_nw(popup_bw, url);
      }
   }
}

/*
 * Menus are popped-up from this timeout callback so the events
 * associated with the button are gone when it pops. This way we
 * avoid a segfault when a new page replaces the page that issued
 * the popup menu.
 */
static void Menu_popup_cb(void *data)
{
   const Fl_Menu_Item *m = ((Fl_Menu_Item *)data)->popup(popup_x, popup_y);

   if (m && m->callback())
      m->do_callback((Fl_Widget *)data);
   a_Timeout_remove();
}

/*
 * Page popup menu (construction & popup)
 */
void a_Menu_page_popup(BrowserWindow *bw, const DilloUrl *url,
                       bool_t has_bugs, void *v_cssUrls)
{
   lout::misc::SimpleVector <DilloUrl*> *cssUrls =
                            (lout::misc::SimpleVector <DilloUrl*> *) v_cssUrls;
   int j = 0;

   static Fl_Menu_Item *stylesheets = NULL;
   static Fl_Menu_Item pm[] = {
      {"View page source", 0, Menu_view_page_source_cb,0,0,0,0,0,0},
      {"View page bugs", 0, Menu_view_page_bugs_cb,0,0,0,0,0,0},
      {"View stylesheets", 0, Menu_nop_cb,0,FL_SUBMENU_POINTER|FL_MENU_DIVIDER,
       0,0,0,0},
      {"Bookmark this page", 0,Menu_add_bookmark_cb,0,FL_MENU_DIVIDER,0,0,0,0},
      {"Find text", 0, Menu_find_text_cb,0,0,0,0,0,0},
      {"Save page as...", 0, Menu_save_page_cb,0,0,0,0,0,0},
      {0,0,0,0,0,0,0,0,0}
   };

   popup_x = Fl::event_x();
   popup_y = Fl::event_y();
   popup_bw = bw;
   a_Url_free(popup_url);
   popup_url = a_Url_dup(url);

   has_bugs == TRUE ? pm[1].activate() : pm[1].deactivate();

   if (strncmp(URL_STR(url), "dpi:/vsource/", 13) == 0)
      pm[0].deactivate();
   else
      pm[0].activate();

   if (stylesheets) {
      while (stylesheets[j].text) {
         dFree((char *) stylesheets[j].label());
         a_Url_free((DilloUrl *) stylesheets[j].user_data());
         j++;
      }
      delete [] stylesheets;
      stylesheets = NULL;
   }

   if (cssUrls && cssUrls->size () > 0) {
      stylesheets = new Fl_Menu_Item[cssUrls->size() + 1];
      memset(stylesheets, '\0', sizeof(Fl_Menu_Item[cssUrls->size() + 1]));

      for (j = 0; j < cssUrls->size(); j++) {

         /* may want ability to Load individual unloaded stylesheets as well */
         const char *action = "View ";
         DilloUrl *url = cssUrls->get(j);
         const char *url_str = URL_STR(url);
         const uint_t head_length = 30, tail_length = 40,
                      url_len = strlen(url_str);;
         char *label;

         if (url_len > head_length + tail_length + 3) {
            /* trim long URLs when making the label */
            char *url_head = dStrndup(url_str, head_length);
            const char *url_tail = url_str + (url_len - tail_length);
            label = dStrconcat(action, url_head, "...", url_tail, NULL);
            dFree(url_head);
         } else {
            label = dStrconcat(action, url_str, NULL);
         }

         stylesheets[j].label(FL_NORMAL_LABEL, label);
         stylesheets[j].callback(Menu_stylesheet_cb, a_Url_dup(url));
      }

      pm[2].user_data(stylesheets);
      pm[2].activate();
   } else {
      pm[2].deactivate();
   }

   a_Timeout_add(0.0, Menu_popup_cb, (void*)pm);
}

/*
 * Link popup menu (construction & popup)
 */
void a_Menu_link_popup(BrowserWindow *bw, const DilloUrl *url)
{
   static Fl_Menu_Item pm[] = {
      {"Open link in new tab", 0, Menu_open_url_nt_cb,0,0,0,0,0,0},
      {"Open link in new window", 0, Menu_open_url_nw_cb,0,FL_MENU_DIVIDER,0,0,
       0,0},
      {"Bookmark this link", 0, Menu_add_bookmark_cb,0,0,0,0,0,0},
      {"Copy link location", 0, Menu_copy_urlstr_cb,0,FL_MENU_DIVIDER,0,0,0,0},
      {"Save link as...", 0, Menu_save_link_cb,0,0,0,0,0,0},
      {0,0,0,0,0,0,0,0,0}
   };

   popup_x = Fl::event_x();
   popup_y = Fl::event_y();
   popup_bw = bw;
   a_Url_free(popup_url);
   popup_url = a_Url_dup(url);

   a_Timeout_add(0.0, Menu_popup_cb, (void*)pm);
}

/*
 * Image popup menu (construction & popup)
 */
void a_Menu_image_popup(BrowserWindow *bw, const DilloUrl *url,
                        bool_t loaded_img, DilloUrl *page_url,
                        DilloUrl *link_url)
{
   static DilloUrl *popup_page_url = NULL;
   static DilloUrl *popup_link_url = NULL;
   static Fl_Menu_Item pm[] = {
      {"Isolate image", 0, Menu_open_url_cb,0,0,0,0,0,0},
      {"Open image in new tab", 0, Menu_open_url_nt_cb,0,0,0,0,0,0},
      {"Open image in new window", 0, Menu_open_url_nw_cb, 0, FL_MENU_DIVIDER,
       0,0,0,0},
      {"Load image", 0, Menu_load_images_cb,0,0,0,0,0,0},
      {"Bookmark this image", 0, Menu_add_bookmark_cb,0,0,0,0,0,0},
      {"Copy image location", 0,Menu_copy_urlstr_cb,0,FL_MENU_DIVIDER,0,0,0,0},
      {"Save image as...", 0, Menu_save_link_cb, 0, FL_MENU_DIVIDER,0,0,0,0},
      {"Link menu", 0, Menu_link_cb,0,0,0,0,0,0},
      {0,0,0,0,0,0,0,0,0}
   };

   popup_x = Fl::event_x();
   popup_y = Fl::event_y();
   popup_bw = bw;
   a_Url_free(popup_url);
   popup_url = a_Url_dup(url);
   a_Url_free(popup_page_url);
   popup_page_url = a_Url_dup(page_url);
   a_Url_free(popup_link_url);
   popup_link_url = a_Url_dup(link_url);


   if (loaded_img) {
      pm[3].deactivate();
   } else {
      pm[3].activate();
      pm[3].user_data(popup_page_url);
   }

   if (link_url) {
      pm[7].activate();
      pm[7].user_data(popup_link_url);
   } else {
      pm[7].deactivate();
   }

   a_Timeout_add(0.0, Menu_popup_cb, (void*)pm);
}

/*
 * Form popup menu (construction & popup)
 */
void a_Menu_form_popup(BrowserWindow *bw, const DilloUrl *page_url,
                       void *formptr, bool_t hidvis)
{
   static bool hiddens_visible;
   static Fl_Menu_Item pm[] = {
      {"Submit form", 0, Menu_form_submit_cb,0,0,0,0,0,0},
      {"Reset form", 0, Menu_form_reset_cb,0,0,0,0,0,0},
      {0, 0, Menu_form_hiddens_cb, &hiddens_visible, 0,0,0,0,0},
      {0,0,0,0,0,0,0,0,0}
   };

   popup_x = Fl::event_x();
   popup_y = Fl::event_y();
   popup_bw = bw;
   a_Url_free(popup_url);
   popup_url = a_Url_dup(page_url);
   popup_form = formptr;

   hiddens_visible = hidvis;
   pm[2].label(hiddens_visible ? "Hide hiddens": "Show hiddens");

   a_Timeout_add(0.0, Menu_popup_cb, (void*)pm);
}

/*
 * File popup menu (construction & popup)
 */
void a_Menu_file_popup(BrowserWindow *bw, void *v_wid)
{
   Fl_Widget *wid = (Fl_Widget*)v_wid;

   static Fl_Menu_Item pm[] = {
      {"New tab", Keys::getShortcut(KEYS_NEW_TAB), filemenu_cb,
       (void*)"nt",0,0,0,0,0},
      {"New window", Keys::getShortcut(KEYS_NEW_WINDOW), filemenu_cb,
       (void*)"nw", FL_MENU_DIVIDER,0,0,0,0},
      {"Open file...", Keys::getShortcut(KEYS_OPEN), filemenu_cb,
       (void*)"of",0,0,0,0,0},
      {"Open URL...", Keys::getShortcut(KEYS_GOTO), filemenu_cb,
       (void*)"ou",0,0,0,0,0},
      {"Close", Keys::getShortcut(KEYS_CLOSE_TAB), filemenu_cb,
       (void*)"cw", FL_MENU_DIVIDER,0,0,0,0},
      {"Exit Dillo", Keys::getShortcut(KEYS_CLOSE_ALL), filemenu_cb,
       (void*)"ed",0,0,0,0,0},
      {0,0,0,0,0,0,0,0,0}
   };

   popup_bw = bw;
   popup_x = wid->x();
   popup_y = wid->y() + wid->h();
   a_Url_free(popup_url);
   popup_url = NULL;

   //pm->label(wid->visible() ? NULL : "File");
   a_Timeout_add(0.0, Menu_popup_cb, (void*)pm);
}

/*
 * Bugmeter popup menu (construction & popup)
 */
void a_Menu_bugmeter_popup(BrowserWindow *bw, const DilloUrl *url)
{
   static Fl_Menu_Item pm[] = {
      {"Validate URL with W3C", 0, Menu_bugmeter_validate_w3c_cb,0,0,0,0,0,0},
      {"Validate URL with WDG", 0, Menu_bugmeter_validate_wdg_cb, 0,
       FL_MENU_DIVIDER,0,0,0,0},
      {"About bug meter", 0, Menu_bugmeter_about_cb,0,0,0,0,0,0},
      {0,0,0,0,0,0,0,0,0}
   };

   popup_x = Fl::event_x();
   popup_y = Fl::event_y();
   popup_bw = bw;
   a_Url_free(popup_url);
   popup_url = a_Url_dup(url);

   a_Timeout_add(0.0, Menu_popup_cb, (void*)pm);
}

/*
 * Navigation History popup menu (construction & popup)
 *
 * direction: {backward = -1, forward = 1}
 */
void a_Menu_history_popup(BrowserWindow *bw, int x, int y, int direction)
{
   static Fl_Menu_Item *pm = 0;
   int i, n;

   popup_bw = bw;
   popup_x = x;
   popup_y = y;
   history_direction = direction;

   // TODO: hook popdown event with delete or similar.
   if (pm)
      delete [] pm;
   if (history_list)
      dFree(history_list);

   // Get a list of URLs for this popup
   history_list = a_UIcmd_get_history(bw, direction);

   for (n = 0; history_list[n] != -1; n++)
      ;

   pm = new Fl_Menu_Item[n + 1];
   memset(pm, '\0', sizeof(Fl_Menu_Item[n + 1]));

   for (i = 0; i < n; i++) {
      pm[i].label(FL_NORMAL_LABEL, a_History_get_title(history_list[i], 1));
      pm[i].callback(Menu_history_cb, INT2VOIDP(i+1));
   }
   a_Timeout_add(0.0, Menu_popup_cb, (void*)pm);
}

/*
 * Toggle use of remote stylesheets
 */
static void Menu_remote_css_cb(Fl_Widget *wid, void*)
{
   Fl_Menu_Item *item = (Fl_Menu_Item*) wid;

   item->flags ^= FL_MENU_VALUE;
   prefs.load_stylesheets = item->flags & FL_MENU_VALUE ? 1 : 0;
   a_UIcmd_repush(popup_bw);
}

/*
 * Toggle use of embedded CSS style
 */
static void Menu_embedded_css_cb(Fl_Widget *wid, void*)
{
   Fl_Menu_Item *item = (Fl_Menu_Item*) wid;

   item->flags ^= FL_MENU_VALUE;
   prefs.parse_embedded_css = item->flags & FL_MENU_VALUE ? 1 : 0;
   a_UIcmd_repush(popup_bw);
}

static void Menu_panel_change_cb(Fl_Widget*, void *user_data)
{
   UI *ui = (UI*)popup_bw->ui;

   if (VOIDP2INT(user_data) == 10) /* small icons */
      ui->change_panel(ui->get_panelsize(), !ui->get_smallicons());
   else
      ui->change_panel(VOIDP2INT(user_data), ui->get_smallicons());
}

/*
 * Toggle loading of images -- and load them if enabling.
 */
static void Menu_imgload_toggle_cb(Fl_Widget *wid, void*)
{
   Fl_Menu_Item *item = (Fl_Menu_Item*) wid;

   item->flags ^= FL_MENU_VALUE;

   if ((prefs.load_images = item->flags & FL_MENU_VALUE ? 1 : 0)) {
      void *doc = a_Bw_get_current_doc(popup_bw);

      if (doc) {
         DilloUrl *pattern = NULL;
         a_Html_load_images(doc, pattern);
      }
   }
}

/*
 * Tools popup menu (construction & popup)
 */
void a_Menu_tools_popup(BrowserWindow *bw, int x, int y)
{
   const Fl_Menu_Item *item;
   UI *ui = (UI*)bw->ui;

   static Fl_Menu_Item pm[] = {
      {"Use remote CSS", 0, Menu_remote_css_cb, 0, FL_MENU_TOGGLE,0,0,0,0},
      {"Use embedded CSS", 0, Menu_embedded_css_cb, 0,
       FL_MENU_TOGGLE|FL_MENU_DIVIDER,0,0,0,0},
      {"Load images", 0, Menu_imgload_toggle_cb, 0,
       FL_MENU_TOGGLE|FL_MENU_DIVIDER,0,0,0,0},
      {"Panel size", 0, Menu_nop_cb, (void*)"Submenu1", FL_SUBMENU,0,0,0,0},
         {"tiny",  0,Menu_panel_change_cb,(void*)0,FL_MENU_RADIO,0,0,0,0},
         {"small", 0,Menu_panel_change_cb,(void*)1,FL_MENU_RADIO,0,0,0,0},
         {"medium",0,Menu_panel_change_cb,(void*)2,
           FL_MENU_RADIO|FL_MENU_DIVIDER,0,0,0,0},
         {"small icons", 0,Menu_panel_change_cb,(void*)10,
           FL_MENU_TOGGLE,0,0,0,0},
         {0,0,0,0,0,0,0,0,0},
      {0,0,0,0,0,0,0,0,0}
   };

   popup_bw = bw;
   int cur_panelsize = ui->get_panelsize();
   int cur_smallicons = ui->get_smallicons();

   if (prefs.load_stylesheets)
      pm[0].set();
   if (prefs.parse_embedded_css)
      pm[1].set();
   if (prefs.load_images)
      pm[2].set();
   pm[4+cur_panelsize].setonly();
   cur_smallicons ? pm[7].set() : pm[7].clear();

   item = pm->popup(x, y);
   if (item) {
      ((Fl_Widget *)item)->do_callback();
   }
}