AUDIT: r16983 - gnucash/trunk/src/gnome-utils - Bug#514003: Couple book closing with component manager.

Andreas Köhler andi5 at cvs.gnucash.org
Fri Feb 29 18:42:24 EST 2008


Author: andi5
Date: 2008-02-29 18:42:24 -0500 (Fri, 29 Feb 2008)
New Revision: 16983
Trac: http://svn.gnucash.org/trac/changeset/16983

Modified:
   gnucash/trunk/src/gnome-utils/dialog-book-close.c
Log:
Bug#514003: Couple book closing with component manager.

BP


Modified: gnucash/trunk/src/gnome-utils/dialog-book-close.c
===================================================================
--- gnucash/trunk/src/gnome-utils/dialog-book-close.c	2008-02-29 21:01:01 UTC (rev 16982)
+++ gnucash/trunk/src/gnome-utils/dialog-book-close.c	2008-02-29 23:42:24 UTC (rev 16983)
@@ -39,8 +39,12 @@
 #include "gnc-gui-query.h"
 #include "dialog-book-close.h"
 #include "gnc-account-sel.h"
+#include "gnc-component-manager.h"
 #include "gnc-date-edit.h"
+#include "gnc-session.h"
 
+#define DIALOG_BOOK_CLOSE_CM_CLASS "dialog-book-close"
+
 void gnc_book_close_response_cb(GtkDialog *, gint, GtkDialog *);
 
 struct CloseBookWindow
@@ -58,6 +62,9 @@
   /* The final settings */
   time_t close_date;
   const char* desc;
+
+  /* Component registration */
+  gint component_manager_id;
 };
 
 struct CloseAccountsCB
@@ -230,7 +237,26 @@
   g_hash_table_destroy(cacb.txns);
 }
 
+static void close_handler(gpointer data)
+{
+  GtkWidget *dialog = data;
 
+  gtk_widget_destroy(dialog);
+}
+
+static void destroy_cb(GtkObject *object, gpointer data)
+{
+  struct CloseBookWindow *cbw;
+
+  cbw = g_object_get_data(G_OBJECT(object), "CloseBookWindow");
+
+  if (cbw->component_manager_id) {
+    gnc_unregister_gui_component(cbw->component_manager_id);
+    cbw->component_manager_id = 0;
+  }
+}
+
+
 void
 gnc_book_close_response_cb(GtkDialog *dialog, gint response, GtkDialog *unused)
 {
@@ -326,6 +352,14 @@
   glade_xml_signal_autoconnect_full(xml, gnc_glade_autoconnect_full_func,
 				    cbw->dialog);
 
+  /* Register dialog with component manager */
+  cbw->component_manager_id =
+    gnc_register_gui_component(DIALOG_BOOK_CLOSE_CM_CLASS, NULL, close_handler,
+			       cbw->dialog);
+  gnc_gui_component_set_session(cbw->component_manager_id,
+				gnc_get_current_session());
+  g_signal_connect(cbw->dialog, "destroy", G_CALLBACK(destroy_cb), NULL);
+
   /* Clean up the xml data structure when the dialog is destroyed */
   g_object_set_data_full(G_OBJECT(cbw->dialog), "dialog-book-close.glade",
 			 xml, g_object_unref);



More information about the gnucash-changes mailing list