GnuCash  2.6.99
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
gnc-plugin-qif-import.c
1 /********************************************************************\
2  * gnc-plugin-qif-import.c -- window for importing QIF files *
3  * (GnuCash) *
4  * Copyright (C) 2003 Jan Arne Petersen <[email protected]> *
5  * *
6  * This program is free software; you can redistribute it and/or *
7  * modify it under the terms of the GNU General Public License as *
8  * published by the Free Software Foundation; either version 2 of *
9  * the License, or (at your option) any later version. *
10  * *
11  * This program is distributed in the hope that it will be useful, *
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14  * GNU General Public License for more details. *
15  * *
16  * You should have received a copy of the GNU General Public License*
17  * along with this program; if not, contact: *
18  * *
19  * Free Software Foundation Voice: +1-617-542-5942 *
20  * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
21  * Boston, MA 02110-1301, USA [email protected] *
22 \********************************************************************/
23 
24 #include "config.h"
25 
26 #include <gtk/gtk.h>
27 #include <glib/gi18n.h>
28 
29 #include "dialog-preferences.h"
30 #include "assistant-qif-import.h"
31 #include "gnc-plugin-manager.h"
32 #include "gnc-plugin-qif-import.h"
33 
34 static void gnc_plugin_qif_import_class_init (GncPluginQifImportClass *klass);
35 static void gnc_plugin_qif_import_init (GncPluginQifImport *plugin);
36 static void gnc_plugin_qif_import_finalize (GObject *object);
37 
38 /* Command callbacks */
39 static void gnc_plugin_qif_import_cmd_new_qif_import (GtkAction *action, GncMainWindowActionData *data);
40 
41 #define PLUGIN_ACTIONS_NAME "gnc-plugin-qif-import-actions"
42 #define PLUGIN_UI_FILENAME "gnc-plugin-qif-import-ui.xml"
43 
44 static GtkActionEntry gnc_plugin_actions [] =
45 {
46  {
47  "QIFImportAction", GTK_STOCK_CONVERT, N_("Import _QIF..."), NULL,
48  N_("Import a Quicken QIF file"),
49  G_CALLBACK (gnc_plugin_qif_import_cmd_new_qif_import)
50  },
51 };
52 static guint gnc_plugin_n_actions = G_N_ELEMENTS (gnc_plugin_actions);
53 
55 {
56  gpointer dummy;
58 
59 #define GNC_PLUGIN_QIF_IMPORT_GET_PRIVATE(o) \
60  (G_TYPE_INSTANCE_GET_PRIVATE ((o), GNC_TYPE_PLUGIN_QIF_IMPORT, GncPluginQifImportPrivate))
61 
62 static GObjectClass *parent_class = NULL;
63 
64 GType
65 gnc_plugin_qif_import_get_type (void)
66 {
67  static GType gnc_plugin_qif_import_type = 0;
68 
69  if (gnc_plugin_qif_import_type == 0)
70  {
71  static const GTypeInfo our_info =
72  {
73  sizeof (GncPluginQifImportClass),
74  NULL, /* base_init */
75  NULL, /* base_finalize */
76  (GClassInitFunc) gnc_plugin_qif_import_class_init,
77  NULL, /* class_finalize */
78  NULL, /* class_data */
79  sizeof (GncPluginQifImport),
80  0, /* n_preallocs */
81  (GInstanceInitFunc) gnc_plugin_qif_import_init,
82  };
83 
84  gnc_plugin_qif_import_type = g_type_register_static (GNC_TYPE_PLUGIN,
85  "GncPluginQifImport",
86  &our_info, 0);
87  }
88 
89  return gnc_plugin_qif_import_type;
90 }
91 
92 GncPlugin *
93 gnc_plugin_qif_import_new (void)
94 {
95  return GNC_PLUGIN (g_object_new (GNC_TYPE_PLUGIN_QIF_IMPORT, NULL));
96 }
97 
98 static void
99 gnc_plugin_qif_import_class_init (GncPluginQifImportClass *klass)
100 {
101  GObjectClass *object_class = G_OBJECT_CLASS (klass);
102  GncPluginClass *plugin_class = GNC_PLUGIN_CLASS (klass);
103 
104  parent_class = g_type_class_peek_parent (klass);
105 
106  object_class->finalize = gnc_plugin_qif_import_finalize;
107 
108  /* plugin info */
109  plugin_class->plugin_name = GNC_PLUGIN_QIF_IMPORT_NAME;
110 
111  /* widget addition/removal */
112  plugin_class->actions_name = PLUGIN_ACTIONS_NAME;
113  plugin_class->actions = gnc_plugin_actions;
114  plugin_class->n_actions = gnc_plugin_n_actions;
115  plugin_class->ui_filename = PLUGIN_UI_FILENAME;
116 
117  g_type_class_add_private(klass, sizeof(GncPluginQifImportPrivate));
118 }
119 
120 static void
121 gnc_plugin_qif_import_init (GncPluginQifImport *plugin)
122 {
123 }
124 
125 static void
126 gnc_plugin_qif_import_finalize (GObject *object)
127 {
128  g_return_if_fail (GNC_IS_PLUGIN_QIF_IMPORT (object));
129 
130  G_OBJECT_CLASS (parent_class)->finalize (object);
131 }
132 
133 /************************************************************
134  * Plugin Function Implementation *
135  ************************************************************/
136 
137 /************************************************************
138  * Command Callbacks *
139  ************************************************************/
140 
141 static void
142 gnc_plugin_qif_import_cmd_new_qif_import (GtkAction *action,
144 {
145  gnc_file_qif_import();
146 }
147 
148 
149 /************************************************************
150  * Plugin Bootstrapping *
151  ************************************************************/
152 
153 void
154 gnc_plugin_qif_import_create_plugin (void)
155 {
156  GncPlugin *plugin = gnc_plugin_qif_import_new ();
158 
159  /* Add to preferences under Online Banking */
160  /* The parameters are; glade file, items to add from glade file - last being the dialog, preference tab name */
161  gnc_preferences_add_to_page ("dialog-account-picker.glade", "prefs_table",
162  _("Online Banking"));
163 }
Plugin management functions for the GnuCash UI.
void gnc_plugin_manager_add_plugin(GncPluginManager *manager, GncPlugin *plugin)
void gnc_preferences_add_to_page(const gchar *filename, const gchar *widgetname, const gchar *tabname)
const gchar * ui_filename
Definition: gnc-plugin.h:137
GtkActionEntry * actions
Definition: gnc-plugin.h:122
GncPluginManager * gnc_plugin_manager_get(void)
Dialog for handling user preferences.
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