From 94f32b83694b4a45e723d0fdfd6f4496701e56e3 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Fri, 24 Oct 2014 20:45:21 +0100 Subject: Move create_form_select_menu to window gui table. --- gtk/gui.c | 54 ------------------------------------------------------ gtk/window.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 54 deletions(-) (limited to 'gtk') diff --git a/gtk/gui.c b/gtk/gui.c index 12f1c1602..5e691be6f 100644 --- a/gtk/gui.c +++ b/gtk/gui.c @@ -52,7 +52,6 @@ #include "content/hlcache.h" #include "content/urldb.h" #include "content/backing_store.h" -#include "render/form.h" #include "desktop/browser.h" #include "desktop/save_complete.h" #include "desktop/save_pdf/pdf_plotters.h" @@ -94,15 +93,10 @@ struct glade_file_location_s *glade_file_location; static GtkWindow *nsgtk_warning_window; GtkWidget *widWarning; -static GtkWidget *select_menu; -static struct form_control *select_menu_control; - static void nsgtk_ssl_accept(GtkButton *w, gpointer data); static void nsgtk_ssl_reject(GtkWidget *w, gpointer data); static gboolean nsgtk_ssl_delete_event(GtkWidget *w, GdkEvent *event, gpointer data); -static void nsgtk_select_menu_clicked(GtkCheckMenuItem *checkmenuitem, - gpointer user_data); #ifdef WITH_PDF_EXPORT static void nsgtk_PDF_set_pass(GtkButton *w, gpointer data); static void nsgtk_PDF_no_pass(GtkButton *w, gpointer data); @@ -557,53 +551,6 @@ static void gui_quit(void) gtk_fetch_filetype_fin(); } -static void nsgtk_select_menu_clicked(GtkCheckMenuItem *checkmenuitem, - gpointer user_data) -{ - form_select_process_selection(select_menu_control, - (intptr_t)user_data); -} - -static void gui_create_form_select_menu(struct gui_window *g, - struct form_control *control) -{ - - intptr_t i; - struct form_option *option; - - GtkWidget *menu_item; - - /* control->data.select.multiple is true if multiple selections - * are allowable. We ignore this, as the core handles it for us. - * Yay. \o/ - */ - - if (select_menu != NULL) - gtk_widget_destroy(select_menu); - - select_menu = gtk_menu_new(); - select_menu_control = control; - - for (i = 0, option = control->data.select.items; option; - i++, option = option->next) { - menu_item = gtk_check_menu_item_new_with_label(option->text); - if (option->selected) - gtk_check_menu_item_set_active( - GTK_CHECK_MENU_ITEM(menu_item), TRUE); - - g_signal_connect(menu_item, "toggled", - G_CALLBACK(nsgtk_select_menu_clicked), (gpointer)i); - - gtk_menu_shell_append(GTK_MENU_SHELL(select_menu), menu_item); - } - - gtk_widget_show_all(select_menu); - - gtk_menu_popup(GTK_MENU(select_menu), NULL, NULL, NULL, - NULL /* data */, 0, gtk_get_current_event_time()); - -} - static nserror gui_launch_url(struct nsurl *url) { gboolean ok; @@ -1240,7 +1187,6 @@ static struct gui_browser_table nsgtk_browser_table = { .quit = gui_quit, .launch_url = gui_launch_url, - .create_form_select_menu = gui_create_form_select_menu, .cert_verify = gui_cert_verify, .login = gui_401login_open, }; diff --git a/gtk/window.c b/gtk/window.c index e444d7bfa..00aad32d2 100644 --- a/gtk/window.c +++ b/gtk/window.c @@ -38,6 +38,7 @@ #include "desktop/searchweb.h" #include "desktop/textinput.h" #include "desktop/gui_window.h" +#include "render/form.h" #include "gtk/compat.h" #include "gtk/gui.h" @@ -54,6 +55,12 @@ extern const GdkPixdata menu_cursor_pixdata; +static GtkWidget *select_menu; +static struct form_control *select_menu_control; + +static void nsgtk_select_menu_clicked(GtkCheckMenuItem *checkmenuitem, + gpointer user_data); + struct gui_window { /** The gtk scaffold object containing menu, buttons, url bar, [tabs], * drawing area, etc that may contain one or more gui_windows. @@ -162,6 +169,13 @@ float nsgtk_get_scale_for_gui(struct gui_window *g) return browser_window_get_scale(g->bw); } +static void nsgtk_select_menu_clicked(GtkCheckMenuItem *checkmenuitem, + gpointer user_data) +{ + form_select_process_selection(select_menu_control, + (intptr_t)user_data); +} + #if GTK_CHECK_VERSION(3,0,0) static gboolean @@ -1199,6 +1213,46 @@ static void gui_window_start_selection(struct gui_window *g) gtk_widget_grab_focus(GTK_WIDGET(g->layout)); } +static void gui_window_create_form_select_menu(struct gui_window *g, + struct form_control *control) +{ + + intptr_t i; + struct form_option *option; + + GtkWidget *menu_item; + + /* control->data.select.multiple is true if multiple selections + * are allowable. We ignore this, as the core handles it for us. + * Yay. \o/ + */ + + if (select_menu != NULL) + gtk_widget_destroy(select_menu); + + select_menu = gtk_menu_new(); + select_menu_control = control; + + for (i = 0, option = control->data.select.items; option; + i++, option = option->next) { + menu_item = gtk_check_menu_item_new_with_label(option->text); + if (option->selected) + gtk_check_menu_item_set_active( + GTK_CHECK_MENU_ITEM(menu_item), TRUE); + + g_signal_connect(menu_item, "toggled", + G_CALLBACK(nsgtk_select_menu_clicked), (gpointer)i); + + gtk_menu_shell_append(GTK_MENU_SHELL(select_menu), menu_item); + } + + gtk_widget_show_all(select_menu); + + gtk_menu_popup(GTK_MENU(select_menu), NULL, NULL, NULL, + NULL /* data */, 0, gtk_get_current_event_time()); + +} + static void gui_window_file_gadget_open(struct gui_window *g, hlcache_handle *hl, @@ -1247,6 +1301,7 @@ static struct gui_window_table window_table = { .set_pointer = gui_window_set_pointer, .place_caret = gui_window_place_caret, .remove_caret = gui_window_remove_caret, + .create_form_select_menu = gui_window_create_form_select_menu, .file_gadget_open = gui_window_file_gadget_open, .start_selection = gui_window_start_selection, -- cgit v1.2.3