diff options
-rw-r--r-- | amiga/gui.c | 12 | ||||
-rw-r--r-- | atari/gui.c | 7 | ||||
-rw-r--r-- | beos/gui.cpp | 8 | ||||
-rw-r--r-- | cocoa/gui.m | 7 | ||||
-rw-r--r-- | content/content.h | 7 | ||||
-rw-r--r-- | css/css.c | 13 | ||||
-rw-r--r-- | desktop/browser.c | 19 | ||||
-rw-r--r-- | desktop/browser.h | 3 | ||||
-rw-r--r-- | desktop/gui.h | 3 | ||||
-rw-r--r-- | desktop/searchweb.c | 8 | ||||
-rw-r--r-- | gtk/gui.c | 4 | ||||
-rw-r--r-- | gtk/theme.c | 14 | ||||
-rw-r--r-- | gtk/window.c | 32 | ||||
-rw-r--r-- | monkey/browser.c | 7 | ||||
-rw-r--r-- | render/html.c | 66 | ||||
-rw-r--r-- | render/html.h | 2 | ||||
-rw-r--r-- | render/html_css.c | 10 | ||||
-rw-r--r-- | render/html_interaction.c | 4 | ||||
-rw-r--r-- | render/html_object.c | 7 | ||||
-rw-r--r-- | render/html_script.c | 30 | ||||
-rw-r--r-- | riscos/gui.c | 8 | ||||
-rw-r--r-- | riscos/theme_install.c | 6 |
22 files changed, 162 insertions, 115 deletions
diff --git a/amiga/gui.c b/amiga/gui.c index 103d3a1e8..8027eeba0 100644 --- a/amiga/gui.c +++ b/amiga/gui.c @@ -4232,8 +4232,8 @@ static void ami_gui_window_update_box_deferred(struct gui_window *g, bool draw) static bool ami_gui_window_update_box_deferred_check(struct MinList *deferred_rects, const struct rect *new_rect) { - struct nsObject *node; - struct nsObject *nnode; +struct nsObject *node; +struct nsObject *nnode; struct rect *rect; if(IsMinListEmpty(deferred_rects)) return true; @@ -5137,3 +5137,11 @@ void ami_gui_splash_close(Object *win_obj) { if(win_obj) DisposeObject(win_obj); } + +void gui_file_gadget_open(struct gui_window *g, hlcache_handle *hl, + struct form_control *gadget) +{ + LOG(("File open dialog rquest for %p/%p", bw, gadget)); + /* browser_window_set_gadget_filename(bw, gadget, "filename"); */ +} + diff --git a/atari/gui.c b/atari/gui.c index e52a6589c..3b3e98943 100644 --- a/atari/gui.c +++ b/atari/gui.c @@ -1098,6 +1098,13 @@ static void gui_init2(int argc, char** argv) toolbar_init(); } +void gui_file_gadget_open(struct gui_window *g, hlcache_handle *hl, + struct form_control *gadget) +{ + LOG(("File open dialog rquest for %p/%p", bw, gadget)); + /* browser_window_set_gadget_filename(bw, gadget, "filename"); */ +} + /* #define WITH_DBG_LOGFILE 1 */ /** Entry point from OS. * diff --git a/beos/gui.cpp b/beos/gui.cpp index 204c11caf..42edc61aa 100644 --- a/beos/gui.cpp +++ b/beos/gui.cpp @@ -1164,3 +1164,11 @@ bool path_add_part(char *path, int length, const char *newpart) return true; } + +void gui_file_gadget_open(struct gui_window *g, hlcache_handle *hl, + struct form_control *gadget) +{ + LOG(("File open dialog rquest for %p/%p", bw, gadget)); + /* browser_window_set_gadget_filename(bw, gadget, "filename"); */ +} + diff --git a/cocoa/gui.m b/cocoa/gui.m index b2ff01dc0..7ee2372f3 100644 --- a/cocoa/gui.m +++ b/cocoa/gui.m @@ -324,3 +324,10 @@ void gui_401login_open(nsurl *url, const char *realm, cb( false, cbpw ); } +void gui_file_gadget_open(struct gui_window *g, hlcache_handle *hl, + struct form_control *gadget) +{ + LOG(("File open dialog rquest for %p/%p", bw, gadget)); + /* browser_window_set_gadget_filename(bw, gadget, "filename"); */ +} + diff --git a/content/content.h b/content/content.h index 467fa6055..91a6ae9df 100644 --- a/content/content.h +++ b/content/content.h @@ -83,7 +83,8 @@ typedef enum { CONTENT_MSG_POINTER, /**< Wants a specific mouse pointer set */ CONTENT_MSG_SELECTION, /**< A selection made or cleared */ CONTENT_MSG_CARET, /**< Caret movement / hiding */ - CONTENT_MSG_DRAG /**< A drag started or ended */ + CONTENT_MSG_DRAG, /**< A drag started or ended */ + CONTENT_MSG_GADGETCLICK/**< A gadget has been clicked on (mainly for file) */ } content_msg; /** RFC5988 metadata link */ @@ -190,6 +191,10 @@ union content_msg_data { } type; const struct rect *rect; } drag; + /** CONTENT_MSG_GADGETCLICK - User clicked on a form gadget */ + struct { + struct form_control *gadget; + } gadget_click; }; /** parameters to content redraw */ @@ -655,19 +655,8 @@ nserror nscss_import(hlcache_handle *handle, /* Already released handle */ break; - case CONTENT_MSG_LOADING: - case CONTENT_MSG_READY: - case CONTENT_MSG_STATUS: - case CONTENT_MSG_REDIRECT: - /* messages content handler will legitamately recive - * but does not need to handle - */ - break; - default: - /* all other messages are unexpected and fatal */ - LOG(("Unhandled message type %d", event->type)); - assert(0); + break; } /* Preserve out-of-memory. Anything else is OK */ diff --git a/desktop/browser.c b/desktop/browser.c index d159a5599..6ec31d22f 100644 --- a/desktop/browser.c +++ b/desktop/browser.c @@ -661,6 +661,13 @@ bool browser_window_drop_file_at_point(struct browser_window *bw, return false; } +void browser_window_set_gadget_filename(struct browser_window *bw, + struct form_control *gadget, const char *fn) +{ + html_set_file_gadget_filename(bw->current_content, + gadget, fn); +} + /* exported interface, documented in browser.h */ void browser_window_debug_dump(struct browser_window *bw, FILE *f) { @@ -1162,7 +1169,7 @@ static void browser_window_convert_to_download(struct browser_window *bw, /** - * Callback for fetchcache() for browser window fetches. + * Callback handler for content event messages. */ static nserror browser_window_callback(hlcache_handle *c, @@ -1555,8 +1562,16 @@ static nserror browser_window_callback(hlcache_handle *c, event->data.selection.read_only); break; + case CONTENT_MSG_GADGETCLICK: + if (event->data.gadget_click.gadget->type == GADGET_FILE) { + gui_file_gadget_open(bw->window, c, + event->data.gadget_click.gadget); + } + + break; + default: - assert(0); + break; } return NSERROR_OK; diff --git a/desktop/browser.h b/desktop/browser.h index ee55e72c4..0ca2e009b 100644 --- a/desktop/browser.h +++ b/desktop/browser.h @@ -173,6 +173,9 @@ bool browser_window_scroll_at_point(struct browser_window *bw, bool browser_window_drop_file_at_point(struct browser_window *bw, int x, int y, char *file); +void browser_window_set_gadget_filename(struct browser_window *bw, + struct form_control *gadget, const char *fn); + void browser_window_refresh_url_bar(struct browser_window *bw, nsurl *url, lwc_string *frag); diff --git a/desktop/gui.h b/desktop/gui.h index 9d35e1727..26a9f4b43 100644 --- a/desktop/gui.h +++ b/desktop/gui.h @@ -116,7 +116,8 @@ void gui_drag_save_selection(struct gui_window *g, const char *selection); void gui_start_selection(struct gui_window *g); void gui_clear_selection(struct gui_window *g); - +void gui_file_gadget_open(struct gui_window *g, hlcache_handle *hl, + struct form_control *gadget); /** * Core asks front end for clipboard contents. diff --git a/desktop/searchweb.c b/desktop/searchweb.c index 87e3e21f1..4c050d97a 100644 --- a/desktop/searchweb.c +++ b/desktop/searchweb.c @@ -304,9 +304,6 @@ nserror search_web_ico_callback(hlcache_handle *ico, const hlcache_event *event, void *pw) { switch (event->type) { - case CONTENT_MSG_LOADING: - case CONTENT_MSG_READY: - break; case CONTENT_MSG_DONE: LOG(("got favicon '%s'", nsurl_access(hlcache_handle_get_url(ico)))); @@ -322,11 +319,8 @@ nserror search_web_ico_callback(hlcache_handle *ico, search_web_retrieve_ico(true); break; - case CONTENT_MSG_STATUS: - break; - default: - assert(0); + break; } return NSERROR_OK; @@ -681,10 +681,6 @@ void gui_quit(void) gtk_fetch_filetype_fin(); } - - - - static void nsgtk_select_menu_clicked(GtkCheckMenuItem *checkmenuitem, gpointer user_data) { diff --git a/gtk/theme.c b/gtk/theme.c index 9d50c5931..ff0144cc8 100644 --- a/gtk/theme.c +++ b/gtk/theme.c @@ -793,11 +793,8 @@ theme_install_callback(hlcache_handle *c, const hlcache_event *event, void *pw) { switch (event->type) { - case CONTENT_MSG_READY: - break; - case CONTENT_MSG_DONE: - { + case CONTENT_MSG_DONE: { const char *source_data; unsigned long source_size; @@ -807,21 +804,14 @@ theme_install_callback(hlcache_handle *c, warn_user("ThemeInvalid", 0); hlcache_handle_release(c); + break; } - break; case CONTENT_MSG_ERROR: warn_user(event->data.error, 0); break; - case CONTENT_MSG_STATUS: - break; - - case CONTENT_MSG_LOADING: - case CONTENT_MSG_REFORMAT: - case CONTENT_MSG_REDRAW: default: - assert(0); break; } diff --git a/gtk/window.c b/gtk/window.c index 8f449ced2..8f05c3799 100644 --- a/gtk/window.c +++ b/gtk/window.c @@ -1162,3 +1162,35 @@ void gui_window_get_dimensions(struct gui_window *g, int *width, int *height, LOG(("width: %i", *width)); LOG(("height: %i", *height)); } + +void gui_file_gadget_open(struct gui_window *g, hlcache_handle *hl, + struct form_control *gadget) +{ + GtkWidget *dialog; + + LOG(("Awooga.")); + + dialog = gtk_file_chooser_dialog_new("Select File", + nsgtk_scaffolding_window(g->scaffold), + GTK_FILE_CHOOSER_ACTION_OPEN, + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, + NULL); + + LOG(("*** open dialog: %p", dialog)); + + int ret = gtk_dialog_run(GTK_DIALOG(dialog)); + LOG(("*** return value: %d", ret)); + if (ret == GTK_RESPONSE_ACCEPT) { + char *filename; + + filename = gtk_file_chooser_get_filename( + GTK_FILE_CHOOSER(dialog)); + + browser_window_set_gadget_filename(g->bw, gadget, filename); + + g_free(filename); + } + + gtk_widget_destroy(dialog); +} diff --git a/monkey/browser.c b/monkey/browser.c index 09ecf4b11..7c28cf8a3 100644 --- a/monkey/browser.c +++ b/monkey/browser.c @@ -390,6 +390,13 @@ gui_window_save_link(struct gui_window *g, const char *url, g->win_num, url, title); } +void gui_file_gadget_open(struct gui_browser *g, hlcache_handle *hl, + struct form_control *gadget) +{ + LOG(("File open dialog rquest for %p/%p", bw, gadget)); + /* browser_window_set_gadget_filename(bw, gadget, "filename"); */ +} + /**** Handlers ****/ diff --git a/render/html.c b/render/html.c index 25147a0a0..e10f1e930 100644 --- a/render/html.c +++ b/render/html.c @@ -1762,6 +1762,44 @@ static void html__dom_user_data_handler(dom_node_operation operation, } } +static void html__set_file_gadget_filename(struct content *c, + struct form_control *gadget, const char *fn) +{ + utf8_convert_ret ret; + char *utf8_fn, *oldfile = NULL; + html_content *html = (html_content *)c; + struct box *file_box = gadget->box; + + ret = utf8_from_local_encoding(fn,0, &utf8_fn); + if (ret != UTF8_CONVERT_OK) { + assert(ret != UTF8_CONVERT_BADENC); + LOG(("utf8_from_local_encoding failed")); + /* Load was for us - just no memory */ + return; + } + + form_gadget_update_value(html, gadget, utf8_fn); + + /* corestring_dom___ns_key_file_name_node_data */ + if (dom_node_set_user_data((dom_node *)file_box->gadget->node, + corestring_dom___ns_key_file_name_node_data, + strdup(fn), html__dom_user_data_handler, + &oldfile) == DOM_NO_ERR) { + if (oldfile != NULL) + free(oldfile); + } + + /* Redraw box. */ + html__redraw_a_box(html, file_box); +} + +void html_set_file_gadget_filename(struct hlcache_handle *hl, + struct form_control *gadget, const char *fn) +{ + return html__set_file_gadget_filename(hlcache_handle_get_content(hl), + gadget, fn); +} + /** * Drop a file onto a content at a particular point, or determine if a file * may be dropped onto the content at given point. @@ -1827,33 +1865,7 @@ static bool html_drop_file_at_point(struct content *c, int x, int y, char *file) /* Handle the drop */ if (file_box) { /* File dropped on file input */ - utf8_convert_ret ret; - char *utf8_fn, *oldfile = NULL; - - ret = utf8_from_local_encoding(file, 0, - &utf8_fn); - if (ret != UTF8_CONVERT_OK) { - /* A bad encoding should never happen */ - assert(ret != UTF8_CONVERT_BADENC); - LOG(("utf8_from_local_encoding failed")); - /* Load was for us - just no memory */ - return true; - } - - /* Found: update form input */ - form_gadget_update_value(html, file_box->gadget, utf8_fn); - - /* corestring_dom___ns_key_file_name_node_data */ - if (dom_node_set_user_data((dom_node *)file_box->gadget->node, - corestring_dom___ns_key_file_name_node_data, - strdup(file), html__dom_user_data_handler, - &oldfile) == DOM_NO_ERR) { - if (oldfile != NULL) - free(oldfile); - } - - /* Redraw box. */ - html__redraw_a_box(html, file_box); + html__set_file_gadget_filename(c, box->gadget, file); } else { /* File dropped on text input */ diff --git a/render/html.h b/render/html.h index 162541d72..7ca75e713 100644 --- a/render/html.h +++ b/render/html.h @@ -178,6 +178,8 @@ struct content_html_frames *html_get_frameset(struct hlcache_handle *h); struct content_html_iframe *html_get_iframe(struct hlcache_handle *h); nsurl *html_get_base_url(struct hlcache_handle *h); const char *html_get_base_target(struct hlcache_handle *h); +void html_set_file_gadget_filename(struct hlcache_handle *hl, + struct form_control *gadget, const char *fn); /** * Retrieve stylesheets used by HTML document diff --git a/render/html_css.c b/render/html_css.c index 88c67697d..ad24804a9 100644 --- a/render/html_css.c +++ b/render/html_css.c @@ -97,14 +97,6 @@ html_convert_css_callback(hlcache_handle *css, assert(i != parent->stylesheet_count); switch (event->type) { - case CONTENT_MSG_LOADING: - break; - - case CONTENT_MSG_READY: - break; - - case CONTENT_MSG_REDIRECT: - break; case CONTENT_MSG_DONE: LOG(("done stylesheet slot %d '%s'", i, @@ -143,7 +135,7 @@ html_convert_css_callback(hlcache_handle *css, return NSERROR_OK; default: - assert(0); + break; } if (html_can_begin_conversion(parent)) { diff --git a/render/html_interaction.c b/render/html_interaction.c index 5d69c987f..84c64ca20 100644 --- a/render/html_interaction.c +++ b/render/html_interaction.c @@ -741,6 +741,10 @@ void html_mouse_action(struct content *c, struct browser_window *bw, break; case GADGET_FILE: status = messages_get("FormFile"); + if (mouse & BROWSER_MOUSE_CLICK_1) { + msg_data.gadget_click.gadget = gadget; + content_broadcast(c, CONTENT_MSG_GADGETCLICK, msg_data); + } break; case GADGET_BUTTON: /* This gadget cannot be activated */ diff --git a/render/html_object.c b/render/html_object.c index 6cd08c1ef..e76919dd4 100644 --- a/render/html_object.c +++ b/render/html_object.c @@ -208,10 +208,6 @@ html_object_callback(hlcache_handle *object, } break; - case CONTENT_MSG_REFORMAT: - case CONTENT_MSG_REDIRECT: - break; - case CONTENT_MSG_REDRAW: if (c->base.status != CONTENT_STATUS_LOADING) { union content_msg_data data = event->data; @@ -377,6 +373,7 @@ html_object_callback(hlcache_handle *object, case CONTENT_MSG_SAVELINK: case CONTENT_MSG_POINTER: + case CONTENT_MSG_GADGETCLICK: /* These messages are for browser window layer. * we're not interested, so pass them on. */ content_broadcast(&c->base, event->type, event->data); @@ -445,7 +442,7 @@ html_object_callback(hlcache_handle *object, break; default: - assert(0); + break; } if (c->base.status == CONTENT_STATUS_READY && c->base.active == 0 && diff --git a/render/html_script.c b/render/html_script.c index 4aa8aff11..4a82bcd70 100644 --- a/render/html_script.c +++ b/render/html_script.c @@ -172,8 +172,6 @@ convert_script_async_cb(hlcache_handle *script, parent->base.active--; LOG(("%d fetches active", parent->base.active)); - - break; case CONTENT_MSG_ERROR: @@ -188,11 +186,8 @@ convert_script_async_cb(hlcache_handle *script, break; - case CONTENT_MSG_STATUS: - break; - default: - assert(0); + break; } return NSERROR_OK; @@ -219,11 +214,6 @@ convert_script_defer_cb(hlcache_handle *script, assert(i != parent->scripts_count); switch (event->type) { - case CONTENT_MSG_LOADING: - break; - - case CONTENT_MSG_READY: - break; case CONTENT_MSG_DONE: LOG(("script %d done '%s'", i, @@ -245,11 +235,8 @@ convert_script_defer_cb(hlcache_handle *script, break; - case CONTENT_MSG_STATUS: - break; - default: - assert(0); + break; } /* if there are no active fetches remaining begin post parse @@ -333,19 +320,8 @@ convert_script_sync_cb(hlcache_handle *script, break; - case CONTENT_MSG_LOADING: - case CONTENT_MSG_READY: - case CONTENT_MSG_STATUS: - case CONTENT_MSG_REDIRECT: - /* messages content handler will legitamately recive - * but does not need to handle - */ - break; - default: - /* all other messages are unexpected and fatal */ - LOG(("Unhandled message type %d", event->type)); - assert(0); + break; } /* if there are no active fetches remaining begin post parse diff --git a/riscos/gui.c b/riscos/gui.c index bb1a318de..900915483 100644 --- a/riscos/gui.c +++ b/riscos/gui.c @@ -2423,3 +2423,11 @@ bool path_add_part(char *path, int length, const char *newpart) return true; } + +void gui_file_gadget_open(struct gui_window *g, hlcache_handle *hl, + struct form_control *gadget) +{ + LOG(("File open dialog rquest for %p/%p", bw, gadget)); + /* browser_window_set_gadget_filename(bw, gadget, "filename"); */ +} + diff --git a/riscos/theme_install.c b/riscos/theme_install.c index 0d436dce8..82377facf 100644 --- a/riscos/theme_install.c +++ b/riscos/theme_install.c @@ -89,8 +89,6 @@ nserror theme_install_callback(hlcache_handle *handle, int author_indent = 0; switch (event->type) { - case CONTENT_MSG_READY: - break; case CONTENT_MSG_DONE: { @@ -129,11 +127,7 @@ nserror theme_install_callback(hlcache_handle *handle, warn_user(event->data.error, 0); break; - case CONTENT_MSG_STATUS: - break; - default: - assert(0); break; } |