From 753b29514d19fd54d51c2346bc6bb08ff1093cac Mon Sep 17 00:00:00 2001 From: Christian Persch Date: Sun, 4 Jan 2004 12:52:05 +0000 Subject: Add API to check if an EphyEmbed has forms with user input in them. 2004-01-04 Christian Persch * embed/ephy-embed.c: (ephy_embed_has_modified_forms): * embed/ephy-embed.h: * embed/mozilla/EphyBrowser.cpp: * embed/mozilla/EphyBrowser.h: * embed/mozilla/mozilla-embed.cpp: Add API to check if an EphyEmbed has forms with user input in them. Currently it required one modified textarea, or two modified text fields. * src/ephy-notebook.c: (ephy_notebook_class_init), (close_button_clicked_cb): * src/ephy-notebook.h: * src/ephy-window.c: (confirm_close_with_modified_forms), (ephy_window_delete_event_cb), (tab_delete_cb), (setup_notebook), (ephy_window_init), (ephy_window_remove_tab): When closing a window or tab, check if there is unsubmitted user input in form fields, and if so, warn the user before closing. Fixes bug #119857. --- src/ephy-notebook.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'src/ephy-notebook.c') diff --git a/src/ephy-notebook.c b/src/ephy-notebook.c index 87bb719a6..799e27b74 100644 --- a/src/ephy-notebook.c +++ b/src/ephy-notebook.c @@ -20,7 +20,7 @@ */ #ifdef HAVE_CONFIG_H -#include +#include "config.h" #endif #include "ephy-notebook.h" @@ -92,13 +92,14 @@ enum TAB_REMOVED, TABS_REORDERED, TAB_DETACHED, + TAB_DELETE, LAST_SIGNAL }; -static GObjectClass *parent_class = NULL; - static guint signals[LAST_SIGNAL] = { 0 }; +static GObjectClass *parent_class = NULL; + GType ephy_notebook_get_type (void) { @@ -175,6 +176,16 @@ ephy_notebook_class_init (EphyNotebookClass *klass) g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); + signals[TAB_DELETE] = + g_signal_new ("tab_delete", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (EphyNotebookClass, tab_delete), + g_signal_accumulator_true_handled, NULL, + ephy_marshal_BOOLEAN__OBJECT, + G_TYPE_BOOLEAN, + 1, + GTK_TYPE_WIDGET); g_type_class_add_private (object_class, sizeof(EphyNotebookPrivate)); } @@ -852,9 +863,15 @@ static void close_button_clicked_cb (GtkWidget *widget, GtkWidget *child) { EphyNotebook *notebook; + gboolean inhibited = FALSE; notebook = EPHY_NOTEBOOK (gtk_widget_get_parent (child)); - ephy_notebook_remove_page (notebook, child); + g_signal_emit (G_OBJECT (notebook), signals[TAB_DELETE], 0, child, &inhibited); + + if (inhibited == FALSE) + { + ephy_notebook_remove_page (notebook, child); + } } static GtkWidget * -- cgit v1.2.3