summaryrefslogtreecommitdiff
path: root/src/form.cc
diff options
context:
space:
mode:
authorcorvid <corvid@lavabit.com>2012-11-24 20:09:42 +0000
committercorvid <corvid@lavabit.com>2012-11-24 20:09:42 +0000
commitfae8ba37e74976b59ab41932d3b2c2165c688d91 (patch)
tree337c2de438120671b0a50380bed71057c60e64cc /src/form.cc
parentd9bccd6d15eb017964fbdfc3aba428dfbc4764b2 (diff)
reset for <select>
Diffstat (limited to 'src/form.cc')
-rw-r--r--src/form.cc39
1 files changed, 13 insertions, 26 deletions
diff --git a/src/form.cc b/src/form.cc
index 11f27b47..b495e7b4 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);
};
@@ -1764,35 +1765,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 +1852,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 ();