gnucash master: Multiple changes pushed

Geert Janssens gjanssens at code.gnucash.org
Mon Nov 2 06:26:24 EST 2015


Updated	 via  https://github.com/Gnucash/gnucash/commit/e0ca9344 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/f41a2149 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/1a6fb375 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/50350c40 (commit)
	from  https://github.com/Gnucash/gnucash/commit/f8271749 (commit)



commit e0ca934438fc384504d0b8efbd7bdcfd6315c5f3
Author: Geert Janssens <janssens-geert at telenet.be>
Date:   Mon Nov 2 12:30:19 2015 +0100

    Set num_accounts upfront for ordinary register exports

diff --git a/src/import-export/csv-exp/assistant-csv-export.c b/src/import-export/csv-exp/assistant-csv-export.c
index d2c9137..32b2b3a 100644
--- a/src/import-export/csv-exp/assistant-csv-export.c
+++ b/src/import-export/csv-exp/assistant-csv-export.c
@@ -687,12 +687,7 @@ csv_export_assistant_finish_page_prepare (GtkAssistant *assistant,
     if (info->export_type == XML_EXPORT_TREE)
         text = g_strdup_printf (gettext (finish_tree_string), info->file_name);
     else
-    {
-        if ((info->export_type == XML_EXPORT_REGISTER) && (info->account != NULL))
-            text = g_strdup_printf (gettext (finish_trans_string), info->file_name, 1);
-        else
-            text = g_strdup_printf (gettext (finish_trans_string), info->file_name, info->csva.num_accounts);
-    }
+        text = g_strdup_printf (gettext (finish_trans_string), info->file_name, info->csva.num_accounts);
 
     gtk_label_set_text (GTK_LABEL(info->finish_label), text);
     g_free (text);
@@ -960,6 +955,8 @@ gnc_file_csv_export_internal (CsvExportType export_type, Query *q, Account *acc)
         info->query = q;
     if (acc)
         info->account = acc;
+    if ((export_type == XML_EXPORT_REGISTER) && acc)
+        info->csva.num_accounts = 1;
 
     csv_export_assistant_create (info);
     gnc_register_gui_component (ASSISTANT_CSV_EXPORT_CM_CLASS,

commit f41a214956a9cb1bc9af1853cc421f7bd5da8d56
Author: Geert Janssens <janssens-geert at telenet.be>
Date:   Mon Nov 2 12:29:35 2015 +0100

    Avoid code duplication

diff --git a/src/import-export/csv-exp/assistant-csv-export.c b/src/import-export/csv-exp/assistant-csv-export.c
index 150ab8a..d2c9137 100644
--- a/src/import-export/csv-exp/assistant-csv-export.c
+++ b/src/import-export/csv-exp/assistant-csv-export.c
@@ -948,21 +948,19 @@ csv_export_assistant_create (CsvExportInfo *info)
     return window;
 }
 
-
-/********************************************************************\
- * gnc_file_csv_export                                              *
- * opens up a assistant to export accounts or transactions based on *
- * the type.                                                        *
- * Args:   export_type                                              *
- * Return: nothing                                                  *
-\********************************************************************/
-void
-gnc_file_csv_export (CsvExportType export_type)
+static void
+gnc_file_csv_export_internal (CsvExportType export_type, Query *q, Account *acc)
 {
     CsvExportInfo *info;
 
     info = g_new0 (CsvExportInfo, 1);
     info->export_type = export_type;
+
+    if (q)
+        info->query = q;
+    if (acc)
+        info->account = acc;
+
     csv_export_assistant_create (info);
     gnc_register_gui_component (ASSISTANT_CSV_EXPORT_CM_CLASS,
                                 NULL, csv_export_close_handler,
@@ -973,6 +971,20 @@ gnc_file_csv_export (CsvExportType export_type)
 
 
 /********************************************************************\
+ * gnc_file_csv_export                                              *
+ * opens up a assistant to export accounts or transactions based on *
+ * the type.                                                        *
+ * Args:   export_type                                              *
+ * Return: nothing                                                  *
+\********************************************************************/
+void
+gnc_file_csv_export (CsvExportType export_type)
+{
+    gnc_file_csv_export_internal (export_type, NULL, NULL);
+}
+
+
+/********************************************************************\
  * gnc_file_csv_export_register                                     *
  * opens up a assistant to export register transactions based.      *
  * Args:   export_type                                              *
@@ -983,16 +995,5 @@ gnc_file_csv_export (CsvExportType export_type)
 void
 gnc_file_csv_export_register (CsvExportType export_type, Query *q, Account *acc)
 {
-    CsvExportInfo *info;
-
-    info = g_new0 (CsvExportInfo, 1);
-    info->export_type = export_type;
-    info->query = q;
-    info->account = acc;
-    csv_export_assistant_create (info);
-    gnc_register_gui_component (ASSISTANT_CSV_EXPORT_CM_CLASS,
-                                NULL, csv_export_close_handler,
-                                info);
-    gtk_widget_show_all (info->window);
-    gnc_window_adjust_for_screen (GTK_WINDOW(info->window));
+    gnc_file_csv_export_internal (export_type, q, acc);
 }

commit 1a6fb3757070faed745e63d71a67227cb46fa9c4
Author: Geert Janssens <janssens-geert at telenet.be>
Date:   Mon Nov 2 12:28:26 2015 +0100

    Rephrase some comments (to help an outsider to better understand what's happening)

diff --git a/src/import-export/csv-exp/assistant-csv-export.c b/src/import-export/csv-exp/assistant-csv-export.c
index be97491..150ab8a 100644
--- a/src/import-export/csv-exp/assistant-csv-export.c
+++ b/src/import-export/csv-exp/assistant-csv-export.c
@@ -628,6 +628,7 @@ csv_export_assistant_start_page_prepare (GtkAssistant *assistant,
         gtk_label_set_text (GTK_LABEL(info->start_label), gettext (start_tree_string));
     else
     {
+        /* General Journal and search registers are always multi-line exported */
         if ((info->export_type == XML_EXPORT_REGISTER) && (info->account == NULL))
             gtk_label_set_text (GTK_LABEL(info->start_label), gettext (start_trans_string));
         else
@@ -829,7 +830,7 @@ csv_export_assistant_create (CsvExportInfo *info)
     {
         GtkWidget *chkbox = GTK_WIDGET(gtk_builder_get_object(builder, "simple_layout"));
 
-        // If export is an account tree or info->account is NULL (Search/gl register)
+        // Don't provide simple export layout for search registers and General Journal
         if ((info->export_type == XML_EXPORT_TREE) || (info->account == NULL))
             gtk_widget_destroy (chkbox);
         gtk_widget_destroy (info->account_page);
@@ -973,7 +974,7 @@ gnc_file_csv_export (CsvExportType export_type)
 
 /********************************************************************\
  * gnc_file_csv_export_register                                     *
- * opens up a assistant to export register transactions based.      *                                                        *
+ * opens up a assistant to export register transactions based.      *
  * Args:   export_type                                              *
  * Args:   Query                                                    *
  * Args:   Account                                                  *

commit 50350c40a737577a705eea3b4bd9f577fdd9e704
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Sat Oct 17 19:43:17 2015 +0100

    Bug 754533 Add CSV Register Export
    
    Allow you to do a CSV export of the active Register View

diff --git a/src/gnome/gnc-plugin-page-register.c b/src/gnome/gnc-plugin-page-register.c
index b5973a1..cfbd953 100644
--- a/src/gnome/gnc-plugin-page-register.c
+++ b/src/gnome/gnc-plugin-page-register.c
@@ -1803,6 +1803,24 @@ gnc_plugin_page_register_summarybar_position_changed (gpointer prefs, gchar* pre
                           (position == GTK_POS_TOP ? 0 : -1) );
 }
 
+/** This function is called to get the query associated with this
+ *  plugin page.
+ *
+ *  @param page A pointer to the GncPluginPage.
+ */
+Query *
+gnc_plugin_page_register_get_query (GncPluginPage *plugin_page)
+{
+    GncPluginPageRegister *page;
+    GncPluginPageRegisterPrivate *priv;
+
+    g_return_if_fail(GNC_IS_PLUGIN_PAGE_REGISTER(plugin_page));
+
+    page = GNC_PLUGIN_PAGE_REGISTER (plugin_page);
+    priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE(page);
+    return gnc_ledger_display_get_query (priv->ledger);
+}
+
 /************************************************************/
 /*                     "Sort By" Dialog                     */
 /************************************************************/
diff --git a/src/gnome/gnc-plugin-page-register.h b/src/gnome/gnc-plugin-page-register.h
index 9bf0ee8..23af07f 100644
--- a/src/gnome/gnc-plugin-page-register.h
+++ b/src/gnome/gnc-plugin-page-register.h
@@ -41,6 +41,7 @@
 #include "gnc-ledger-display.h"
 #include "gnc-plugin-page.h"
 #include "gnc-split-reg.h"
+#include "Query.h"
 
 G_BEGIN_DECLS
 
@@ -133,6 +134,15 @@ GNCSplitReg *
 gnc_plugin_page_register_get_gsr (GncPluginPage *plugin_page);
 
 
+/** Get the Query associated with this "register" plugin page.
+ *
+ *  @param plugin_page The "register" page to modify.
+ *
+ *  @return The query.
+ */
+Query *
+gnc_plugin_page_register_get_query (GncPluginPage *plugin_page);
+
 /** Get the Account associated with this register page.
  *
  *  @param page A "register" page.
diff --git a/src/gnome/gnc-plugin-page-register2.c b/src/gnome/gnc-plugin-page-register2.c
index 3b2772c..7e1bc9f 100644
--- a/src/gnome/gnc-plugin-page-register2.c
+++ b/src/gnome/gnc-plugin-page-register2.c
@@ -1825,6 +1825,24 @@ gnc_plugin_page_register2_summarybar_position_changed (gpointer prefs, gchar* pr
                           (position == GTK_POS_TOP ? 0 : -1) );
 }
 
+/** This function is called to get the query associated with this
+ *  plugin page.
+ *
+ *  @param page A pointer to the GncPluginPage.
+ */
+Query *
+gnc_plugin_page_register2_get_query (GncPluginPage *plugin_page)
+{
+    GncPluginPageRegister2 *page;
+    GncPluginPageRegister2Private *priv;
+
+    g_return_if_fail(GNC_IS_PLUGIN_PAGE_REGISTER2(plugin_page));
+
+    page = GNC_PLUGIN_PAGE_REGISTER2 (plugin_page);
+    priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE(page);
+    return gnc_ledger_display2_get_query (priv->ledger);
+}
+
 /*#################################################################################*/
 /*#################################################################################*/
 
diff --git a/src/gnome/gnc-plugin-page-register2.h b/src/gnome/gnc-plugin-page-register2.h
index eaf8add..f4986fd 100644
--- a/src/gnome/gnc-plugin-page-register2.h
+++ b/src/gnome/gnc-plugin-page-register2.h
@@ -31,6 +31,7 @@
 #include "gnc-ledger-display2.h"
 #include "gnc-plugin-page.h"
 #include "gnc-split-reg2.h"
+#include "Query.h"
 
 G_BEGIN_DECLS
 /** @ingroup Register
@@ -136,6 +137,16 @@ GNCLedgerDisplay2 *
 gnc_plugin_page_register2_get_ledger (GncPluginPage *plugin_page);
 
 
+/** Get the Query associated with this "register" plugin page.
+ *
+ *  @param plugin_page A "register" page.
+ *
+ *  @return The query.
+ */
+Query *
+gnc_plugin_page_register2_get_query (GncPluginPage *plugin_page);
+
+
 /** Get the Account associated with this register page.
  *
  *  @param page A "register" page.
diff --git a/src/import-export/csv-exp/Makefile.am b/src/import-export/csv-exp/Makefile.am
index 2e8f1a7..c6ceabd 100644
--- a/src/import-export/csv-exp/Makefile.am
+++ b/src/import-export/csv-exp/Makefile.am
@@ -38,6 +38,9 @@ AM_CPPFLAGS = \
   -I${top_srcdir}/src/app-utils \
   -I${top_srcdir}/src/gnome \
   -I${top_srcdir}/src/gnome-utils \
+  -I${top_srcdir}/src/register/ledger-core \
+  -I${top_srcdir}/src/register/register-core \
+  -I${top_srcdir}/src/register/register-gnome \
   -I${top_srcdir}/src/import-export \
   -I${top_srcdir}/src/libqof/qof \
   -I${top_srcdir}/lib/libc \
diff --git a/src/import-export/csv-exp/assistant-csv-export.c b/src/import-export/csv-exp/assistant-csv-export.c
index 21ce9ef..be97491 100644
--- a/src/import-export/csv-exp/assistant-csv-export.c
+++ b/src/import-export/csv-exp/assistant-csv-export.c
@@ -87,14 +87,24 @@ static const gchar *finish_trans_string = N_(
             "You can also verify your selections by clicking on 'Back' or 'Cancel' to Abort Export.\n");
 
 static const gchar *start_tree_string = N_(
-        "This assistant will help you export the Account Tree to a file\n"
-        " with the separator specified below.\n\n"
-        "Select the settings you require for the file and then click 'Forward' to proceed"
-        " or 'Cancel' to Abort Export.\n");
+            "This assistant will help you export the Account Tree to a file\n"
+            " with the separator specified below.\n\n"
+            "Select the settings you require for the file and then click 'Forward' to proceed"
+            " or 'Cancel' to Abort Export.\n");
 
 static const gchar *start_trans_string = N_(
             "This assistant will help you export the Transactions to a file\n"
             " with the separator specified below.\n\n"
+            "There will be multiple rows for each transaction and may"
+            " require further manipulation to get them in a format you can use.\n\n"
+            "Each Transaction will appear once in the export and will be listed in"
+            " the order the accounts were processed\n\n"
+            "Select the settings you require for the file and then click 'Forward' to proceed"
+            " or 'Cancel' to Abort Export.\n");
+
+static const gchar *start_trans_simple_string = N_(
+            "This assistant will help you export the Transactions to a file\n"
+            " with the separator specified below.\n\n"
             "There will be multiple rows for each transaction and may require further"
             " manipulation to get them in a format you can use. Each Transaction will"
             " appear once in the export and will be listed in the order the accounts"
@@ -617,7 +627,12 @@ csv_export_assistant_start_page_prepare (GtkAssistant *assistant,
     if (info->export_type == XML_EXPORT_TREE)
         gtk_label_set_text (GTK_LABEL(info->start_label), gettext (start_tree_string));
     else
-        gtk_label_set_text (GTK_LABEL(info->start_label), gettext (start_trans_string));
+    {
+        if ((info->export_type == XML_EXPORT_REGISTER) && (info->account == NULL))
+            gtk_label_set_text (GTK_LABEL(info->start_label), gettext (start_trans_string));
+        else
+            gtk_label_set_text (GTK_LABEL(info->start_label), gettext (start_trans_simple_string));
+    }
 
     /* Enable the Assistant Buttons */
     gtk_assistant_set_page_complete (assistant, page, TRUE);
@@ -671,7 +686,12 @@ csv_export_assistant_finish_page_prepare (GtkAssistant *assistant,
     if (info->export_type == XML_EXPORT_TREE)
         text = g_strdup_printf (gettext (finish_tree_string), info->file_name);
     else
-        text = g_strdup_printf (gettext (finish_trans_string), info->file_name, info->csva.num_accounts);
+    {
+        if ((info->export_type == XML_EXPORT_REGISTER) && (info->account != NULL))
+            text = g_strdup_printf (gettext (finish_trans_string), info->file_name, 1);
+        else
+            text = g_strdup_printf (gettext (finish_trans_string), info->file_name, info->csva.num_accounts);
+    }
 
     gtk_label_set_text (GTK_LABEL(info->finish_label), text);
     g_free (text);
@@ -805,11 +825,13 @@ csv_export_assistant_create (CsvExportInfo *info)
     /* Account Page */
     info->account_page = GTK_WIDGET(gtk_builder_get_object(builder, "account_page"));
 
-    if (info->export_type == XML_EXPORT_TREE)
+    if ((info->export_type == XML_EXPORT_TREE) || (info->export_type == XML_EXPORT_REGISTER))
     {
         GtkWidget *chkbox = GTK_WIDGET(gtk_builder_get_object(builder, "simple_layout"));
 
-        gtk_widget_destroy (chkbox);
+        // If export is an account tree or info->account is NULL (Search/gl register)
+        if ((info->export_type == XML_EXPORT_TREE) || (info->account == NULL))
+            gtk_widget_destroy (chkbox);
         gtk_widget_destroy (info->account_page);
     }
     else
@@ -947,3 +969,29 @@ gnc_file_csv_export (CsvExportType export_type)
     gtk_widget_show_all (info->window);
     gnc_window_adjust_for_screen (GTK_WINDOW(info->window));
 }
+
+
+/********************************************************************\
+ * gnc_file_csv_export_register                                     *
+ * opens up a assistant to export register transactions based.      *                                                        *
+ * Args:   export_type                                              *
+ * Args:   Query                                                    *
+ * Args:   Account                                                  *
+ * Return: nothing                                                  *
+\********************************************************************/
+void
+gnc_file_csv_export_register (CsvExportType export_type, Query *q, Account *acc)
+{
+    CsvExportInfo *info;
+
+    info = g_new0 (CsvExportInfo, 1);
+    info->export_type = export_type;
+    info->query = q;
+    info->account = acc;
+    csv_export_assistant_create (info);
+    gnc_register_gui_component (ASSISTANT_CSV_EXPORT_CM_CLASS,
+                                NULL, csv_export_close_handler,
+                                info);
+    gtk_widget_show_all (info->window);
+    gnc_window_adjust_for_screen (GTK_WINDOW(info->window));
+}
diff --git a/src/import-export/csv-exp/assistant-csv-export.h b/src/import-export/csv-exp/assistant-csv-export.h
index 7ea4416..b9dcc61 100644
--- a/src/import-export/csv-exp/assistant-csv-export.h
+++ b/src/import-export/csv-exp/assistant-csv-export.h
@@ -29,11 +29,13 @@
 #define GNC_ASSISTANT_CSV_EXPORT_H
 
 #include "Account.h"
+#include "Query.h"
 
 typedef enum
 {
     XML_EXPORT_TREE,
-    XML_EXPORT_TRANS
+    XML_EXPORT_TRANS,
+    XML_EXPORT_REGISTER
 } CsvExportType;
 
 typedef struct
@@ -68,6 +70,9 @@ typedef struct
     CsvExportDate   csvd;
     CsvExportAcc    csva;
     GList          *trans_list;
+
+    Query          *query;
+    Account        *account;
     
     GtkWidget      *start_page;
     GtkWidget      *account_page;
@@ -96,9 +101,14 @@ typedef struct
 } CsvExportInfo;
 
 
-/** The gnc_file_csv_export() will let the user export thte
+/** The gnc_file_csv_export() will let the user export the
  *  account tree or transactions to a delimited file.
  */
 void gnc_file_csv_export (CsvExportType export_type);
 
+/** The gnc_file_csv_export_register() will let the user export the
+ *  active register transactions to a delimited file.
+ */
+void gnc_file_csv_export_register (CsvExportType export_type, Query *query, Account *acc);
+
 #endif
diff --git a/src/import-export/csv-exp/csv-transactions-export.c b/src/import-export/csv-exp/csv-transactions-export.c
index 215a890..8590425 100644
--- a/src/import-export/csv-exp/csv-transactions-export.c
+++ b/src/import-export/csv-exp/csv-transactions-export.c
@@ -570,26 +570,29 @@ make_complex_split_line (Transaction *trans, Split *split, CsvExportInfo *info)
 static
 void account_splits (CsvExportInfo *info, Account *acc, FILE *fh )
 {
-    Query   *q;
     GSList  *p1, *p2;
     GList   *splits;
     QofBook *book;
 
-    q = qof_query_create_for (GNC_ID_SPLIT);
-    book = gnc_get_current_book();
-    qof_query_set_book (q, book);
-
-    /* Sort by transaction date */
-    p1 = g_slist_prepend (NULL, TRANS_DATE_POSTED);
-    p1 = g_slist_prepend (p1, SPLIT_TRANS);
-    p2 = g_slist_prepend (NULL, QUERY_DEFAULT_SORT);
-    qof_query_set_sort_order (q, p1, p2, NULL);
-
-    xaccQueryAddSingleAccountMatch (q, acc, QOF_QUERY_AND);
-    xaccQueryAddDateMatchTT (q, TRUE, info->csvd.start_time, TRUE, info->csvd.end_time, QOF_QUERY_AND);
+    // Setup the query for normal transaction export
+    if (info->export_type == XML_EXPORT_TRANS)
+    {
+        info->query = qof_query_create_for (GNC_ID_SPLIT);
+        book = gnc_get_current_book();
+        qof_query_set_book (info->query, book);
+
+        /* Sort by transaction date */
+        p1 = g_slist_prepend (NULL, TRANS_DATE_POSTED);
+        p1 = g_slist_prepend (p1, SPLIT_TRANS);
+        p2 = g_slist_prepend (NULL, QUERY_DEFAULT_SORT);
+        qof_query_set_sort_order (info->query, p1, p2, NULL);
+
+        xaccQueryAddSingleAccountMatch (info->query, acc, QOF_QUERY_AND);
+        xaccQueryAddDateMatchTT (info->query, TRUE, info->csvd.start_time, TRUE, info->csvd.end_time, QOF_QUERY_AND);
+    }
 
     /* Run the query */
-    for (splits = qof_query_run (q); splits; splits = splits->next)
+    for (splits = qof_query_run (info->query); splits; splits = splits->next)
     {
         Split       *split;
         Transaction *trans;
@@ -609,7 +612,11 @@ void account_splits (CsvExportInfo *info, Account *acc, FILE *fh )
         if (g_list_find (info->trans_list, trans) != NULL)
             continue;
 
-        // Simple Layout
+        // Look for blank split
+        if (xaccSplitGetAccount (split) == NULL)
+            continue;
+
+        // This will be a simple layout equivalent to a single line register view.
         if (info->simple_layout)
         {
             line = make_simple_trans_line (acc, trans, split, info);
@@ -655,7 +662,8 @@ void account_splits (CsvExportInfo *info, Account *acc, FILE *fh )
         }
         info->trans_list = g_list_prepend (info->trans_list, trans); // add trans to trans_list
     }
-    qof_query_destroy (q);
+    if (info->export_type == XML_EXPORT_TRANS)
+        qof_query_destroy (info->query);
     g_list_free (splits);
 }
 
@@ -729,13 +737,19 @@ void csv_transactions_export (CsvExportInfo *info)
         }
         g_free (header);
 
-        /* Go through list of accounts */
-        for (ptr = info->csva.account_list, i = 0; ptr; ptr = g_list_next(ptr), i++)
+        if (info->export_type == XML_EXPORT_TRANS)
         {
-            acc = ptr->data;
-            DEBUG("Account being processed is : %s", xaccAccountGetName (acc));
-            account_splits (info, acc, fh);
+            /* Go through list of accounts */
+            for (ptr = info->csva.account_list, i = 0; ptr; ptr = g_list_next(ptr), i++)
+            {
+                acc = ptr->data;
+                DEBUG("Account being processed is : %s", xaccAccountGetName (acc));
+                account_splits (info, acc, fh);
+            }
         }
+        else
+            account_splits (info, info->account, fh);
+
         g_list_free (info->trans_list); // free trans_list
     }
     else
diff --git a/src/import-export/csv-exp/gnc-plugin-csv-export-ui.xml b/src/import-export/csv-exp/gnc-plugin-csv-export-ui.xml
index 566e980..2a46ce3 100644
--- a/src/import-export/csv-exp/gnc-plugin-csv-export-ui.xml
+++ b/src/import-export/csv-exp/gnc-plugin-csv-export-ui.xml
@@ -5,6 +5,7 @@
       	<placeholder name="FileExportPlaceholder">
       	   <menuitem name="FileCsvExportTree" action="CsvExportTreeAction"/>
       	   <menuitem name="FileCsvExportTrans" action="CsvExportTransAction"/>
+	   <menuitem name="FileCsvExportRegister" action="CsvExportRegisterAction"/>
       	</placeholder>
       </menu>
     </menu>
diff --git a/src/import-export/csv-exp/gnc-plugin-csv-export.c b/src/import-export/csv-exp/gnc-plugin-csv-export.c
index 7b11068..de144b7 100644
--- a/src/import-export/csv-exp/gnc-plugin-csv-export.c
+++ b/src/import-export/csv-exp/gnc-plugin-csv-export.c
@@ -30,6 +30,12 @@
 
 #include "assistant-csv-export.h"
 
+#include "gnc-plugin-page-register.h"
+/*################## Added for Reg2 #################*/
+#include "gnc-plugin-page-register2.h"
+/*################## Added for Reg2 #################*/
+#include "Query.h"
+
 static void gnc_plugin_csv_export_class_init (GncPluginCsvExportClass *klass);
 static void gnc_plugin_csv_export_init (GncPluginCsvExport *plugin);
 static void gnc_plugin_csv_export_finalize (GObject *object);
@@ -37,6 +43,7 @@ static void gnc_plugin_csv_export_finalize (GObject *object);
 /* Command callbacks */
 static void gnc_plugin_csv_export_tree_cmd (GtkAction *action, GncMainWindowActionData *data);
 static void gnc_plugin_csv_export_trans_cmd (GtkAction *action, GncMainWindowActionData *data);
+static void gnc_plugin_csv_export_register_cmd (GtkAction *action, GncMainWindowActionData *data);
 
 #define PLUGIN_ACTIONS_NAME "gnc-plugin-csv-export-actions"
 #define PLUGIN_UI_FILENAME  "gnc-plugin-csv-export-ui.xml"
@@ -53,6 +60,11 @@ static GtkActionEntry gnc_plugin_actions [] =
         N_("Export the Transactions to a CSV file"),
         G_CALLBACK (gnc_plugin_csv_export_trans_cmd)
     },
+    {
+        "CsvExportRegisterAction", GTK_STOCK_CONVERT, N_("Export _Active Register to CSV..."), NULL,
+        N_("Export the Active Register to a CSV file"),
+        G_CALLBACK (gnc_plugin_csv_export_register_cmd)
+    },
 };
 static guint gnc_plugin_n_actions = G_N_ELEMENTS (gnc_plugin_actions);
 
@@ -156,6 +168,33 @@ gnc_plugin_csv_export_trans_cmd (GtkAction *action,
     gnc_file_csv_export(XML_EXPORT_TRANS);
 }
 
+static void
+gnc_plugin_csv_export_register_cmd (GtkAction *action,
+                                 GncMainWindowActionData *data)
+{
+    Query   *query;
+    GList   *splits;
+    Account *acc;
+
+    GncPluginPage *page = gnc_main_window_get_current_page (data->window);
+
+    if (GNC_IS_PLUGIN_PAGE_REGISTER(page))
+    {
+        query = gnc_plugin_page_register_get_query (page);
+        acc = gnc_plugin_page_register_get_account (GNC_PLUGIN_PAGE_REGISTER(page));
+        gnc_file_csv_export_register (XML_EXPORT_REGISTER, query, acc);
+    }
+
+/*################## Added for Reg2 #################*/
+    if (GNC_IS_PLUGIN_PAGE_REGISTER2(page))
+    {
+        query = gnc_plugin_page_register2_get_query (page);
+        acc = gnc_plugin_page_register2_get_account (GNC_PLUGIN_PAGE_REGISTER2(page));
+        gnc_file_csv_export_register (XML_EXPORT_REGISTER, query, acc);
+    }
+/*################## Added for Reg2 #################*/
+}
+
 /************************************************************
  *                    Plugin Bootstrapping                   *
  ************************************************************/



Summary of changes:
 src/gnome/gnc-plugin-page-register.c               | 18 +++++
 src/gnome/gnc-plugin-page-register.h               | 10 +++
 src/gnome/gnc-plugin-page-register2.c              | 18 +++++
 src/gnome/gnc-plugin-page-register2.h              | 11 +++
 src/import-export/csv-exp/Makefile.am              |  3 +
 src/import-export/csv-exp/assistant-csv-export.c   | 79 +++++++++++++++++-----
 src/import-export/csv-exp/assistant-csv-export.h   | 14 +++-
 .../csv-exp/csv-transactions-export.c              | 56 +++++++++------
 .../csv-exp/gnc-plugin-csv-export-ui.xml           |  1 +
 src/import-export/csv-exp/gnc-plugin-csv-export.c  | 39 +++++++++++
 10 files changed, 210 insertions(+), 39 deletions(-)



More information about the gnucash-changes mailing list