19#include <FL/Fl_Menu_Item.H>
40 const Fl_Menu_Item *picked;
41 const Fl_Menu_Item *menu;
72 if (strcmp((
char*)data,
"nw") == 0) {
74 }
else if (strcmp((
char*)data,
"nt") == 0) {
76 }
else if (strcmp((
char*)data,
"of") == 0) {
78 }
else if (strcmp((
char*)data,
"ou") == 0) {
80 }
else if (strcmp((
char*)data,
"cw") == 0) {
82 }
else if (strcmp((
char*)data,
"ed") == 0) {
102 _MSG(
"Open URL cb: click! :-)\n");
112 _MSG(
"Open URL in new window cb: click! :-)\n");
123 if (Fl::event_state(FL_SHIFT)) focus = !focus;
217 bool visible = *((
bool *) user_data);
226 int mb = Fl::event_button();
231 }
else if (mb == 2) {
234 if (Fl::event_state(FL_SHIFT)) focus = !focus;
247 *ptr = strrchr(popup_str,
'#');
248 char *no_fragment = ptr ?
dStrndup(popup_str, ptr - popup_str)
267 "https://validator.w3.org/nu/"
268 "?useragent=Validator.nu%%2FLV+https%%3A%%2F%%2Fvalidator.w3.org%%2Fservices"
279 "https://validator.w3.org/check?uri=%s"
280 "&charset=%%28detect+automatically%%29"
281 "&doctype=Inline&group=0"
282 "&user-agent=W3C_Validator%%2F1.3+");
299 int mb = Fl::event_button();
305 }
else if (mb == 2) {
309 if (Fl::event_state(FL_SHIFT)) focus = !focus;
325 const Fl_Menu_Item *m;
327 ((
UI*)
popup_bw->
ui)->window()->cursor(FL_CURSOR_DEFAULT);
331 if (m && m->callback())
332 m->do_callback((Fl_Widget *)data);
338 const Fl_Menu_Item *picked;
339 Menu_popup_data_t *d = (Menu_popup_data_t *)data;
341 ((
UI*)
popup_bw->
ui)->window()->cursor(FL_CURSOR_DEFAULT);
346 if (picked->callback())
347 picked->do_callback((Fl_Widget *)(d->menu));
356 bool_t has_bugs,
void *v_cssUrls)
358 lout::misc::SimpleVector <DilloUrl*> *cssUrls =
359 (lout::misc::SimpleVector <DilloUrl*> *) v_cssUrls;
362 static Fl_Menu_Item *stylesheets = NULL;
363 static Fl_Menu_Item pm[] = {
366 {
"View stylesheets", 0,
Menu_nop_cb,0,FL_SUBMENU_POINTER|FL_MENU_DIVIDER,
373 static Menu_popup_data_t page_data = {
"Page menu", NULL, pm};
381 has_bugs ==
TRUE ? pm[1].activate() : pm[1].deactivate();
384 strncmp(
URL_PATH(url),
"/vsource/", 9) == 0)
392 while (stylesheets[j].text) {
393 dFree((
char *) stylesheets[j].label());
397 delete [] stylesheets;
401 if (cssUrls && cssUrls->
size () > 0) {
402 stylesheets =
new Fl_Menu_Item[cssUrls->
size() + 1];
403 memset(stylesheets,
'\0', (cssUrls->
size() + 1) *
sizeof(Fl_Menu_Item));
405 for (j = 0; j < cssUrls->
size(); j++) {
407 const char *url_str =
URL_STR(url);
408 const uint_t head_length = 30, tail_length = 40,
409 url_len = strlen(url_str);
412 if (url_len > head_length + tail_length + 3) {
414 char *url_head =
dStrndup(url_str, head_length);
415 const char *url_tail = url_str + (url_len - tail_length);
416 label =
dStrconcat(url_head,
"...", url_tail, NULL);
422 stylesheets[j].label(FL_NORMAL_LABEL, label);
426 pm[2].user_data(stylesheets);
449struct link_menu_item {
464 struct link_menu_item *mitem = (
struct link_menu_item *) user_data;
466 const DilloUrl *origin = mitem->origin;
467 Action *action = mitem->action;
470 setenv(
"url",
URL_STR(url), 1);
471 setenv(
"origin",
URL_STR(origin), 1);
476 int ret = system(action->
cmd);
478 MSG(
"Cannot run '%s': %s\n", action->
cmd, strerror(errno));
480 }
else if (ret != 0) {
481 MSG(
"Command exited with '%d': %s\n", ret, action->
cmd);
492 static Fl_Menu_Item *link_menu = NULL;
493 static struct link_menu_item *link_menu_item = NULL;
496 if (link_menu != NULL)
507 int ntotal = nstatic + nactions;
508 link_menu = (Fl_Menu_Item *) calloc(ntotal + 1,
sizeof(Fl_Menu_Item));
509 link_menu_item = (
struct link_menu_item *) calloc(nactions,
sizeof(
struct link_menu_item));
512 for (
int i = 0; i < nstatic; i++) {
513 memcpy(&link_menu[i], &
link_menu_[i],
sizeof(Fl_Menu_Item));
517 for (
int i = 0; i < nactions; i++) {
519 struct link_menu_item *mitem = &link_menu_item[i];
521 mitem->action = action;
523 Fl_Menu_Item *item = &link_menu[nstatic + i];
524 item->text = action->
label;
526 item->user_data_ = mitem;
535 for (
int i = 0; link_menu[i].label(); i++) {
537 struct link_menu_item *mitem = (
struct link_menu_item *) link_menu[i].user_data_;
540 mitem->origin = page_url;
542 link_menu[i].user_data_ = (
void *) url;
552 static Menu_popup_data_t link_data = {
"Link menu", NULL, NULL};
561 link_data.menu = link_menu;
575 static DilloUrl *popup_page_url = NULL;
576 static DilloUrl *popup_link_url = NULL;
577 static Fl_Menu_Item pm[] = {
589 static Menu_popup_data_t image_data = {
"Image menu", NULL, pm};
610 pm[3].user_data(popup_page_url);
631 void *formptr,
bool_t hidvis)
633 static bool hiddens_visible;
634 static Fl_Menu_Item pm[] = {
640 static Menu_popup_data_t form_data = {
"Form menu", NULL, pm};
649 hiddens_visible = hidvis;
650 pm[2].label(hiddens_visible ?
"Hide hiddens":
"Show hiddens");
660 Fl_Widget *wid = (Fl_Widget*)v_wid;
662 static Fl_Menu_Item pm[] = {
664 (
void*)
"nt",0,0,0,0,0},
666 (
void*)
"nw", FL_MENU_DIVIDER,0,0,0,0},
668 (
void*)
"of",0,0,0,0,0},
670 (
void*)
"ou",0,0,0,0,0},
672 (
void*)
"cw", FL_MENU_DIVIDER,0,0,0,0},
674 (
void*)
"ed",0,0,0,0,0},
693 static Fl_Menu_Item pm[] = {
694 {
"Validate URL with W3C Nu validator (HTML5 only)", 0,
696 {
"Validate URL with W3C validator (HTML 4.01 and older)", 0,
698 {
"About bug meter", 0,
719 static Fl_Menu_Item *pm = 0;
739 pm =
new Fl_Menu_Item[n + 1];
740 memset(pm,
'\0', (n + 1) *
sizeof(Fl_Menu_Item));
742 for (i = 0; i < n; i++) {
754 Fl_Menu_Item *item = (Fl_Menu_Item*) wid;
756 item->flags ^= FL_MENU_VALUE;
766 Fl_Menu_Item *item = (Fl_Menu_Item*) wid;
768 item->flags ^= FL_MENU_VALUE;
779 Fl_Menu_Item *item = (Fl_Menu_Item*) wid;
781 item->flags ^= FL_MENU_VALUE;
801 Fl_Menu_Item *item = (Fl_Menu_Item*) wid;
803 item->flags ^= FL_MENU_VALUE;
820 Fl_Menu_Item *item = (Fl_Menu_Item*) wid;
822 item->flags ^= FL_MENU_VALUE;
832 const Fl_Menu_Item *item;
835 static Fl_Menu_Item pm[] = {
838 FL_MENU_TOGGLE|FL_MENU_DIVIDER,0,0,0,0},
840 FL_MENU_TOGGLE,0,0,0,0},
842 FL_MENU_TOGGLE|FL_MENU_DIVIDER,0,0,0,0},
844 FL_MENU_TOGGLE|FL_MENU_DIVIDER,0,0,0,0},
845 {
"Panel size", 0,
Menu_nop_cb, (
void*)
"Submenu1", FL_SUBMENU,0,0,0,0},
849 FL_MENU_RADIO|FL_MENU_DIVIDER,0,0,0,0},
851 FL_MENU_TOGGLE,0,0,0,0},
870 pm[6+cur_panelsize].setonly();
871 cur_smallicons ? pm[9].set() : pm[9].clear();
873 item = pm->popup(x, y);
875 ((Fl_Widget *)item)->do_callback();
Dlist * a_Actions_link_get(void)
void * a_Bw_get_url_doc(BrowserWindow *bw, const DilloUrl *url)
Get document by URL.
void * a_Bw_get_current_doc(BrowserWindow *bw)
Get current document.
static int getShortcut(KeysCommand_t cmd)
Given a keys command, return a shortcut for it, or 0 if there is none (e.g., for KEYS_NEW_WINDOW,...
void change_panel(int new_size, int small_icons)
On-the-fly panel style change.
T get(int i) const
Return the one element, explicitly.
int size() const
Return the number of elements put into this vector.
char * dStrconcat(const char *s1,...)
Concatenate a NULL-terminated list of strings.
int dStrAsciiCasecmp(const char *s1, const char *s2)
char * dStrdup(const char *s)
Dstr * dStr_sized_new(int sz)
Create a new string with a given size.
int dList_length(Dlist *lp)
For completing the ADT.
void * dList_nth_data(Dlist *lp, int n0)
Return the nth data item, NULL when not found or 'n0' is out of range.
void dStr_free(Dstr *ds, int all)
Free a dillo string.
char * dStrndup(const char *s, size_t sz)
void dStr_sprintf(Dstr *ds, const char *format,...)
Printf-like function.
const DilloUrl * a_History_get_url(int idx)
Return the DilloUrl field (by index)
const char * a_History_get_title(int idx, int force)
Return the title field (by index) ('force' returns URL_STR when there's no title)
void a_Html_form_display_hiddens(void *v_html, void *v_form, bool_t display)
Used by the "Show/Hide hiddens" form menuitem.
void a_Html_form_submit(void *v_html, void *v_form)
Used by the "Submit form" form menuitem.
void a_Html_load_images(void *v_html, DilloUrl *pattern)
Used by the "Load images" page menuitem.
void a_Html_form_reset(void *v_html, void *v_form)
Used by the "Reset form" form menuitem.
DilloPrefs prefs
Global Data.
Contains the specific data for a single window.
void * ui
Pointer to the UI object this bw belongs to.
bool_t parse_embedded_css
bool_t load_background_images
bool_t middle_click_opens_new_tab
void a_Timeout_add(float t, TimeoutCb_t cb, void *cbdata)
Hook a one-time timeout function 'cb' after 't' seconds with 'cbdata" as its data.
void a_Timeout_remove()
Stop running a timeout function.
void a_UIcmd_copy_urlstr(BrowserWindow *bw, const char *urlstr)
void a_UIcmd_close_bw(void *vbw)
int * a_UIcmd_get_history(BrowserWindow *bw, int direction)
void a_UIcmd_open_file(void *vbw)
void a_UIcmd_focus_location(void *vbw)
void a_UIcmd_open_url_nw(BrowserWindow *bw, const DilloUrl *url)
void a_UIcmd_view_page_source(BrowserWindow *bw, const DilloUrl *url)
void a_UIcmd_view_page_bugs(void *vbw)
void a_UIcmd_nav_jump(BrowserWindow *bw, int offset, int new_bw)
void a_UIcmd_open_urlstr(void *vbw, const char *urlstr)
void a_UIcmd_save(void *vbw)
void a_UIcmd_save_link(BrowserWindow *bw, const DilloUrl *url)
void a_UIcmd_repush(void *vbw)
void a_UIcmd_close_all_bw(void *)
void a_UIcmd_add_bookmark(BrowserWindow *bw, const DilloUrl *url)
void a_UIcmd_open_url(BrowserWindow *bw, const DilloUrl *url)
void a_UIcmd_open_url_nt(void *vbw, const DilloUrl *url, int focus)
char * a_Url_encode_hex_str(const char *str)
Urlencode 'str'.
void a_Url_free(DilloUrl *url)
Free a DilloUrl.
DilloUrl * a_Url_dup(const DilloUrl *ori)
Duplicate a Url structure.