aboutsummaryrefslogtreecommitdiff
path: root/src/menu.cc
diff options
context:
space:
mode:
authorcorvid <corvid@lavabit.com>2011-01-09 04:20:12 +0000
committercorvid <corvid@lavabit.com>2011-01-09 04:20:12 +0000
commit5bb91804ea4617f5da1689db3752e1a25ffc2dfa (patch)
tree7c3b29ff8bd15e89260dbb558987439e752d1f42 /src/menu.cc
parent8f25f501b9bd60cbb0efecf7a2297cb828c0dba7 (diff)
fair amount of menu
Diffstat (limited to 'src/menu.cc')
-rw-r--r--src/menu.cc431
1 files changed, 173 insertions, 258 deletions
diff --git a/src/menu.cc b/src/menu.cc
index 4090e1ae..da72a99a 100644
--- a/src/menu.cc
+++ b/src/menu.cc
@@ -11,6 +11,7 @@
// Functions/Methods for menus
+#include <FL/Fl.H>
#include <FL/Fl_Menu_Item.H>
#include "lout/misc.hh" /* SimpleVector */
@@ -23,8 +24,6 @@
#include "keys.hh"
#include "timeout.hh"
-using namespace fltk;
-
/*
* Local data
*/
@@ -34,6 +33,7 @@ using namespace fltk;
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 filemenu popup
static int popup_x, popup_y;
// History popup direction (-1 = back, 1 = forward).
@@ -46,7 +46,7 @@ static int *history_list = NULL;
* Used to add the hint for history popup menus, and to remember
* the mouse button pressed over a menu item.
*/
-class CustItem : public Item {
+class CustItem : public Fl_Menu_Item {
int EventButton;
public:
CustItem (const char* label) : Item(label) { EventButton = 0; };
@@ -96,7 +96,7 @@ static void filemenu_cb(Fl_Widget *wid, void *data)
}
-static void Menu_copy_urlstr_cb(Fl_Widget *)
+static void Menu_copy_urlstr_cb(Fl_Widget*, void*)
{
if (popup_url)
a_UIcmd_copy_urlstr(popup_bw, URL_STR(popup_url));
@@ -114,7 +114,7 @@ static void Menu_link_cb(Fl_Widget*, void *user_data)
/*
* Open URL
*/
-static void Menu_open_url_cb(Fl_Widget* )
+static void Menu_open_url_cb(Fl_Widget*, void* )
{
_MSG("Open URL cb: click! :-)\n");
a_UIcmd_open_url(popup_bw, popup_url);
@@ -123,7 +123,7 @@ static void Menu_open_url_cb(Fl_Widget* )
/*
* Open URL in new window
*/
-static void Menu_open_url_nw_cb(Fl_Widget* )
+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);
@@ -132,7 +132,7 @@ static void Menu_open_url_nw_cb(Fl_Widget* )
/*
* Open URL in new Tab
*/
-static void Menu_open_url_nt_cb(Fl_Widget* )
+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;
@@ -142,7 +142,7 @@ static void Menu_open_url_nt_cb(Fl_Widget* )
/*
* Add bookmark
*/
-static void Menu_add_bookmark_cb(Fl_Widget* )
+static void Menu_add_bookmark_cb(Fl_Widget*, void* )
{
a_UIcmd_add_bookmark(popup_bw, popup_url);
}
@@ -150,7 +150,7 @@ static void Menu_add_bookmark_cb(Fl_Widget* )
/*
* Find text
*/
-static void Menu_find_text_cb(Fl_Widget* )
+static void Menu_find_text_cb(Fl_Widget*, void* )
{
((UI *)popup_bw->ui)->set_findbar_visibility(1);
}
@@ -158,7 +158,7 @@ static void Menu_find_text_cb(Fl_Widget* )
/*
* Save link
*/
-static void Menu_save_link_cb(Fl_Widget* )
+static void Menu_save_link_cb(Fl_Widget*, void* )
{
a_UIcmd_save_link(popup_bw, popup_url);
}
@@ -166,7 +166,7 @@ static void Menu_save_link_cb(Fl_Widget* )
/*
* Save current page
*/
-static void Menu_save_page_cb(Fl_Widget* )
+static void Menu_save_page_cb(Fl_Widget*, void* )
{
a_UIcmd_save(popup_bw);
}
@@ -174,7 +174,7 @@ static void Menu_save_page_cb(Fl_Widget* )
/*
* View current page source
*/
-static void Menu_view_page_source_cb(Fl_Widget* )
+static void Menu_view_page_source_cb(Fl_Widget*, void* )
{
a_UIcmd_view_page_source(popup_bw, popup_url);
}
@@ -182,7 +182,7 @@ static void Menu_view_page_source_cb(Fl_Widget* )
/*
* View current page's bugs
*/
-static void Menu_view_page_bugs_cb(Fl_Widget* )
+static void Menu_view_page_bugs_cb(Fl_Widget*, void* )
{
a_UIcmd_view_page_bugs(popup_bw);
}
@@ -202,23 +202,23 @@ static void Menu_load_images_cb(Fl_Widget*, void *user_data)
/*
* Submit form
*/
-static void Menu_form_submit_cb(Fl_Widget*, void *v_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, v_form);
+ a_Html_form_submit(doc, popup_form);
}
/*
* Reset form
*/
-static void Menu_form_reset_cb(Fl_Widget*, void *v_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, v_form);
+ a_Html_form_reset(doc, popup_form);
}
/*
@@ -226,12 +226,11 @@ static void Menu_form_reset_cb(Fl_Widget*, void *v_form)
*/
static void Menu_form_hiddens_cb(Fl_Widget *w, void *user_data)
{
- void *v_form = w->parent()->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, v_form, !visible);
+ a_Html_form_display_hiddens(doc, popup_form, !visible);
}
static void Menu_stylesheet_cb(Fl_Widget *w, void *vUrl)
@@ -243,7 +242,7 @@ static void Menu_stylesheet_cb(Fl_Widget *w, void *vUrl)
/*
* Validate URL with the W3C
*/
-static void Menu_bugmeter_validate_w3c_cb(Fl_Widget* )
+static void Menu_bugmeter_validate_w3c_cb(Fl_Widget*, void* )
{
Dstr *dstr = dStr_sized_new(128);
@@ -256,7 +255,7 @@ static void Menu_bugmeter_validate_w3c_cb(Fl_Widget* )
/*
* Validate URL with the WDG
*/
-static void Menu_bugmeter_validate_wdg_cb(Fl_Widget* )
+static void Menu_bugmeter_validate_wdg_cb(Fl_Widget*, void* )
{
Dstr *dstr = dStr_sized_new(128);
@@ -270,7 +269,7 @@ static void Menu_bugmeter_validate_wdg_cb(Fl_Widget* )
/*
* Show info page for the bug meter
*/
-static void Menu_bugmeter_about_cb(Fl_Widget* )
+static void Menu_bugmeter_about_cb(Fl_Widget*, void* )
{
a_UIcmd_open_urlstr(popup_bw, "http://www.dillo.org/help/bug_meter.html");
}
@@ -307,18 +306,10 @@ static void Menu_history_cb(Fl_Widget *wid, void *data)
*/
static void Menu_popup_cb(void *data)
{
- ((PopupMenu *)data)->popup();
- a_Timeout_remove();
-}
+ const Fl_Menu_Item *m = ((Fl_Menu_Item *)data)->popup(popup_x, popup_y);
-/*
- * Same as above but with coordinates.
- */
-static void Menu_popup_cb2(void *data)
-{
- Menu *m = (Menu *)data;
- m->value(-1);
- m->popup(Rectangle(popup_x,popup_y,m->w(),m->h()), m->label());
+ if (m)
+ ((Fl_Widget *)m)->do_callback();
a_Timeout_remove();
}
@@ -330,65 +321,48 @@ void a_Menu_page_popup(BrowserWindow *bw, const DilloUrl *url,
{
lout::misc::SimpleVector <DilloUrl*> *cssUrls =
(lout::misc::SimpleVector <DilloUrl*> *) v_cssUrls;
- Item *i;
- int j;
- // One menu for every browser window
- static PopupMenu *pm = 0;
- // Active/inactive control.
- static Item *view_page_bugs_item = 0, *view_source_item = 0;
- static ItemGroup *stylesheets = 0;
-
+ 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, 0, 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);
- if (!pm) {
- pm = new PopupMenu(0,0,0,0,"&PAGE OPTIONS");
- pm->begin();
- i = view_source_item = new Item("View page Source");
- i->callback(Menu_view_page_source_cb);
- i = view_page_bugs_item = new Item("View page Bugs");
- i->callback(Menu_view_page_bugs_cb);
- stylesheets = new ItemGroup("View Stylesheets");
- new Divider();
- i = new Item("Bookmark this page");
- i->callback(Menu_add_bookmark_cb);
- new Divider();
- i = new Item("Find Text");
- i->callback(Menu_find_text_cb);
- //i->shortcut(CTRL+'f');
- i = new Item("Jump to...");
- i->deactivate();
- new Divider();
- i = new Item("Save page As...");
- i->callback(Menu_save_page_cb);
-
- pm->type(PopupMenu::POPUP123);
- pm->end();
- }
-
- if (has_bugs == TRUE)
- view_page_bugs_item->activate();
- else
- view_page_bugs_item->deactivate();
+ has_bugs == TRUE ? pm[1].activate() : pm[1].deactivate();
if (strncmp(URL_STR(url), "dpi:/vsource/", 13) == 0)
- view_source_item->deactivate();
+ pm[0].deactivate();
else
- view_source_item->activate();
-
- int n = stylesheets->children();
- for (j = 0; j < n; j++) {
- /* get rid of the old ones */
- Fl_Widget *child = stylesheets->child(0);
- dFree((char *)child->label());
- a_Url_free((DilloUrl *)child->user_data());
- delete child;
+ 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->activate();
+ 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);
@@ -407,14 +381,14 @@ void a_Menu_page_popup(BrowserWindow *bw, const DilloUrl *url,
label = dStrconcat(action, url_str, NULL);
}
- i = new Item(label);
- i->clear_flag(SHORTCUT_LABEL);
- i->user_data(a_Url_dup(url));
- i->callback(Menu_stylesheet_cb);
- stylesheets->add(i);
+ 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 {
- stylesheets->deactivate();
+ pm[2].deactivate();
}
a_Timeout_add(0.0, Menu_popup_cb, (void *)pm);
@@ -425,33 +399,20 @@ void a_Menu_page_popup(BrowserWindow *bw, const DilloUrl *url,
*/
void a_Menu_link_popup(BrowserWindow *bw, const DilloUrl *url)
{
- // One menu for every browser window
- static PopupMenu *pm = 0;
-
+ static Fl_Menu_Item pm[] = {
+ {"Open link in new window", 0, Menu_open_url_nw_cb,0,0,0,0,0,0},
+ {"Open link in new tab",0,Menu_open_url_nt_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);
- if (!pm) {
- Item *i;
- pm = new PopupMenu(0,0,0,0,"&LINK OPTIONS");
- //pm->callback(Menu_link_cb, url);
- pm->begin();
- i = new Item("Open Link in New Window");
- i->callback(Menu_open_url_nw_cb);
- i = new Item("Open Link in New Tab");
- i->callback(Menu_open_url_nt_cb);
- new Divider();
- i = new Item("Bookmark this Link");
- i->callback(Menu_add_bookmark_cb);
- i = new Item("Copy Link location");
- i->callback(Menu_copy_urlstr_cb);
- new Divider();
- i = new Item("Save Link As...");
- i->callback(Menu_save_link_cb);
-
- pm->type(PopupMenu::POPUP123);
- pm->end();
- }
a_Timeout_add(0.0, Menu_popup_cb, (void *)pm);
}
@@ -463,14 +424,23 @@ void a_Menu_image_popup(BrowserWindow *bw, const DilloUrl *url,
bool_t loaded_img, DilloUrl *page_url,
DilloUrl *link_url)
{
- // One menu for every browser window
- static PopupMenu *pm = 0;
- // Active/inactive control.
- static Item *link_menuitem = 0;
- static Item *load_img_menuitem = 0;
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 window", 0, Menu_open_url_nw_cb,0,0,0,0,0,0},
+ {"Open image in new tab", 0, Menu_open_url_nt_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);
@@ -479,46 +449,19 @@ void a_Menu_image_popup(BrowserWindow *bw, const DilloUrl *url,
a_Url_free(popup_link_url);
popup_link_url = a_Url_dup(link_url);
- if (!pm) {
- Item *i;
- pm = new PopupMenu(0,0,0,0,"&IMAGE OPTIONS");
- pm->begin();
- i = new Item("Isolate Image");
- i->callback(Menu_open_url_cb);
- i = new Item("Open Image in New Window");
- i->callback(Menu_open_url_nw_cb);
- i = new Item("Open Image in New Tab");
- i->callback(Menu_open_url_nt_cb);
- new Divider();
- i = load_img_menuitem = new Item("Load image");
- i->callback(Menu_load_images_cb);
- i = new Item("Bookmark this Image");
- i->callback(Menu_add_bookmark_cb);
- i = new Item("Copy Image location");
- i->callback(Menu_copy_urlstr_cb);
- new Divider();
- i = new Item("Save Image As...");
- i->callback(Menu_save_link_cb);
- new Divider();
- i = link_menuitem = new Item("Link menu");
- i->callback(Menu_link_cb);
-
- pm->type(PopupMenu::POPUP123);
- pm->end();
- }
if (loaded_img) {
- load_img_menuitem->deactivate();
+ pm[3].deactivate();
} else {
- load_img_menuitem->activate();
- load_img_menuitem->user_data(popup_page_url);
+ pm[3].activate();
+ pm[3].user_data(popup_page_url);
}
if (link_url) {
- link_menuitem->user_data(popup_link_url);
- link_menuitem->activate();
+ pm[7].activate();
+ pm[7].user_data(popup_link_url);
} else {
- link_menuitem->deactivate();
+ pm[7].deactivate();
}
a_Timeout_add(0.0, Menu_popup_cb, (void *)pm);
@@ -530,29 +473,23 @@ void a_Menu_image_popup(BrowserWindow *bw, const DilloUrl *url,
void a_Menu_form_popup(BrowserWindow *bw, const DilloUrl *page_url,
void *formptr, bool_t hidvis)
{
- static PopupMenu *pm = 0;
- static Item *hiddens_item = 0;
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);
- if (!pm) {
- Item *i;
- pm = new PopupMenu(0,0,0,0,"FORM OPTIONS");
- pm->add(i = new Item("Submit form"));
- i->callback(Menu_form_submit_cb);
- pm->add(i = new Item("Reset form"));
- i->callback(Menu_form_reset_cb);
- pm->add(hiddens_item = new Item(""));
- hiddens_item->callback(Menu_form_hiddens_cb);
- hiddens_item->user_data(&hiddens_visible);
- pm->type(PopupMenu::POPUP123);
- }
- pm->user_data(formptr);
+ popup_form = formptr;
hiddens_visible = hidvis;
- hiddens_item->label(hiddens_visible ? "Hide hiddens": "Show hiddens");
+ pm[2].label(hiddens_visible ? "Hide hiddens": "Show hiddens");
a_Timeout_add(0.0, Menu_popup_cb, (void *)pm);
}
@@ -564,8 +501,22 @@ void a_Menu_file_popup(BrowserWindow *bw, void *v_wid)
{
UI *ui = (UI *)bw->ui;
Fl_Widget *wid = (Fl_Widget*)v_wid;
- // One menu for every browser window
- static PopupMenu *pm = 0;
+
+ static Fl_Menu_Item pm[] = {
+ {"New window", Keys::getShortcut(KEYS_NEW_WINDOW), filemenu_cb,
+ (void*)"nw",0,0,0,0,0},
+ {"New tab", Keys::getShortcut(KEYS_NEW_TAB), filemenu_cb,
+ (void*)"nt", 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();
@@ -575,31 +526,8 @@ void a_Menu_file_popup(BrowserWindow *bw, void *v_wid)
a_Url_free(popup_url);
popup_url = NULL;
- if (!pm) {
- int shortcut;
- Item *i;
- pm = new PopupMenu(0,0,0,0,"File");
- pm->begin();
- shortcut = Keys::getShortcut(KEYS_NEW_WINDOW);
- i = new Item("New Window", shortcut, filemenu_cb, (void*)"nw");
- shortcut = Keys::getShortcut(KEYS_NEW_TAB);
- i = new Item("New Tab", shortcut, filemenu_cb, (void*)"nt");
- new Divider();
- shortcut = Keys::getShortcut(KEYS_OPEN);
- i = new Item("Open File...", shortcut, filemenu_cb, (void*)"of");
- shortcut = Keys::getShortcut(KEYS_GOTO);
- i = new Item("Open URL...", shortcut, filemenu_cb, (void*)"ou");
- shortcut = Keys::getShortcut(KEYS_CLOSE_TAB);
- i = new Item("Close", shortcut, filemenu_cb, (void*)"cw");
- new Divider();
- shortcut = Keys::getShortcut(KEYS_CLOSE_ALL);
- i = new Item("Exit Dillo", shortcut, filemenu_cb, (void*)"ed");
- pm->type(PopupMenu::POPUP123);
- pm->end();
- }
-
- pm->label(wid->visible() ? NULL : "File");
- a_Timeout_add(0.0, Menu_popup_cb2, (void *)pm);
+ //pm->label(wid->visible() ? NULL : "File");
+ a_Timeout_add(0.0, Menu_popup_cb, (void *)pm);
}
/*
@@ -607,28 +535,21 @@ void a_Menu_file_popup(BrowserWindow *bw, void *v_wid)
*/
void a_Menu_bugmeter_popup(BrowserWindow *bw, const DilloUrl *url)
{
- // One menu for every browser window
- static PopupMenu *pm = 0;
+ 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);
- if (!pm) {
- Item *i;
- pm = new PopupMenu(0,0,0,0,"&BUG METER OPTIONS");
- pm->begin();
- i = new Item("Validate URL with W3C");
- i->callback(Menu_bugmeter_validate_w3c_cb);
- i = new Item("Validate URL with WDG");
- i->callback(Menu_bugmeter_validate_wdg_cb);
- new Divider();
- i = new Item("About Bug Meter...");
- i->callback(Menu_bugmeter_about_cb);
- pm->type(PopupMenu::POPUP123);
- pm->end();
- }
- pm->popup();
+ a_Timeout_add(0.0, Menu_popup_cb, (void *)pm);
}
/*
@@ -638,65 +559,65 @@ void a_Menu_bugmeter_popup(BrowserWindow *bw, const DilloUrl *url)
*/
void a_Menu_history_popup(BrowserWindow *bw, int direction)
{
- static PopupMenu *pm = 0;
- Item *it;
- int i;
+ static Fl_Menu_Item *pm = 0;
+ int i, n;
popup_bw = bw;
history_direction = direction;
// TODO: hook popdown event with delete or similar.
if (pm)
- delete(pm);
+ delete [] pm;
if (history_list)
dFree(history_list);
- if (direction == -1) {
- pm = new PopupMenu(0,0,0,0, "&PREVIOUS PAGES");
- } else {
- pm = new PopupMenu(0,0,0,0, "&FOLLOWING PAGES");
- }
-
// Get a list of URLs for this popup
history_list = a_UIcmd_get_history(bw, direction);
- pm->begin();
- for (i = 0; history_list[i] != -1; i += 1) {
- // TODO: restrict title size
- it = new CustItem(a_History_get_title(history_list[i], 1));
- it->callback(Menu_history_cb, INT2VOIDP(i+1));
- }
- pm->type(PopupMenu::POPUP123);
- pm->end();
+ for (n = 0; history_list[n] != -1; n++)
+ ;
- pm->popup();
+ 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)
+static void Menu_remote_css_cb(Fl_Widget *wid, void*)
{
+ Fl_Menu_Item *item = (Fl_Menu_Item*) wid;
+
_MSG("Menu_remote_css_cb\n");
- prefs.load_stylesheets = wid->state() ? 1 : 0;
+ prefs.load_stylesheets = item->value() ? 1 : 0;
a_UIcmd_repush(popup_bw);
}
/*
* Toggle use of embedded CSS style
*/
-static void Menu_embedded_css_cb(Fl_Widget *wid)
+static void Menu_embedded_css_cb(Fl_Widget *wid, void*)
{
- prefs.parse_embedded_css = wid->state() ? 1 : 0;
+ Fl_Menu_Item *item = (Fl_Menu_Item*) wid;
+
+ prefs.parse_embedded_css = item->value() ? 1 : 0;
a_UIcmd_repush(popup_bw);
}
/*
* Toggle loading of images -- and load them if enabling.
*/
-static void Menu_imgload_toggle_cb(Fl_Widget *wid)
+static void Menu_imgload_toggle_cb(Fl_Widget *wid, void*)
{
- if ((prefs.load_images = wid->state() ? 1 : 0)) {
+ Fl_Menu_Item *item = (Fl_Menu_Item*) wid;
+
+ if ((prefs.load_images = item->value() ? 1 : 0)) {
void *doc = a_Bw_get_current_doc(popup_bw);
if (doc) {
@@ -711,31 +632,25 @@ static void Menu_imgload_toggle_cb(Fl_Widget *wid)
*/
void a_Menu_tools_popup(BrowserWindow *bw, void *v_wid)
{
- // One menu shared by every browser window
- static PopupMenu *pm = NULL;
Fl_Widget *wid = (Fl_Widget*)v_wid;
- Item *it;
+
+ 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,0,0,0,0},
+ {0,0,0,0,0,0,0,0,0}
+ };
popup_bw = bw;
- if (!pm) {
- pm = new PopupMenu(0,0,0,0, "TOOLS");
- pm->begin();
- it = new ToggleItem("Use remote CSS");
- it->callback(Menu_remote_css_cb);
- it->state(prefs.load_stylesheets);
- it = new ToggleItem("Use embedded CSS");
- it->callback(Menu_embedded_css_cb);
- it->state(prefs.parse_embedded_css);
- new Divider();
- it = new ToggleItem("Load images");
- it->callback(Menu_imgload_toggle_cb);
- it->state(prefs.load_images);
- pm->type(PopupMenu::POPUP13);
- pm->end();
- }
- //pm->popup();
- pm->value(-1);
- ((Menu*)pm)->popup(Rectangle(0,wid->h(),pm->w(),pm->h()));
+ if (prefs.load_stylesheets)
+ pm[0].set();
+ if (prefs.parse_embedded_css)
+ pm[1].set();
+ if (prefs.load_images)
+ pm[2].set();
+
+ pm->popup(wid->x(), wid->y());
}