Index: gedit-app.c =================================================================== RCS file: /cvs/gnome/gedit/gedit/Attic/gedit-app.c,v retrieving revision 1.1.2.16 diff -u -p -r1.1.2.16 gedit-app.c --- gedit-app.c 8 Dec 2005 16:35:25 -0000 1.1.2.16 +++ gedit-app.c 8 Dec 2005 22:03:45 -0000 @@ -166,12 +166,27 @@ window_destroy (GeditWindow *window, } } +static gboolean +close_tab (GeditTab *tab) +{ + GtkWidget *window; + + window = gtk_widget_get_toplevel (GTK_WIDGET (tab)); + _gedit_cmd_file_close_tab (tab, GEDIT_WINDOW (window)); + + return FALSE; +} + static gboolean -notebook_tab_delete (GeditNotebook *notebook, - GeditTab *tab, - GtkWindow *window) +notebook_tab_close_request (GeditNotebook *notebook, + GeditTab *tab, + GtkWindow *window) { - return _gedit_cmd_file_can_close (tab, window); + /* do the actual closing in an idle + * so that we finish handling the signal + * before destroying the tab + */ + g_idle_add ((GSourceFunc) close_tab, tab); } /* Generates a unique string for a window role */ @@ -267,8 +282,8 @@ gedit_app_create_window_real (GeditApp notebook = _gedit_window_get_notebook (GEDIT_WINDOW (window)); g_signal_connect (notebook, - "tab_delete", - G_CALLBACK (notebook_tab_delete), + "tab_close_request", + G_CALLBACK (notebook_tab_close_request), window); return GEDIT_WINDOW (window); Index: gedit-commands-file.c =================================================================== RCS file: /cvs/gnome/gedit/gedit/Attic/gedit-commands-file.c,v retrieving revision 1.1.2.15 diff -u -p -r1.1.2.15 gedit-commands-file.c --- gedit-commands-file.c 8 Dec 2005 16:35:25 -0000 1.1.2.15 +++ gedit-commands-file.c 8 Dec 2005 22:03:48 -0000 @@ -1504,9 +1504,9 @@ close_confirmation_dialog_response_handl } /* Returns TRUE if the tab can be immediately closed */ -gboolean -_gedit_cmd_file_can_close (GeditTab *tab, - GtkWindow *window) +static gboolean +tab_can_close (GeditTab *tab, + GtkWindow *window) { GeditDocument *doc; @@ -1536,17 +1536,19 @@ _gedit_cmd_file_can_close (GeditTab *ta return TRUE; } +/* CHECK: we probably need this one public for plugins... + * maybe even a _list variant. Or maybe it's better make + * gedit_window_close_tab always run the confirm dialog? + * we should not allow closing a tab without resetting the + * GEDIT_IS_CLOSING_ALL flag! + */ void -gedit_cmd_file_close (GtkAction *action, - GeditWindow *window) +_gedit_cmd_file_close_tab (GeditTab *tab, + GeditWindow *window) { - GeditTab *active_tab; - gedit_debug (DEBUG_COMMANDS); - active_tab = gedit_window_get_active_tab (window); - if (active_tab == NULL) - return; + g_return_if_fail (GTK_WIDGET (window) == gtk_widget_get_toplevel (GTK_WIDGET (tab))); g_object_set_data (G_OBJECT (window), GEDIT_IS_CLOSING_ALL, @@ -1556,8 +1558,23 @@ gedit_cmd_file_close (GtkAction *actio GEDIT_IS_QUITTING, GBOOLEAN_TO_POINTER (FALSE)); - if (_gedit_cmd_file_can_close (active_tab, GTK_WINDOW (window))) - gedit_window_close_tab (window, active_tab); + if (tab_can_close (tab, GTK_WINDOW (window))) + gedit_window_close_tab (window, tab); +} + +void +gedit_cmd_file_close (GtkAction *action, + GeditWindow *window) +{ + GeditTab *active_tab; + + gedit_debug (DEBUG_COMMANDS); + + active_tab = gedit_window_get_active_tab (window); + if (active_tab == NULL) + return; + + _gedit_cmd_file_close_tab (active_tab, window); } /* Close all tabs */ Index: gedit-commands.h =================================================================== RCS file: /cvs/gnome/gedit/gedit/gedit-commands.h,v retrieving revision 1.10.10.8 diff -u -p -r1.10.10.8 gedit-commands.h --- gedit-commands.h 4 Dec 2005 15:08:46 -0000 1.10.10.8 +++ gedit-commands.h 8 Dec 2005 22:03:48 -0000 @@ -125,8 +125,8 @@ void gedit_cmd_help_about (GtkAction /* * Non-exported function */ -gboolean _gedit_cmd_file_can_close (GeditTab *tab, - GtkWindow *window); +void _gedit_cmd_file_close_tab (GeditTab *tab, + GeditWindow *window); void _gedit_cmd_file_save_documents_list (GeditWindow *window, GList *docs); Index: gedit-notebook.c =================================================================== RCS file: /cvs/gnome/gedit/gedit/Attic/gedit-notebook.c,v retrieving revision 1.1.2.22 diff -u -p -r1.1.2.22 gedit-notebook.c --- gedit-notebook.c 8 Dec 2005 16:35:25 -0000 1.1.2.22 +++ gedit-notebook.c 8 Dec 2005 22:03:50 -0000 @@ -95,7 +95,7 @@ enum TAB_REMOVED, TABS_REORDERED, TAB_DETACHED, - TAB_DELETE, + TAB_CLOSE_REQUEST, LAST_SIGNAL }; @@ -147,14 +147,14 @@ gedit_notebook_class_init (GeditNotebook g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); - signals[TAB_DELETE] = - g_signal_new ("tab_delete", + signals[TAB_CLOSE_REQUEST] = + g_signal_new ("tab-close-request", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GeditNotebookClass, tab_delete), - g_signal_accumulator_true_handled, NULL, - gedit_marshal_BOOLEAN__OBJECT, - G_TYPE_BOOLEAN, + G_STRUCT_OFFSET (GeditNotebookClass, tab_close_request), + NULL, NULL, + g_cclosure_marshal_VOID__OBJECT, + G_TYPE_NONE, 1, GEDIT_TYPE_TAB); @@ -775,13 +775,9 @@ close_button_clicked_cb (GtkWidget *widg GtkWidget *tab) { GeditNotebook *notebook; - gboolean can_close = TRUE; notebook = GEDIT_NOTEBOOK (gtk_widget_get_parent (tab)); - g_signal_emit (G_OBJECT (notebook), signals[TAB_DELETE], 0, tab, &can_close); - - if (can_close) - gedit_notebook_remove_tab (notebook, GEDIT_TAB (tab)); + g_signal_emit (notebook, signals[TAB_CLOSE_REQUEST], 0, tab); } static GtkWidget * Index: gedit-notebook.h =================================================================== RCS file: /cvs/gnome/gedit/gedit/Attic/gedit-notebook.h,v retrieving revision 1.1.2.5 diff -u -p -r1.1.2.5 gedit-notebook.h --- gedit-notebook.h 8 Dec 2005 16:35:25 -0000 1.1.2.5 +++ gedit-notebook.h 8 Dec 2005 22:03:50 -0000 @@ -88,7 +88,8 @@ struct _GeditNotebookClass void (* tab_detached) (GeditNotebook *notebook, GeditTab *tab); void (* tabs_reordered) (GeditNotebook *notebook); - gboolean (* tab_delete) (GeditNotebook *notebook, + void (* tab_close_request) + (GeditNotebook *notebook, GeditTab *tab); };