GnuCash  5.6-150-g038405b370+
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 <jpetersen@uni-bonn.de> *
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 gnu@gnu.org *
22 \********************************************************************/
23 
24 #include <config.h>
25 
26 #include <gtk/gtk.h>
27 #include <glib/gi18n.h>
28 
29 #include "dialog-new-user.h"
30 #include "dialog-preferences.h"
31 #include "assistant-qif-import.h"
32 #include "gnc-plugin-manager.h"
33 #include "gnc-plugin-qif-import.h"
34 
35 static void gnc_plugin_qif_import_finalize (GObject *object);
36 
37 /* Command callbacks */
38 static void gnc_plugin_qif_import_cmd_new_qif_import (GSimpleAction *simple, GVariant *parameter, gpointer user_data);
39 
40 #define PLUGIN_ACTIONS_NAME "gnc-plugin-qif-import-actions"
41 #define PLUGIN_UI_FILENAME "gnc-plugin-qif-import.ui"
42 
43 static GActionEntry gnc_plugin_actions [] =
44 {
45  { "QIFImportAction", gnc_plugin_qif_import_cmd_new_qif_import, NULL, NULL, NULL },
46 };
48 static guint gnc_plugin_n_actions = G_N_ELEMENTS(gnc_plugin_actions);
49 
51 static const gchar *gnc_plugin_load_ui_items [] =
52 {
53  "FilePlaceholder1",
54  NULL,
55 };
56 
58 {
59  GncPlugin gnc_plugin;
60 };
61 
62 G_DEFINE_TYPE(GncPluginQifImport, gnc_plugin_qif_import, GNC_TYPE_PLUGIN)
63 
64 GncPlugin *
65 gnc_plugin_qif_import_new (void)
66 {
67  return GNC_PLUGIN (g_object_new (GNC_TYPE_PLUGIN_QIF_IMPORT, NULL));
68 }
69 
70 static void
71 gnc_plugin_qif_import_class_init (GncPluginQifImportClass *klass)
72 {
73  GObjectClass *object_class = G_OBJECT_CLASS (klass);
74  GncPluginClass *plugin_class = GNC_PLUGIN_CLASS (klass);
75 
76  object_class->finalize = gnc_plugin_qif_import_finalize;
77 
78  /* plugin info */
79  plugin_class->plugin_name = GNC_PLUGIN_QIF_IMPORT_NAME;
80 
81  /* widget addition/removal */
82  plugin_class->actions_name = PLUGIN_ACTIONS_NAME;
83  plugin_class->actions = gnc_plugin_actions;
84  plugin_class->n_actions = gnc_plugin_n_actions;
85  plugin_class->ui_filename = PLUGIN_UI_FILENAME;
86  plugin_class->ui_updates = gnc_plugin_load_ui_items;
87 }
88 
89 static void
90 gnc_plugin_qif_import_init (GncPluginQifImport *plugin)
91 {
92 }
93 
94 static void
95 gnc_plugin_qif_import_finalize (GObject *object)
96 {
97  g_return_if_fail (GNC_IS_PLUGIN_QIF_IMPORT (object));
98 
99  G_OBJECT_CLASS (gnc_plugin_qif_import_parent_class)->finalize (object);
100 }
101 
102 /************************************************************
103  * Plugin Function Implementation *
104  ************************************************************/
105 
106 /************************************************************
107  * Command Callbacks *
108  ************************************************************/
109 
110 static void
111 gnc_plugin_qif_import_cmd_new_qif_import (GSimpleAction *simple,
112  GVariant *parameter,
113  gpointer user_data)
114 {
115  gnc_file_qif_import();
116 }
117 
118 
119 /************************************************************
120  * Plugin Bootstrapping *
121  ************************************************************/
122 
123 void
124 gnc_plugin_qif_import_create_plugin (void)
125 {
126  GncPlugin *plugin = gnc_plugin_qif_import_new ();
128 
129  gnc_new_user_dialog_register_qif_assistant
130  ((void (*)())gnc_file_qif_import);
131 
132  scm_c_use_module("gnucash qif-import");
133 
134  /* Add to preferences under Online Banking */
135  /* The parameters are; glade file, items to add from glade file - last being the dialog, preference tab name */
136  gnc_preferences_add_to_page ("dialog-account-picker.glade", "prefs_table",
137  _("Import"));
138 }
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.
void gnc_preferences_add_to_page(const gchar *filename, const gchar *widgetname, const gchar *tabname)
This function adds a partial page of preferences to the preferences dialog.
GncPluginManager * gnc_plugin_manager_get(void)
Retrieve a pointer to the plugin manager.
Dialog for handling user preferences.
#define PLUGIN_ACTIONS_NAME
The label given to the main window for this plugin.
#define PLUGIN_UI_FILENAME
The name of the UI description file for this plugin.