changeset 958:1a26b2bd7138

[mq]: view-stylesheets
author Jorge Arellano Cid <jcid@dillo.org>
date Tue, 17 Feb 2009 10:49:19 -0300
parents bd699ba9a469
children 0f798c4b1375
files ChangeLog src/html.cc src/menu.cc src/menu.hh src/plain.cc src/uicmd.cc src/uicmd.hh
diffstat 7 files changed, 45 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Tue Feb 17 10:24:07 2009 -0300
+++ b/ChangeLog	Tue Feb 17 10:49:19 2009 -0300
@@ -33,6 +33,7 @@
  - Replace image loading button and page menu option with a tools menu option.
  - Implemented the "overline" text-decoration.
  - Enhanced and cleaned up text decorations for SUB and SUP.
+ - Added "View Stylesheets" to the page menu.
    Patches: place (AKA corvid)
 +- Switched SSL-enabled to configure.in (./configure --enable-ssl).
  - Standardised the installation of dpid/dpidrc with auto* tools.
--- a/src/html.cc	Tue Feb 17 10:24:07 2009 -0300
+++ b/src/html.cc	Tue Feb 17 10:49:19 2009 -0300
@@ -732,7 +732,7 @@
          ret = true;
       } else {
          if (link == -1) {
-            a_UIcmd_page_popup(bw, bw->num_page_bugs != 0);
+            a_UIcmd_page_popup(bw, bw->num_page_bugs != 0, html->cssUrls);
             ret = true;
          } else {
             a_UIcmd_link_popup(bw, html->links->get(link));
--- a/src/menu.cc	Tue Feb 17 10:24:07 2009 -0300
+++ b/src/menu.cc	Tue Feb 17 10:49:19 2009 -0300
@@ -19,6 +19,7 @@
 #include <fltk/ToggleItem.h>
 #include <fltk/Divider.h>
 
+#include "lout/misc.hh"    /* SimpleVector */
 #include "msg.h"
 #include "menu.hh"
 #include "uicmd.hh"
@@ -238,6 +239,11 @@
       a_Html_form_display_hiddens(doc, v_form, !visible);
 }
 
+static void Menu_stylesheet_cb(Widget *w, void *)
+{
+   a_UIcmd_open_urlstr(popup_bw, w->label() + 5);
+}
+
 /*
  * Validate URL with the W3C
  */
@@ -324,25 +330,31 @@
  * Page popup menu (construction & popup)
  */
 void a_Menu_page_popup(BrowserWindow *bw, const DilloUrl *url,
-                       bool_t has_bugs)
+                       bool_t has_bugs, void *v_cssUrls)
 {
+   lout::misc::SimpleVector <DilloUrl*> *cssUrls =
+                            (lout::misc::SimpleVector <DilloUrl*> *) v_cssUrls;
+   Item *i;
+   int j;
    // One menu for every browser window
    static PopupMenu *pm = 0;
    // Active/inactive control.
    static Item *view_page_bugs_item = 0;
+   static ItemGroup *stylesheets = 0;
 
    popup_bw = bw;
    a_Url_free(popup_url);
    popup_url = a_Url_dup(url);
 
    if (!pm) {
-      Item *i;
       pm = new PopupMenu(0,0,0,0,"&PAGE OPTIONS");
       pm->begin();
        i = new Item("View page Source");
        i->callback(Menu_view_page_source_cb);
        i = view_page_bugs_item = new Item("View page Bugs");
        i->callback(Menu_view_page_bugs_cb);
+       stylesheets = new ItemGroup("View Stylesheets");
+       new Divider();
        i = new Item("Bookmark this page");
        i->callback(Menu_add_bookmark_cb);
        new Divider();
@@ -364,6 +376,30 @@
    else
       view_page_bugs_item->deactivate();
 
+   int n = stylesheets->children();
+   for (j = 0; j < n; j++) {
+      /* get rid of the old ones */
+      Widget *child = stylesheets->child(0);
+      dFree((char *)child->label());
+      delete child;
+   }
+
+   if (cssUrls && cssUrls->size () > 0) {
+      stylesheets->activate();
+      for (j = 0; j < cssUrls->size(); j++) {
+         DilloUrl *url = cssUrls->get(j);
+         const char *action = "View ";
+         /* may want ability to Load individual unloaded stylesheets as well */
+         char *label = dStrconcat(action, URL_STR(url), NULL);
+         i = new Item(label);
+         i->set_flag(RAW_LABEL);
+         i->callback(Menu_stylesheet_cb);
+         stylesheets->add(i);
+      }
+   } else {
+      stylesheets->deactivate();
+   }
+
    a_Timeout_add(0.0, Menu_popup_cb, (void *)pm);
 }
 
--- a/src/menu.hh	Tue Feb 17 10:24:07 2009 -0300
+++ b/src/menu.hh	Tue Feb 17 10:49:19 2009 -0300
@@ -8,7 +8,7 @@
 #endif /* __cplusplus */
 
 void a_Menu_page_popup(BrowserWindow *bw, const DilloUrl *url,
-                       bool_t has_bugs);
+                       bool_t has_bugs, void *v_cssUrls);
 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 *page_url,
--- a/src/plain.cc	Tue Feb 17 10:24:07 2009 -0300
+++ b/src/plain.cc	Tue Feb 17 10:49:19 2009 -0300
@@ -139,7 +139,7 @@
    _MSG("DilloPlain::PlainEventReceiver::buttonPress\n");
 
    if (event->button == 3) {
-      a_UIcmd_page_popup(plain->bw, FALSE);
+      a_UIcmd_page_popup(plain->bw, FALSE, NULL);
       return true;
    }
    return false;
--- a/src/uicmd.cc	Tue Feb 17 10:24:07 2009 -0300
+++ b/src/uicmd.cc	Tue Feb 17 10:49:19 2009 -0300
@@ -875,11 +875,11 @@
 /*
  * Popup the page menu
  */
-void a_UIcmd_page_popup(void *vbw, bool_t has_bugs)
+void a_UIcmd_page_popup(void *vbw, bool_t has_bugs, void *v_cssUrls)
 {
    BrowserWindow *bw = (BrowserWindow*)vbw;
    DilloUrl *url = a_History_get_url(NAV_TOP_UIDX(bw));
-   a_Menu_page_popup(bw, url, has_bugs);
+   a_Menu_page_popup(bw, url, has_bugs, v_cssUrls);
 }
 
 /*
--- a/src/uicmd.hh	Tue Feb 17 10:24:07 2009 -0300
+++ b/src/uicmd.hh	Tue Feb 17 10:49:19 2009 -0300
@@ -39,7 +39,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);
+void a_UIcmd_page_popup(void *vbw, bool_t has_bugs, void *v_cssUrls);
 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 *page_url, DilloUrl *link_url);