From 33dc55587e907102c7fff4550ace43ff7d256e81 Mon Sep 17 00:00:00 2001 From: Rob Kendrick Date: Sat, 18 Oct 2008 14:37:29 +0000 Subject: Ctrl+W now closes just the current tab, and Ctrl+Shift+W closes the window. Added menu item to do this, too. svn path=/trunk/netsurf/; revision=5593 --- Makefile.config | 4 ++-- gtk/gtk_scaffolding.c | 11 ++++++++++ gtk/gtk_tabs.c | 14 ++++++++++++ gtk/gtk_tabs.h | 1 + gtk/res/netsurf.glade | 61 ++++++++++++++++++++++++++++++++++----------------- 5 files changed, 69 insertions(+), 22 deletions(-) diff --git a/Makefile.config b/Makefile.config index 239dd21ab..3ca25efe0 100644 --- a/Makefile.config +++ b/Makefile.config @@ -104,10 +104,10 @@ ifeq ($(TARGET),gtk) # Where to search for NetSurf's resources after looking in ~/.netsurf and # $NETSURFRES. It must have a trailing / - NETSURF_GTK_RESOURCES := /usr/local/share/netsurf/ + NETSURF_GTK_RESOURCES := /home/rjek/usr/netsurf/share/netsurf/ # Where to install the netsurf binary - NETSURF_GTK_BIN := /usr/local/bin/ + NETSURF_GTK_BIN := /home/rjek/usr/netsurf/bin/ # Enable NetSurf's use of Hubbub to parse HTML, rather than libxml2 # Valid options: YES, NO, AUTO (highly recommended) diff --git a/gtk/gtk_scaffolding.c b/gtk/gtk_scaffolding.c index 6cf9aa971..d1df660a4 100644 --- a/gtk/gtk_scaffolding.c +++ b/gtk/gtk_scaffolding.c @@ -192,6 +192,7 @@ MENUPROTO(global_history); /* tabs menu */ MENUPROTO(next_tab); MENUPROTO(prev_tab); +MENUPROTO(close_tab); /* help menu */ MENUPROTO(about); @@ -245,6 +246,7 @@ static struct menu_events menu_events[] = { /* tab menu */ MENUEVENT(next_tab), MENUEVENT(prev_tab), + MENUEVENT(close_tab), /* help menu */ MENUEVENT(about), @@ -1003,6 +1005,15 @@ MENUHANDLER(prev_tab) return TRUE; } +MENUHANDLER(close_tab) +{ + struct gtk_scaffolding *gw = (struct gtk_scaffolding *)g; + + nsgtk_tab_close_current(gw->notebook); + + return TRUE; +} + MENUHANDLER(about) { struct gtk_scaffolding *gw = (struct gtk_scaffolding *)g; diff --git a/gtk/gtk_tabs.c b/gtk/gtk_tabs.c index 9d22267e6..0926fc085 100644 --- a/gtk/gtk_tabs.c +++ b/gtk/gtk_tabs.c @@ -165,3 +165,17 @@ void nsgtk_tab_page_changed(GtkNotebook *notebook, GtkNotebookPage *page, if (gw) nsgtk_scaffolding_set_top_level(gw); } + +void nsgtk_tab_close_current(GtkNotebook *notebook) +{ + gint curr_page = gtk_notebook_get_current_page(notebook); + GtkWidget *window = gtk_notebook_get_nth_page(notebook, curr_page); + struct gui_window *gw = g_object_get_data(G_OBJECT(window), + "gui_window"); + + if (gtk_notebook_get_n_pages(notebook) < 2) + return; /* wicked things happen if we close the last tab */ + + gtk_notebook_remove_page(notebook, curr_page); + nsgtk_window_destroy_browser(gw); +} diff --git a/gtk/gtk_tabs.h b/gtk/gtk_tabs.h index cf4b9cae7..052ca8ef9 100644 --- a/gtk/gtk_tabs.h +++ b/gtk/gtk_tabs.h @@ -23,5 +23,6 @@ void nsgtk_tab_init(GtkWidget *tabs); void nsgtk_tab_add(struct gui_window *window); void nsgtk_tab_set_title(struct gui_window *g, const char *title); void nsgtk_tab_options_changed(GtkWidget *tabs); +void nsgtk_tab_close_current(GtkNotebook *notebook); #endif diff --git a/gtk/res/netsurf.glade b/gtk/res/netsurf.glade index 0bbc45f25..a66f65292 100644 --- a/gtk/res/netsurf.glade +++ b/gtk/res/netsurf.glade @@ -48,7 +48,7 @@ - + True gtk-new 1 @@ -70,7 +70,7 @@ - + True gtk-new 1 @@ -92,7 +92,7 @@ - + True gtk-open 1 @@ -111,10 +111,10 @@ Close this browser window. _Close Window True - + - + True gtk-close 1 @@ -142,7 +142,7 @@ True - + True gtk-save-as 1 @@ -223,7 +223,7 @@ - + True gtk-print-preview 1 @@ -245,7 +245,7 @@ - + True gtk-print 1 @@ -365,7 +365,7 @@ True - + True gtk-preferences 1 @@ -399,7 +399,7 @@ - + True gtk-stop 1 @@ -420,7 +420,7 @@ - + True gtk-refresh 1 @@ -447,7 +447,7 @@ True - + True gtk-zoom-in 1 @@ -468,7 +468,7 @@ True - + True gtk-zoom-in 1 @@ -488,7 +488,7 @@ True - + True gtk-zoom-100 1 @@ -508,7 +508,7 @@ True - + True gtk-zoom-out 1 @@ -533,7 +533,7 @@ - + True gtk-fullscreen 1 @@ -711,7 +711,7 @@ - + True gtk-go-back 1 @@ -732,7 +732,7 @@ - + True gtk-go-forward 1 @@ -753,7 +753,7 @@ - + True gtk-home 1 @@ -865,6 +865,27 @@ + + + + True + _Close tab + True + + + + + True + gtk-close + 1 + 0.5 + 0.5 + 0 + 0 + + + + @@ -888,7 +909,7 @@ True - + True gtk-help 1 -- cgit v1.2.3