changeset 907:35054b4e3b1b

Switched load images on/off feature to the Tools menu
author corvid <corvid@lavabit.com>
date Sun, 08 Feb 2009 14:02:56 -0300
parents e766286e0884
children 40bc2df4de7a 3002267a8555
files src/html.cc src/menu.cc src/menu.hh src/pixmaps.h src/plain.cc src/ui.cc src/ui.hh src/uicmd.cc src/uicmd.hh
diffstat 9 files changed, 35 insertions(+), 106 deletions(-) [+]
line wrap: on
line diff
--- a/src/html.cc	Sat Feb 07 09:54:28 2009 +0100
+++ b/src/html.cc	Sun Feb 08 14:02:56 2009 -0300
@@ -732,8 +732,7 @@
          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 @@
 //    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 @@
    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)
--- a/src/menu.cc	Sat Feb 07 09:54:28 2009 +0100
+++ b/src/menu.cc	Sun Feb 08 14:02:56 2009 -0300
@@ -199,8 +199,8 @@
    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 @@
  * 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 @@
        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 @@
    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 @@
 }
 
 /*
+ * 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 @@
        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();
    }
--- a/src/menu.hh	Sat Feb 07 09:54:28 2009 +0100
+++ b/src/menu.hh	Sun Feb 08 14:02:56 2009 -0300
@@ -8,7 +8,7 @@
 #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);
--- a/src/pixmaps.h	Sat Feb 07 09:54:28 2009 +0100
+++ b/src/pixmaps.h	Sun Feb 08 14:02:56 2009 -0300
@@ -1615,48 +1615,6 @@
 };
 
 /* 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",
--- a/src/plain.cc	Sat Feb 07 09:54:28 2009 +0100
+++ b/src/plain.cc	Sun Feb 08 14:02:56 2009 -0300
@@ -139,7 +139,7 @@
    _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;
--- a/src/ui.cc	Sat Feb 07 09:54:28 2009 +0100
+++ b/src/ui.cc	Sun Feb 08 14:02:56 2009 -0300
@@ -40,7 +40,7 @@
    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 @@
                   *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 @@
                   *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 @@
    // 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 @@
    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 @@
       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();
 }
--- a/src/ui.hh	Sat Feb 07 09:54:28 2009 +0100
+++ b/src/ui.hh	Sun Feb 08 14:02:56 2009 -0300
@@ -50,7 +50,7 @@
 
    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 @@
    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(); }
 
--- a/src/uicmd.cc	Sat Feb 07 09:54:28 2009 +0100
+++ b/src/uicmd.cc	Sun Feb 08 14:02:56 2009 -0300
@@ -659,11 +659,11 @@
 /*
  * 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 @@
 }
 
 /*
- * 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)
--- a/src/uicmd.hh	Sat Feb 07 09:54:28 2009 +0100
+++ b/src/uicmd.hh	Sun Feb 08 14:02:56 2009 -0300
@@ -38,7 +38,7 @@
 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_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);