diff options
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/gui.c | 2 | ||||
-rw-r--r-- | gtk/scaffolding.c | 14 | ||||
-rw-r--r-- | gtk/search.c | 78 | ||||
-rw-r--r-- | gtk/search.h | 21 |
4 files changed, 32 insertions, 83 deletions
@@ -69,6 +69,7 @@ #include "gtk/window.h" #include "gtk/schedule.h" #include "gtk/selection.h" +#include "gtk/search.h" #include "render/form.h" #include "utils/filepath.h" @@ -1015,6 +1016,7 @@ int main(int argc, char** argv) .clipboard = nsgtk_clipboard_table, .download = nsgtk_download_table, .fetch = nsgtk_fetch_table, + .search = nsgtk_search_table, }; /* check home directory is available */ diff --git a/gtk/scaffolding.c b/gtk/scaffolding.c index 51d395102..c5dd524ff 100644 --- a/gtk/scaffolding.c +++ b/gtk/scaffolding.c @@ -1385,9 +1385,6 @@ MULTIHANDLER(reload) /* clear potential search effects */ browser_window_search_clear(bw); - nsgtk_search_set_forward_state(true, g->top_level); - nsgtk_search_set_back_state(true, g->top_level); - browser_window_reload(bw, true); return TRUE; @@ -1404,9 +1401,6 @@ MULTIHANDLER(back) /* clear potential search effects */ browser_window_search_clear(bw); - nsgtk_search_set_forward_state(true, g->top_level); - nsgtk_search_set_back_state(true, g->top_level); - browser_window_history_back(bw, false); nsgtk_window_update_back_forward(g); @@ -1424,9 +1418,6 @@ MULTIHANDLER(forward) /* clear potential search effects */ browser_window_search_clear(bw); - nsgtk_search_set_forward_state(true, g->top_level); - nsgtk_search_set_back_state(true, g->top_level); - browser_window_history_forward(bw, false); nsgtk_window_update_back_forward(g); @@ -2399,8 +2390,6 @@ void nsgtk_scaffolding_toggle_search_bar_visibility(nsgtk_scaffolding *g) if (bw != NULL) { browser_window_search_clear(bw); } - nsgtk_search_set_forward_state(true, g->top_level); - nsgtk_search_set_back_state(true, g->top_level); gtk_widget_hide(GTK_WIDGET(g->search->bar)); } else { @@ -2438,9 +2427,6 @@ void nsgtk_scaffolding_set_top_level(struct gui_window *gw) /* clear effects of potential searches */ browser_window_search_clear(bw); - nsgtk_search_set_forward_state(true, gw); - nsgtk_search_set_back_state(true, gw); - nsgtk_scaffolding_set_icon(gw); /* Ensure the window's title bar is updated */ diff --git a/gtk/search.c b/gtk/search.c index f340bfad2..44f9ddeb6 100644 --- a/gtk/search.c +++ b/gtk/search.c @@ -25,10 +25,6 @@ #include <string.h> #include <gdk/gdkkeysyms.h> -#include "gtk/compat.h" -#include "gtk/search.h" -#include "gtk/scaffolding.h" -#include "gtk/window.h" #include "utils/config.h" #include "content/content.h" #include "content/hlcache.h" @@ -40,41 +36,18 @@ #include "utils/messages.h" #include "utils/utils.h" -/** -* Change the displayed search status. -* \param found search pattern matched in text -* \param p the pointer sent to search_verify_new() / search_create_context() -*/ - -static void nsgtk_search_set_status(bool found, void *p) -{ -} - -/** -* display hourglass while searching -* \param active start/stop indicator -* \param p the pointer sent to search_verify_new() / search_create_context() -*/ - -static void nsgtk_search_set_hourglass(bool active, void *p) -{ -} +#include "gtk/compat.h" +#include "gtk/search.h" +#include "gtk/scaffolding.h" +#include "gtk/window.h" /** -* add search string to recent searches list -* front is at liberty how to implement the bare notification -* should normally store a strdup() of the string; -* core gives no guarantee of the integrity of the const char * -* \param string search pattern -* \param p the pointer sent to search_verify_new() / search_create_context() -*/ - -static void nsgtk_search_add_recent(const char *string, void *p) -{ -} - -/* exported function documented in gtk/search.h */ -void nsgtk_search_set_forward_state(bool active, struct gui_window *gw) + * activate search forwards button in gui. + * + * \param active activate/inactivate + * \param p the pointer sent to search_verify_new() / search_create_context() + */ +static void nsgtk_search_set_forward_state(bool active, struct gui_window *gw) { if (gw != NULL && nsgtk_get_browser_window(gw) != NULL) { struct gtk_scaffolding *g = nsgtk_get_scaffold(gw); @@ -84,8 +57,13 @@ void nsgtk_search_set_forward_state(bool active, struct gui_window *gw) } } -/* exported function documented in gtk/search.h */ -void nsgtk_search_set_back_state(bool active, struct gui_window *gw) +/** + * activate search back button in gui. + * + * \param active activate/inactivate + * \param p the pointer sent to search_verify_new() / search_create_context() + */ +static void nsgtk_search_set_back_state(bool active, struct gui_window *gw) { if (gw != NULL && nsgtk_get_browser_window(gw) != NULL) { struct gtk_scaffolding *g = nsgtk_get_scaffold(gw); @@ -94,14 +72,6 @@ void nsgtk_search_set_back_state(bool active, struct gui_window *gw) } } -static struct gui_search_callbacks nsgtk_search_callbacks = { - (void *)nsgtk_search_set_forward_state, - (void *)nsgtk_search_set_back_state, - nsgtk_search_set_status, - nsgtk_search_set_hourglass, - nsgtk_search_add_recent -}; - /** connected to the search forward button */ gboolean nsgtk_search_forward_button_clicked(GtkWidget *widget, gpointer data) @@ -120,7 +90,7 @@ gboolean nsgtk_search_forward_button_clicked(GtkWidget *widget, gpointer data) nsgtk_scaffolding_search(g)->checkAll)) ? SEARCH_FLAG_SHOWALL : 0); - browser_window_search(bw, &nsgtk_search_callbacks, (void *)gw, flags, + browser_window_search(bw, gw, flags, gtk_entry_get_text(nsgtk_scaffolding_search(g)->entry)); return TRUE; } @@ -143,7 +113,7 @@ gboolean nsgtk_search_back_button_clicked(GtkWidget *widget, gpointer data) nsgtk_scaffolding_search(g)->checkAll)) ? SEARCH_FLAG_SHOWALL : 0); - browser_window_search(bw, &nsgtk_search_callbacks, (void *)gw, flags, + browser_window_search(bw, gw, flags, gtk_entry_get_text(nsgtk_scaffolding_search(g)->entry)); return TRUE; } @@ -178,7 +148,7 @@ gboolean nsgtk_search_entry_changed(GtkWidget *widget, gpointer data) nsgtk_scaffolding_search(g)->checkAll)) ? SEARCH_FLAG_SHOWALL : 0); - browser_window_search(bw, &nsgtk_search_callbacks, (void *)gw, flags, + browser_window_search(bw, gw, flags, gtk_entry_get_text(nsgtk_scaffolding_search(g)->entry)); return TRUE; } @@ -201,7 +171,7 @@ gboolean nsgtk_search_entry_activate(GtkWidget *widget, gpointer data) nsgtk_scaffolding_search(g)->checkAll)) ? SEARCH_FLAG_SHOWALL : 0); - browser_window_search(bw, &nsgtk_search_callbacks, (void *)gw, flags, + browser_window_search(bw, gw, flags, gtk_entry_get_text(nsgtk_scaffolding_search(g)->entry)); return FALSE; } @@ -249,3 +219,9 @@ gboolean nsgtk_websearch_clear(GtkWidget *widget, GdkEventFocus *f, +static struct gui_search_table search_table = { + .forward_state = (void *)nsgtk_search_set_forward_state, + .back_state = (void *)nsgtk_search_set_back_state, +}; + +struct gui_search_table *nsgtk_search_table = &search_table; diff --git a/gtk/search.h b/gtk/search.h index 8a8054478..470ebb3fd 100644 --- a/gtk/search.h +++ b/gtk/search.h @@ -19,8 +19,9 @@ #ifndef _NETSURF_GTK_SEARCH_H_ #define _NETSURF_GTK_SEARCH_H_ -#include <gtk/gtk.h> -#include "gtk/scaffolding.h" +struct gui_search_table *nsgtk_search_table; + +struct gtk_scaffolding; void nsgtk_search_bar_toggle_visibility(struct gtk_scaffolding * g); gboolean nsgtk_search_entry_changed(GtkWidget *widget, gpointer data); @@ -31,21 +32,5 @@ gboolean nsgtk_search_back_button_clicked(GtkWidget *widget, gpointer data); gboolean nsgtk_search_close_button_clicked(GtkWidget *widget, gpointer data); gboolean nsgtk_websearch_activate(GtkWidget *widget, gpointer data); gboolean nsgtk_websearch_clear(GtkWidget *widget, GdkEventFocus *f, gpointer data); - -/** - * activate search forwards button in gui. - * - * \param active activate/inactivate - * \param p the pointer sent to search_verify_new() / search_create_context() - */ -void nsgtk_search_set_forward_state(bool active, struct gui_window *gw); - -/** - * activate search back button in gui. - * - * \param active activate/inactivate - * \param p the pointer sent to search_verify_new() / search_create_context() - */ -void nsgtk_search_set_back_state(bool active, struct gui_window *gw); #endif |