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));
355 {
"View stylesheets", 0,
Menu_nop_cb,0,FL_SUBMENU_POINTER|FL_MENU_DIVIDER,
384 static Fl_Menu_Item *page_menu = NULL;
387 if (page_menu != NULL)
398 int ntotal = nstatic + nactions;
399 page_menu = (Fl_Menu_Item *) calloc(ntotal + 1,
sizeof(Fl_Menu_Item));
402 for (
int i = 0; i < nstatic; i++) {
403 memcpy(&page_menu[i], &
page_menu_[i],
sizeof(Fl_Menu_Item));
407 for (
int i = 0; i < nactions; i++) {
409 Fl_Menu_Item *item = &page_menu[nstatic + i];
410 item->text = action->
label;
412 item->user_data_ = action;
422 bool_t has_bugs,
void *v_cssUrls)
424 lout::misc::SimpleVector <DilloUrl*> *cssUrls =
425 (lout::misc::SimpleVector <DilloUrl*> *) v_cssUrls;
428 static Fl_Menu_Item *stylesheets = NULL;
429 static Menu_popup_data_t page_data = {
"Page menu", NULL, NULL};
441 has_bugs ==
TRUE ? pm[1].activate() : pm[1].deactivate();
444 strncmp(
URL_PATH(url),
"/vsource/", 9) == 0)
452 while (stylesheets[j].text) {
453 dFree((
char *) stylesheets[j].label());
457 delete [] stylesheets;
461 if (cssUrls && cssUrls->
size () > 0) {
462 stylesheets =
new Fl_Menu_Item[cssUrls->
size() + 1];
463 memset(stylesheets,
'\0', (cssUrls->
size() + 1) *
sizeof(Fl_Menu_Item));
465 for (j = 0; j < cssUrls->
size(); j++) {
467 const char *url_str =
URL_STR(url);
468 const uint_t head_length = 30, tail_length = 40,
469 url_len = strlen(url_str);
472 if (url_len > head_length + tail_length + 3) {
474 char *url_head =
dStrndup(url_str, head_length);
475 const char *url_tail = url_str + (url_len - tail_length);
476 label =
dStrconcat(url_head,
"...", url_tail, NULL);
482 stylesheets[j].label(FL_NORMAL_LABEL, label);
486 pm[2].user_data(stylesheets);
509struct link_menu_item {
524 struct link_menu_item *mitem = (
struct link_menu_item *) user_data;
526 const DilloUrl *origin = mitem->origin;
527 Action *action = mitem->action;
530 setenv(
"url",
URL_STR(url), 1);
531 setenv(
"origin",
URL_STR(origin), 1);
538 static Fl_Menu_Item *link_menu = NULL;
539 static struct link_menu_item *link_menu_item = NULL;
542 if (link_menu != NULL)
553 int ntotal = nstatic + nactions;
554 link_menu = (Fl_Menu_Item *) calloc(ntotal + 1,
sizeof(Fl_Menu_Item));
555 link_menu_item = (
struct link_menu_item *) calloc(nactions,
sizeof(
struct link_menu_item));
558 for (
int i = 0; i < nstatic; i++) {
559 memcpy(&link_menu[i], &
link_menu_[i],
sizeof(Fl_Menu_Item));
563 for (
int i = 0; i < nactions; i++) {
565 struct link_menu_item *mitem = &link_menu_item[i];
567 mitem->action = action;
569 Fl_Menu_Item *item = &link_menu[nstatic + i];
570 item->text = action->
label;
572 item->user_data_ = mitem;
581 for (
int i = 0; link_menu[i].label(); i++) {
583 struct link_menu_item *mitem = (
struct link_menu_item *) link_menu[i].user_data_;
586 mitem->origin = page_url;
588 link_menu[i].user_data_ = (
void *) url;
598 static Menu_popup_data_t link_data = {
"Link menu", NULL, NULL};
607 link_data.menu = link_menu;
621 static DilloUrl *popup_page_url = NULL;
622 static DilloUrl *popup_link_url = NULL;
623 static Fl_Menu_Item pm[] = {
635 static Menu_popup_data_t image_data = {
"Image menu", NULL, pm};
656 pm[3].user_data(popup_page_url);
677 void *formptr,
bool_t hidvis)
679 static bool hiddens_visible;
680 static Fl_Menu_Item pm[] = {
686 static Menu_popup_data_t form_data = {
"Form menu", NULL, pm};
695 hiddens_visible = hidvis;
696 pm[2].label(hiddens_visible ?
"Hide hiddens":
"Show hiddens");
706 Fl_Widget *wid = (Fl_Widget*)v_wid;
708 static Fl_Menu_Item pm[] = {
710 (
void*)
"nt",0,0,0,0,0},
712 (
void*)
"nw", FL_MENU_DIVIDER,0,0,0,0},
714 (
void*)
"of",0,0,0,0,0},
716 (
void*)
"ou",0,0,0,0,0},
718 (
void*)
"cw", FL_MENU_DIVIDER,0,0,0,0},
720 (
void*)
"ed",0,0,0,0,0},
739 static Fl_Menu_Item pm[] = {
740 {
"Validate URL with W3C Nu validator (HTML5 only)", 0,
742 {
"Validate URL with W3C validator (HTML 4.01 and older)", 0,
744 {
"About bug meter", 0,
765 static Fl_Menu_Item *pm = 0;
785 pm =
new Fl_Menu_Item[n + 1];
786 memset(pm,
'\0', (n + 1) *
sizeof(Fl_Menu_Item));
788 for (i = 0; i < n; i++) {
800 Fl_Menu_Item *item = (Fl_Menu_Item*) wid;
802 item->flags ^= FL_MENU_VALUE;
812 Fl_Menu_Item *item = (Fl_Menu_Item*) wid;
814 item->flags ^= FL_MENU_VALUE;
825 Fl_Menu_Item *item = (Fl_Menu_Item*) wid;
827 item->flags ^= FL_MENU_VALUE;
847 Fl_Menu_Item *item = (Fl_Menu_Item*) wid;
849 item->flags ^= FL_MENU_VALUE;
866 Fl_Menu_Item *item = (Fl_Menu_Item*) wid;
868 item->flags ^= FL_MENU_VALUE;
878 const Fl_Menu_Item *item;
881 static Fl_Menu_Item pm[] = {
884 FL_MENU_TOGGLE|FL_MENU_DIVIDER,0,0,0,0},
886 FL_MENU_TOGGLE,0,0,0,0},
888 FL_MENU_TOGGLE|FL_MENU_DIVIDER,0,0,0,0},
890 FL_MENU_TOGGLE|FL_MENU_DIVIDER,0,0,0,0},
891 {
"Panel size", 0,
Menu_nop_cb, (
void*)
"Submenu1", FL_SUBMENU,0,0,0,0},
895 FL_MENU_RADIO|FL_MENU_DIVIDER,0,0,0,0},
897 FL_MENU_TOGGLE,0,0,0,0},
916 pm[6+cur_panelsize].setonly();
917 cur_smallicons ? pm[9].set() : pm[9].clear();
919 item = pm->popup(x, y);
921 ((Fl_Widget *)item)->do_callback();
Dlist * a_Actions_page_get(void)
int a_Actions_run(Action *action)
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_close_bw(void *vbw)
int * a_UIcmd_get_history(BrowserWindow *bw, int direction)
void a_UIcmd_copy_urlstr(BrowserWindow *bw, const char *urlstr, int destination)
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_close_all_bw(void *force)
void a_UIcmd_open_urlstr(void *vbw, const char *urlstr)
void a_UIcmd_save(void *vbw)
void a_UIcmd_repush(void *vbw)
void a_UIcmd_add_bookmark(BrowserWindow *bw, const DilloUrl *url)
void a_UIcmd_open_url(BrowserWindow *bw, const DilloUrl *url)
void a_UIcmd_save_link(BrowserWindow *bw, const DilloUrl *url, char *filename)
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.