diff options
author | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2008-11-13 21:12:44 +0100 |
---|---|---|
committer | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2008-11-13 21:12:44 +0100 |
commit | f0acc85e5c31a7df366c7dd9492438731a1d65ef (patch) | |
tree | 78010a14a23bd0c0a09609228e56260be370d990 /src | |
parent | b45b1791eee02392840984d6836368c004fbfb5a (diff) | |
parent | 41fcd4d8148404ebcad1ed19f11858a4b502148e (diff) |
merge with cvs
Diffstat (limited to 'src')
-rw-r--r-- | src/IO/dpi.c | 6 | ||||
-rw-r--r-- | src/IO/http.c | 1 | ||||
-rw-r--r-- | src/cookies.c | 3 | ||||
-rw-r--r-- | src/css.cc | 4 | ||||
-rw-r--r-- | src/dialog.cc | 2 | ||||
-rw-r--r-- | src/dillo.cc | 7 | ||||
-rw-r--r-- | src/dns.c | 34 | ||||
-rw-r--r-- | src/dns.h | 2 | ||||
-rw-r--r-- | src/html.cc | 20 | ||||
-rw-r--r-- | src/prefs.c | 6 | ||||
-rw-r--r-- | src/prefs.h | 1 | ||||
-rw-r--r-- | src/styleengine.cc | 1 | ||||
-rw-r--r-- | src/table.cc | 7 | ||||
-rw-r--r-- | src/ui.cc | 12 | ||||
-rw-r--r-- | src/ui.hh | 3 | ||||
-rw-r--r-- | src/uicmd.cc | 54 | ||||
-rw-r--r-- | src/uicmd.hh | 3 | ||||
-rw-r--r-- | src/url.h | 12 |
18 files changed, 128 insertions, 50 deletions
diff --git a/src/IO/dpi.c b/src/IO/dpi.c index 7c4357da..01d3a5b5 100644 --- a/src/IO/dpi.c +++ b/src/IO/dpi.c @@ -353,7 +353,7 @@ static int Dpi_check_uds(char *uds_name) strncpy(pun.sun_path, uds_name, sizeof (pun.sun_path)); if ((SockFD = socket(AF_LOCAL, SOCK_STREAM, 0)) == -1 || - connect(SockFD, (void*)&pun, D_SUN_LEN(&pun)) == -1) { + connect(SockFD, (struct sockaddr *) &pun, D_SUN_LEN(&pun)) == -1) { MSG("Dpi_check_uds: %s %s\n", dStrerror(errno), uds_name); } else { Dpi_close_fd(SockFD); @@ -497,7 +497,7 @@ static char *Dpi_get_server_uds_name(const char *server_name) _MSG("dpid_uds_name = [%s]\n", dpid_uds_name); strncpy(dpid.sun_path, dpid_uds_name, sizeof(dpid.sun_path)); - if (connect(sock, (struct sockaddr *) &dpid, sizeof(dpid)) == -1) + if (connect(sock, (struct sockaddr *) &dpid, D_SUN_LEN(&dpid)) == -1) perror("connect"); /* ask dpid to check the server plugin and send its UDS name back */ request = a_Dpip_build_cmd("cmd=%s msg=%s", "check_server", server_name); @@ -717,7 +717,6 @@ void a_Dpi_bye_dpid() srs_name = Dpi_get_dpid_uds_name(); sun_path_len = sizeof(sa.sun_path); - addr_len = sizeof(sa); sa.sun_family = AF_LOCAL; @@ -725,6 +724,7 @@ void a_Dpi_bye_dpid() MSG("a_Dpi_bye_dpid: %s\n", dStrerror(errno)); } strncpy(sa.sun_path, srs_name, sizeof (sa.sun_path)); + addr_len = D_SUN_LEN(&sa); if (connect(new_socket, (struct sockaddr *) &sa, addr_len) == -1) { MSG("a_Dpi_bye_dpid: %s\n", dStrerror(errno)); MSG("%s\n", sa.sun_path); diff --git a/src/IO/http.c b/src/IO/http.c index 692a9520..2c50e829 100644 --- a/src/IO/http.c +++ b/src/IO/http.c @@ -398,6 +398,7 @@ static int Http_must_use_proxy(const DilloUrl *url) dFree(np); } } + _MSG("Http_must_use_proxy: %s\n %s\n", URL_STR(url), ret ? "YES":"NO"); return ret; } diff --git a/src/cookies.c b/src/cookies.c index 1b336b83..b4843a1d 100644 --- a/src/cookies.c +++ b/src/cookies.c @@ -254,12 +254,11 @@ static int Cookie_control_init(void) j = 0; /* Get the domain */ - while (!isspace(line[i])) + while (line[i] != '\0' && !isspace(line[i])) domain[j++] = line[i++]; domain[j] = '\0'; /* Skip past whitespaces */ - i++; while (isspace(line[i])) i++; @@ -144,6 +144,10 @@ CssContext::CssContext () { sheet[CSS_PRIMARY_USER_IMPORTANT] = userImportantStyle; } +CssContext::~CssContext () { +} + + void CssContext::apply (CssPropertyList *props, Doctree *docTree, CssPropertyList *tagStyle, CssPropertyList *nonCss) { diff --git a/src/dialog.cc b/src/dialog.cc index 69781f32..8408782f 100644 --- a/src/dialog.cc +++ b/src/dialog.cc @@ -193,7 +193,7 @@ int a_Dialog_choice5(const char *QuestionTxt, txt[0] = txt[6] = NULL; txt[1] = alt1; txt[2] = alt2; txt[3] = alt3; txt[4] = alt4; txt[5] = alt5; - for (int i=1; txt[i]; ++i, ++nb); + for (int i=1; txt[i]; ++i, ++nb) ; Window *window = new Window(ww,wh,"Choice5"); window->begin(); diff --git a/src/dillo.cc b/src/dillo.cc index 7e29ac32..c20d1f02 100644 --- a/src/dillo.cc +++ b/src/dillo.cc @@ -26,6 +26,7 @@ #include <fltk/Window.h> #include <fltk/TabGroup.h> +#include <fltk/Font.h> #include <fltk/run.h> #include "msg.h" @@ -108,6 +109,12 @@ int main(int argc, char **argv) // WORKAROUND: sometimes the default pager triggers redraw storms fltk::TabGroup::default_pager(fltk::PAGER_SHRINK); + fltk::Font *dfont = fltk::font(prefs.vw_fontname, 0); + if (dfont) { + fltk::Widget::default_style->textfont(dfont); + fltk::Widget::default_style->labelfont(dfont); + } + // Create a new UI/bw pair BrowserWindow *bw = a_UIcmd_browser_window_new(0, 0, NULL); @@ -18,6 +18,7 @@ #include <netdb.h> #include <sys/types.h> #include <sys/socket.h> +#include <arpa/inet.h> #include <netinet/in.h> #include <errno.h> #include <unistd.h> @@ -268,6 +269,8 @@ static void *Dns_server(void *data) struct addrinfo hints, *res0; int error; Dlist *hosts; + size_t length, i; + char addr_string[40]; memset(&hints, 0, sizeof(hints)); hints.ai_family = AF_UNSPEC; @@ -307,8 +310,18 @@ static void *Dns_server(void *data) } /* tell our findings */ - MSG("Dns_server [%d]: %s is %p\n", channel, - dns_server[channel].hostname, hosts); + MSG("Dns_server [%d]: %s is", channel, + dns_server[channel].hostname); + if ((length = dList_length(hosts))) { + for (i = 0; i < length; i++) { + a_Dns_dillohost_to_string(dList_nth_data(hosts, i), + addr_string, sizeof(addr_string)); + MSG(" %s", addr_string); + } + MSG("\n"); + } else { + MSG(" (nil)\n"); + } dns_server[channel].addr_list = hosts; dns_server[channel].ip_ready = TRUE; @@ -482,3 +495,20 @@ void a_Dns_freeall(void) dFree(dns_cache); } +/* + * Writes a string representation of the given DilloHost + * into dst. dst will be \0 terminated. + * Please note that dst must be at least 40 bytes long for IPv6 + * addresses. + */ +void a_Dns_dillohost_to_string(DilloHost *host, char *dst, size_t size) +{ + if (!inet_ntop(host->af, host->data, dst, size)) { + switch (errno) { + case EAFNOSUPPORT: + snprintf(dst, size, "Unknown address family"); + case ENOSPC: + snprintf(dst, size, "Buffer too small"); + } + } +} @@ -22,7 +22,7 @@ typedef struct _DilloHost int alen; char data[DILLO_ADDR_MAX]; } DilloHost; - +void a_Dns_dillohost_to_string(DilloHost *host, char *dst, size_t size); #ifdef __cplusplus } diff --git a/src/html.cc b/src/html.cc index b618fa96..47fa4885 100644 --- a/src/html.cc +++ b/src/html.cc @@ -724,10 +724,12 @@ bool DilloHtml::HtmlLinkReceiver::enter (Widget *widget, int link, int img, if (link == -1) { _MSG(" Link LEAVE notify...\n"); a_UIcmd_set_msg(bw, ""); + a_UIcmd_set_pointer_on_link(bw, FALSE); } else { _MSG(" Link ENTER notify...\n"); Html_set_link_coordinates(html, link, x, y); a_UIcmd_set_msg(bw, "%s", URL_STR(html->links->get(link))); + a_UIcmd_set_pointer_on_link(bw, TRUE); } return true; } @@ -997,7 +999,7 @@ static int Html_parse_entity(DilloHtml *html, const char *token, } else if (isalpha(*s)) { /* character entity reference */ - while (*++s && (isalnum(*s) || strchr(":_.-", *s))); + while (*++s && (isalnum(*s) || strchr(":_.-", *s))) ; c = *s; *s = 0; @@ -1177,10 +1179,10 @@ static void Html_process_word(DilloHtml *html, const char *word, int size) Pword = a_Html_parse_entities(html, word, size); for (start = i = 0; Pword[i]; start = i) if (isspace(Pword[i])) { - while (Pword[++i] && isspace(Pword[i])); + while (Pword[++i] && isspace(Pword[i])) ; Html_process_space(html, Pword + start, i - start); } else { - while (Pword[++i] && !isspace(Pword[i])); + while (Pword[++i] && !isspace(Pword[i])) ; ch = Pword[i]; Pword[i] = 0; DW2TB(html->dw)->addText(Pword, html->styleEngine->style ()); @@ -1199,7 +1201,7 @@ static void Html_process_word(DilloHtml *html, const char *word, int size) Pword = a_Html_parse_entities(html, word, size); for (i = 0; Pword[i]; ++i) if (strchr("\t\f\n\r", Pword[i])) - for (j = i; (Pword[j] = Pword[j+1]); ++j); + for (j = i; (Pword[j] = Pword[j+1]); ++j) ; DW2TB(html->dw)->addText(Pword, html->styleEngine->style ()); dFree(Pword); @@ -1319,8 +1321,8 @@ static void Html_tag_cleanup_at_close(DilloHtml *html, int TagIdx) (cmp = (new_idx != html->stack->getRef(stack_idx)->tag_idx)) && ((w3c_mode && Tags[html->stack->getRef(stack_idx)->tag_idx].EndTag == 'O') || - (!w3c_mode && - (Tags[html->stack->getRef(stack_idx)->tag_idx].EndTag == 'O') || + ((!w3c_mode && + (Tags[html->stack->getRef(stack_idx)->tag_idx].EndTag == 'O')) || Tags[html->stack->getRef(stack_idx)->tag_idx].TagLevel < Tags[new_idx].TagLevel))) { --stack_idx; @@ -1504,7 +1506,7 @@ static void Html_parse_doctype(DilloHtml *html, const char *tag, int tagsize) * and replace '\n' and '\r' with ' ' inside quoted strings. */ for (i = 0, p = ntag; *p; ++p) { if (isspace(*p)) { - for (ntag[i++] = ' '; isspace(p[1]); ++p); + for (ntag[i++] = ' '; isspace(p[1]); ++p) ; } else if ((quote = *p) == '"' || *p == '\'') { for (ntag[i++] = *p++; (ntag[i++] = *p) && *p != quote; ++p) { if (*p == '\n' || *p == '\r') @@ -2892,7 +2894,7 @@ static void Html_tag_open_meta(DilloHtml *html, const char *tag, int tagsize) sprintf(delay_str, "."); /* Skip to anything after "URL=" */ - while (*content && *(content++) != '='); + while (*content && *(content++) != '=') ; /* Send a custom HTML message. * TODO: This is a hairy hack, @@ -3745,7 +3747,7 @@ static int Html_write_raw(DilloHtml *html, char *buf, int bufsize, int Eof) if (isspace(buf[buf_index])) { /* whitespace: group all available whitespace */ - while (++buf_index < bufsize && isspace(buf[buf_index])); + while (++buf_index < bufsize && isspace(buf[buf_index])) ; Html_process_space(html, buf + token_start, buf_index - token_start); token_start = buf_index; diff --git a/src/prefs.c b/src/prefs.c index 10e87d0c..29ed9442 100644 --- a/src/prefs.c +++ b/src/prefs.c @@ -61,6 +61,7 @@ DilloPrefs prefs; /* define enumeration values to be returned for specific symbols */ typedef enum { + DRC_TOKEN_MIDDLE_CLICK_DRAGS_PAGE, DRC_TOKEN_ALLOW_WHITE_BG, DRC_TOKEN_BG_COLOR, DRC_TOKEN_CONTRAST_VISITED_COLOR, @@ -141,6 +142,7 @@ static const SymNode_t symbols[] = { { "limit_text_width", DRC_TOKEN_LIMIT_TEXT_WIDTH }, { "link_color", DRC_TOKEN_LINK_COLOR }, { "load_images", DRC_TOKEN_LOAD_IMAGES }, + { "middle_click_drags_page", DRC_TOKEN_MIDDLE_CLICK_DRAGS_PAGE }, { "middle_click_opens_new_tab", DRC_TOKEN_MIDDLE_CLICK_OPENS_NEW_TAB }, { "no_proxy", DRC_TOKEN_NOPROXY }, { "panel_size", DRC_TOKEN_PANEL_SIZE }, @@ -236,6 +238,9 @@ static int Prefs_parse_pair(char *name, char *value) case DRC_TOKEN_ALLOW_WHITE_BG: prefs.allow_white_bg = (strcmp(value, "YES") == 0); break; + case DRC_TOKEN_MIDDLE_CLICK_DRAGS_PAGE: + prefs.middle_click_drags_page = (strcmp(value, "YES") == 0); + break; case DRC_TOKEN_FORCE_MY_COLORS: prefs.force_my_colors = (strcmp(value, "YES") == 0); break; @@ -459,6 +464,7 @@ void a_Prefs_init(void) prefs.save_dir = dStrdup(D_SAVE_DIR); prefs.show_msg = TRUE; prefs.show_extra_warnings = FALSE; + prefs.middle_click_drags_page = TRUE; /* this locale stuff is to avoid parsing problems with float numbers */ old_locale = dStrdup (setlocale (LC_NUMERIC, NULL)); diff --git a/src/prefs.h b/src/prefs.h index 7a409631..ec807f46 100644 --- a/src/prefs.h +++ b/src/prefs.h @@ -62,6 +62,7 @@ struct _DilloPrefs { char *save_dir; bool_t show_msg; bool_t show_extra_warnings; + bool_t middle_click_drags_page; }; /* Global Data */ diff --git a/src/styleengine.cc b/src/styleengine.cc index cbdcf8a2..9eaca826 100644 --- a/src/styleengine.cc +++ b/src/styleengine.cc @@ -41,6 +41,7 @@ StyleEngine::StyleEngine (dw::core::Layout *layout) { StyleEngine::~StyleEngine () { delete stack; + delete cssContext; } /** diff --git a/src/table.cc b/src/table.cc index bd57141a..ee93c5b0 100644 --- a/src/table.cc +++ b/src/table.cc @@ -35,7 +35,7 @@ using namespace dw::core::style; static void Html_tag_open_table_cell(DilloHtml *html, const char *tag, int tagsize, - dw::core::style::TextAlignType text_align); + dw::core::style::TextAlignType text_align); /* * <TABLE> @@ -287,8 +287,9 @@ static void Html_tag_open_table_cell(DilloHtml *html, if (html->styleEngine->style ()->textAlign == TEXT_ALIGN_STRING) - col_tb = new dw::TableCell (((dw::Table*)S_TOP(html)->table)->getCellRef (), - prefs.limit_text_width); + col_tb = new dw::TableCell ( + ((dw::Table*)S_TOP(html)->table)->getCellRef (), + prefs.limit_text_width); else col_tb = new Textblock (prefs.limit_text_width); @@ -621,9 +621,7 @@ UI::UI(int x, int y, int ww, int wh, const char* label, const UI *cur_ui) : { int s_h = 20; - Font *f = font(prefs.vw_fontname, 0); - if (f) - this->labelfont(f); + PointerOnLink = FALSE; Tabs = NULL; TabTooltip = NULL; @@ -801,6 +799,14 @@ int UI::handle(int event) ret = 1; } } + + } else if (event == PUSH) { + if (prefs.middle_click_drags_page == 0 && + event_button() == MiddleButton && + !a_UIcmd_pointer_on_link(a_UIcmd_get_bw_by_widget(this))) { + paste_url(); + ret = 1; + } } if (!ret) @@ -64,6 +64,7 @@ class UI : public fltk::Group { UIPanelmode Panelmode; Findbar *findbar; + int PointerOnLink; PackedGroup *make_toolbar(int tw, int th); PackedGroup *make_location(); @@ -103,6 +104,8 @@ public: CustTabGroup *tabs() { return Tabs; } void tabs(CustTabGroup *tabs) { Tabs = tabs; } + int pointerOnLink() { return PointerOnLink; } + void pointerOnLink(int flag) { PointerOnLink = flag; } // Hooks to method callbacks void panel_cb_i(); diff --git a/src/uicmd.cc b/src/uicmd.cc index 564e9957..9534a7fb 100644 --- a/src/uicmd.cc +++ b/src/uicmd.cc @@ -33,6 +33,8 @@ #include "nav.h" +#define DEFAULT_TAB_LABEL "Dillo" + // Handy macro #define BW2UI(bw) ((UI*)((bw)->ui)) @@ -83,11 +85,12 @@ public: void remove (Widget *w) { TabGroup::remove (w); /* fixup resizable in case we just removed it */ - if (resizable () == w) + if (resizable () == w) { if (children () > 0) resizable (child (children () - 1)); else resizable (NULL); + } if (children () < 2) hideLabels (); @@ -177,7 +180,7 @@ BrowserWindow *a_UIcmd_browser_window_new(int ww, int wh, const void *vbw) win->add(DilloTabs); // Create and set the UI - UI *new_ui = new UI(0, 0, ww, wh, "Label", old_bw ? BW2UI(old_bw) : NULL); + UI *new_ui = new UI(0, 0, ww, wh, DEFAULT_TAB_LABEL, old_bw ? BW2UI(old_bw) : NULL); new_ui->set_status("http://www.dillo.org/"); new_ui->tabs(DilloTabs); @@ -242,7 +245,7 @@ BrowserWindow *UIcmd_tab_new(const void *vbw) vbw); // Create and set the UI - UI *new_ui = new UI(0, 0, ui->w(), ui->h(), "Label", ui); + UI *new_ui = new UI(0, 0, ui->w(), ui->h(), DEFAULT_TAB_LABEL, ui); new_ui->tabs(ui->tabs()); new_ui->tabs()->add(new_ui); @@ -481,24 +484,21 @@ void a_UIcmd_set_save_dir(const char *dir) void a_UIcmd_save(void *vbw) { const char *name; - char *SuggestedName, *urlstr; - DilloUrl *url; - - a_UIcmd_set_save_dir(prefs.save_dir); - - urlstr = a_UIcmd_get_location_text((BrowserWindow*)vbw); - url = a_Url_new(urlstr, NULL); - SuggestedName = UIcmd_make_save_filename(URL_PATH(url)); - name = a_Dialog_save_file("Save Page as File", NULL, SuggestedName); - MSG("a_UIcmd_save: %s\n", name); - dFree(SuggestedName); - dFree(urlstr); + char *SuggestedName; + BrowserWindow *bw = (BrowserWindow *)vbw; + const DilloUrl *url = a_History_get_url(NAV_TOP_UIDX(bw)); - if (name) { - a_Nav_save_url((BrowserWindow*)vbw, url, name); - } + if (url) { + a_UIcmd_set_save_dir(prefs.save_dir); + SuggestedName = UIcmd_make_save_filename(URL_PATH(url)); + name = a_Dialog_save_file("Save Page as File", NULL, SuggestedName); + MSG("a_UIcmd_save: %s\n", name); + dFree(SuggestedName); - a_Url_free(url); + if (name) { + a_Nav_save_url(bw, url, name); + } + } } /* @@ -912,6 +912,22 @@ void a_UIcmd_set_buttons_sens(BrowserWindow *bw) } /* + * Keep track of mouse pointer over a link. + */ +void a_UIcmd_set_pointer_on_link(BrowserWindow *bw, int flag) +{ + BW2UI(bw)->pointerOnLink(flag); +} + +/* + * Is the mouse pointer over a link? + */ +int a_UIcmd_pointer_on_link(BrowserWindow *bw) +{ + return BW2UI(bw)->pointerOnLink(); +} + +/* * Toggle control panel (aka. fullscreen) */ void a_UIcmd_fullscreen_toggle(BrowserWindow *bw) diff --git a/src/uicmd.hh b/src/uicmd.hh index 02dbae8a..c4e34736 100644 --- a/src/uicmd.hh +++ b/src/uicmd.hh @@ -73,7 +73,8 @@ bool_t a_UIcmd_get_images_enabled(BrowserWindow *bw); void a_UIcmd_set_images_enabled(BrowserWindow *bw, int flag); void a_UIcmd_set_buttons_sens(BrowserWindow *bw); void a_UIcmd_fullscreen_toggle(BrowserWindow *bw); - +void a_UIcmd_set_pointer_on_link(BrowserWindow *bw, int flag); +int a_UIcmd_pointer_on_link(BrowserWindow *bw); #ifdef __cplusplus } @@ -95,12 +95,12 @@ extern "C" { struct _DilloUrl { Dstr *url_string; const char *buffer; - const char *scheme; // - const char *authority; // - const char *path; // These are references only - const char *query; // (no need to free them) - const char *fragment; // - const char *hostname; // + const char *scheme; /**/ + const char *authority; /**/ + const char *path; /* These are references only */ + const char *query; /* (no need to free them) */ + const char *fragment; /**/ + const char *hostname; /**/ int port; int flags; Dstr *data; /* POST */ |