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
This commit is contained in:
Rob Kendrick 2008-10-18 14:37:29 +00:00
parent cde05b7d9f
commit 33dc55587e
5 changed files with 69 additions and 22 deletions

View File

@ -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)

View File

@ -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;

View File

@ -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);
}

View File

@ -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

View File

@ -48,7 +48,7 @@
<accelerator key="n" modifiers="GDK_CONTROL_MASK" signal="activate"/>
<child internal-child="image">
<widget class="GtkImage" id="image571">
<widget class="GtkImage" id="image608">
<property name="visible">True</property>
<property name="stock">gtk-new</property>
<property name="icon_size">1</property>
@ -70,7 +70,7 @@
<accelerator key="t" modifiers="GDK_CONTROL_MASK" signal="activate"/>
<child internal-child="image">
<widget class="GtkImage" id="image572">
<widget class="GtkImage" id="image609">
<property name="visible">True</property>
<property name="stock">gtk-new</property>
<property name="icon_size">1</property>
@ -92,7 +92,7 @@
<accelerator key="o" modifiers="GDK_CONTROL_MASK" signal="activate"/>
<child internal-child="image">
<widget class="GtkImage" id="image573">
<widget class="GtkImage" id="image610">
<property name="visible">True</property>
<property name="stock">gtk-open</property>
<property name="icon_size">1</property>
@ -111,10 +111,10 @@
<property name="tooltip" translatable="yes">Close this browser window.</property>
<property name="label" translatable="yes">_Close Window</property>
<property name="use_underline">True</property>
<accelerator key="w" modifiers="GDK_CONTROL_MASK" signal="activate"/>
<accelerator key="w" modifiers="GDK_CONTROL_MASK | GDK_SHIFT_MASK" signal="activate"/>
<child internal-child="image">
<widget class="GtkImage" id="image574">
<widget class="GtkImage" id="image611">
<property name="visible">True</property>
<property name="stock">gtk-close</property>
<property name="icon_size">1</property>
@ -142,7 +142,7 @@
<property name="use_underline">True</property>
<child internal-child="image">
<widget class="GtkImage" id="image575">
<widget class="GtkImage" id="image612">
<property name="visible">True</property>
<property name="stock">gtk-save-as</property>
<property name="icon_size">1</property>
@ -223,7 +223,7 @@
<accelerator key="P" modifiers="GDK_CONTROL_MASK | GDK_SHIFT_MASK" signal="activate"/>
<child internal-child="image">
<widget class="GtkImage" id="image576">
<widget class="GtkImage" id="image613">
<property name="visible">True</property>
<property name="stock">gtk-print-preview</property>
<property name="icon_size">1</property>
@ -245,7 +245,7 @@
<accelerator key="P" modifiers="GDK_CONTROL_MASK" signal="activate"/>
<child internal-child="image">
<widget class="GtkImage" id="image577">
<widget class="GtkImage" id="image614">
<property name="visible">True</property>
<property name="stock">gtk-print</property>
<property name="icon_size">1</property>
@ -365,7 +365,7 @@
<property name="use_underline">True</property>
<child internal-child="image">
<widget class="GtkImage" id="image578">
<widget class="GtkImage" id="image615">
<property name="visible">True</property>
<property name="stock">gtk-preferences</property>
<property name="icon_size">1</property>
@ -399,7 +399,7 @@
<accelerator key="Escape" modifiers="0" signal="activate"/>
<child internal-child="image">
<widget class="GtkImage" id="image579">
<widget class="GtkImage" id="image616">
<property name="visible">True</property>
<property name="stock">gtk-stop</property>
<property name="icon_size">1</property>
@ -420,7 +420,7 @@
<accelerator key="F5" modifiers="0" signal="activate"/>
<child internal-child="image">
<widget class="GtkImage" id="image580">
<widget class="GtkImage" id="image617">
<property name="visible">True</property>
<property name="stock">gtk-refresh</property>
<property name="icon_size">1</property>
@ -447,7 +447,7 @@
<property name="use_underline">True</property>
<child internal-child="image">
<widget class="GtkImage" id="image581">
<widget class="GtkImage" id="image618">
<property name="visible">True</property>
<property name="stock">gtk-zoom-in</property>
<property name="icon_size">1</property>
@ -468,7 +468,7 @@
<property name="use_underline">True</property>
<child internal-child="image">
<widget class="GtkImage" id="image582">
<widget class="GtkImage" id="image619">
<property name="visible">True</property>
<property name="stock">gtk-zoom-in</property>
<property name="icon_size">1</property>
@ -488,7 +488,7 @@
<property name="use_underline">True</property>
<child internal-child="image">
<widget class="GtkImage" id="image583">
<widget class="GtkImage" id="image620">
<property name="visible">True</property>
<property name="stock">gtk-zoom-100</property>
<property name="icon_size">1</property>
@ -508,7 +508,7 @@
<property name="use_underline">True</property>
<child internal-child="image">
<widget class="GtkImage" id="image584">
<widget class="GtkImage" id="image621">
<property name="visible">True</property>
<property name="stock">gtk-zoom-out</property>
<property name="icon_size">1</property>
@ -533,7 +533,7 @@
<accelerator key="F11" modifiers="0" signal="activate"/>
<child internal-child="image">
<widget class="GtkImage" id="image585">
<widget class="GtkImage" id="image622">
<property name="visible">True</property>
<property name="stock">gtk-fullscreen</property>
<property name="icon_size">1</property>
@ -711,7 +711,7 @@
<accelerator key="Left" modifiers="GDK_MOD1_MASK" signal="activate"/>
<child internal-child="image">
<widget class="GtkImage" id="image586">
<widget class="GtkImage" id="image623">
<property name="visible">True</property>
<property name="stock">gtk-go-back</property>
<property name="icon_size">1</property>
@ -732,7 +732,7 @@
<accelerator key="Right" modifiers="GDK_MOD1_MASK" signal="activate"/>
<child internal-child="image">
<widget class="GtkImage" id="image587">
<widget class="GtkImage" id="image624">
<property name="visible">True</property>
<property name="stock">gtk-go-forward</property>
<property name="icon_size">1</property>
@ -753,7 +753,7 @@
<accelerator key="Down" modifiers="GDK_MOD1_MASK" signal="activate"/>
<child internal-child="image">
<widget class="GtkImage" id="image588">
<widget class="GtkImage" id="image625">
<property name="visible">True</property>
<property name="stock">gtk-home</property>
<property name="icon_size">1</property>
@ -865,6 +865,27 @@
<accelerator key="Left" modifiers="GDK_CONTROL_MASK" signal="activate"/>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="close_tab">
<property name="visible">True</property>
<property name="label" translatable="yes">_Close tab</property>
<property name="use_underline">True</property>
<accelerator key="W" modifiers="GDK_CONTROL_MASK" signal="activate"/>
<child internal-child="image">
<widget class="GtkImage" id="image626">
<property name="visible">True</property>
<property name="stock">gtk-close</property>
<property name="icon_size">1</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
</child>
</widget>
</child>
</widget>
</child>
</widget>
@ -888,7 +909,7 @@
<property name="use_underline">True</property>
<child internal-child="image">
<widget class="GtkImage" id="image589">
<widget class="GtkImage" id="image627">
<property name="visible">True</property>
<property name="stock">gtk-help</property>
<property name="icon_size">1</property>