aboutsummaryrefslogtreecommitdiff
path: root/src/menu.cc
diff options
context:
space:
mode:
authorcorvid <corvid@lavabit.com>2008-12-21 08:39:20 -0300
committercorvid <corvid@lavabit.com>2008-12-21 08:39:20 -0300
commit1e1f9f423355b880238b2b2b65e53221c66ecea2 (patch)
tree392ccb9839e791c0c8f257d13146b79d963c4b94 /src/menu.cc
parent197c6074b6b7ca6932e98872f412c3aa1bf550e4 (diff)
Added a popup menu to form's submit button
Diffstat (limited to 'src/menu.cc')
-rw-r--r--src/menu.cc63
1 files changed, 63 insertions, 0 deletions
diff --git a/src/menu.cc b/src/menu.cc
index ac23117d..9b75c422 100644
--- a/src/menu.cc
+++ b/src/menu.cc
@@ -212,6 +212,44 @@ static void Menu_load_images_cb(Widget*, void *user_data)
}
}
+/*
+ * Submit form
+ */
+static void Menu_form_submit_cb(Widget*, void *v_form)
+{
+ if (popup_bw && popup_bw->Docs) {
+ if (dList_find_custom(popup_bw->PageUrls, popup_url,
+ (dCompareFunc)a_Url_cmp)){
+ /* HTML page is still there */
+ int n = dList_length(popup_bw->Docs);
+ if (n == 1) {
+ a_Html_form_submit(dList_nth_data(popup_bw->Docs, 0), v_form);
+ } else if (n > 1) {
+ MSG ("Menu_form_submit_cb multiple Docs not implemented\n");
+ }
+ }
+ }
+}
+
+/*
+ * Reset form
+ */
+static void Menu_form_reset_cb(Widget*, void *v_form)
+{
+ if (popup_bw && popup_bw->Docs) {
+ if (dList_find_custom(popup_bw->PageUrls, popup_url,
+ (dCompareFunc)a_Url_cmp)){
+ /* HTML page is still there */
+ int n = dList_length(popup_bw->Docs);
+ if (n == 1) {
+ a_Html_form_reset(dList_nth_data(popup_bw->Docs, 0), v_form);
+ } else if (n > 1) {
+ MSG ("Menu_form_reset_cb multiple Docs not implemented\n");
+ }
+ }
+ }
+}
+
/*
* Validate URL with the W3C
*/
@@ -452,6 +490,31 @@ void a_Menu_image_popup(BrowserWindow *bw, const DilloUrl *url,
}
/*
+ * Form popup menu (construction & popup)
+ */
+void a_Menu_form_popup(BrowserWindow *bw, const DilloUrl *page_url,
+ void *formptr)
+{
+ static PopupMenu *pm = 0;
+
+ popup_bw = bw;
+ a_Url_free(popup_url);
+ popup_url = a_Url_dup(page_url);
+ if (!pm) {
+ Item *i;
+ pm = new PopupMenu(0,0,0,0,"FORM OPTIONS");
+ pm->add(i = new Item("Submit form"));
+ i->callback(Menu_form_submit_cb);
+ pm->add(i = new Item("Reset form"));
+ i->callback(Menu_form_reset_cb);
+ pm->type(PopupMenu::POPUP123);
+ }
+ pm->user_data(formptr);
+
+ a_Timeout_add(0.0, Menu_popup_cb, (void *)pm);
+}
+
+/*
* File popup menu (construction & popup)
*/
void a_Menu_file_popup(BrowserWindow *bw, void *v_wid)