diff options
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/dialogs/preferences.c | 4 | ||||
-rw-r--r-- | gtk/download.c | 30 | ||||
-rw-r--r-- | gtk/download.h | 2 | ||||
-rw-r--r-- | gtk/gui.c | 240 | ||||
-rw-r--r-- | gtk/gui.h | 6 | ||||
-rw-r--r-- | gtk/login.c | 1 | ||||
-rw-r--r-- | gtk/scaffolding.c | 5 | ||||
-rw-r--r-- | gtk/scaffolding.h | 7 | ||||
-rw-r--r-- | gtk/selection.c | 11 | ||||
-rw-r--r-- | gtk/selection.h | 4 | ||||
-rw-r--r-- | gtk/toolbar.c | 4 | ||||
-rw-r--r-- | gtk/window.c | 137 | ||||
-rw-r--r-- | gtk/window.h | 3 |
13 files changed, 236 insertions, 218 deletions
diff --git a/gtk/dialogs/preferences.c b/gtk/dialogs/preferences.c index 0669f8d9f..18c8d7b6c 100644 --- a/gtk/dialogs/preferences.c +++ b/gtk/dialogs/preferences.c @@ -944,9 +944,7 @@ nsgtk_preferences_comboSearch_changed(GtkComboBox *widget, struct ppref *priv) search_web_retrieve_ico(false); /* callback may handle changing gui */ - if (search_web_ico() != NULL) { - gui_window_set_search_ico(search_web_ico()); - } + gui_set_search_ico(search_web_ico()); /* set entry */ name = search_web_provider_name(); diff --git a/gtk/download.c b/gtk/download.c index e882ec798..3d287d4d2 100644 --- a/gtk/download.c +++ b/gtk/download.c @@ -712,8 +712,8 @@ static void nsgtk_download_store_create_item (struct gui_download_window *dl) NSGTK_DOWNLOAD, dl, -1); } -struct gui_download_window *gui_download_window_create(download_context *ctx, - struct gui_window *gui) +static struct gui_download_window * +gui_download_window_create(download_context *ctx, struct gui_window *gui) { const char *url = download_context_get_url(ctx); unsigned long total_size = download_context_get_total_length(ctx); @@ -797,7 +797,7 @@ struct gui_download_window *gui_download_window_create(download_context *ctx, } -nserror gui_download_window_data(struct gui_download_window *dw, +static nserror gui_download_window_data(struct gui_download_window *dw, const char *data, unsigned int size) { g_io_channel_write_chars(dw->write, data, size, NULL, &dw->error); @@ -820,13 +820,13 @@ nserror gui_download_window_data(struct gui_download_window *dw, } -void gui_download_window_error(struct gui_download_window *dw, +static void gui_download_window_error(struct gui_download_window *dw, const char *error_msg) { } -void gui_download_window_done(struct gui_download_window *dw) +static void gui_download_window_done(struct gui_download_window *dw) { g_io_channel_shutdown(dw->write, TRUE, &dw->error); g_io_channel_unref(dw->write); @@ -845,17 +845,11 @@ void gui_download_window_done(struct gui_download_window *dw) } +static struct gui_download_table download_table = { + .create = gui_download_window_create, + .data = gui_download_window_data, + .error = gui_download_window_error, + .done = gui_download_window_done, +}; - - - - - - - - - - - - - +struct gui_download_table *nsgtk_download_table = &download_table; diff --git a/gtk/download.h b/gtk/download.h index e85c4126a..a6e624fbd 100644 --- a/gtk/download.h +++ b/gtk/download.h @@ -21,6 +21,8 @@ #include <gtk/gtk.h> +struct gui_download_table *nsgtk_download_table; + bool nsgtk_download_init(const char *glade_file_location); void nsgtk_download_destroy (void); bool nsgtk_check_for_downloads(GtkWindow *parent); @@ -55,6 +55,7 @@ #include "desktop/textinput.h" #include "desktop/tree.h" #include "css/utils.h" + #include "gtk/compat.h" #include "gtk/completion.h" #include "gtk/cookies.h" @@ -67,6 +68,7 @@ #include "gtk/treeview.h" #include "gtk/window.h" #include "gtk/schedule.h" +#include "gtk/selection.h" #include "render/form.h" #include "utils/filepath.h" @@ -183,7 +185,7 @@ nsgtk_new_ui(char **respath, const char *name, GtkBuilder **pglade) filepath = filepath_find(respath, resname); if (filepath == NULL) { - snprintf(errorstr, NEW_GLADE_ERROR_SIZE, + snprintf(errorstr, NEW_GLADE_ERROR_SIZE, "Unable to locate %s glade template file.\n", name); die(errorstr); } @@ -192,7 +194,7 @@ nsgtk_new_ui(char **respath, const char *name, GtkBuilder **pglade) if (!gtk_builder_add_from_file(builder, filepath, &error)) { g_warning ("Couldn't load builder file: %s", error->message); g_error_free (error); - snprintf(errorstr, NEW_GLADE_ERROR_SIZE, + snprintf(errorstr, NEW_GLADE_ERROR_SIZE, "Unable to load glade %s window definitions.\n", name); die(errorstr); @@ -212,7 +214,7 @@ nsgtk_new_ui(char **respath, const char *name, GtkBuilder **pglade) /** * Load definitions from glade files. */ -static void +static void nsgtk_init_glade(char **respath) { GtkBuilder *gladeWarning; @@ -322,7 +324,7 @@ static void check_options(char **respath) } -nsurl *gui_get_resource_url(const char *path) +static nsurl *gui_get_resource_url(const char *path) { char buf[PATH_MAX]; char *raw; @@ -334,7 +336,7 @@ nsurl *gui_get_resource_url(const char *path) /* favicon.ico -> favicon.png */ if (strcmp(path, "favicon.ico") == 0) - path = "favicon.png"; + path = "favicon.png"; raw = path_to_url(filepath_sfind(respaths, buf, path)); if (raw != NULL) { @@ -357,32 +359,32 @@ static void gui_init(int argc, char** argv, char **respath) nsurl *url; nserror error; - /* find the languages file */ + /* find the languages file */ languages_file_location = filepath_find(respath, "languages"); - if ((languages_file_location == NULL) || + if ((languages_file_location == NULL) || (strlen(languages_file_location) < 10)) { - die("Unable to find resources.\n"); + die("Unable to find resources.\n"); } - /* find the theme list file */ + /* find the theme list file */ themelist_file_location = filepath_find(respath, "themelist"); if ((themelist_file_location != NULL) && (strlen(themelist_file_location) < 10)) { free(themelist_file_location); themelist_file_location = NULL; } - if (themelist_file_location == NULL) { + if (themelist_file_location == NULL) { LOG(("Unable to find themelist - disabling")); } - /* Obtain resources path location. + /* Obtain resources path location. * * Uses the directory the languages file was found in, * @todo find and slaughter all references to this! */ res_dir_location = calloc(1, strlen(languages_file_location) - 8); - memcpy(res_dir_location, - languages_file_location, + memcpy(res_dir_location, + languages_file_location, strlen(languages_file_location) - 9); LOG(("Using '%s' for resource path", res_dir_location)); @@ -411,7 +413,7 @@ static void gui_init(int argc, char** argv, char **respath) free(resource_filename); if (favicon_pixbuf == NULL) { favicon_pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, false, 8, 16,16); - + } } @@ -419,7 +421,7 @@ static void gui_init(int argc, char** argv, char **respath) toolbar_indices_file_location = filepath_find(respath, "toolbarIndices"); LOG(("Using '%s' as custom toolbar settings file", toolbar_indices_file_location)); - /* load throbber images */ + /* load throbber images */ if (nsgtk_throbber_init(respath, THROBBER_FRAMES) == false) die("Unable to load throbber image.\n"); @@ -535,75 +537,15 @@ static void nsgtk_check_homedir(void) */ static bool nslog_stream_configure(FILE *fptr) { - /* set log stream to be non-buffering */ + /* set log stream to be non-buffering */ setbuf(fptr, NULL); return true; } -/** - * Main entry point from OS. - */ -int main(int argc, char** argv) -{ - char *messages; - char *options; - nserror ret; - - /* check home directory is available */ - nsgtk_check_homedir(); - respaths = nsgtk_init_resource("${HOME}/.netsurf/:${NETSURFRES}:"GTK_RESPATH":./gtk/res"); - gtk_init(&argc, &argv); - - /* initialise logging. Not fatal if it fails but not much we - * can do about it either. - */ - nslog_init(nslog_stream_configure, &argc, argv); - - /* user options setup */ - ret = nsoption_init(set_defaults, &nsoptions, &nsoptions_default); - if (ret != NSERROR_OK) { - fprintf(stderr, "Options failed to initialise (%s)\n", - messages_get_errorcode(ret)); - return 1; - } - options = filepath_find(respaths, "Choices"); - nsoption_read(options, nsoptions); - free(options); - nsoption_commandline(&argc, argv, nsoptions); - check_options(respaths); /* check user options */ - - /* common initialisation */ - messages = filepath_find(respaths, "Messages"); - ret = netsurf_init(messages); - free(messages); - if (ret != NSERROR_OK) { - fprintf(stderr, "NetSurf core failed to initialise (%s)\n", - messages_get_errorcode(ret)); - return 1; - } - - /* run the browser */ - gui_init(argc, argv, respaths); - - /* Ensure all scaffoldings are destroyed before we go into exit */ - while (scaf_list != NULL) { - nsgtk_scaffolding_destroy(scaf_list); - } - - /* common finalisation */ - netsurf_exit(); - - /* finalise options */ - nsoption_finalise(nsoptions, nsoptions_default); - - return 0; -} - - -void gui_poll(bool active) +static void gui_poll(bool active) { CURLMcode code; fd_set read_fd_set, write_fd_set, exc_fd_set; @@ -613,7 +555,7 @@ void gui_poll(bool active) bool block = true; schedule_run(); - + if (browser_reformat_pending) block = false; @@ -666,8 +608,15 @@ void gui_poll(bool active) } -void gui_quit(void) +static void gui_quit(void) { + LOG(("Quitting GUI")); + + /* Ensure all scaffoldings are destroyed before we go into exit */ + while (scaf_list != NULL) { + nsgtk_scaffolding_destroy(scaf_list); + } + nsgtk_download_destroy(); urldb_save_cookies(nsoption_charp(cookie_jar)); urldb_save(nsoption_charp(url_file)); @@ -688,7 +637,7 @@ static void nsgtk_select_menu_clicked(GtkCheckMenuItem *checkmenuitem, select_menu_control, (intptr_t)user_data); } -void gui_create_form_select_menu(struct browser_window *bw, +static void gui_create_form_select_menu(struct browser_window *bw, struct form_control *control) { @@ -729,12 +678,7 @@ void gui_create_form_select_menu(struct browser_window *bw, } -void gui_window_save_link(struct gui_window *g, const char *url, - const char *title) -{ -} - -void gui_launch_url(const char *url) +static void gui_launch_url(const char *url) { gboolean ok; GError *error = NULL; @@ -772,11 +716,11 @@ void die(const char * const error) } -void gui_cert_verify(nsurl *url, const struct ssl_cert_info *certs, +static void gui_cert_verify(nsurl *url, const struct ssl_cert_info *certs, unsigned long num, nserror (*cb)(bool proceed, void *pw), void *cbpw) -{ - static struct nsgtk_treeview *ssl_window; +{ + static struct nsgtk_treeview *ssl_window; struct sslcert_session_data *data; GtkButton *accept, *reject; void **session; @@ -784,7 +728,7 @@ void gui_cert_verify(nsurl *url, const struct ssl_cert_info *certs, GtkScrolledWindow *scrolled; GtkDrawingArea *drawing_area; GError* error = NULL; - GtkBuilder* builder; + GtkBuilder* builder; builder = gtk_builder_new (); if (!gtk_builder_add_from_file(builder, glade_file_location->ssl, &error)) { @@ -808,28 +752,28 @@ void gui_cert_verify(nsurl *url, const struct ssl_cert_info *certs, ssl_window = nsgtk_treeview_create(TREE_SSLCERT, window, scrolled, drawing_area); - + if (ssl_window == NULL) { free(session); return; } - + accept = GTK_BUTTON(gtk_builder_get_object(builder, "sslaccept")); - reject = GTK_BUTTON(gtk_builder_get_object(builder, "sslreject")); + reject = GTK_BUTTON(gtk_builder_get_object(builder, "sslreject")); session[0] = builder; session[1] = ssl_window; session[2] = data; - + #define CONNECT(obj, sig, callback, ptr) \ - g_signal_connect(G_OBJECT(obj), (sig), G_CALLBACK(callback), (ptr)) - + g_signal_connect(G_OBJECT(obj), (sig), G_CALLBACK(callback), (ptr)) + CONNECT(accept, "clicked", nsgtk_ssl_accept, session); CONNECT(reject, "clicked", nsgtk_ssl_reject, session); CONNECT(window, "delete_event", G_CALLBACK(nsgtk_ssl_delete_event), (gpointer)session); - - gtk_widget_show(GTK_WIDGET(window)); + + gtk_widget_show(GTK_WIDGET(window)); } void nsgtk_ssl_accept(GtkButton *w, gpointer data) @@ -840,7 +784,7 @@ void nsgtk_ssl_accept(GtkButton *w, gpointer data) struct sslcert_session_data *ssl_data = session[2]; sslcert_viewer_accept(ssl_data); - + nsgtk_treeview_destroy(wnd); g_object_unref(G_OBJECT(x)); free(session); @@ -854,7 +798,7 @@ void nsgtk_ssl_reject(GtkWidget *w, gpointer data) struct sslcert_session_data *ssl_data = session[2]; sslcert_viewer_reject(ssl_data); - + nsgtk_treeview_destroy(wnd); g_object_unref(G_OBJECT(x)); free(session); @@ -906,7 +850,7 @@ char *path_to_url(const char *path) if (path == NULL) { return NULL; } - + urllen = strlen(path) + FILE_SCHEME_PREFIX_LEN + 1; url = malloc(urllen); @@ -916,7 +860,7 @@ char *path_to_url(const char *path) if (*path == '/') { path++; /* file: paths are already absolute */ - } + } snprintf(url, urllen, "%s%s", FILE_SCHEME_PREFIX, path); @@ -1057,7 +1001,7 @@ uint32_t gtk_gui_gdkkey_to_nskey(GdkEventKey *key) * now. I hope. */ switch (key->keyval) { - + case GDK_KEY(Tab): return KEY_TAB; @@ -1137,12 +1081,12 @@ uint32_t gtk_gui_gdkkey_to_nskey(GdkEventKey *key) case GDK_KEY(Super_L): case GDK_KEY(Super_R): case GDK_KEY(Hyper_L): - case GDK_KEY(Hyper_R): + case GDK_KEY(Hyper_R): return 0; - default: + default: return gdk_keyval_to_unicode(key->keyval); - } + } } /** @@ -1152,7 +1096,7 @@ uint32_t gtk_gui_gdkkey_to_nskey(GdkEventKey *key) * \return filename (will be freed with free()) */ -char *filename_from_path(char *path) +static char *filename_from_path(char *path) { char *leafname; @@ -1174,7 +1118,7 @@ char *filename_from_path(char *path) * \return true on success */ -bool path_add_part(char *path, int length, const char *newpart) +static bool path_add_part(char *path, int length, const char *newpart) { if(path[strlen(path) - 1] != '/') strncat(path, "/", length); @@ -1183,3 +1127,83 @@ bool path_add_part(char *path, int length, const char *newpart) return true; } + +static struct gui_clipboard_table nsgtk_clipboard_table = { + .get = gui_get_clipboard, + .set = gui_set_clipboard, +}; + +static struct gui_browser_table nsgtk_browser_table = { + .poll = gui_poll, + .quit = gui_quit, + .set_search_ico = gui_set_search_ico, + .get_resource_url = gui_get_resource_url, + .launch_url = gui_launch_url, + .create_form_select_menu = gui_create_form_select_menu, + .cert_verify = gui_cert_verify, + .filename_from_path = filename_from_path, + .path_add_part = path_add_part, + .login = gui_401login_open, +}; + +/** + * Main entry point from OS. + */ +int main(int argc, char** argv) +{ + char *messages; + char *options; + nserror ret; + struct gui_table nsgtk_gui_table = { + .browser = &nsgtk_browser_table, + .window = nsgtk_window_table, + .clipboard = &nsgtk_clipboard_table, + .download = nsgtk_download_table, + }; + + /* check home directory is available */ + nsgtk_check_homedir(); + + respaths = nsgtk_init_resource("${HOME}/.netsurf/:${NETSURFRES}:"GTK_RESPATH":./gtk/res"); + + gtk_init(&argc, &argv); + + /* initialise logging. Not fatal if it fails but not much we + * can do about it either. + */ + nslog_init(nslog_stream_configure, &argc, argv); + + /* user options setup */ + ret = nsoption_init(set_defaults, &nsoptions, &nsoptions_default); + if (ret != NSERROR_OK) { + fprintf(stderr, "Options failed to initialise (%s)\n", + messages_get_errorcode(ret)); + return 1; + } + options = filepath_find(respaths, "Choices"); + nsoption_read(options, nsoptions); + free(options); + nsoption_commandline(&argc, argv, nsoptions); + check_options(respaths); /* check user options */ + + /* common initialisation */ + messages = filepath_find(respaths, "Messages"); + ret = netsurf_init(messages, &nsgtk_gui_table); + free(messages); + if (ret != NSERROR_OK) { + fprintf(stderr, "NetSurf core failed to initialise (%s)\n", + messages_get_errorcode(ret)); + return 1; + } + + /* run the browser */ + gui_init(argc, argv, respaths); + + /* common finalisation */ + netsurf_exit(); + + /* finalise options */ + nsoption_finalise(nsoptions, nsoptions_default); + + return 0; +} @@ -29,7 +29,8 @@ #include <inttypes.h> #include <stdbool.h> #include <gtk/gtk.h> -//#include <glade/glade.h> + +#include "utils/nsurl.h" struct glade_file_location_s { char *netsurf; @@ -60,5 +61,8 @@ extern GdkPixbuf *favicon_pixbuf; /* favicon default pixbuf */ uint32_t gtk_gui_gdkkey_to_nskey(GdkEventKey *); +extern void gui_401login_open(nsurl *url, const char *realm, + nserror (*cb)(bool proceed, void *pw), void *cbpw); + #endif /* GTK_GUI_H */ diff --git a/gtk/login.c b/gtk/login.c index 3b8d68254..baf37d094 100644 --- a/gtk/login.c +++ b/gtk/login.c @@ -28,7 +28,6 @@ #include "content/hlcache.h" #include "content/urldb.h" #include "desktop/browser.h" -#include "desktop/401login.h" #include "desktop/gui.h" #include "utils/messages.h" #include "utils/url.h" diff --git a/gtk/scaffolding.c b/gtk/scaffolding.c index b39283cc6..098d5e121 100644 --- a/gtk/scaffolding.c +++ b/gtk/scaffolding.c @@ -2147,8 +2147,7 @@ nsgtk_scaffolding *nsgtk_new_scaffolding(struct gui_window *toplevel) nsgtk_theme_implement(g); /* set web search ico */ - if (search_web_ico() != NULL) - gui_window_set_search_ico(search_web_ico()); + gui_set_search_ico(search_web_ico()); /* finally, show the window. */ gtk_widget_show(GTK_WIDGET(g->window)); @@ -2261,7 +2260,7 @@ nsgtk_scaffolding_set_icon(struct gui_window *gw) gtk_widget_show_all(GTK_WIDGET(sc->buttons[URL_BAR_ITEM]->button)); } -void gui_window_set_search_ico(hlcache_handle *ico) +void gui_set_search_ico(hlcache_handle *ico) { struct bitmap *srch_bitmap; nsgtk_scaffolding *current; diff --git a/gtk/scaffolding.h b/gtk/scaffolding.h index 79e3fa0df..43eb41b19 100644 --- a/gtk/scaffolding.h +++ b/gtk/scaffolding.h @@ -177,4 +177,11 @@ gboolean nsgtk_window_url_changed(GtkWidget *, GdkEventKey *, gpointer); nserror nsgtk_scaffolding_new_tab(struct gui_window *gw); +/* core acessors */ +void gui_window_set_title(struct gui_window *g, const char *title); +void gui_window_set_url(struct gui_window *g, const char *url); +void gui_window_start_throbber(struct gui_window *g); +void gui_window_stop_throbber(struct gui_window *g); +void gui_set_search_ico(hlcache_handle *ico); + #endif /* NETSURF_GTK_SCAFFOLDING_H */ diff --git a/gtk/selection.c b/gtk/selection.c index b0978b385..8bdc0f8c8 100644 --- a/gtk/selection.c +++ b/gtk/selection.c @@ -30,17 +30,6 @@ static GString *current_selection = NULL; static GtkClipboard *clipboard; - - -void gui_start_selection(struct gui_window *g) -{ - gtk_widget_grab_focus(GTK_WIDGET(nsgtk_window_get_layout(g))); -} - -void gui_clear_selection(struct gui_window *g) -{ -} - /** * Core asks front end for clipboard contents. * diff --git a/gtk/selection.h b/gtk/selection.h index c2a0b35f4..0d3ec7371 100644 --- a/gtk/selection.h +++ b/gtk/selection.h @@ -22,4 +22,8 @@ #include <gtk/gtk.h> #include "desktop/gui.h" +void gui_get_clipboard(char **buffer, size_t *length); +void gui_set_clipboard(const char *buffer, size_t length, nsclipboard_styles styles[], int n_styles); + + #endif diff --git a/gtk/toolbar.c b/gtk/toolbar.c index d543ca5fd..8453f4e27 100644 --- a/gtk/toolbar.c +++ b/gtk/toolbar.c @@ -449,8 +449,8 @@ void nsgtk_toolbar_close(nsgtk_scaffolding *g) TRUE); /* update favicon etc */ nsgtk_scaffolding_set_top_level(nsgtk_scaffolding_top_level(g)); - if (search_web_ico()) - gui_window_set_search_ico(search_web_ico()); + + gui_set_search_ico(search_web_ico()); } /** diff --git a/gtk/window.c b/gtk/window.c index 8f05c3799..0ba3c5052 100644 --- a/gtk/window.c +++ b/gtk/window.c @@ -28,6 +28,7 @@ #include "content/hlcache.h" #include "gtk/window.h" +#include "gtk/selection.h" #include "desktop/browser_private.h" #include "desktop/mouse.h" #include "utils/nsoption.h" @@ -655,10 +656,11 @@ static void window_destroy(GtkWidget *widget, gpointer data) browser_window_destroy(gw->bw); } -/* Core interface docuemnted in desktop/gui.h to create a gui_window */ -struct gui_window *gui_create_browser_window(struct browser_window *bw, - struct browser_window *clone, - bool new_tab) +/* Core interface documented in desktop/gui.h to create a gui_window */ +static struct gui_window * +gui_window_create(struct browser_window *bw, + struct browser_window *clone, + bool new_tab) { struct gui_window *g; /**< what we're creating to return */ GError* error = NULL; @@ -837,7 +839,7 @@ void nsgtk_window_destroy_browser(struct gui_window *gw) gtk_widget_destroy(gw->container); } -void gui_window_destroy(struct gui_window *g) +static void gui_window_destroy(struct gui_window *g) { LOG(("gui_window: %p", g)); assert(g != NULL); @@ -860,7 +862,7 @@ void gui_window_destroy(struct gui_window *g) /** * set favicon */ -void gui_window_set_icon(struct gui_window *gw, hlcache_handle *icon) +static void gui_window_set_icon(struct gui_window *gw, hlcache_handle *icon) { struct bitmap *icon_bitmap = NULL; @@ -887,6 +889,20 @@ void gui_window_set_icon(struct gui_window *gw, hlcache_handle *icon) nsgtk_scaffolding_set_icon(gw); } +static bool gui_window_get_scroll(struct gui_window *g, int *sx, int *sy) +{ + GtkAdjustment *vadj = nsgtk_layout_get_vadjustment(g->layout); + GtkAdjustment *hadj = nsgtk_layout_get_hadjustment(g->layout); + + assert(vadj); + assert(hadj); + + *sy = (int)(gtk_adjustment_get_value(vadj)); + *sx = (int)(gtk_adjustment_get_value(hadj)); + + return true; +} + static void nsgtk_redraw_caret(struct gui_window *g) { int sx, sy; @@ -901,7 +917,7 @@ static void nsgtk_redraw_caret(struct gui_window *g) } -void gui_window_remove_caret(struct gui_window *g) +static void gui_window_remove_caret(struct gui_window *g) { int sx, sy; int oh = g->careth; @@ -918,12 +934,12 @@ void gui_window_remove_caret(struct gui_window *g) } -void gui_window_redraw_window(struct gui_window *g) +static void gui_window_redraw_window(struct gui_window *g) { gtk_widget_queue_draw(GTK_WIDGET(g->layout)); } -void gui_window_update_box(struct gui_window *g, const struct rect *rect) +static void gui_window_update_box(struct gui_window *g, const struct rect *rect) { int sx, sy; hlcache_handle *c = g->bw->current_content; @@ -940,28 +956,15 @@ void gui_window_update_box(struct gui_window *g, const struct rect *rect) (rect->y1 - rect->y0) * g->bw->scale); } -void gui_window_set_status(struct gui_window *g, const char *text) +static void gui_window_set_status(struct gui_window *g, const char *text) { assert(g); assert(g->status_bar); gtk_label_set_text(g->status_bar, text); } -bool gui_window_get_scroll(struct gui_window *g, int *sx, int *sy) -{ - GtkAdjustment *vadj = nsgtk_layout_get_vadjustment(g->layout); - GtkAdjustment *hadj = nsgtk_layout_get_hadjustment(g->layout); - - assert(vadj); - assert(hadj); - - *sy = (int)(gtk_adjustment_get_value(vadj)); - *sx = (int)(gtk_adjustment_get_value(hadj)); - return true; -} - -void gui_window_set_scroll(struct gui_window *g, int sx, int sy) +static void gui_window_set_scroll(struct gui_window *g, int sx, int sy) { GtkAdjustment *vadj = nsgtk_layout_get_vadjustment(g->layout); GtkAdjustment *hadj = nsgtk_layout_get_hadjustment(g->layout); @@ -986,14 +989,7 @@ void gui_window_set_scroll(struct gui_window *g, int sx, int sy) gtk_adjustment_set_value(hadj, x); } -void gui_window_scroll_visible(struct gui_window *g, int x0, int y0, - int x1, int y1) -{ - gui_window_set_scroll(g,x0,y0); -} - - -void gui_window_update_extent(struct gui_window *g) +static void gui_window_update_extent(struct gui_window *g) { if (!g->bw->current_content) return; @@ -1014,7 +1010,8 @@ static GdkCursor *nsgtk_create_menu_cursor(void) return cursor; } -void gui_window_set_pointer(struct gui_window *g, gui_pointer_shape shape) +static void gui_window_set_pointer(struct gui_window *g, + gui_pointer_shape shape) { GdkCursor *cursor = NULL; GdkCursorType cursortype; @@ -1098,12 +1095,8 @@ void gui_window_set_pointer(struct gui_window *g, gui_pointer_shape shape) nsgdk_cursor_unref(cursor); } -void gui_window_hide_pointer(struct gui_window *g) -{ -} - -void gui_window_place_caret(struct gui_window *g, int x, int y, int height, +static void gui_window_place_caret(struct gui_window *g, int x, int y, int height, const struct rect *clip) { nsgtk_redraw_caret(g); @@ -1117,34 +1110,8 @@ void gui_window_place_caret(struct gui_window *g, int x, int y, int height, gtk_widget_grab_focus(GTK_WIDGET(g->layout)); } -void gui_window_new_content(struct gui_window *g) -{ - -} - -bool gui_window_scroll_start(struct gui_window *g) -{ - return true; -} - -bool gui_window_drag_start(struct gui_window *g, gui_drag_type type, - const struct rect *rect) -{ - return true; -} - -void gui_drag_save_object(gui_save_type type, hlcache_handle *c, - struct gui_window *g) -{ -} - -void gui_drag_save_selection(struct gui_window *g, const char *selection) -{ - -} - -void gui_window_get_dimensions(struct gui_window *g, int *width, int *height, +static void gui_window_get_dimensions(struct gui_window *g, int *width, int *height, bool scaled) { GtkAllocation alloc; @@ -1163,13 +1130,18 @@ void gui_window_get_dimensions(struct gui_window *g, int *width, int *height, LOG(("height: %i", *height)); } -void gui_file_gadget_open(struct gui_window *g, hlcache_handle *hl, - struct form_control *gadget) +static void gui_window_start_selection(struct gui_window *g) +{ + gtk_widget_grab_focus(GTK_WIDGET(g->layout)); +} + +static void +gui_window_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, @@ -1194,3 +1166,30 @@ void gui_file_gadget_open(struct gui_window *g, hlcache_handle *hl, gtk_widget_destroy(dialog); } + +static struct gui_window_table window_table = { + .create = gui_window_create, + .destroy = gui_window_destroy, + .redraw = gui_window_redraw_window, + .update = gui_window_update_box, + .get_scroll = gui_window_get_scroll, + .set_scroll = gui_window_set_scroll, + .get_dimensions = gui_window_get_dimensions, + .update_extent = gui_window_update_extent, + + .set_icon = gui_window_set_icon, + .set_status = gui_window_set_status, + .set_pointer = gui_window_set_pointer, + .place_caret = gui_window_place_caret, + .remove_caret = gui_window_remove_caret, + .file_gadget_open = gui_window_file_gadget_open, + .start_selection = gui_window_start_selection, + + /* from scaffold */ + .set_title = gui_window_set_title, + .set_url = gui_window_set_url, + .start_throbber = gui_window_start_throbber, + .stop_throbber = gui_window_stop_throbber, +}; + +struct gui_window_table *nsgtk_window_table = &window_table; diff --git a/gtk/window.h b/gtk/window.h index 2def42dd5..e242b6e7a 100644 --- a/gtk/window.h +++ b/gtk/window.h @@ -23,6 +23,7 @@ #include "desktop/browser.h" #include "gtk/scaffolding.h" +extern struct gui_window_table *nsgtk_window_table; typedef enum nsgtk_window_signals { NSGTK_WINDOW_SIGNAL_CLICK, @@ -33,7 +34,6 @@ typedef enum nsgtk_window_signals { extern struct gui_window *window_list; extern int temp_open_background; - struct browser_window *nsgtk_get_browser_window(struct gui_window *g); nsgtk_scaffolding *nsgtk_get_scaffold(struct gui_window *g); GdkPixbuf *nsgtk_get_icon(struct gui_window *gw); @@ -48,5 +48,4 @@ struct gui_window *nsgtk_window_iterate(struct gui_window *g); GtkWidget *nsgtk_window_get_tab(struct gui_window *g); void nsgtk_window_set_tab(struct gui_window *g, GtkWidget *w); - #endif /* NETSURF_GTK_WINDOW_H */ |