From 550c8cd73c06f0984ce22b844d5a216d332cee43 Mon Sep 17 00:00:00 2001 From: Rob Kendrick Date: Sun, 5 Jan 2014 16:45:32 +0000 Subject: Change gui_file_gadget_interface to pass gui_window not browser_window, add GTK implementation that of course does not work. --- amiga/gui.c | 2 +- atari/gui.c | 2 +- beos/gui.cpp | 2 +- cocoa/gui.m | 2 +- desktop/browser.c | 2 +- desktop/gui.h | 2 +- gtk/gui.c | 7 ------- gtk/window.c | 32 ++++++++++++++++++++++++++++++++ monkey/browser.c | 2 +- riscos/gui.c | 2 +- 10 files changed, 40 insertions(+), 15 deletions(-) diff --git a/amiga/gui.c b/amiga/gui.c index 76185e949..8027eeba0 100644 --- a/amiga/gui.c +++ b/amiga/gui.c @@ -5138,7 +5138,7 @@ void ami_gui_splash_close(Object *win_obj) if(win_obj) DisposeObject(win_obj); } -void gui_file_gadget_open(struct browser_window *bw, hlcache_handle *hl, +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)); diff --git a/atari/gui.c b/atari/gui.c index badb4206c..3b3e98943 100644 --- a/atari/gui.c +++ b/atari/gui.c @@ -1098,7 +1098,7 @@ static void gui_init2(int argc, char** argv) toolbar_init(); } -void gui_file_gadget_open(struct browser_window *bw, hlcache_handle *hl, +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)); diff --git a/beos/gui.cpp b/beos/gui.cpp index 6c9d1ed12..42edc61aa 100644 --- a/beos/gui.cpp +++ b/beos/gui.cpp @@ -1165,7 +1165,7 @@ bool path_add_part(char *path, int length, const char *newpart) return true; } -void gui_file_gadget_open(struct browser_window *bw, hlcache_handle *hl, +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)); diff --git a/cocoa/gui.m b/cocoa/gui.m index 3804ad249..7ee2372f3 100644 --- a/cocoa/gui.m +++ b/cocoa/gui.m @@ -324,7 +324,7 @@ void gui_401login_open(nsurl *url, const char *realm, cb( false, cbpw ); } -void gui_file_gadget_open(struct browser_window *bw, hlcache_handle *hl, +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)); diff --git a/desktop/browser.c b/desktop/browser.c index 3d279f727..6ec31d22f 100644 --- a/desktop/browser.c +++ b/desktop/browser.c @@ -1564,7 +1564,7 @@ static nserror browser_window_callback(hlcache_handle *c, case CONTENT_MSG_GADGETCLICK: if (event->data.gadget_click.gadget->type == GADGET_FILE) { - gui_file_gadget_open(bw, c, + gui_file_gadget_open(bw->window, c, event->data.gadget_click.gadget); } diff --git a/desktop/gui.h b/desktop/gui.h index 4bbf08718..26a9f4b43 100644 --- a/desktop/gui.h +++ b/desktop/gui.h @@ -116,7 +116,7 @@ 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 browser_window *bw, hlcache_handle *hl, +void gui_file_gadget_open(struct gui_window *g, hlcache_handle *hl, struct form_control *gadget); /** diff --git a/gtk/gui.c b/gtk/gui.c index 0f815a7a2..77b72f874 100644 --- a/gtk/gui.c +++ b/gtk/gui.c @@ -681,13 +681,6 @@ void gui_quit(void) gtk_fetch_filetype_fin(); } -void gui_file_gadget_open(struct browser_window *bw, hlcache_handle *hl, - struct form_control *gadget) -{ - LOG(("File open dialog rquest for %p/%p", bw, gadget)); - /* browser_window_set_gadget_filename(bw, gadget, "plinth"); */ -} - static void nsgtk_select_menu_clicked(GtkCheckMenuItem *checkmenuitem, gpointer user_data) { 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 47fb07bc1..7c28cf8a3 100644 --- a/monkey/browser.c +++ b/monkey/browser.c @@ -390,7 +390,7 @@ gui_window_save_link(struct gui_window *g, const char *url, g->win_num, url, title); } -void gui_file_gadget_open(struct browser_window *bw, hlcache_handle *hl, +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)); diff --git a/riscos/gui.c b/riscos/gui.c index 0c8ebecc7..900915483 100644 --- a/riscos/gui.c +++ b/riscos/gui.c @@ -2424,7 +2424,7 @@ bool path_add_part(char *path, int length, const char *newpart) return true; } -void gui_file_gadget_open(struct browser_window *bw, hlcache_handle *hl, +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)); -- cgit v1.2.3