diff -aur Thunar-1.6.9.orig/thunar/thunar-preferences.c Thunar-1.6.9.new/thunar/thunar-preferences.c --- Thunar-1.6.9.orig/thunar/thunar-preferences.c 2015-05-20 09:29:57.567519767 +0100 +++ Thunar-1.6.9.new/thunar/thunar-preferences.c 2015-05-20 10:08:53.105457375 +0100 @@ -95,6 +95,7 @@ PROP_SHORTCUTS_ICON_SIZE, PROP_TREE_ICON_EMBLEMS, PROP_TREE_ICON_SIZE, + PROP_PRESERVE_FINAL_TAB, N_PROPERTIES, }; @@ -759,6 +760,18 @@ THUNAR_ICON_SIZE_SMALLEST, EXO_PARAM_READWRITE); + /** + * ThunarPreferences:Preserve final tab: + * + * Preserves the final tab. + **/ + preferences_props[PROP_PRESERVE_FINAL_TAB] = + g_param_spec_boolean ("preserve-final-tab", + "PreserveFinalTab", + NULL, + FALSE, + EXO_PARAM_READWRITE); + /* install all properties */ g_object_class_install_properties (gobject_class, N_PROPERTIES, preferences_props); } diff -aur Thunar-1.6.9.orig/thunar/thunar-preferences-dialog.c Thunar-1.6.9.new/thunar/thunar-preferences-dialog.c --- Thunar-1.6.9.orig/thunar/thunar-preferences-dialog.c 2015-05-20 09:29:57.560852954 +0100 +++ Thunar-1.6.9.new/thunar/thunar-preferences-dialog.c 2015-05-20 09:55:11.034109226 +0100 @@ -581,6 +581,26 @@ gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, TRUE, 0); gtk_widget_show (button); + frame = g_object_new (GTK_TYPE_FRAME, "border-width", 0, "shadow-type", GTK_SHADOW_NONE, NULL); + gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, TRUE, 0); + gtk_widget_show (frame); + + label = gtk_label_new (_("Tab")); + gtk_label_set_attributes (GTK_LABEL (label), thunar_pango_attr_list_bold ()); + gtk_frame_set_label_widget (GTK_FRAME (frame), label); + gtk_widget_show (label); + + vbox = gtk_vbox_new (FALSE, 6); + gtk_container_add (GTK_CONTAINER (frame), vbox); + gtk_container_set_border_width (GTK_CONTAINER (vbox), 12); + gtk_widget_show (vbox); + + button = gtk_check_button_new_with_mnemonic (_("Preserve final tab")); + exo_mutual_binding_new (G_OBJECT (dialog->preferences), "preserve-final-tab", G_OBJECT (button), "active"); + gtk_widget_set_tooltip_text (button, _("Preserve the final tab.")); + gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, TRUE, 0); + gtk_widget_show (button); + /* Advanced */ diff -aur Thunar-1.6.9.orig/thunar/thunar-window.c Thunar-1.6.9.new/thunar/thunar-window.c --- Thunar-1.6.9.orig/thunar/thunar-window.c 2015-05-20 09:29:57.560852954 +0100 +++ Thunar-1.6.9.new/thunar/thunar-window.c 2015-05-20 10:39:08.545170693 +0100 @@ -2481,8 +2481,21 @@ thunar_window_action_close_tab (GtkAction *action, ThunarWindow *window) { - if (window->view != NULL) - gtk_widget_destroy (window->view); + if (window->view != NULL) { + gboolean preserve_last_tab = FALSE; + gint n_pages; + + g_object_get (G_OBJECT (window->preferences), "preserve-final-tab", &preserve_last_tab, NULL); + if (preserve_last_tab) { + n_pages = gtk_notebook_get_n_pages (GTK_NOTEBOOK (window->notebook)); + if (n_pages > 1) { + gtk_widget_destroy (window->view); + } + } + else { + gtk_widget_destroy (window->view); + } + } }