From 20d7717c7db4d60f69d37e563d8e424e427c53ea Mon Sep 17 00:00:00 2001 From: Rob Kendrick Date: Thu, 17 Aug 2006 20:03:28 +0000 Subject: Redraw nsgtk browser windows when Choices...Apply is clicked. svn path=/trunk/netsurf/; revision=2860 --- gtk/gtk_options.c | 2 ++ gtk/gtk_window.c | 43 +++++++++++++++++++++++++++++++++++++------ gtk/gtk_window.h | 3 ++- 3 files changed, 41 insertions(+), 7 deletions(-) diff --git a/gtk/gtk_options.c b/gtk/gtk_options.c index 7ce4a58aa..7dd5ac3eb 100644 --- a/gtk/gtk_options.c +++ b/gtk/gtk_options.c @@ -14,6 +14,7 @@ #include "netsurf/desktop/options.h" #include "netsurf/gtk/options.h" #include "netsurf/gtk/gtk_gui.h" +#include "netsurf/gtk/gtk_window.h" #include "netsurf/gtk/gtk_options.h" GtkWindow *wndChoices; @@ -156,5 +157,6 @@ void nsgtk_options_save(void) { /* TODO: save the other options */ options_write(options_file_location); + nsgtk_reflow_all_windows(); } diff --git a/gtk/gtk_window.c b/gtk/gtk_window.c index b0c58e1c7..6fe604c38 100644 --- a/gtk/gtk_window.c +++ b/gtk/gtk_window.c @@ -65,6 +65,8 @@ struct gui_window { struct gtk_history_window *history_window; int last_x, last_y; + + struct gui_window *next, *prev; }; struct gtk_history_window { @@ -87,6 +89,7 @@ struct menu_events { }; static int open_windows = 0; /**< current number of open browsers */ +static struct gui_window *window_list = 0; /**< first entry in win list*/ static wchar_t gdkkey_to_nskey(GdkEventKey *); static void nsgtk_window_destroy_event(GtkWidget *, gpointer); @@ -184,6 +187,16 @@ static struct menu_events menu_events[] = { { NULL, NULL } }; +void nsgtk_reflow_all_windows(void) +{ + struct gui_window *g = window_list; + + while (g != NULL) { + nsgtk_perform_deferred_resize(g); + g = g->next; + } +} + void nsgtk_attach_menu_handlers(GladeXML *xml, gpointer g) { struct menu_events *event = menu_events; @@ -240,10 +253,7 @@ void nsgtk_window_destroy_event(GtkWidget *widget, gpointer data) { struct gui_window *g = data; - gtk_widget_destroy(GTK_WIDGET(g->history_window->window)); gui_window_destroy(g); - if (--open_windows == 0) - netsurf_quit = true; } gboolean nsgtk_window_expose_event(GtkWidget *widget, @@ -663,6 +673,16 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw, g->careth = 0; + /* add the window to the list of open windows. */ + g->prev = 0; + g->next = window_list; + + if (window_list) + window_list->prev = g; + window_list = g; + + open_windows++; + /* load the window template from the glade xml file, and extract * widget references from it for later use. */ @@ -807,9 +827,6 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw, /* set up the menu signal handlers */ nsgtk_attach_menu_handlers(g->xml, g); - - /* increase the number of open windows. */ - open_windows++; /* finally, show the window. */ gtk_widget_show(GTK_WIDGET(g->window)); @@ -819,7 +836,21 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw, void gui_window_destroy(struct gui_window *g) { + if (g->prev) + g->prev->next = g->next; + else + window_list = g->next; + + if (g->next) + g->next->prev = g->prev; + gtk_widget_destroy(GTK_WIDGET(g->history_window->window)); + gtk_widget_destroy(GTK_WIDGET(g->window)); + + free(g); + + if (--open_windows == 0) + netsurf_quit = true; } void gui_window_set_title(struct gui_window *g, const char *title) diff --git a/gtk/gtk_window.h b/gtk/gtk_window.h index f44545773..6b446fc15 100644 --- a/gtk/gtk_window.h +++ b/gtk/gtk_window.h @@ -6,7 +6,7 @@ */ #include - +#include "netsurf/desktop/plotters.h" extern GtkWidget *current_widget; extern GdkDrawable *current_drawable; @@ -18,3 +18,4 @@ extern cairo_t *current_cr; void nsgtk_plot_set_scale(float s); float nsgtk_plot_get_scale(void); void nsgtk_set_colour(colour c); +void nsgtk_reflow_all_windows(void); -- cgit v1.2.3