diff options
author | Jorge Arellano Cid <jcid@dillo.org> | 2009-02-17 10:49:19 -0300 |
---|---|---|
committer | Jorge Arellano Cid <jcid@dillo.org> | 2009-02-17 10:49:19 -0300 |
commit | 6e528e088f46f9b75fcd7dc34987096ffa41f71e (patch) | |
tree | 44d3e3854c01ba9e46d7dc51eca961b717f185da | |
parent | c51e8062a3614ccb1a2ca711f73036dffc66cbe0 (diff) |
[mq]: view-stylesheets
-rw-r--r-- | ChangeLog | 1 | ||||
-rw-r--r-- | src/html.cc | 2 | ||||
-rw-r--r-- | src/menu.cc | 40 | ||||
-rw-r--r-- | src/menu.hh | 2 | ||||
-rw-r--r-- | src/plain.cc | 2 | ||||
-rw-r--r-- | src/uicmd.cc | 4 | ||||
-rw-r--r-- | src/uicmd.hh | 2 |
7 files changed, 45 insertions, 8 deletions
@@ -33,6 +33,7 @@ dillo-2.1 - 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. diff --git a/src/html.cc b/src/html.cc index bbf49bd4..ad0f37e2 100644 --- a/src/html.cc +++ b/src/html.cc @@ -732,7 +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); + a_UIcmd_page_popup(bw, bw->num_page_bugs != 0, html->cssUrls); ret = true; } else { a_UIcmd_link_popup(bw, html->links->get(link)); diff --git a/src/menu.cc b/src/menu.cc index ee9a1bda..b94800af 100644 --- a/src/menu.cc +++ b/src/menu.cc @@ -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 @@ static void Menu_form_hiddens_cb(Widget *w, void *user_data) 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 @@ 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 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 @@ void a_Menu_page_popup(BrowserWindow *bw, const DilloUrl *url, 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); } diff --git a/src/menu.hh b/src/menu.hh index 36f7ad21..668de001 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 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, diff --git a/src/plain.cc b/src/plain.cc index 2fb725a3..5366f87e 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); + a_UIcmd_page_popup(plain->bw, FALSE, NULL); return true; } return false; diff --git a/src/uicmd.cc b/src/uicmd.cc index 0c0b8bfe..eb90f64f 100644 --- a/src/uicmd.cc +++ b/src/uicmd.cc @@ -875,11 +875,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) +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); } /* diff --git a/src/uicmd.hh b/src/uicmd.hh index 90e7c89d..134ed5ec 100644 --- a/src/uicmd.hh +++ b/src/uicmd.hh @@ -39,7 +39,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); +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); |