/*! \brief Unsaved data dialog * * This is the "Unsaved data -- are you sure you want to quit?" dialog * box which is thrown up before the user quits. */ void x_dialog_unsaved_data() { GtkWidget *dialog; gchar *tmp; gchar *str; tmp = _("Save the changes before closing?"); str = g_strconcat (N_("<big><b>"), tmp, N_("</b></big>"), NULL); tmp = _("If you don't save, all your changes will be permanently lost."); str = g_strconcat (str, "\n\n", tmp, NULL); dialog = gtk_message_dialog_new (GTK_WINDOW (window), GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_WARNING, GTK_BUTTONS_NONE, NULL); gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG (dialog), str); gtk_dialog_add_buttons (GTK_DIALOG (dialog), _("Close without saving"), GTK_RESPONSE_NO, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_SAVE, GTK_RESPONSE_YES, NULL); /* Set the alternative button order (ok, cancel, help) for other systems */ gtk_dialog_set_alternative_button_order(GTK_DIALOG(dialog), GTK_RESPONSE_YES, GTK_RESPONSE_NO, GTK_RESPONSE_CANCEL, -1); gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_YES); switch (gtk_dialog_run (GTK_DIALOG (dialog))) { case GTK_RESPONSE_NO: { gattrib_quit(0); break; } case GTK_RESPONSE_YES: { s_toplevel_gtksheet_to_toplevel(pr_current); /* Dumps sheet data into TOPLEVEL */ s_page_save_all(pr_current); /* saves all pages in design */ sheet_head->CHANGED = FALSE; gattrib_quit(0); break; } case GTK_RESPONSE_CANCEL: default: { break; } } gtk_widget_destroy (dialog); return; }
/*! \brief gattrib_really_quit callback -- called when user * selects "quit" from menubar. Checks for unsaved * changes. * \par * * \return Returns 0 to shell (successful quit). * *------------------------------------------------------------------*/ gboolean gattrib_really_quit(void) { if (sheet_head->CHANGED == TRUE) { x_dialog_unsaved_data(); } else { gattrib_quit(0); } return TRUE; }