aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorcorvid <corvid@lavabit.com>2009-02-08 14:02:56 -0300
committercorvid <corvid@lavabit.com>2009-02-08 14:02:56 -0300
commit4e417d3988cff4143da06f438fcd39cb228ed1f9 (patch)
treedb15fc7be182ecd004909797aae4a431812cae68 /src
parent175197dc885e13446fcc8662fd58a58dc46ad9d3 (diff)
Switched load images on/off feature to the Tools menu
Diffstat (limited to 'src')
-rw-r--r--src/html.cc7
-rw-r--r--src/menu.cc36
-rw-r--r--src/menu.hh2
-rw-r--r--src/pixmaps.h42
-rw-r--r--src/plain.cc2
-rw-r--r--src/ui.cc24
-rw-r--r--src/ui.hh4
-rw-r--r--src/uicmd.cc20
-rw-r--r--src/uicmd.hh4
9 files changed, 35 insertions, 106 deletions
diff --git a/src/html.cc b/src/html.cc
index 83462849..9dff41a0 100644
--- a/src/html.cc
+++ b/src/html.cc
@@ -732,8 +732,7 @@ bool DilloHtml::HtmlLinkReceiver::press (Widget *widget, int link, int img,
ret = true;
} else {
if (link == -1) {
- a_UIcmd_page_popup(bw, bw->num_page_bugs != 0,
- html->unloadedImages());
+ a_UIcmd_page_popup(bw, bw->num_page_bugs != 0);
ret = true;
} else {
a_UIcmd_link_popup(bw, html->links->get(link));
@@ -1952,7 +1951,7 @@ DilloImage *a_Html_add_new_image(DilloHtml *html, const char *tag,
// style_attrs->x_tooltip = a_Dw_tooltip_new_no_ref(attrbuf);
alt_ptr = a_Html_get_attr_wdef(html, tag, tagsize, "alt", NULL);
- if ((!alt_ptr || !*alt_ptr) && !a_UIcmd_get_images_enabled(html->bw)) {
+ if ((!alt_ptr || !*alt_ptr) && !prefs.load_images) {
dFree(alt_ptr);
alt_ptr = dStrdup("[IMG]"); // Place holder for img_off mode
}
@@ -2042,7 +2041,7 @@ DilloImage *a_Html_add_new_image(DilloHtml *html, const char *tag,
if (DW2TB(html->dw)->getBgColor())
Image->bg_color = DW2TB(html->dw)->getBgColor()->getColor();
- load_now = a_UIcmd_get_images_enabled(html->bw) ||
+ load_now = prefs.load_images ||
(a_Capi_get_flags(url) & CAPI_IsCached);
Html_add_new_linkimage(html, &url, load_now ? NULL : Image);
if (load_now)
diff --git a/src/menu.cc b/src/menu.cc
index 3b675bdf..32d8ba94 100644
--- a/src/menu.cc
+++ b/src/menu.cc
@@ -199,8 +199,8 @@ static void *Menu_get_bw_doc()
void *doc = NULL;
if (popup_bw && popup_bw->Docs) {
- if (dList_find_custom(popup_bw->PageUrls, popup_url,
- (dCompareFunc)a_Url_cmp)){
+ if (!popup_url || dList_find_custom(popup_bw->PageUrls, popup_url,
+ (dCompareFunc)a_Url_cmp)){
/* HTML page is still there */
if (dList_length(popup_bw->Docs) == 1)
doc = dList_nth_data(popup_bw->Docs, 0);
@@ -344,13 +344,12 @@ static void Menu_popup_cb2(void *data)
* Page popup menu (construction & popup)
*/
void a_Menu_page_popup(BrowserWindow *bw, const DilloUrl *url,
- bool_t has_bugs, bool_t unloaded_imgs)
+ bool_t has_bugs)
{
// One menu for every browser window
static PopupMenu *pm = 0;
// Active/inactive control.
static Item *view_page_bugs_item = 0;
- static Item *load_images_item = 0;
popup_bw = bw;
a_Url_free(popup_url);
@@ -364,8 +363,6 @@ void a_Menu_page_popup(BrowserWindow *bw, const DilloUrl *url,
i->callback(Menu_view_page_source_cb);
i = view_page_bugs_item = new Item("View page Bugs");
i->callback(Menu_view_page_bugs_cb);
- i = load_images_item = new Item("Load images");
- i->callback(Menu_load_images_cb);
i = new Item("Bookmark this page");
i->callback(Menu_add_bookmark_cb);
new Divider();
@@ -387,13 +384,6 @@ void a_Menu_page_popup(BrowserWindow *bw, const DilloUrl *url,
else
view_page_bugs_item->deactivate();
- if (unloaded_imgs == TRUE) {
- load_images_item->activate();
- load_images_item->user_data(NULL); /* wildcard */
- } else {
- load_images_item->deactivate();
- }
-
a_Timeout_add(0.0, Menu_popup_cb, (void *)pm);
}
@@ -658,6 +648,22 @@ static void Menu_embedded_css_cb(Widget *wid)
}
/*
+ * Toggle loading of images -- and load them if enabling.
+ */
+static void Menu_imgload_toggle_cb(Widget *wid)
+{
+ if ((prefs.load_images = wid->state() ? 1 : 0)) {
+ popup_url = NULL;
+ void *doc = Menu_get_bw_doc();
+
+ if (doc) {
+ DilloUrl *pattern = NULL;
+ a_Html_load_images(doc, pattern);
+ }
+ }
+}
+
+/*
* Tools popup menu (construction & popup)
*/
void a_Menu_tools_popup(BrowserWindow *bw, void *v_wid)
@@ -678,6 +684,10 @@ void a_Menu_tools_popup(BrowserWindow *bw, void *v_wid)
it = new ToggleItem("Use embedded CSS");
it->callback(Menu_embedded_css_cb);
it->state(prefs.parse_embedded_css);
+ new Divider();
+ it = new ToggleItem("Load images");
+ it->callback(Menu_imgload_toggle_cb);
+ it->state(prefs.load_images);
pm->type(PopupMenu::POPUP13);
pm->end();
}
diff --git a/src/menu.hh b/src/menu.hh
index 90b9d50b..d0246c2e 100644
--- a/src/menu.hh
+++ b/src/menu.hh
@@ -8,7 +8,7 @@ extern "C" {
#endif /* __cplusplus */
void a_Menu_page_popup(BrowserWindow *bw, const DilloUrl *url,
- bool_t has_bugs, bool_t unloaded_imgs);
+ bool_t has_bugs);
void a_Menu_link_popup(BrowserWindow *bw, const DilloUrl *url);
void a_Menu_image_popup(BrowserWindow *bw, const DilloUrl *url,
bool_t loaded_img, DilloUrl *link_url);
diff --git a/src/pixmaps.h b/src/pixmaps.h
index bb6bbe08..0f76c330 100644
--- a/src/pixmaps.h
+++ b/src/pixmaps.h
@@ -1615,48 +1615,6 @@ static const char *const mini_ok_xpm[] = {
};
/* XPM */
-static const char *const imgload_on_xpm[] = {
-"15 15 2 1",
-" c None",
-". c #00000000CF3C",
-" ",
-" . . . ... ",
-" . .. .. . . ",
-" . . . . . ",
-" . . . . .. ",
-" . . . . . ",
-" . . . ... ",
-" ",
-" ... . . ",
-" . . .. . ",
-" . . . . . ",
-" . . . .. ",
-" . . . . ",
-" ... . . ",
-" "};
-
-/* XPM */
-static const char *const imgload_off_xpm[] = {
-"15 15 2 1",
-" c None",
-". c #CF3C00000000",
-" ",
-" . . . ... ",
-" . .. .. . . ",
-" . . . . . ",
-" . . . . .. ",
-" . . . . . ",
-" . . . ... ",
-" ",
-" ... ... ... ",
-" . . . . ",
-" . . ... ... ",
-" . . . . ",
-" . . . . ",
-" ... . . ",
-" "};
-
-/* XPM */
static const char *const left_i_xpm[] = {
"22 22 3 1",
" c None",
diff --git a/src/plain.cc b/src/plain.cc
index c18da3e7..eefc6614 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, FALSE, FALSE);
+ a_UIcmd_page_popup(plain->bw, FALSE);
return true;
}
return false;
diff --git a/src/ui.cc b/src/ui.cc
index e572d439..caa48444 100644
--- a/src/ui.cc
+++ b/src/ui.cc
@@ -40,7 +40,7 @@ struct iconset {
Image *ImgMeterOK, *ImgMeterBug,
*ImgHome, *ImgReload, *ImgSave, *ImgBook, *ImgTools,
*ImgClear,*ImgSearch;
- MultiImage *ImgLeftMulti, *ImgRightMulti, *ImgStopMulti, *ImgImageLoadMulti;
+ MultiImage *ImgLeftMulti, *ImgRightMulti, *ImgStopMulti;
};
static struct iconset standard_icons = {
@@ -59,8 +59,6 @@ static struct iconset standard_icons = {
*new xpmImage(right_i_xpm)),
new MultiImage(*new xpmImage(stop_xpm), INACTIVE_R,
*new xpmImage(stop_i_xpm)),
- new MultiImage(*new xpmImage(imgload_off_xpm), STATE,
- *new xpmImage(imgload_on_xpm))
};
static struct iconset small_icons = {
@@ -79,7 +77,6 @@ static struct iconset small_icons = {
*new xpmImage(right_si_xpm)),
new MultiImage(*new xpmImage(stop_s_xpm), INACTIVE_R,
*new xpmImage(stop_si_xpm)),
- standard_icons.ImgImageLoadMulti
};
@@ -683,9 +680,8 @@ UI::UI(int x, int y, int ww, int wh, const char* label, const UI *cur_ui) :
// Status Panel
StatusPanel = new Group(0, 0, ww, s_h, 0);
// Status box
- int il_w = 16;
int bm_w = 16;
- Status = new Output(0, 0, ww-bm_w-il_w, s_h, 0);
+ Status = new Output(0, 0, ww-bm_w, s_h, 0);
Status->value("");
Status->box(THIN_DOWN_BOX);
Status->clear_click_to_focus();
@@ -694,18 +690,6 @@ UI::UI(int x, int y, int ww, int wh, const char* label, const UI *cur_ui) :
StatusPanel->add(Status);
//Status->throw_focus();
- // Image loading indicator
- ImageLoad = new HighlightButton(ww-il_w-bm_w,0,il_w,s_h,0);
- ImageLoad->type(Button::TOGGLE);
- ImageLoad->state(prefs.load_images);
- ImageLoad->image(icons->ImgImageLoadMulti);
-
- ImageLoad->box(THIN_DOWN_BOX);
- ImageLoad->align(ALIGN_INSIDE|ALIGN_CLIP|ALIGN_LEFT);
- ImageLoad->tooltip("Toggle image loading");
- ImageLoad->clear_tab_to_focus();
- StatusPanel->add(ImageLoad);
-
// Bug Meter
BugMeter = new HighlightButton(ww-bm_w,0,bm_w,s_h,0);
BugMeter->image(icons->ImgMeterOK);
@@ -946,9 +930,7 @@ void UI::set_bug_prog(int n_bug)
BugMeter->redraw_label();
new_w = strlen(str)*8 + 20;
}
- Status->resize(0,0,StatusPanel->w()-ImageLoad->w()-new_w,Status->h());
- ImageLoad->resize(StatusPanel->w()-ImageLoad->w()-new_w, 0, ImageLoad->w(),
- ImageLoad->h());
+ Status->resize(0,0,StatusPanel->w()-new_w,Status->h());
BugMeter->resize(StatusPanel->w()-new_w, 0, new_w, BugMeter->h());
StatusPanel->init_sizes();
}
diff --git a/src/ui.hh b/src/ui.hh
index 9f832fa3..946e7669 100644
--- a/src/ui.hh
+++ b/src/ui.hh
@@ -50,7 +50,7 @@ class UI : public fltk::Group {
Group *TopGroup;
Button *Back, *Forw, *Home, *Reload, *Save, *Stop, *Bookmarks, *Tools,
- *Clear, *Search, *FullScreen, *ImageLoad, *BugMeter, *FileButton;
+ *Clear, *Search, *FullScreen, *BugMeter, *FileButton;
Input *Location;
PackedGroup *ProgBox;
CustProgressBox *PProg, *IProg;
@@ -98,8 +98,6 @@ public:
void set_panelmode(UIPanelmode mode);
UIPanelmode get_panelmode();
void set_findbar_visibility(bool visible);
- bool images_enabled() { return ImageLoad->state();}
- void images_enabled(int flag) { ImageLoad->state(flag);}
Widget *fullscreen_button() { return FullScreen; }
void fullscreen_toggle() { FullScreen->do_callback(); }
diff --git a/src/uicmd.cc b/src/uicmd.cc
index 844518a7..75d6336e 100644
--- a/src/uicmd.cc
+++ b/src/uicmd.cc
@@ -659,11 +659,11 @@ void a_UIcmd_add_bookmark(BrowserWindow *bw, const DilloUrl *url)
/*
* Popup the page menu
*/
-void a_UIcmd_page_popup(void *vbw, bool_t has_bugs, bool_t unloaded_imgs)
+void a_UIcmd_page_popup(void *vbw, bool_t has_bugs)
{
BrowserWindow *bw = (BrowserWindow*)vbw;
DilloUrl *url = a_History_get_url(NAV_TOP_UIDX(bw));
- a_Menu_page_popup(bw, url, has_bugs, unloaded_imgs);
+ a_Menu_page_popup(bw, url, has_bugs);
}
/*
@@ -905,22 +905,6 @@ void a_UIcmd_set_msg(BrowserWindow *bw, const char *format, ...)
}
/*
- * Check whether the UI has automatic image loading enabled.
- */
-bool_t a_UIcmd_get_images_enabled(BrowserWindow *bw)
-{
- return BW2UI(bw)->images_enabled();
-}
-
-/*
- * Enable/Disable automatic image loading.
- */
-void a_UIcmd_set_images_enabled(BrowserWindow *bw, int flag)
-{
- BW2UI(bw)->images_enabled(flag);
-}
-
-/*
* Set the sensitivity of back/forw/stop buttons.
*/
void a_UIcmd_set_buttons_sens(BrowserWindow *bw)
diff --git a/src/uicmd.hh b/src/uicmd.hh
index 9a752924..ca5b7cc5 100644
--- a/src/uicmd.hh
+++ b/src/uicmd.hh
@@ -38,7 +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, bool_t has_bugs, bool_t unloaded_imgs);
+void a_UIcmd_page_popup(void *vbw, bool_t has_bugs);
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);
@@ -72,8 +72,6 @@ void a_UIcmd_set_img_prog(BrowserWindow *bw, int n_img, int t_img, int cmd);
void a_UIcmd_set_bug_prog(BrowserWindow *bw, int n_bug);
void a_UIcmd_set_page_title(BrowserWindow *bw, const char *label);
void a_UIcmd_set_msg(BrowserWindow *bw, const char *format, ...);
-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);