[Gnucash-changes] Catch the window manager delete signal and query the user before

David Hampton hampton at cvs.gnucash.org
Thu Jul 7 22:51:35 EDT 2005


Log Message:
-----------
Catch the window manager delete signal and query the user before
allowing the last window to be deleted.

Tags:
----
gnucash-gnome2-dev

Modified Files:
--------------
    gnucash:
        ChangeLog
    gnucash/src/gnome-utils:
        gnc-main-window.c

Revision Data
-------------
Index: ChangeLog
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/ChangeLog,v
retrieving revision 1.1487.2.237
retrieving revision 1.1487.2.238
diff -LChangeLog -LChangeLog -u -r1.1487.2.237 -r1.1487.2.238
--- ChangeLog
+++ ChangeLog
@@ -1,5 +1,84 @@
+2005-07-07  David Hampton  <hampton at employees.org>
+
+	* src/business/business-gnome/Makefile.am:
+	* src/business/business-gnome/dialog-invoice.[ch]:
+	* src/business/business-gnome/gnc-plugin-page-invoice.[ch]:
+	* src/business/business-gnome/glade/invoice.glade:
+	* src/business/business-gnome/ui/Makefile.am:
+	* src/business/business-gnome/ui/gnc-plugin-page-invoice-ui.xml:
+	Convert the invoice dialog over to a GncPluginPage.  The new file
+	is in large part a wrapper around the original dialog code, since
+	the same logic was actually used to drive two different dialogs.
+
+	* src/business/business-gnome/business-gnome.scm: 
+	* src/business/business-gnome/businessmod-gnome.c:
+	* src/business/business-gnome/gnc-plugin-business.[ch]:
+	* src/business/business-gnome/gw-business-gnome-spec.scm: Move the
+	logic to call the bills due dialog at startup.  Track the window
+	where the last business command was issued and use this value to
+	place any new business pages created.  Update accelerator keys.
+
+	* src/business/business-gnome/ui/gnc-plugin-business-ui.xml:
+	Add a couple of placeholders.
+	
+	* src/gnome-utils/gnc-main-window.c: Catch the window manager
+	delete signal and query the user before allowing the last window
+	to be deleted.
+
+	* src/import-export/binary-import/Makefile.am:
+	* src/import-export/binary-import/druid-commodity.[ch]:
+	* src/import-export/binary-import/gncmod-binary-import.c:
+	* src/import-export/binary-import/binary-import.scm (removed):
+	* src/import-export/binary-import/gw-binary-import-spec.scm (removed):
+	Rewrite this module's book-opened-hook into C.
+	
+	* src/enginc/gnc-hooks.[ch]:
+	* src/engine/gw-engine-spec.scm: Explicitly state the number of
+	arguments a hook callback should have.  Scheme gets very unhappy
+	if you don't supply the right number of arguments.
+
+	* src/app-file/gw-app-file-spec.scm: Eliminate double free of
+	memory.
+	
+2005-07-06  David Hampton  <hampton at employees.org>
+
+	* src/register/register-gnome/gnucash-sheet.c: The register uses a
+	non-visible GtkEntry to handle its data input.  Except this widget
+	from being shown by gtk_widget_show_all.
+
+2005-07-05  David Hampton  <hampton at employees.org>
+
+	* src/app-file/gnc-file.c:
+	* src/gnome/dialog-new-user.c:
+	* src/gnome/top-level.c: Eliminate double call of some hooks.
+	
+	* src/gnome/top_level.c: 
+	* src/gnome-utils/gnc-main-window.c: A new GncMainWindow should
+	show itself instead of requiring the caller to call
+	gtk_widget_show.
+
+	* src/gnome/gnc-plugin-page-account-tree.c:
+	* src/gnome/gnc-plugin-page-register.c:
+	* src/gnome-utils/gnc-main-window.[ch]:
+	* src/gnome-utils/gnc-plugin-page.[ch]:
+	* src/gnome-utils/gnc-window.c:
+	* src/report/report-gnome/gnc-plugin-page-report.c: Move some of
+	the fields in a GncPluginPage from the public to the private data
+	structures.
+
+	* src/gnome-utils/dialog-query-list.c: 
+
+	Look for the window manager deletion signal and clean up the
+	dialog.
+
+	* src/gnome-utils/dialog-query-list.glade: Give the dialog a
+	default size.
+
 2005-07-03  David Hampton  <hampton at employees.org>
 
+	* src/gnome/glade/price.glade: Update to use HIG2.0 guidelines for
+	widget spacing.
+
 	* src/gnome/dialog-print-check.c:
 	* src/gnome-utils/gnc-html.c:
 	* src/gnome-utils/gw-gnome-utils-spec.scm:
Index: gnc-main-window.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/gnome-utils/Attic/gnc-main-window.c,v
retrieving revision 1.1.2.6
retrieving revision 1.1.2.7
diff -Lsrc/gnome-utils/gnc-main-window.c -Lsrc/gnome-utils/gnc-main-window.c -u -r1.1.2.6 -r1.1.2.7
--- src/gnome-utils/gnc-main-window.c
+++ src/gnome-utils/gnc-main-window.c
@@ -297,6 +297,59 @@
 	return FALSE;
 }
 
+
+static gboolean
+gnc_main_window_delete_event (GtkWidget *window,
+			      GdkEvent *event,
+			      gpointer user_data)
+{
+  QofSession *session;
+  GtkWidget *dialog;
+  gint response;
+
+  if (g_list_length(active_windows) > 1)
+    return FALSE;
+
+  dialog = gtk_message_dialog_new_with_markup (GTK_WINDOW(window),
+				   GTK_DIALOG_MODAL,
+				   GTK_MESSAGE_WARNING,
+				   GTK_BUTTONS_NONE,
+				   _("<b>Quit Gnucash?</b>\n\n"
+				     "You are attempting to close the last "
+				     "Gnucash window.  Doing so will quit the "
+				     "application.  Are you sure that this is "
+				     "what you want to do?"));
+  session = qof_session_get_current_session();
+
+#ifdef DIRECTORY_ORDERING_PROBLEM_FIXED
+  if (qof_book_not_saved(qof_session_get_book(session))) {
+    gtk_dialog_add_buttons(GTK_DIALOG(dialog),
+			   GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+			   "_Save and Quit", GTK_RESPONSE_ACCEPT,
+			   GTK_STOCK_QUIT, GTK_RESPONSE_OK,
+			   NULL);
+  } else {
+#endif
+    gtk_dialog_add_buttons(GTK_DIALOG(dialog),
+			   GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+			   GTK_STOCK_QUIT, GTK_RESPONSE_OK,
+			   NULL);
+#ifdef DIRECTORY_ORDERING_PROBLEM_FIXED
+  }
+#endif
+  response = gtk_dialog_run (GTK_DIALOG (dialog));
+  gtk_widget_destroy(dialog);
+
+#ifdef DIRECTORY_ORDERING_PROBLEM_FIXED
+  if (response == GTK_RESPONSE_ACCEPT)
+    gnc_file_save();
+#endif
+
+  return ((response != GTK_RESPONSE_OK) &&
+	  (response != GTK_RESPONSE_OK));
+}
+
+
 /** This function handles any event notifications from the engine.
  *  The only event it currently cares about is the deletion of a book.
  *  When a book is deleted, it runs through all installed pages
@@ -1258,6 +1311,10 @@
 	gchar *filename, *style;
 	SCM debugging;
 
+	/* Catch window manager delete signal */
+	g_signal_connect (G_OBJECT (window), "delete-event",
+			  G_CALLBACK (gnc_main_window_delete_event), window);
+
 	/* Create widgets and add them to the window */
 	main_vbox = gtk_vbox_new (FALSE, 0);
 	gtk_widget_show (main_vbox);


More information about the gnucash-changes mailing list