diff options
Diffstat (limited to 'src/form.cc')
-rw-r--r-- | src/form.cc | 50 |
1 files changed, 18 insertions, 32 deletions
diff --git a/src/form.cc b/src/form.cc index 11f27b47..454b052c 100644 --- a/src/form.cc +++ b/src/form.cc @@ -177,6 +177,7 @@ public: void addOption (char *value, bool selected, bool enabled); void ensureSelection (); void addOptionsTo (SelectionResource *res); + void reset (SelectionResource *res); void appendValuesTo (Dlist *values, SelectionResource *res); }; @@ -547,10 +548,11 @@ void Html_tag_open_input(DilloHtml *html, const char *tag, int tagsize) if (a_Html_get_attr(html, tag, tagsize, "readonly")) ((EntryResource *) resource)->setEditable(false); -// /* Maximum length of the text in the entry */ -// if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "maxlength"))) -// gtk_entry_set_max_length(GTK_ENTRY(widget), -// strtol(attrbuf, NULL, 10)); + /* Maximum length of the text in the entry */ + if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "maxlength"))) { + int maxlen = strtol(attrbuf, NULL, 10); + ((EntryResource *) resource)->setMaxLength(maxlen); + } } if (prefs.show_tooltip && (attrbuf = a_Html_get_attr(html, tag, tagsize, "title"))) { @@ -982,8 +984,6 @@ void DilloHtmlForm::submit(DilloHtmlInput *active_input, EventButton *event) } a_Url_free(url); } - // /* now, make the rendered area have its focus back */ - // gtk_widget_grab_focus(GTK_BIN(bw->render_main_scroll)->child); } /* @@ -1764,35 +1764,12 @@ void DilloHtmlInput::reset () } break; case DILLO_HTML_INPUT_SELECT: + case DILLO_HTML_INPUT_SEL_LIST: if (select != NULL) { - /* 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 = select->num_options - 1; i >= 0; i--) { -// if (select->options[i].init_val) { -// gtk_menu_item_activate(GTK_MENU_ITEM -// (select->options[i].menuitem)); -// Html_select_set_history(input); -// break; -// } -// } + SelectionResource *sr = (SelectionResource *) embed->getResource(); + select->reset(sr); } break; - case DILLO_HTML_INPUT_SEL_LIST: - if (!select) - break; -// for (i = 0; i < select->num_options; i++) { -// if (select->options[i].init_val) { -// if (select->options[i].menuitem->state == GTK_STATE_NORMAL) -// gtk_list_select_child(GTK_LIST(select->menu), -// select->options[i].menuitem); -// } else { -// if (select->options[i].menuitem->state==GTK_STATE_SELECTED) -// gtk_list_unselect_child(GTK_LIST(select->menu), -// select->options[i].menuitem); -// } -// } - break; case DILLO_HTML_INPUT_TEXTAREA: if (init_str != NULL) { MultiLineTextResource *textres = @@ -1874,6 +1851,15 @@ void DilloHtmlSelect::addOptionsTo (SelectionResource *res) } } +void DilloHtmlSelect::reset (SelectionResource *res) +{ + int size = options->size (); + for (int i = 0; i < size; i++) { + DilloHtmlOption *option = options->get (i); + res->setItem(i, option->selected); + } +} + void DilloHtmlSelect::appendValuesTo (Dlist *values, SelectionResource *res) { int size = options->size (); |