aboutsummaryrefslogtreecommitdiff
path: root/src/menu.cc
diff options
context:
space:
mode:
authorJorge Arellano Cid <jcid@dillo.org>2009-02-17 10:49:19 -0300
committerJorge Arellano Cid <jcid@dillo.org>2009-02-17 10:49:19 -0300
commit6e528e088f46f9b75fcd7dc34987096ffa41f71e (patch)
tree44d3e3854c01ba9e46d7dc51eca961b717f185da /src/menu.cc
parentc51e8062a3614ccb1a2ca711f73036dffc66cbe0 (diff)
[mq]: view-stylesheets
Diffstat (limited to 'src/menu.cc')
-rw-r--r--src/menu.cc40
1 files changed, 38 insertions, 2 deletions
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);
}