changeset 84:03f9a7877a2e

Implemented the SELECT element in FORMS!
author jcid
date Mon, 31 Dec 2007 22:48:27 +0100
parents 866d074448f6
children bc65960ce3fe
files ChangeLog dpid/dpid.c dpid/main.c src/IO/IO.c src/IO/IO.h src/IO/dpi.c src/IO/http.c src/IO/mime.c src/cache.c src/capi.c src/dillo.cc src/dns.h src/html.cc src/klist.c src/nav.c src/pixmaps.h src/plain.cc
diffstat 17 files changed, 208 insertions(+), 270 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Mon Dec 31 22:29:20 2007 +0100
+++ b/ChangeLog	Mon Dec 31 22:48:27 2007 +0100
@@ -96,6 +96,7 @@
    Patch: Frank Gevaerts
 +- Bound Ctrl-R to reload.
    Made dialogs use font_factor (e.g. view source).
+   Implemented the SELECT element in FORMS!
    Patches: Jeremy Henty
 
  TODO:
--- a/dpid/dpid.c	Mon Dec 31 22:29:20 2007 +0100
+++ b/dpid/dpid.c	Mon Dec 31 22:48:27 2007 +0100
@@ -38,7 +38,7 @@
 
 /*! Return the basename of a filename
  */
-char *get_basename(char *filename)
+static char *get_basename(char *filename)
 {
    char *p;
 
--- a/dpid/main.c	Mon Dec 31 22:29:20 2007 +0100
+++ b/dpid/main.c	Mon Dec 31 22:48:27 2007 +0100
@@ -185,7 +185,7 @@
 /*
  * Check whether a dpi server is running
  */
-int server_is_running(char *server_id)
+static int server_is_running(char *server_id)
 {
    int i;
 
--- a/src/IO/IO.c	Mon Dec 31 22:29:20 2007 +0100
+++ b/src/IO/IO.c	Mon Dec 31 22:48:27 2007 +0100
@@ -24,7 +24,6 @@
 #include "../msg.h"
 #include "../chain.h"
 #include "../klist.h"
-#include "../list.h"
 #include "IO.h"
 #include "iowatch.hh"
 
--- a/src/IO/IO.h	Mon Dec 31 22:29:20 2007 +0100
+++ b/src/IO/IO.h	Mon Dec 31 22:48:27 2007 +0100
@@ -7,7 +7,6 @@
 #include "d_size.h"
 #include "../../dlib/dlib.h"
 #include "../chain.h"
-#include "iowatch.hh"
 
 /*
  * IO Operations
--- a/src/IO/dpi.c	Mon Dec 31 22:29:20 2007 +0100
+++ b/src/IO/dpi.c	Mon Dec 31 22:48:27 2007 +0100
@@ -38,7 +38,6 @@
 #include "../klist.h"
 #include "IO.h"
 #include "Url.h"
-#include "../misc.h"
 #include "../../dpip/dpip.h"
 
 /* #define DEBUG_LEVEL 2 */
--- a/src/IO/http.c	Mon Dec 31 22:29:20 2007 +0100
+++ b/src/IO/http.c	Mon Dec 31 22:48:27 2007 +0100
@@ -31,7 +31,6 @@
 #include "../msg.h"
 #include "../klist.h"
 #include "../dns.h"
-#include "../cache.h"
 #include "../web.hh"
 #include "../cookies.h"
 #include "../prefs.h"
--- a/src/IO/mime.c	Mon Dec 31 22:29:20 2007 +0100
+++ b/src/IO/mime.c	Mon Dec 31 22:48:27 2007 +0100
@@ -10,7 +10,6 @@
  */
 
 #include "mime.h"
-#include "../msg.h"
 #include "../list.h"
 
 
--- a/src/cache.c	Mon Dec 31 22:29:20 2007 +0100
+++ b/src/cache.c	Mon Dec 31 22:48:27 2007 +0100
@@ -23,7 +23,6 @@
 #include <unistd.h>
 
 #include "msg.h"
-#include "list.h"
 #include "IO/Url.h"
 #include "IO/IO.h"
 #include "web.hh"
--- a/src/capi.c	Mon Dec 31 22:29:20 2007 +0100
+++ b/src/capi.c	Mon Dec 31 22:48:27 2007 +0100
@@ -25,7 +25,6 @@
 #include "list.h"
 #include "history.h"
 #include "nav.h"
-#include "misc.h"
 #include "dpiapi.h"
 #include "uicmd.hh"
 #include "../dpip/dpip.h"
--- a/src/dillo.cc	Mon Dec 31 22:29:20 2007 +0100
+++ b/src/dillo.cc	Mon Dec 31 22:48:27 2007 +0100
@@ -27,9 +27,8 @@
 #include "dir.h"
 #include "uicmd.hh"
 
-#include "msg.h"
+#include "prefs.h"
 #include "bw.h"
-#include "bookmark.h"
 #include "misc.h"
 #include "nav.h"
 
--- a/src/dns.h	Mon Dec 31 22:29:20 2007 +0100
+++ b/src/dns.h	Mon Dec 31 22:48:27 2007 +0100
@@ -3,8 +3,6 @@
 
 #include <netinet/in.h>
 
-#include "chain.h"
-
 #ifdef __cplusplus
 extern "C" {
 #endif /* __cplusplus */
--- a/src/html.cc	Mon Dec 31 22:29:20 2007 +0100
+++ b/src/html.cc	Mon Dec 31 22:48:27 2007 +0100
@@ -38,7 +38,6 @@
 #include "nav.h"
 #include "menu.hh"
 #include "prefs.h"
-#include "misc.h"
 #include "capi.h"
 #include "html.hh"
 
@@ -90,9 +89,9 @@
 typedef struct _DilloHtmlClass   DilloHtmlClass;
 typedef struct _DilloHtmlState   DilloHtmlState;
 typedef struct _DilloHtmlForm    DilloHtmlForm;
+typedef struct _DilloHtmlInput   DilloHtmlInput;
+typedef struct _DilloHtmlSelect  DilloHtmlSelect;
 typedef struct _DilloHtmlOption  DilloHtmlOption;
-typedef struct _DilloHtmlSelect  DilloHtmlSelect;
-typedef struct _DilloHtmlInput   DilloHtmlInput;
 
 typedef enum {
    DT_NONE,           
@@ -175,10 +174,11 @@
    IN_BODY        = 1 << 2,
    IN_FORM        = 1 << 3,
    IN_SELECT      = 1 << 4,
-   IN_TEXTAREA    = 1 << 5,
-   IN_MAP         = 1 << 6,
-   IN_PRE         = 1 << 7,
-   IN_BUTTON      = 1 << 8
+   IN_OPTION      = 1 << 5,
+   IN_TEXTAREA    = 1 << 6,
+   IN_MAP         = 1 << 7,
+   IN_PRE         = 1 << 8,
+   IN_BUTTON      = 1 << 9,
 } DilloHtmlProcessingState;
 
 /*-----------------------------------------------------------------------------
@@ -231,18 +231,12 @@
 };
 
 struct _DilloHtmlOption {
-   //GtkWidget *menuitem;
-   char *value;
-   bool_t init_val;
+   char *value, *content;
+   bool selected, enabled;
 };
 
 struct _DilloHtmlSelect {
-   //GtkWidget *menu;
-   int size;
-
-   DilloHtmlOption *options;
-   int num_options;
-   int num_options_max;
+   misc::SimpleVector<DilloHtmlOption *> *options;
 };
 
 struct _DilloHtmlInput {
@@ -858,31 +852,33 @@
  */
 DilloHtml::~DilloHtml()
 {
-   int i, j, k;
-   DilloHtmlForm *form;
-   DilloHtmlInput *input_j;
-
    _MSG("::~DilloHtml(this=%p)\n", this);
 
    a_Bw_remove_doc(bw, this);
 
    a_Url_free(base_url);
 
-   for (i = 0; i < forms->size(); i++) {
-      form = forms->getRef(i);
+   for (int i = 0; i < forms->size(); i++) {
+      DilloHtmlForm *form = forms->getRef(i);
       a_Url_free(form->action);
-      for (j = 0; j < form->inputs->size(); j++) {
-         input_j = form->inputs->getRef(j);
-         dFree(input_j->name);
-         dFree(input_j->init_str);
-
-         if (input_j->type == DILLO_HTML_INPUT_SELECT ||
-            input_j->type == DILLO_HTML_INPUT_SEL_LIST) {
-            for (k = 0; k < input_j->select->num_options; k++) {
-               dFree(input_j->select->options[k].value);
+      for (int j = 0; j < form->inputs->size(); j++) {
+         DilloHtmlInput *input = form->inputs->getRef(j);
+         dFree(input->name);
+         dFree(input->init_str);
+
+         if (input->type == DILLO_HTML_INPUT_SELECT ||
+             input->type == DILLO_HTML_INPUT_SEL_LIST) {
+
+            int size = input->select->options->size ();
+            for (int k = 0; k < size; k++) {
+               DilloHtmlOption *option =
+                  input->select->options->get (k);
+               dFree(option->value);
+               dFree(option->content);
+               delete(option);
             }
-            dFree(input_j->select->options);
-            dFree(input_j->select);
+            delete(input->select->options);
+            delete(input->select);
          }
       }
       delete(form->inputs);
@@ -890,12 +886,12 @@
    }
    delete(forms);
 
-   for (i = 0; i < links->size(); i++)
+   for (int i = 0; i < links->size(); i++)
       if (links->get(i))
          a_Url_free(links->get(i));
    delete (links);
 
-   for (i = 0; i < images->size(); i++) {
+   for (int i = 0; i < images->size(); i++) {
       DilloLinkImage *li = images->get(i);
       a_Url_free(li->url);
       if (li->image)
@@ -3428,6 +3424,9 @@
       return;
    }
    html->InFlags |= IN_FORM;
+   html->InFlags &= ~IN_SELECT;
+   html->InFlags &= ~IN_OPTION;
+   html->InFlags &= ~IN_TEXTAREA;
 
    method = DILLO_HTML_METHOD_GET;
    if ((attrbuf = Html_get_attr(html, tag, tagsize, "method"))) {
@@ -3484,9 +3483,12 @@
 //       }
 //    }
    }
+
    html->InFlags &= ~IN_FORM;
    html->InFlags &= ~IN_SELECT;
+   html->InFlags &= ~IN_OPTION;
    html->InFlags &= ~IN_TEXTAREA;
+
    Html_pop_tag(html, TagIdx);
 }
 
@@ -3574,8 +3576,6 @@
  */
 static void Html_reset_input(DilloHtmlInput *input)
 {
-   int i;
-
    switch (input->type) {
    case DILLO_HTML_INPUT_TEXT:
    case DILLO_HTML_INPUT_PASSWORD:
@@ -3594,20 +3594,20 @@
          /* this is in reverse order so that, in case more than one was
           * selected, we get the last one, which is consistent with handling
           * of multiple selected options in the layout code. */
-         for (i = input->select->num_options - 1; i >= 0; i--) {
-            if (input->select->options[i].init_val) {
+//       for (i = input->select->num_options - 1; i >= 0; i--) {
+//          if (input->select->options[i].init_val) {
 //             gtk_menu_item_activate(GTK_MENU_ITEM
 //                                    (input->select->options[i].menuitem));
 //             Html_select_set_history(input);
-               break;
-            }
-         }
+//             break;
+//          }
+//       }
       }
       break;
    case DILLO_HTML_INPUT_SEL_LIST:
       if (!input->select)
          break;
-      for (i = 0; i < input->select->num_options; i++) {
+//    for (i = 0; i < input->select->num_options; i++) {
 //       if (input->select->options[i].init_val) {
 //          if (input->select->options[i].menuitem->state == GTK_STATE_NORMAL)
 //             gtk_list_select_child(GTK_LIST(input->select->menu),
@@ -3617,7 +3617,7 @@
 //             gtk_list_unselect_child(GTK_LIST(input->select->menu),
 //                                     input->select->options[i].menuitem);
 //       }
-      }
+//    }
       break;
    case DILLO_HTML_INPUT_TEXTAREA:
       if (input->init_str != NULL) {
@@ -3798,25 +3798,21 @@
          case DILLO_HTML_INPUT_HIDDEN:
             Html_append_input(DataStr, input->name, input->init_str);
             break;
-//       case DILLO_HTML_INPUT_SELECT:
-//          for (i = 0; i < input->select->num_options; i++) {
-//             if (GTK_CHECK_MENU_ITEM(input->select->options[i].menuitem)->
-//                 active) {
-//                Html_append_input(DataStr, input->name,
-//                                  input->select->options[i].value);
-//                break;
-//             }
-//          }
-//          break;
-//       case DILLO_HTML_INPUT_SEL_LIST:
-//          for (i = 0; i < input->select->num_options; i++) {
-//             if (input->select->options[i].menuitem->state ==
-//                 GTK_STATE_SELECTED) {
-//                Html_append_input(DataStr, input->name,
-//                                  input->select->options[i].value);
-//             }
-//          }
-//          break;
+         case DILLO_HTML_INPUT_SELECT:
+         case DILLO_HTML_INPUT_SEL_LIST:
+         {  // brackets for compiler happiness.
+            SelectionResource *sel_res =
+               (SelectionResource*)((Embed*)input->widget)->getResource();
+            int size = input->select->options->size ();
+            for (int i = 0; i < size; i++) {
+               if (sel_res->isSelected(i)) {
+                  DilloHtmlOption *option =
+                     input->select->options->get (i);
+                  Html_append_input(DataStr, input->name, option->value);
+               }
+            }
+            break;
+         }
 //       case DILLO_HTML_INPUT_INDEX:
 //          Html_urlencode_append(DataStr,
 //             gtk_entry_get_text(GTK_ENTRY(input->widget)));
@@ -4205,7 +4201,8 @@
    Widget *widget;
    int i;
 
-   if (html->InFlags & IN_FORM && html->InFlags & IN_TEXTAREA) {
+   if (html->InFlags & IN_FORM &&
+       html->InFlags & IN_TEXTAREA) {
       /* Remove the line ending that follows the opening tag */
       if (html->Stash->str[0] == '\r')
          dStr_erase(html->Stash, 0, 1);
@@ -4332,28 +4329,29 @@
 /* The select tag is quite tricky, because of gorpy html syntax. */
 static void Html_tag_open_select(DilloHtml *html, const char *tag, int tagsize)
 {
-// DilloHtmlForm *form;
-// DilloHtmlSelect *Select;
-// GtkWidget *widget, *menu;
-// char *name;
 // const char *attrbuf;
 // int size, type, multi;
-//
-// if (!(html->InFlags & IN_FORM)) {
-//    MSG_HTML("<select> outside <form>\n");
-//    return;
-// }
-// if (html->InFlags & IN_SELECT) {
-//    MSG_HTML("nested <select>\n");
-//    return;
-// }
-// html->InFlags |= IN_SELECT;
-//
-//
-// form = forms->getRef (forms->size() - 1);
-//
-// name = Html_get_attr_wdef(html, tag, tagsize, "name", NULL);
-//
+
+   if (!(html->InFlags & IN_FORM)) {
+      MSG_HTML("<select> outside <form>\n");
+      return;
+   }
+   if (html->InFlags & IN_SELECT) {
+      MSG_HTML("nested <select>\n");
+      return;
+   }
+   html->InFlags |= IN_SELECT;
+   html->InFlags &= ~IN_OPTION;
+
+   DilloHtmlForm *form = html->forms->getRef (html->forms->size() - 1);
+   char *name = Html_get_attr_wdef(html, tag, tagsize, "name", NULL);
+   OptionMenuResource *res =
+      HT2LT(html)->getResourceFactory()->createOptionMenuResource ();
+   Widget *widget;
+   Embed *embed;
+   widget = embed = new Embed(res);
+   DW2TB(html->dw)->addWidget (embed, S_TOP(html)->style);
+
 // size = 0;
 // if ((attrbuf = Html_get_attr(html, tag, tagsize, "size")))
 //    size = strtol(attrbuf, NULL, 10);
@@ -4373,17 +4371,13 @@
 //       gtk_list_set_selection_mode(GTK_LIST(menu), GTK_SELECTION_MULTIPLE);
 //    type = DILLO_HTML_INPUT_SEL_LIST;
 // }
-//
-// Select = dNew(DilloHtmlSelect, 1);
-// Select->menu = menu;
-// Select->size = size;
-// Select->num_options = 0;
-// Select->num_options_max = 8;
-// Select->options = dNew(DilloHtmlOption, Select->num_options_max);
-//
-// Html_add_input(form, type, widget, name, NULL, Select, FALSE);
-// Html_stash_init(html);
-// dFree(name);
+
+   DilloHtmlSelect *select = new DilloHtmlSelect;
+   select->options = new misc::SimpleVector<DilloHtmlOption *> (4);
+   Html_add_input(form, DILLO_HTML_INPUT_SELECT, widget, embed, name,
+                  NULL, select, false);
+   Html_stash_init(html);
+   dFree(name);
 }
 
 /*
@@ -4391,47 +4385,19 @@
  */
 static void Html_option_finish(DilloHtml *html)
 {
-// DilloHtmlForm *form;
-// DilloHtmlInput *input;
-// GtkWidget *menuitem;
-// GSList *group;
-// DilloHtmlSelect *select;
-//
-// if (!(html->InFlags & IN_FORM))
-//    return;
-//
-// form = html->forms->getRef (html->forms->size() - 1);
-// input = form->inputs->getRef (form->inputs->size() - 1);
-// if (input->select->num_options <= 0)
-//    return;
-//
-// select = input->select;
-// if (input->type == DILLO_HTML_INPUT_SELECT ) {
-//    if (select->num_options == 1)
-//       group = NULL;
-//    else
-//       group = gtk_radio_menu_item_group(GTK_RADIO_MENU_ITEM
-//                                 (select->options[0].menuitem));
-//    menuitem = gtk_radio_menu_item_new_with_label(group, html->Stash->str);
-//    select->options[select->num_options - 1].menuitem = menuitem;
-//    if (select->options[select->num_options - 1].value == NULL)
-//       select->options[select->num_options - 1].value =
-//           dStrdup(html->Stash->str);
-//    gtk_menu_append(GTK_MENU(select->menu), menuitem);
-//    if (select->options[select->num_options - 1].init_val)
-//       gtk_menu_item_activate(GTK_MENU_ITEM(menuitem));
-//    gtk_widget_show(menuitem);
-// } else if (input->type == DILLO_HTML_INPUT_SEL_LIST) {
-//    menuitem = gtk_list_item_new_with_label(html->Stash->str);
-//    select->options[select->num_options - 1].menuitem = menuitem;
-//    if (select->options[select->num_options - 1].value == NULL)
-//       select->options[select->num_options - 1].value =
-//           dStrdup(html->Stash->str);
-//    gtk_container_add(GTK_CONTAINER(select->menu), menuitem);
-//    if (select->options[select->num_options - 1].init_val)
-//       gtk_list_select_child(GTK_LIST(select->menu), menuitem);
-//    gtk_widget_show(menuitem);
-// }
+   DilloHtmlForm *form =
+      html->forms->getRef (html->forms->size() - 1);
+   DilloHtmlInput *input =
+      form->inputs->getRef (form->inputs->size() - 1);
+   if (input->type == DILLO_HTML_INPUT_SELECT ||
+       input->type == DILLO_HTML_INPUT_SEL_LIST) {
+      DilloHtmlSelect *select =
+         input->select;
+      DilloHtmlOption *option =
+         select->options->get (select->options->size() - 1);
+      option->content =
+         Html_parse_entities(html, html->Stash->str, html->Stash->len);
+   }
 }
 
 /*
@@ -4439,28 +4405,36 @@
  */
 static void Html_tag_open_option(DilloHtml *html, const char *tag, int tagsize)
 {
-// DilloHtmlForm *form;
-// DilloHtmlInput *input;
-// int no;
-//
-// if (!(html->InFlags & IN_SELECT))
-//    return;
-//
-// form = forms->getRef (forms->size() - 1);
-// input = form->inputs->getRef (form->inputs->size() - 1);
-// if (input->type == DILLO_HTML_INPUT_SELECT ||
-//     input->type == DILLO_HTML_INPUT_SEL_LIST) {
-//    Html_option_finish(html);
-//    no = input->select->num_options;
-//    a_List_add(input->select->options, no, input->select->num_options_max);
-//    input->select->options[no].menuitem = NULL;
-//    input->select->options[no].value = Html_get_attr_wdef(html, tag, tagsize,
-//                                                         "value", NULL);
-//    input->select->options[no].init_val =
-//       (Html_get_attr(html, tag, tagsize, "selected") != NULL);
-//    input->select->num_options++;
-// }
-// Html_stash_init(html);
+   if (!(html->InFlags & IN_FORM &&
+         html->InFlags & IN_SELECT ))
+      return;
+   if (html->InFlags & IN_OPTION)
+      Html_option_finish(html);
+   html->InFlags |= IN_OPTION;
+
+   DilloHtmlForm *form =
+      html->forms->getRef (html->forms->size() - 1);
+   DilloHtmlInput *input =
+      form->inputs->getRef (form->inputs->size() - 1);
+
+   if (input->type == DILLO_HTML_INPUT_SELECT ||
+       input->type == DILLO_HTML_INPUT_SEL_LIST) {
+
+      DilloHtmlOption *option = new DilloHtmlOption;
+      option->value =
+         Html_get_attr_wdef(html, tag, tagsize, "value", NULL);
+      option->content = NULL;
+      option->selected =
+         (Html_get_attr(html, tag, tagsize, "selected") != NULL);
+      option->enabled =
+         (Html_get_attr(html, tag, tagsize, "disabled") == NULL);
+
+      int size = input->select->options->size ();
+      input->select->options->increase ();
+      input->select->options->set (size, option);
+   }
+
+   Html_stash_init(html);
 }
 
 /*
@@ -4468,71 +4442,49 @@
  */
 static void Html_tag_close_select(DilloHtml *html, int TagIdx)
 {
-// // AL
-// DilloHtmlForm *form;
-// DilloHtmlInput *input;
-// GtkWidget *scrolledwindow;
-// Widget *embed_gtk;
-// GtkRequisition req;
-// int height;
-//
-// if (html->InFlags & IN_SELECT) {
-//    html->InFlags &= ~IN_SELECT;
-//
-//    form = forms->getRef (forms->size() - 1);
-//    input = form->inputs->getRef (form->inputs->size() - 1);
-//    if (input->type == DILLO_HTML_INPUT_SELECT) {
-//       Html_option_finish(html);
-//
-//       gtk_option_menu_set_menu(GTK_OPTION_MENU(input->widget),
-//                                input->select->menu);
-//       Html_select_set_history(input);
-//
-//       // gtk_option_menu_set_history(GTK_OPTION_MENU(input->widget), 1);
-//
-//       gtk_widget_show(input->widget);
-//
-//       embed_gtk = a_Dw_embed_gtk_new ();
-//       a_Dw_embed_gtk_add_gtk (DW_EMBED_GTK (embed_gtk), input->widget);
-//       DW2TB(html->dw)->addWidget (embed_gtk,
-//                                   S_TOP(html)->style);
-//    } else if (input->type == DILLO_HTML_INPUT_SEL_LIST) {
-//       Html_option_finish(html);
-//
-//       if (input->select->size < input->select->num_options) {
-//          scrolledwindow = gtk_scrolled_window_new(NULL, NULL);
-//          gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwindow),
-//                                         GTK_POLICY_NEVER,
-//                                         GTK_POLICY_AUTOMATIC);
-//          gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW
-//                                                (scrolledwindow),
-//                                                input->widget);
-//
-//          gtk_container_set_focus_vadjustment
-//             (GTK_CONTAINER (input->widget),
-//              gtk_scrolled_window_get_vadjustment
-//              (GTK_SCROLLED_WINDOW(scrolledwindow)));
-//
-//          /* Calculate the height of the scrolled window */
-//          gtk_widget_size_request(input->select->options[0].menuitem, &req);
-//          height = input->select->size * req.height +
-//             2 * scrolledwindow->style->klass->ythickness;
-//          gtk_widget_set_usize(scrolledwindow, -1, height);
-//
-//          gtk_widget_show(input->widget);
-//          input->widget = scrolledwindow;
-//       }
-//       gtk_widget_show(input->widget);
-//
-//       /* note: In this next call, scrolledwindows get a warning from
-//        * gdkwindow.c:422. I'm not really going to sweat it now - the
-//        * embedded widget stuff is going to get massively redone anyway. */
-//       embed_gtk = a_Dw_embed_gtk_new ();
-//       a_Dw_embed_gtk_add_gtk (DW_EMBED_GTK (embed_gtk), input->widget);
-//       DW2TB(html->dw)->addWidget (embed_gtk,
-//                                   S_TOP(html)->style);
-//    }
-// }
+   if (html->InFlags & IN_FORM &&
+       html->InFlags & IN_SELECT) {
+      if (html->InFlags & IN_OPTION)
+         Html_option_finish(html);
+      html->InFlags &= ~IN_SELECT;
+      html->InFlags &= ~IN_OPTION;
+
+      DilloHtmlForm *form =
+         html->forms->getRef (html->forms->size() - 1);
+      DilloHtmlInput *input =
+         form->inputs->getRef (form->inputs->size() - 1);
+      SelectionResource *res =
+         (SelectionResource*)((Embed*)input->widget)->getResource();
+
+      int size = input->select->options->size ();
+      if (size > 0) {
+         // is anything selected? 
+         bool some_selected = false;
+         for (int i = 0; i < size; i++) {
+            DilloHtmlOption *option =
+               input->select->options->get (i);
+            if (option->selected) {
+               some_selected = true;
+               break;
+            }
+         }
+
+         // select the first if nothing else is selected 
+         // BUG(?): should not do this for MULTI selections 
+         if (! some_selected)
+            input->select->options->get (0)->selected = true;
+
+         // add the items to the resource 
+         for (int i = 0; i < size; i++) {
+            DilloHtmlOption *option =
+               input->select->options->get (i);
+            bool enabled = option->enabled;
+            bool selected = option->selected;
+            res->addItem(option->content,enabled,selected);
+         }
+      }
+   }
+
    Html_pop_tag(html, TagIdx);
 }
 
--- a/src/klist.c	Mon Dec 31 22:29:20 2007 +0100
+++ b/src/klist.c	Mon Dec 31 22:48:27 2007 +0100
@@ -18,7 +18,6 @@
  * remains with the caller.
  */
 
-#include "msg.h"
 #include "klist.h"
 
 
--- a/src/nav.c	Mon Dec 31 22:29:20 2007 +0100
+++ b/src/nav.c	Mon Dec 31 22:48:27 2007 +0100
@@ -14,7 +14,6 @@
 #include <stdio.h>
 #include <sys/stat.h>
 #include "msg.h"
-#include "list.h"
 #include "nav.h"
 #include "history.h"
 #include "web.hh"
--- a/src/pixmaps.h	Mon Dec 31 22:29:20 2007 +0100
+++ b/src/pixmaps.h	Mon Dec 31 22:48:27 2007 +0100
@@ -14,7 +14,7 @@
 #define __PIXMAPS_H__
 
 /* XPM
-static char * history_xpm[] = {
+static const char *const history_xpm[] = {
 "11 20 6 1",
 "       c None",
 ".      c #000000000000",
@@ -44,7 +44,7 @@
 "           "};
 */
 /* XPM */
-static char * left_xpm[] = {
+static const char *const left_xpm[] = {
 "22 22 46 1",
 "       c None",
 ".      c #000000",
@@ -115,7 +115,7 @@
 "                   .  ",
 "                      "};
 /* XPM */
-static char * right_xpm[] = {
+static const char *const right_xpm[] = {
 "22 22 46 1",
 "       c None",
 ".      c #000000",
@@ -186,7 +186,7 @@
 "                   .  ",
 "                      "};
 /* XPM */
-static char * reload_xpm[] = {
+static const char *const reload_xpm[] = {
 "22 22 147 2",
 "       c None",
 ".      c #000000",
@@ -358,7 +358,7 @@
 "      . k.l.m.j j n.[.o.h.p.3 3 3 3 3 3 { . ",
 "          . . . . . . . . . . . . . . . . . "};
 /* XPM */
-static char * home_xpm[] = {
+static const char *const home_xpm[] = {
 "22 22 106 2",
 "       c None",
 ".      c #190E0B",
@@ -489,7 +489,7 @@
 "        # # # # # # # # # # # # # #         ",
 "                                            "};
 /* XPM */
-static char * save_xpm[] = {
+static const char *const save_xpm[] = {
 "22 22 59 1",
 "       c None",
 ".      c #000000",
@@ -574,7 +574,7 @@
 "                      "};
 
 /* XPM */
-static char * stop_xpm[] = {
+static const char *const stop_xpm[] = {
 "22 22 77 1",
 "       c None",
 ".      c #000000",
@@ -676,7 +676,7 @@
 "      .........       ",
 "                      "};
 /* XPM */
-static char * bm_xpm[] = {
+static const char *const bm_xpm[] = {
 "22 22 86 1",
 "       c None",
 ".      c #000000",
@@ -790,7 +790,7 @@
 /* Small icons here */
 
 /* XPM */
-static char * left_s_xpm[] = {
+static const char *const left_s_xpm[] = {
 "16 16 33 1",
 "       c None",
 ".      c #000000",
@@ -842,7 +842,7 @@
 "      ..    .;. ",
 "             .  "};
 /* XPM */
-static char * right_s_xpm[] = {
+static const char *const right_s_xpm[] = {
 "16 16 56 1",
 "       c None",
 ".      c #000000",
@@ -917,7 +917,7 @@
 "        ..  .>. ",
 "             .  "};
 /* XPM */
-static char * home_s_xpm[] = {
+static const char *const home_s_xpm[] = {
 "16 16 54 1",
 "       c None",
 ".      c #170E0B",
@@ -990,7 +990,7 @@
 "  +lm+n+mmmml+  ",
 "  ++++o+++++++  "};
 /* XPM */
-static char * reload_s_xpm[] = {
+static const char *const reload_s_xpm[] = {
 "16 16 74 1",
 "       c None",
 ".      c #000000",
@@ -1083,7 +1083,7 @@
 "   .GHI%%IHG.   ",
 "     ......     "};
 /* XPM */
-static char * save_s_xpm[] = {
+static const char *const save_s_xpm[] = {
 "16 16 51 1",
 "       c None",
 ".      c #000000",
@@ -1153,7 +1153,7 @@
 ".h.iiijkkkkkl.. ",
 " .............  "};
 /* XPM */
-static char * stop_s_xpm[] = {
+static const char *const stop_s_xpm[] = {
 "16 16 65 1",
 "       c None",
 ".      c #000000",
@@ -1238,7 +1238,7 @@
 "    ........    "};
 
 /* XPM */
-static char * bm_s_xpm[] = {
+static const char *const bm_s_xpm[] = {
 "16 16 63 1",
 "       c None",
 ".      c #000000",
@@ -1321,7 +1321,7 @@
 "      .v. wx.   "};
 
 /* XPM */
-static char * new_s_xpm[] = {
+static const char *const new_s_xpm[] = {
 "11 11 35 1",
 "       c None",
 ".      c #000000",
@@ -1371,7 +1371,7 @@
 "  .     .  "};
 
 /* XPM */
-static char * search_xpm[] = {
+static const char *const search_xpm[] = {
 "14 16 11 1",
 "       c None",
 ".      c #000000",
@@ -1402,7 +1402,7 @@
 "         11   "};
 
 /* XPM */
-static char * full_screen_on_xpm[] = {
+static const char *const full_screen_on_xpm[] = {
 "13 15 2 1",
 "       c None",
 ".      c #000000",
@@ -1423,7 +1423,7 @@
 "             "};
 
 /* XPM */
-static char * full_screen_off_xpm[] = {
+static const char *const full_screen_off_xpm[] = {
 "13 15 2 1",
 "       c None",
 ".      c #000000",
@@ -1444,7 +1444,7 @@
 "             "};
 
 /* XPM */
-static char * mini_bug_xpm[] = {
+static const char *const mini_bug_xpm[] = {
 "15 16 6 1",
 "       c None",
 ".      c #000000000000",
@@ -1470,7 +1470,7 @@
 "            .  "};
 
 /* XPM */
-static char * mini_ok_xpm[] = {
+static const char *const mini_ok_xpm[] = {
 "15 15 5 1",
 "@ c #000000",
 "a c #808080",
@@ -1495,7 +1495,7 @@
 };
 
 /* XPM */
-static char * imgload_on_xpm[] = {
+static const char *const imgload_on_xpm[] = {
 "15 15 2 1",
 " 	c #FFFFFFFFFFFF",
 ".	c #00000000CF3C",
@@ -1516,7 +1516,7 @@
 "               "};
 
 /* XPM */
-static char * imgload_off_xpm[] = {
+static const char *const imgload_off_xpm[] = {
 "15 15 2 1",
 " 	c #FFFFFFFFFFFF",
 ".	c #CF3C00000000",
@@ -1537,7 +1537,7 @@
 "               "};
 
 /* XPM */
-static char *left_i_xpm[] = {
+static const char *const left_i_xpm[] = {
 "22 22 3 1",
 "  c None",
 ". c #000000",
@@ -1566,7 +1566,7 @@
 "                      "};
 
 /* XPM */
-static char *right_i_xpm[] = {
+static const char *const right_i_xpm[] = {
 "22 22 3 1",
 "  c None",
 ". c #000000",
@@ -1595,7 +1595,7 @@
 "                      "};
 
 /* XPM */
-static char *stop_i_xpm[] = {
+static const char *const stop_i_xpm[] = {
 /* columns rows colors chars-per-pixel */
 "22 22 2 1",
 "       c None",
@@ -1626,7 +1626,7 @@
 };
 
 /* XPM */
-static char * stop_si_xpm[] = {
+static const char *const stop_si_xpm[] = {
 "16 16 2 1",
 "       c None",
 "@      c gray70",
@@ -1648,7 +1648,7 @@
 "    @@@@@@@@    "};
 
 /* XPM */
-static char * left_si_xpm[] = {
+static const char *const left_si_xpm[] = {
 "16 16 2 1",
 "       c None",
 "@      c gray70",
@@ -1670,7 +1670,7 @@
 "             @  "};
 
 /* XPM */
-static char * right_si_xpm[] = {
+static const char *const right_si_xpm[] = {
 "16 16 2 1",
 "       c None",
 "@      c gray70",
--- a/src/plain.cc	Mon Dec 31 22:29:20 2007 +0100
+++ b/src/plain.cc	Mon Dec 31 22:48:27 2007 +0100
@@ -22,9 +22,6 @@
 #include "bw.h"
 #include "web.hh"
 #include "misc.h"
-#include "history.h"
-#include "nav.h"
-#include "menu.hh"
 
 #include "uicmd.hh"