summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/history.c34
-rw-r--r--src/history.h2
-rw-r--r--src/html.cc20
-rw-r--r--src/menu.cc50
-rw-r--r--src/menu.hh1
-rw-r--r--src/pixmaps.h119
-rw-r--r--src/plain.cc2
-rw-r--r--src/ui.cc18
-rw-r--r--src/ui.hh3
-rw-r--r--src/uicmd.cc23
-rw-r--r--src/uicmd.hh5
11 files changed, 243 insertions, 34 deletions
diff --git a/src/history.c b/src/history.c
index 4b8fb426..626c3015 100644
--- a/src/history.c
+++ b/src/history.c
@@ -75,19 +75,6 @@ int a_History_add_url(DilloUrl *url)
}
/*
- * Set the page-title for a given URL (by idx)
- * (this is known when the first chunks of HTML data arrive)
- */
-int a_History_set_title(int idx, const char *title)
-{
- dReturn_val_if_fail(idx >= 0 && idx < history_size, 0);
-
- dFree(history[idx].title);
- history[idx].title = dStrdup(title);
- return 1;
-}
-
-/*
* Return the DilloUrl field (by index)
*/
DilloUrl *a_History_get_url(int idx)
@@ -137,6 +124,27 @@ const char *a_History_get_title_by_url(const DilloUrl *url, int force)
return NULL;
}
+/*
+ * Set the page-title for a given URL
+ */
+void a_History_set_title_by_url(const DilloUrl *url, const char *title)
+{
+ int i;
+
+ dReturn_if (url == NULL);
+
+ for (i = history_size - 1; i >= 0; --i)
+ if (a_Url_cmp(url, history[i].url) == 0)
+ break;
+
+ if (i >= 0) {
+ dFree(history[i].title);
+ history[i].title = dStrdup(title);
+ } else {
+ MSG_ERR("a_History_set_title_by_url: %s not found\n", URL_STR(url));
+ }
+}
+
/*
* Free all the memory used by this module
diff --git a/src/history.h b/src/history.h
index da520c87..4d7ec467 100644
--- a/src/history.h
+++ b/src/history.h
@@ -10,7 +10,7 @@ extern "C" {
#endif /* __cplusplus */
int a_History_add_url(DilloUrl *url);
-int a_History_set_title(int idx, const char *title);
+void a_History_set_title_by_url(const DilloUrl *url, const char *title);
DilloUrl *a_History_get_url(int idx);
const char *a_History_get_title(int idx, int force);
const char *a_History_get_title_by_url(const DilloUrl *url, int force);
diff --git a/src/html.cc b/src/html.cc
index f5c10e33..375594c8 100644
--- a/src/html.cc
+++ b/src/html.cc
@@ -33,7 +33,6 @@
#include "misc.h"
#include "uicmd.hh"
#include "history.h"
-#include "nav.h"
#include "menu.hh"
#include "prefs.h"
#include "capi.h"
@@ -721,8 +720,7 @@ bool DilloHtml::HtmlLinkReceiver::press (Widget *widget, int link, int img,
ret = true;
} else {
if (link == -1) {
- a_UIcmd_page_popup(bw, a_History_get_url(NAV_TOP_UIDX(bw)),
- bw->num_page_bugs != 0,
+ a_UIcmd_page_popup(bw, bw->num_page_bugs != 0,
html->unloadedImages());
ret = true;
} else {
@@ -1575,7 +1573,7 @@ static void Html_tag_close_head(DilloHtml *html, int TagIdx)
if (html->repush_after_head) {
html->stop_parser = true;
MSG(" [html->stop_parser = true]\n");
- a_Nav_repush(html->bw);
+ a_UIcmd_repush(html->bw);
}
}
}
@@ -1599,7 +1597,7 @@ static void Html_tag_close_title(DilloHtml *html, int TagIdx)
if (html->InFlags & IN_HEAD) {
/* title is only valid inside HEAD */
a_UIcmd_set_page_title(html->bw, html->Stash->str);
- a_History_set_title(NAV_TOP_UIDX(html->bw),html->Stash->str);
+ a_History_set_title_by_url(html->page_url, html->Stash->str);
} else {
BUG_MSG("the TITLE element must be inside the HEAD section\n");
}
@@ -2792,7 +2790,7 @@ static void Html_css_load_callback(int Op, CacheClient_t *Client)
BrowserWindow *bw = ((DilloWeb *)Client->Web)->bw;
/* Repush when we've got them all */
if (--bw->NumPendingStyleSheets == 0)
- a_Nav_repush(bw);
+ a_UIcmd_repush(bw);
}
}
@@ -2803,11 +2801,11 @@ static void Html_load_stylesheet(DilloHtml *html, DilloUrl *url)
{
char *data;
int len;
- if (a_Nav_get_buf(url, &data, &len)) {
+ if (a_Capi_get_buf(url, &data, &len)) {
/* Haven't looked into what origin_count is */
if (a_Capi_get_flags(url) & CAPI_Completed)
html->styleEngine->parse(data, len, 0, CSS_ORIGIN_AUTHOR);
- a_Nav_unref_buf(url);
+ a_Capi_unref_buf(url);
} else if (!html->repush_after_head) {
/* Fill a Web structure for the cache query */
int ClientKey;
@@ -2838,9 +2836,11 @@ static void Html_tag_open_link(DilloHtml *html, const char *tag, int tagsize)
//MSG("Html_tag_open_link(): %s\n", tag_str);
//dFree(tag_str);
+ /* Remote stylesheets enabled? */
+ dReturn_if_fail (prefs.load_stylesheets);
/* When viewing suspicious HTML email, don't load LINK */
- if (URL_FLAGS(html->base_url) & URL_SpamSafe)
- return;
+ dReturn_if (URL_FLAGS(html->base_url) & URL_SpamSafe);
+
/* Ignore LINK outside HEAD */
if (!(html->InFlags & IN_HEAD)) {
BUG_MSG("the LINK element must be inside the HEAD section\n");
diff --git a/src/menu.cc b/src/menu.cc
index 31ef8c73..f2b2b184 100644
--- a/src/menu.cc
+++ b/src/menu.cc
@@ -16,6 +16,7 @@
#include <fltk/events.h>
#include <fltk/PopupMenu.h>
#include <fltk/Item.h>
+#include <fltk/ToggleItem.h>
#include <fltk/Divider.h>
#include "msg.h"
@@ -619,7 +620,6 @@ void a_Menu_bugmeter_popup(BrowserWindow *bw, const DilloUrl *url)
*/
void a_Menu_history_popup(BrowserWindow *bw, int direction)
{
- // One menu for every browser window
static PopupMenu *pm = 0;
Item *it;
int i;
@@ -654,3 +654,51 @@ void a_Menu_history_popup(BrowserWindow *bw, int direction)
pm->popup();
}
+/*
+ * Toggle use of remote stylesheets
+ */
+static void Menu_remote_css_cb(Widget *wid)
+{
+ _MSG("Menu_remote_css_cb\n");
+ prefs.load_stylesheets = wid->state() ? 1 : 0;
+ a_UIcmd_repush(popup_bw);
+}
+
+/*
+ * Toggle use of embedded CSS style
+ */
+static void Menu_embedded_css_cb(Widget *wid)
+{
+ prefs.parse_embedded_css = wid->state() ? 1 : 0;
+ a_UIcmd_repush(popup_bw);
+}
+
+/*
+ * Tools popup menu (construction & popup)
+ */
+void a_Menu_tools_popup(BrowserWindow *bw, void *v_wid)
+{
+ // One menu shared by every browser window
+ static PopupMenu *pm = NULL;
+ Widget *wid = (Widget*)v_wid;
+ Item *it;
+
+ 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(true);
+ it = new ToggleItem("Use embedded CSS");
+ it->callback(Menu_embedded_css_cb);
+ it->state(true);
+ pm->type(PopupMenu::POPUP13);
+ pm->end();
+ }
+ //pm->popup();
+ pm->value(-1);
+ ((Menu*)pm)->popup(Rectangle(0,wid->h(),pm->w(),pm->h()));
+}
+
diff --git a/src/menu.hh b/src/menu.hh
index 3cbddfac..90b9d50b 100644
--- a/src/menu.hh
+++ b/src/menu.hh
@@ -17,6 +17,7 @@ void a_Menu_form_popup(BrowserWindow *bw, const DilloUrl *page_url,
void a_Menu_file_popup(BrowserWindow *bw, void *v_wid);
void a_Menu_bugmeter_popup(BrowserWindow *bw, const DilloUrl *url);
void a_Menu_history_popup(BrowserWindow *bw, int direction);
+void a_Menu_tools_popup(BrowserWindow *bw, void *v_wid);
#ifdef __cplusplus
diff --git a/src/pixmaps.h b/src/pixmaps.h
index 4e54ff71..bb6bbe08 100644
--- a/src/pixmaps.h
+++ b/src/pixmaps.h
@@ -675,6 +675,7 @@ static const char *const stop_xpm[] = {
" .KLLLLLLLK. ",
" ......... ",
" "};
+
/* XPM */
static const char *const bm_xpm[] = {
"22 22 86 1",
@@ -787,6 +788,57 @@ static const char *const bm_xpm[] = {
" .S. TU. ",
" . . "};
+/* XPM */
+static const char *const tools_xpm[] = {
+"22 22 25 1",
+" c #None",
+". c #696977777676",
+"X c #96969B9B9B9B",
+"o c #848490908F8F",
+"O c #D7D7D7D7D7D7",
+"+ c #B5B5B7B7B7B7",
+"@ c #EAEAEAEAEAEA",
+"# c #797987878787",
+"$ c #F1F1EFEFEFEF",
+"% c #CCCCCCCCCCCC",
+"& c #8B8B97979696",
+"* c #CACACACACACA",
+"= c #787878787878",
+"- c #AAAAB5B5B5B5",
+"; c #F9F9F8F8F9F9",
+": c #A6A6A8A8A8A8",
+"> c #7F7F90907F7F",
+", c #A4A4BDBDA4A4",
+"< c #A5A58A8A5353",
+"1 c #00008B8B0000",
+"2 c #6C6C6C6C6C6C",
+"3 c #BCBCC3C3C2C2",
+"4 c #CACAD8D8D8D8",
+"5 c #9999A8A8A8A8",
+"6 c #848489898989",
+" ",
+" ",
+" .XXo. ",
+" oO $$+. ",
+" oo@$$$@# ",
+" #o@$$$O# ",
+" #X$$$$%X ",
+" &#% #X$$$@o ",
+" #*o =-@$$$# ",
+" oO*o #$@$$$$# ",
+" oOOOX oO@;$$$$X ",
+" #@O*OXo:>,<$$$$o ",
+" XO@O*O*12>,<$$$# ",
+" X$@O*+<12>,<$$& ",
+" +$@O*+<12>,<;@ ",
+" :$@O*+<12>,<$@ ",
+" &34O*-<11>,<$$ ",
+" -X&X&<12>,<$O ",
+" 45<11>,<3 ",
+" 45<1=>O# ",
+" -&X6&=# ",
+" "};
+
/* Small icons here */
/* XPM */
@@ -1321,6 +1373,73 @@ static const char *const bm_s_xpm[] = {
" .v. wx. "};
/* XPM */
+static const char *const tools_s_xpm[] = {
+"16 16 45 1",
+" c #7B127D1C7D08",
+". c #82778EED8E15",
+"X c #8F3F975396FF",
+"o c #9A98A40CA38F",
+"O c #833D8EC28E02",
+"+ c #99C89EDF9EC2",
+"@ c #B347BD91BD42",
+"# c #7E4181A081AF",
+"$ c #8744915990DA",
+"% c #86728A968A7C",
+"& c #8D56924B9226",
+"* c #96DF9AC79AA6",
+"= c #9E01A473A438",
+"- c #AB41B55EB546",
+"; c #ABD1B155B117",
+": c #B5BFBC3DBC2F",
+"> c #B917BCECBCAB",
+", c #B558B98BB958",
+"< c #CEA2CFDBCFD4",
+"1 c #A699AC55ABF1",
+"2 c #C2A5C5A8C57A",
+"3 c #C8B2CA27CA1C",
+"4 c #D80FD952D955",
+"5 c #DF19E120E134",
+"6 c #EAC7E9ECE9FE",
+"7 c #F164EF95EF9D",
+"8 c #F6E0F5E6F61C",
+"9 c #F013EEAEEEBF",
+"0 c #487651675130",
+"q c #6E4D7BA97B06",
+"w c #88F190679051",
+"e c #92339C0E9BC1",
+"r c #A1BBAB0FAA98",
+"t c #A24AA7C4A7A7",
+"y c #86C7935E92DC",
+"u c #C8C4D721D725",
+"i c #D0E6D516D518",
+"p c #76A38450834A",
+"a c #6B4B7B507A6D",
+"s c #7C6D882B878D",
+"d c #88F395099487",
+"f c #DB34DCE9DCF5",
+"g c #5B05673F66CD",
+"h c #9402A0549FCC",
+" c None",
+/* pixels */
+" ",
+" gO+Oq ",
+" p*45<Xg ",
+" h.>885oa ",
+" p.3883Xg ",
+" i$O s$488;s ",
+" O>1p e;588;a ",
+" O331sr;7778:s ",
+" O343,**3678;a ",
+" f,643;#%368:s ",
+" t<64>= &374f ",
+" t244>= &379ih",
+" d@:;=& &475u",
+" ssr-* *44r",
+" u-%#*%0",
+" feww0g"
+};
+
+/* XPM */
static const char *const new_s_xpm[] = {
"11 11 35 1",
" c None",
diff --git a/src/plain.cc b/src/plain.cc
index 1295f99f..c18da3e7 100644
--- a/src/plain.cc
+++ b/src/plain.cc
@@ -139,7 +139,7 @@ bool DilloPlain::PlainEventReceiver::buttonPress (Widget *widget,
_MSG("DilloPlain::PlainEventReceiver::buttonPress\n");
if (event->button == 3) {
- a_UIcmd_page_popup(plain->bw, plain->url, FALSE, FALSE);
+ a_UIcmd_page_popup(plain->bw, FALSE, FALSE);
return true;
}
return false;
diff --git a/src/ui.cc b/src/ui.cc
index 9af1b2a4..97e6027c 100644
--- a/src/ui.cc
+++ b/src/ui.cc
@@ -38,7 +38,8 @@ using namespace fltk;
struct iconset {
Image *ImgMeterOK, *ImgMeterBug,
- *ImgHome, *ImgReload, *ImgSave, *ImgBook, *ImgClear, *ImgSearch;
+ *ImgHome, *ImgReload, *ImgSave, *ImgBook, *ImgTools,
+ *ImgClear,*ImgSearch;
MultiImage *ImgLeftMulti, *ImgRightMulti, *ImgStopMulti, *ImgImageLoadMulti;
};
@@ -49,6 +50,7 @@ static struct iconset standard_icons = {
new xpmImage(reload_xpm),
new xpmImage(save_xpm),
new xpmImage(bm_xpm),
+ new xpmImage(tools_xpm),
new xpmImage(new_s_xpm),
new xpmImage(search_xpm),
new MultiImage(*new xpmImage(left_xpm), INACTIVE_R,
@@ -68,6 +70,7 @@ static struct iconset small_icons = {
new xpmImage(reload_s_xpm),
new xpmImage(save_s_xpm),
new xpmImage(bm_s_xpm),
+ new xpmImage(tools_s_xpm),
new xpmImage(new_s_xpm),
standard_icons.ImgSearch,
new MultiImage(*new xpmImage(left_s_xpm), INACTIVE_R,
@@ -189,7 +192,7 @@ public:
// Toolbar buttons -----------------------------------------------------------
//
//static const char *button_names[] = {
-// "Back", "Forward", "Home", "Reload", "Save", "Stop", "Bookmarks",
+// "Back", "Forward", "Home", "Reload", "Save", "Stop", "Bookmarks", "Tools",
// "Clear", "Search"
//};
@@ -324,6 +327,11 @@ static void b1_cb(Widget *wid, void *cb_data)
a_UIcmd_book(a_UIcmd_get_bw_by_widget(wid));
}
break;
+ case UI_TOOLS:
+ if (k == 1 || k == 3) {
+ a_UIcmd_tools(a_UIcmd_get_bw_by_widget(wid), wid);
+ }
+ break;
default:
break;
}
@@ -411,6 +419,12 @@ PackedGroup *UI::make_toolbar(int tw, int th)
b->callback(b1_cb, (void *)UI_BOOK);
b->clear_tab_to_focus();
+ Tools = b = new HighlightButton(xpos, 0, bw, bh, (lbl) ? "Tools" : 0);
+ b->image(icons->ImgTools);
+ b->tooltip("Settings");
+ b->callback(b1_cb, (void *)UI_TOOLS);
+ b->clear_tab_to_focus();
+
p1->type(PackedGroup::ALL_CHILDREN_VERTICAL);
p1->end();
diff --git a/src/ui.hh b/src/ui.hh
index 926a800f..9f832fa3 100644
--- a/src/ui.hh
+++ b/src/ui.hh
@@ -26,6 +26,7 @@ typedef enum {
UI_SAVE,
UI_STOP,
UI_BOOK,
+ UI_TOOLS,
UI_CLEAR,
UI_SEARCH
} UIButton;
@@ -48,7 +49,7 @@ class UI : public fltk::Group {
char *TabTooltip;
Group *TopGroup;
- Button *Back, *Forw, *Home, *Reload, *Save, *Stop, *Bookmarks,
+ Button *Back, *Forw, *Home, *Reload, *Save, *Stop, *Bookmarks, *Tools,
*Clear, *Search, *FullScreen, *ImageLoad, *BugMeter, *FileButton;
Input *Location;
PackedGroup *ProgBox;
diff --git a/src/uicmd.cc b/src/uicmd.cc
index da416dcd..844518a7 100644
--- a/src/uicmd.cc
+++ b/src/uicmd.cc
@@ -439,6 +439,14 @@ void a_UIcmd_reload(void *vbw)
}
/*
+ * Repush current URL
+ */
+void a_UIcmd_repush(void *vbw)
+{
+ a_Nav_repush((BrowserWindow*)vbw);
+}
+
+/*
* Return a suitable filename for a given URL path.
*/
static char *UIcmd_make_save_filename(const char *pathstr)
@@ -526,6 +534,14 @@ void a_UIcmd_stop(void *vbw)
}
/*
+ * Popup the tools menu
+ */
+void a_UIcmd_tools(void *vbw, void *v_wid)
+{
+ a_Menu_tools_popup((BrowserWindow*)vbw, v_wid);
+}
+
+/*
* Open URL with dialog chooser
*/
void a_UIcmd_open_file(void *vbw)
@@ -643,10 +659,11 @@ void a_UIcmd_add_bookmark(BrowserWindow *bw, const DilloUrl *url)
/*
* Popup the page menu
*/
-void a_UIcmd_page_popup(void *vbw, const DilloUrl *url,
- bool_t has_bugs, bool_t unloaded_imgs)
+void a_UIcmd_page_popup(void *vbw, bool_t has_bugs, bool_t unloaded_imgs)
{
- a_Menu_page_popup((BrowserWindow*)vbw, url, has_bugs, unloaded_imgs);
+ BrowserWindow *bw = (BrowserWindow*)vbw;
+ DilloUrl *url = a_History_get_url(NAV_TOP_UIDX(bw));
+ a_Menu_page_popup(bw, url, has_bugs, unloaded_imgs);
}
/*
diff --git a/src/uicmd.hh b/src/uicmd.hh
index 6adb43ad..9a752924 100644
--- a/src/uicmd.hh
+++ b/src/uicmd.hh
@@ -21,8 +21,10 @@ void a_UIcmd_forw(void *vbw);
void a_UIcmd_forw_popup(void *vbw);
void a_UIcmd_home(void *vbw);
void a_UIcmd_reload(void *vbw);
+void a_UIcmd_repush(void *vbw);
void a_UIcmd_save(void *vbw);
void a_UIcmd_stop(void *vbw);
+void a_UIcmd_tools(void *vbw, void *v_wid);
void a_UIcmd_save_link(BrowserWindow *bw, const DilloUrl *url);
void a_UIcmd_open_file(void *vbw);
const char *a_UIcmd_select_file();
@@ -36,8 +38,7 @@ void a_UIcmd_findtext_search(BrowserWindow *bw,const char *key,int case_sens);
void a_UIcmd_findtext_reset(BrowserWindow *bw);
void a_UIcmd_focus_main_area(BrowserWindow *bw);
void a_UIcmd_focus_location(void *vbw);
-void a_UIcmd_page_popup(void *vbw, const DilloUrl *url,
- bool_t has_bugs, bool_t unloaded_imgs);
+void a_UIcmd_page_popup(void *vbw, bool_t has_bugs, bool_t unloaded_imgs);
void a_UIcmd_link_popup(void *vbw, const DilloUrl *url);
void a_UIcmd_image_popup(void *vbw, const DilloUrl *url, bool_t loaded_img,
DilloUrl *link_url);