r20350 - gnucash/trunk/src/gnome - Present already open budget page if the user tries to open a budget more than once

Geert Janssens gjanssens at code.gnucash.org
Mon Feb 28 06:28:02 EST 2011


Author: gjanssens
Date: 2011-02-28 06:28:02 -0500 (Mon, 28 Feb 2011)
New Revision: 20350
Trac: http://svn.gnucash.org/trac/changeset/20350

Modified:
   gnucash/trunk/src/gnome/gnc-plugin-page-budget.c
Log:
Present already open budget page if the user tries to open a budget more than once

Modified: gnucash/trunk/src/gnome/gnc-plugin-page-budget.c
===================================================================
--- gnucash/trunk/src/gnome/gnc-plugin-page-budget.c	2011-02-28 11:27:54 UTC (rev 20349)
+++ gnucash/trunk/src/gnome/gnc-plugin-page-budget.c	2011-02-28 11:28:02 UTC (rev 20350)
@@ -46,6 +46,7 @@
 #include "dialog-utils.h"
 #include "gnc-gconf-utils.h"
 #include "gnc-gnome-utils.h"
+#include "gnc-gobject-utils.h"
 #include "gnc-icons.h"
 #include "gnc-plugin-page-budget.h"
 #include "gnc-plugin-budget.h"
@@ -247,9 +248,24 @@
     GncPluginPageBudget *plugin_page;
     GncPluginPageBudgetPrivate *priv;
     gchar* label;
+    const GList *item;
 
     g_return_val_if_fail(GNC_IS_BUDGET(budget), NULL);
     ENTER(" ");
+
+    /* Is there an existing page? */
+    item = gnc_gobject_tracking_get_list(GNC_PLUGIN_PAGE_BUDGET_NAME);
+    for ( ; item; item = g_list_next(item))
+    {
+        plugin_page = (GncPluginPageBudget *)item->data;
+        priv = GNC_PLUGIN_PAGE_BUDGET_GET_PRIVATE(plugin_page);
+        if (priv->budget == budget)
+        {
+            LEAVE("existing budget page %p", plugin_page);
+            return GNC_PLUGIN_PAGE(plugin_page);
+        }
+    }
+
     plugin_page = g_object_new(GNC_TYPE_PLUGIN_PAGE_BUDGET, NULL);
 
     priv = GNC_PLUGIN_PAGE_BUDGET_GET_PRIVATE(plugin_page);



More information about the gnucash-changes mailing list