GnuCash  2.6.99
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
gnc-plugin-csv-import.c
1 /*
2  * gnc-plugin-csv-import.c -- csv import plugin
3  * Copyright (C) 2011 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-import.h"
29 #include "gnc-plugin-manager.h"
30 
33 
34 static void gnc_plugin_csv_import_class_init (GncPluginCsvImportClass *klass);
35 static void gnc_plugin_csv_import_init (GncPluginCsvImport *plugin);
36 static void gnc_plugin_csv_import_finalize (GObject *object);
37 
38 /* Command callbacks */
39 static void gnc_plugin_csv_import_tree_cmd (GtkAction *action, GncMainWindowActionData *data);
40 static void gnc_plugin_csv_import_trans_cmd (GtkAction *action, GncMainWindowActionData *data);
41 
42 #define PLUGIN_ACTIONS_NAME "gnc-plugin-csv-import-actions"
43 #define PLUGIN_UI_FILENAME "gnc-plugin-csv-import-ui.xml"
44 
45 static GtkActionEntry gnc_plugin_actions [] =
46 {
47  {
48  "CsvImportAccountAction", GTK_STOCK_CONVERT, N_("Import _Accounts from CSV..."), NULL,
49  N_("Import Accounts from a CSV file"),
50  G_CALLBACK (gnc_plugin_csv_import_tree_cmd)
51  },
52  {
53  "CsvImportTransAction", GTK_STOCK_CONVERT, N_("Import _Transactions from CSV..."), NULL,
54  N_("Import Transactions from a CSV file"),
55  G_CALLBACK (gnc_plugin_csv_import_trans_cmd)
56  },
57 };
58 static guint gnc_plugin_n_actions = G_N_ELEMENTS (gnc_plugin_actions);
59 
61 {
62  gpointer dummy;
64 
65 #define GNC_PLUGIN_CSV_IMPORT_GET_PRIVATE(o) \
66  (G_TYPE_INSTANCE_GET_PRIVATE ((o), GNC_TYPE_PLUGIN_CSV_IMPORT, GncPluginCsvImportPrivate))
67 
68 static GObjectClass *parent_class = NULL;
69 
70 GType
71 gnc_plugin_csv_import_get_type (void)
72 {
73  static GType gnc_plugin_csv_import_type = 0;
74 
75  if (gnc_plugin_csv_import_type == 0)
76  {
77  static const GTypeInfo our_info =
78  {
79  sizeof (GncPluginCsvImportClass),
80  NULL, /* base_init */
81  NULL, /* base_finalize */
82  (GClassInitFunc) gnc_plugin_csv_import_class_init,
83  NULL, /* class_finalize */
84  NULL, /* class_data */
85  sizeof (GncPluginCsvImport),
86  0, /* n_preallocs */
87  (GInstanceInitFunc) gnc_plugin_csv_import_init,
88  };
89 
90  gnc_plugin_csv_import_type = g_type_register_static (GNC_TYPE_PLUGIN,
91  "GncPluginCsvImport",
92  &our_info, 0);
93  }
94 
95  return gnc_plugin_csv_import_type;
96 }
97 
98 GncPlugin *
99 gnc_plugin_csv_import_new (void)
100 {
101  return GNC_PLUGIN (g_object_new (GNC_TYPE_PLUGIN_CSV_IMPORT, NULL));
102 }
103 
104 static void
105 gnc_plugin_csv_import_class_init (GncPluginCsvImportClass *klass)
106 {
107  GObjectClass *object_class = G_OBJECT_CLASS (klass);
108  GncPluginClass *plugin_class = GNC_PLUGIN_CLASS (klass);
109 
110  parent_class = g_type_class_peek_parent (klass);
111 
112  object_class->finalize = gnc_plugin_csv_import_finalize;
113 
114  /* plugin info */
115  plugin_class->plugin_name = GNC_PLUGIN_CSV_IMPORT_NAME;
116 
117  /* widget addition/removal */
118  plugin_class->actions_name = PLUGIN_ACTIONS_NAME;
119  plugin_class->actions = gnc_plugin_actions;
120  plugin_class->n_actions = gnc_plugin_n_actions;
121  plugin_class->ui_filename = PLUGIN_UI_FILENAME;
122 
123  g_type_class_add_private(klass, sizeof(GncPluginCsvImportPrivate));
124 }
125 
126 static void
127 gnc_plugin_csv_import_init (GncPluginCsvImport *plugin)
128 {
129 }
130 
131 static void
132 gnc_plugin_csv_import_finalize (GObject *object)
133 {
134  g_return_if_fail (GNC_IS_PLUGIN_CSV_IMPORT (object));
135 
136  G_OBJECT_CLASS (parent_class)->finalize (object);
137 }
138 
139 /************************************************************
140  * Plugin Function Implementation *
141  ************************************************************/
142 
143 /************************************************************
144  * Command Callbacks *
145  ************************************************************/
146 static void
147 gnc_plugin_csv_import_tree_cmd (GtkAction *action,
149 {
151 }
152 
153 static void
154 gnc_plugin_csv_import_trans_cmd (GtkAction *action,
156 {
158 }
159 
160 /************************************************************
161  * Plugin Bootstrapping *
162  ************************************************************/
163 void
164 gnc_plugin_csv_import_create_plugin (void)
165 {
166  GncPlugin *plugin = gnc_plugin_csv_import_new ();
167 
169 }
CSV Import Assistant.
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
GtkActionEntry * actions
Definition: gnc-plugin.h:122
GncPluginManager * gnc_plugin_manager_get(void)
void gnc_file_csv_account_import(void)
const gchar * actions_name
Definition: gnc-plugin.h:119
const gchar * plugin_name
Definition: gnc-plugin.h:112
CSV Import Assistant.
#define PLUGIN_ACTIONS_NAME
void gnc_file_csv_trans_import(void)
#define PLUGIN_UI_FILENAME