diff -rwbBpu dillo-0.2.4/src/dw_page.c dillo-0.2.4.eg/src/dw_page.c --- dillo-0.2.4/src/dw_page.c Tue Aug 22 00:54:09 2000 +++ dillo-0.2.4.eg/src/dw_page.c Fri Aug 25 22:15:39 2000 @@ -647,19 +647,10 @@ static void Dw_page_handle_event(Dw *dw, /* todo: I think we need to do a grab. Do we do it here, or in * the gtk_dw_view? */ - if (button->button == 1) { + if (button->button == 1 || button->button == 2) { /* Button 1: follow link */ - page->link_pressed = Dw_page_find_link(page, button->x, button->y); - } - if (button->button == 2) { /* Button 2: open link in a new window */ - gint link_pressed = Dw_page_find_link(page, button->x, button->y); - if (link_pressed >= 0) { - menu_popup.info.title = ""; - menu_popup.info.url = page->links[link_pressed].url; - a_Commands_open_link_nw_callback(NULL, NULL); - } - return; + page->link_pressed = Dw_page_find_link(page, button->x, button->y); } if (button->button == 3) { /* Button 3: show link-relative pop-up menu */ @@ -691,17 +682,25 @@ static void Dw_page_handle_event(Dw *dw, button->x, button->y, button->button); #endif - if (button->button == 1) { + if (button->button == 1 || button->button == 2) { gint link_pressed = page->link_pressed; page->link_pressed = -1; if (link_pressed >= 0 && link_pressed == Dw_page_find_link(page, button->x, button->y)) { -#ifdef VERBOSE - g_print("dw_page_handle_event: link %s\n", - page->links[page->link_pressed].url); -#endif - if (page->link != NULL) +//#ifdef VERBOSE + g_print("dw_page_handle_event: link %s (target=%s)\n", + page->links[link_pressed].url, + page->links[link_pressed].target); +//#endif + if(button->button == 2 || + strcmp(page->links[link_pressed].target,"_blank") == 0) { + /* target=blank or Button 2: open link in a new window */ + menu_popup.info.title = ""; + menu_popup.info.url = page->links[link_pressed].url; + a_Commands_open_link_nw_callback(NULL, NULL); + } + else if (page->link != NULL) (*page->link) (page->link_data, page->links[link_pressed].url); } } @@ -826,7 +825,10 @@ static void Dw_page_destroy(Dw *dw) g_free(page->colors); g_free(page->attrs); for (link_index = 0; link_index < page->num_links; link_index++) + { g_free(page->links[link_index].url); + g_free(page->links[link_index].target); + } g_free(page->links); if(page->gc != NULL) gdk_gc_unref(page->gc); @@ -1038,13 +1040,18 @@ gint a_Dw_page_find_font(DwPage *page, c /* * Create a new link, return the index. */ -gint a_Dw_page_new_link(DwPage *page, const char *url) +gint a_Dw_page_new_link(DwPage *page, const char *url, const char *target) { gint nl; nl = page->num_links; a_List_add(page->links, nl, sizeof(*page->links), page->num_links_max); page->links[nl].url = g_strdup(url); + page->links[nl].target = g_strdup(target); +#ifdef VERBOSE + g_print ("a_Dw_page_new_link: link[%d] : %s (target=%s)\n", + page->num_links, url, target); +#endif return page->num_links++; } diff -rwbBpu dillo-0.2.4/src/dw_page.h dillo-0.2.4.eg/src/dw_page.h --- dillo-0.2.4/src/dw_page.h Mon Aug 21 06:27:44 2000 +++ dillo-0.2.4.eg/src/dw_page.h Fri Aug 25 18:25:33 2000 @@ -38,6 +38,7 @@ struct _DwPageFont { struct _DwPageLink { char *url; + char *target; }; struct _DwPageAttr { @@ -168,7 +169,7 @@ void a_Dw_page_update_end (DwPage *page) void a_Dw_page_init_attr (DwPage *page, DwPageAttr *attr); gint a_Dw_page_find_font (DwPage *page, const DwPageFont *font); -gint a_Dw_page_new_link (DwPage *page, const char *url); +gint a_Dw_page_new_link (DwPage *page, const char *url, const char *target); gint a_Dw_page_find_color (DwPage *page, gint32 color); gint a_Dw_page_add_attr (DwPage *page, const DwPageAttr *attr); void a_Dw_page_add_text (DwPage *page, char *text, gint attr); diff -rwbBpu dillo-0.2.4/src/html.c dillo-0.2.4.eg/src/html.c --- dillo-0.2.4/src/html.c Mon Aug 21 06:29:23 2000 +++ dillo-0.2.4.eg/src/html.c Fri Aug 25 21:42:14 2000 @@ -826,6 +826,7 @@ static void Html_tag_open_a(DilloHtml *h char href[1024]; char name[512]; + char target[80]; gchar *url; guint idx; @@ -833,6 +834,9 @@ static void Html_tag_open_a(DilloHtml *h page = (DwPage *) html->dw; + if ( Html_get_attr(tag, tagsize, "target", target, sizeof(target)) ) { + } + /* can have both a "href" attribute and a "name" attribute */ if ( Html_get_attr(tag, tagsize, "href", href, sizeof(href)) ) { url = a_Url_resolve_relative(html->linkblock->base_url, href); @@ -840,7 +844,9 @@ static void Html_tag_open_a(DilloHtml *h return; idx = html->stack[html->stack_top].attr; attr = page->attrs[idx]; - attr.link = a_Dw_page_new_link(page, url); + if (!Html_get_attr(tag, tagsize, "target", target, sizeof(target))) + strcpy(target,"_self"); + attr.link = a_Dw_page_new_link(page, url, target); attr.color = a_Dw_page_find_color(page, page->link_color); html->stack[html->stack_top].attr = a_Dw_page_add_attr(page, &attr); g_free(url);