GnuCash  5.6-150-g038405b370+
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 gnu@gnu.org
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 
34 
35 static void gnc_plugin_csv_import_finalize (GObject *object);
36 
37 /* Command callbacks */
38 static void gnc_plugin_csv_import_tree_cmd (GSimpleAction *simple, GVariant *parameter, gpointer user_data);
39 static void gnc_plugin_csv_import_trans_cmd (GSimpleAction *simple, GVariant *parameter, gpointer user_data);
40 static void gnc_plugin_csv_import_price_cmd (GSimpleAction *simple, GVariant *parameter, gpointer user_data);
41 
42 #define PLUGIN_ACTIONS_NAME "gnc-plugin-csv-import-actions"
43 #define PLUGIN_UI_FILENAME "gnc-plugin-csv-import.ui"
44 
45 static GActionEntry gnc_plugin_actions [] =
46 {
47  { "CsvImportAccountAction", gnc_plugin_csv_import_tree_cmd, NULL, NULL, NULL },
48  { "CsvImportTransAction", gnc_plugin_csv_import_trans_cmd, NULL, NULL, NULL },
49  { "CsvImportPriceAction", gnc_plugin_csv_import_price_cmd, NULL, NULL, NULL },
50 };
52 static guint gnc_plugin_n_actions = G_N_ELEMENTS(gnc_plugin_actions);
53 
55 static const gchar *gnc_plugin_load_ui_items [] =
56 {
57  "FilePlaceholder1",
58  NULL,
59 };
60 
62 {
63  GncPlugin gnc_plugin;
64 };
65 
66 G_DEFINE_TYPE(GncPluginCsvImport, gnc_plugin_csv_import, GNC_TYPE_PLUGIN)
67 
68 GncPlugin *
69 gnc_plugin_csv_import_new (void)
70 {
71  return GNC_PLUGIN (g_object_new (GNC_TYPE_PLUGIN_CSV_IMPORT, NULL));
72 }
73 
74 static void
75 gnc_plugin_csv_import_class_init (GncPluginCsvImportClass *klass)
76 {
77  GObjectClass *object_class = G_OBJECT_CLASS (klass);
78  GncPluginClass *plugin_class = GNC_PLUGIN_CLASS (klass);
79 
80  object_class->finalize = gnc_plugin_csv_import_finalize;
81 
82  /* plugin info */
83  plugin_class->plugin_name = GNC_PLUGIN_CSV_IMPORT_NAME;
84 
85  /* widget addition/removal */
86  plugin_class->actions_name = PLUGIN_ACTIONS_NAME;
87  plugin_class->actions = gnc_plugin_actions;
88  plugin_class->n_actions = gnc_plugin_n_actions;
89  plugin_class->ui_filename = PLUGIN_UI_FILENAME;
90  plugin_class->ui_updates = gnc_plugin_load_ui_items;
91 }
92 
93 static void
94 gnc_plugin_csv_import_init (GncPluginCsvImport *plugin)
95 {
96 }
97 
98 static void
99 gnc_plugin_csv_import_finalize (GObject *object)
100 {
101  g_return_if_fail (GNC_IS_PLUGIN_CSV_IMPORT (object));
102 
103  G_OBJECT_CLASS (gnc_plugin_csv_import_parent_class)->finalize (object);
104 }
105 
106 /************************************************************
107  * Plugin Function Implementation *
108  ************************************************************/
109 
110 /************************************************************
111  * Command Callbacks *
112  ************************************************************/
113 static void
114 gnc_plugin_csv_import_tree_cmd (GSimpleAction *simple,
115  GVariant *parameter,
116  gpointer user_data)
117 {
119 }
120 
121 static void
122 gnc_plugin_csv_import_trans_cmd (GSimpleAction *simple,
123  GVariant *parameter,
124  gpointer user_data)
125 {
127 }
128 
129 static void
130 gnc_plugin_csv_import_price_cmd (GSimpleAction *simple,
131  GVariant *parameter,
132  gpointer user_data)
133 {
135 }
136 
137 /************************************************************
138  * Plugin Bootstrapping *
139  ************************************************************/
140 void
141 gnc_plugin_csv_import_create_plugin (void)
142 {
143  GncPlugin *plugin = gnc_plugin_csv_import_new ();
144 
146 }
void gnc_file_csv_trans_import(void)
The gnc_file_csv_trans_import() will let the user import the account tree or transactions to a delimi...
CSV Import Assistant.
Plugin management functions for the GnuCash UI.
void gnc_plugin_manager_add_plugin(GncPluginManager *manager, GncPlugin *plugin)
Add a plugin to the list maintained by the plugin manager.
GncPluginManager * gnc_plugin_manager_get(void)
Retrieve a pointer to the plugin manager.
void gnc_file_csv_account_import(void)
The gnc_file_csv_account_import() will let the user import accounts from a delimited file...
CSV Import Assistant.
#define PLUGIN_ACTIONS_NAME
The label given to the main window for this plugin.
void gnc_file_csv_price_import(void)
The gnc_file_csv_price_import() will let the user import the commodity prices from a file...
CSV Import Assistant.
#define PLUGIN_UI_FILENAME
The name of the UI description file for this plugin.