GnuCash  2.6.99
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
gnc-plugin-csv-export.c
1 /*
2  * gnc-plugin-csv-export.c -- csv export plugin
3  * Copyright (C) 2012 Robert Fewell
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License as
7  * published by the Free Software Foundation; either version 2 of
8  * the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, contact:
17  *
18  * Free Software Foundation Voice: +1-617-542-5942
19  * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
20  * Boston, MA 02110-1301, USA [email protected]
21  */
22 
23 #include "config.h"
24 
25 #include <gtk/gtk.h>
26 #include <glib/gi18n.h>
27 
28 #include "gnc-plugin-csv-export.h"
29 #include "gnc-plugin-manager.h"
30 
31 #include "assistant-csv-export.h"
32 
33 static void gnc_plugin_csv_export_class_init (GncPluginCsvExportClass *klass);
34 static void gnc_plugin_csv_export_init (GncPluginCsvExport *plugin);
35 static void gnc_plugin_csv_export_finalize (GObject *object);
36 
37 /* Command callbacks */
38 static void gnc_plugin_csv_export_tree_cmd (GtkAction *action, GncMainWindowActionData *data);
39 static void gnc_plugin_csv_export_trans_cmd (GtkAction *action, GncMainWindowActionData *data);
40 
41 #define PLUGIN_ACTIONS_NAME "gnc-plugin-csv-export-actions"
42 #define PLUGIN_UI_FILENAME "gnc-plugin-csv-export-ui.xml"
43 
44 static GtkActionEntry gnc_plugin_actions [] =
45 {
46  {
47  "CsvExportTreeAction", GTK_STOCK_CONVERT, N_("Export Account T_ree to CSV..."), NULL,
48  N_("Export the Account Tree to a CSV file"),
49  G_CALLBACK (gnc_plugin_csv_export_tree_cmd)
50  },
51  {
52  "CsvExportTransAction", GTK_STOCK_CONVERT, N_("Export _Transactions to CSV..."), NULL,
53  N_("Export the Transactions to a CSV file"),
54  G_CALLBACK (gnc_plugin_csv_export_trans_cmd)
55  },
56 };
57 static guint gnc_plugin_n_actions = G_N_ELEMENTS (gnc_plugin_actions);
58 
60 {
61  gpointer dummy;
63 
64 #define GNC_PLUGIN_CSV_EXPORT_GET_PRIVATE(o) \
65  (G_TYPE_INSTANCE_GET_PRIVATE ((o), GNC_TYPE_PLUGIN_CSV_EXPORT, GncPluginCsvExportPrivate))
66 
67 static GObjectClass *parent_class = NULL;
68 
69 GType
70 gnc_plugin_csv_export_get_type (void)
71 {
72  static GType gnc_plugin_csv_export_type = 0;
73 
74  if (gnc_plugin_csv_export_type == 0)
75  {
76  static const GTypeInfo our_info =
77  {
78  sizeof (GncPluginCsvExportClass),
79  NULL, /* base_init */
80  NULL, /* base_finalize */
81  (GClassInitFunc) gnc_plugin_csv_export_class_init,
82  NULL, /* class_finalize */
83  NULL, /* class_data */
84  sizeof (GncPluginCsvExport),
85  0, /* n_preallocs */
86  (GInstanceInitFunc) gnc_plugin_csv_export_init,
87  };
88 
89  gnc_plugin_csv_export_type = g_type_register_static (GNC_TYPE_PLUGIN,
90  "GncPluginCsvExport",
91  &our_info, 0);
92  }
93 
94  return gnc_plugin_csv_export_type;
95 }
96 
97 GncPlugin *
98 gnc_plugin_csv_export_new (void)
99 {
100  return GNC_PLUGIN (g_object_new (GNC_TYPE_PLUGIN_CSV_EXPORT, NULL));
101 }
102 
103 static void
104 gnc_plugin_csv_export_class_init (GncPluginCsvExportClass *klass)
105 {
106  GObjectClass *object_class = G_OBJECT_CLASS (klass);
107  GncPluginClass *plugin_class = GNC_PLUGIN_CLASS (klass);
108 
109  parent_class = g_type_class_peek_parent (klass);
110 
111  object_class->finalize = gnc_plugin_csv_export_finalize;
112 
113  /* plugin info */
114  plugin_class->plugin_name = GNC_PLUGIN_CSV_EXPORT_NAME;
115 
116  /* widget addition/removal */
117  plugin_class->actions_name = PLUGIN_ACTIONS_NAME;
118  plugin_class->actions = gnc_plugin_actions;
119  plugin_class->n_actions = gnc_plugin_n_actions;
120  plugin_class->ui_filename = PLUGIN_UI_FILENAME;
121 
122  g_type_class_add_private(klass, sizeof(GncPluginCsvExportPrivate));
123 }
124 
125 static void
126 gnc_plugin_csv_export_init (GncPluginCsvExport *plugin)
127 {
128 }
129 
130 static void
131 gnc_plugin_csv_export_finalize (GObject *object)
132 {
133  g_return_if_fail (GNC_IS_PLUGIN_CSV_EXPORT (object));
134 
135  G_OBJECT_CLASS (parent_class)->finalize (object);
136 }
137 
138 /************************************************************
139  * Plugin Function Implementation *
140  ************************************************************/
141 
142 /************************************************************
143  * Command Callbacks *
144  ************************************************************/
145 static void
146 gnc_plugin_csv_export_tree_cmd (GtkAction *action,
148 {
149  gnc_file_csv_export(XML_EXPORT_TREE);
150 }
151 
152 static void
153 gnc_plugin_csv_export_trans_cmd (GtkAction *action,
155 {
156  gnc_file_csv_export(XML_EXPORT_TRANS);
157 }
158 
159 /************************************************************
160  * Plugin Bootstrapping *
161  ************************************************************/
162 void
163 gnc_plugin_csv_export_create_plugin (void)
164 {
165  GncPlugin *plugin = gnc_plugin_csv_export_new ();
166 
168 }
Plugin management functions for the GnuCash UI.
void gnc_plugin_manager_add_plugin(GncPluginManager *manager, GncPlugin *plugin)
const gchar * ui_filename
Definition: gnc-plugin.h:137
CSV Export Assistant.
GtkActionEntry * actions
Definition: gnc-plugin.h:122
GncPluginManager * gnc_plugin_manager_get(void)
void gnc_file_csv_export(CsvExportType export_type)
const gchar * actions_name
Definition: gnc-plugin.h:119
const gchar * plugin_name
Definition: gnc-plugin.h:112
#define PLUGIN_ACTIONS_NAME
#define PLUGIN_UI_FILENAME