changeset 364:87a4bce3e024

- Switched the image load button to be a per-window choice.
author jcid
date Mon, 29 Sep 2008 17:48:59 +0200
parents 700c47d18fec
children b268f3c9ace0
files src/html.cc src/ui.cc src/ui.hh src/uicmd.cc src/uicmd.hh
diffstat 5 files changed, 21 insertions(+), 38 deletions(-) [+]
line wrap: on
line diff
--- a/src/html.cc	Mon Sep 29 15:49:38 2008 +0200
+++ b/src/html.cc	Mon Sep 29 17:48:59 2008 +0200
@@ -2071,7 +2071,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 (!prefs.load_images && (!alt_ptr || !*alt_ptr)) {
+   if ((!alt_ptr || !*alt_ptr) && !a_UIcmd_get_images_enabled(html->bw)) {
       dFree(alt_ptr);
       alt_ptr = dStrdup("[IMG]"); // Place holder for img_off mode
    }
@@ -2126,7 +2126,8 @@
                       style_attrs);
    }
 
-   load_now = prefs.load_images || (a_Capi_get_flags(url) & CAPI_IsCached);
+   load_now = a_UIcmd_get_images_enabled(html->bw) ||
+              (a_Capi_get_flags(url) & CAPI_IsCached);
    Html_add_new_linkimage(html, &url, load_now ? NULL : Image);
    if (load_now)
       Html_load_image(html->bw, url, Image);
--- a/src/ui.cc	Mon Sep 29 15:49:38 2008 +0200
+++ b/src/ui.cc	Mon Sep 29 17:48:59 2008 +0200
@@ -292,20 +292,6 @@
    }
 }
 
-/*
- * Callback for the image loading button.
- */
-static void imageload_cb(Widget *w, void *data)
-{
-   int k = event_key();
-   //if (k && k <= 7)
-   //   MSG("[ImageLoad], mouse button %d was pressed\n", k);
-   if (k == 1) {
-      ((UI*)data)->imageload_toggle();
-   }
-}
-
-
 //////////////////////////////////////////////////////////////////////////////
 // UI class methods
 //
@@ -677,17 +663,16 @@
 
    // Image loading indicator
    ImageLoad = new HighlightButton(ww-il_w-bm_w,0,il_w,s_h,0);
-   ImgImageLoadOn = new xpmImage(imgload_on_xpm);
+   ImageLoad->type(Button::TOGGLE);
    ImgImageLoadOff = new xpmImage(imgload_off_xpm);
-   if (prefs.load_images) {
-      ImageLoad->image(ImgImageLoadOn);
-   } else {
-      ImageLoad->image(ImgImageLoadOff);
-   }
+   ImgImageLoadOn = new xpmImage(imgload_on_xpm);
+   ImgImageLoadMulti = new MultiImage(*ImgImageLoadOff,STATE,*ImgImageLoadOn);
+   ImageLoad->state(prefs.load_images);
+   ImageLoad->image(ImgImageLoadMulti);
+
    ImageLoad->box(THIN_DOWN_BOX);
    ImageLoad->align(ALIGN_INSIDE|ALIGN_CLIP|ALIGN_LEFT);
    ImageLoad->tooltip("Toggle image loading");
-   ImageLoad->callback(imageload_cb, this);
    ImageLoad->clear_tab_to_focus();
    StatusPanel->add(ImageLoad);
 
@@ -744,6 +729,7 @@
  */
 void UI::delete_status_panel_images()
 {
+   delete ImgImageLoadMulti;
    delete ImgImageLoadOn;
    delete ImgImageLoadOff;
    delete ImgMeterOK;
@@ -1052,19 +1038,6 @@
 }
 
 /*
- * Toggle image loading
- */
-void UI::imageload_toggle()
-{
-   prefs.load_images = !prefs.load_images;
-   if (prefs.load_images) {
-      ImageLoad->image(ImgImageLoadOn);
-   } else {
-      ImageLoad->image(ImgImageLoadOff);
-   }
-}
-
-/*
  * Set 'nw' as the main render area widget
  */
 void UI::set_render_layout(Widget &nw)
--- a/src/ui.hh	Mon Sep 29 15:49:38 2008 +0200
+++ b/src/ui.hh	Mon Sep 29 17:48:59 2008 +0200
@@ -58,7 +58,7 @@
          *ImgStopIns, *ImgStopSens, *ImgFullScreenOn, *ImgFullScreenOff,
          *ImgImageLoadOn, *ImgImageLoadOff, *ImgMeterOK, *ImgMeterBug,
          *ImgHome, *ImgReload, *ImgSave, *ImgBook, *ImgClear, *ImgSearch;
-   MultiImage *ImgLeftMulti, *ImgRightMulti, *ImgStopMulti;
+   MultiImage *ImgLeftMulti, *ImgRightMulti, *ImgStopMulti, *ImgImageLoadMulti;
    Group *Panel, *StatusPanel;
    Widget *Main;
    Output *Status;
@@ -103,6 +103,7 @@
    void set_panelmode(UIPanelmode mode);
    UIPanelmode get_panelmode();
    void set_findbar_visibility(bool visible);
+   bool get_images_enabled() { return ImageLoad->state();}
    Widget *fullscreen_button() { return FullScreen; }
    void fullscreen_toggle() { FullScreen->do_callback(); }
 
@@ -116,7 +117,6 @@
    void color_change_cb_i();
    void toggle_cb_i();
    void panelmode_cb_i();
-   void imageload_toggle();
 };
 
 #endif // __UI_HH__
--- a/src/uicmd.cc	Mon Sep 29 15:49:38 2008 +0200
+++ b/src/uicmd.cc	Mon Sep 29 17:48:59 2008 +0200
@@ -815,6 +815,14 @@
 }
 
 /*
+ * Check whether the UI has automatic image loading enabled.
+ */
+bool_t a_UIcmd_get_images_enabled(BrowserWindow *bw)
+{
+   return BW2UI(bw)->get_images_enabled();
+}
+
+/*
  * Set the sensitivity of back/forw/stop buttons.
  */
 static void a_UIcmd_set_buttons_sens_cb(void *vbw)
--- a/src/uicmd.hh	Mon Sep 29 15:49:38 2008 +0200
+++ b/src/uicmd.hh	Mon Sep 29 17:48:59 2008 +0200
@@ -66,6 +66,7 @@
 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_buttons_sens(BrowserWindow *bw);
 void a_UIcmd_fullscreen_toggle(BrowserWindow *bw);