GnuCash  2.6.99
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
gnc-plugin-account-tree.c
Go to the documentation of this file.
1 /*
2  * gnc-plugin-account-tree.c --
3  *
4  * Copyright (C) 2003 Jan Arne Petersen
5  * Author: Jan Arne Petersen <[email protected]>
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License as
9  * published by the Free Software Foundation; either version 2 of
10  * the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, contact:
19  *
20  * Free Software Foundation Voice: +1-617-542-5942
21  * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
22  * Boston, MA 02110-1301, USA [email protected]
23  */
24 
34 #include "config.h"
35 
36 #include <gtk/gtk.h>
37 #include <glib/gi18n.h>
38 #include <string.h>
39 
42 
43 static void gnc_plugin_account_tree_class_init (GncPluginAccountTreeClass *klass);
44 static void gnc_plugin_account_tree_init (GncPluginAccountTree *plugin);
45 static void gnc_plugin_account_tree_finalize (GObject *object);
46 
47 /* Command callbacks */
48 static void gnc_plugin_account_tree_cmd_new_account_tree (GtkAction *action, GncMainWindowActionData *data);
49 
50 
51 #define PLUGIN_ACTIONS_NAME "gnc-plugin-account-tree-actions"
52 #define PLUGIN_UI_FILENAME "gnc-plugin-account-tree-ui.xml"
53 
56 static GtkActionEntry gnc_plugin_actions [] =
57 {
58  {
59  "ViewAccountTreeAction", NULL, N_("New Accounts _Page"), NULL,
60  N_("Open a new Account Tree page"),
61  G_CALLBACK (gnc_plugin_account_tree_cmd_new_account_tree)
62  },
63 };
65 static guint gnc_plugin_n_actions = G_N_ELEMENTS (gnc_plugin_actions);
66 
67 
70 {
71  gpointer dummy;
73 
74 #define GNC_PLUGIN_ACCOUNT_TREE_GET_PRIVATE(o) \
75  (G_TYPE_INSTANCE_GET_PRIVATE ((o), GNC_TYPE_PLUGIN_ACCOUNT_TREE, GncPluginAccountTreePrivate))
76 
78 static GObjectClass *parent_class = NULL;
79 
80 
81 /* Get the type of the account tree menu plugin. */
82 GType
84 {
85  static GType gnc_plugin_account_tree_type = 0;
86 
87  if (gnc_plugin_account_tree_type == 0)
88  {
89  static const GTypeInfo our_info =
90  {
92  NULL, /* base_init */
93  NULL, /* base_finalize */
94  (GClassInitFunc) gnc_plugin_account_tree_class_init,
95  NULL, /* class_finalize */
96  NULL, /* class_data */
97  sizeof (GncPluginAccountTree),
98  0, /* n_preallocs */
99  (GInstanceInitFunc) gnc_plugin_account_tree_init
100  };
101 
102  gnc_plugin_account_tree_type = g_type_register_static (GNC_TYPE_PLUGIN,
103  "GncPluginAccountTree",
104  &our_info, 0);
105  }
106 
107  return gnc_plugin_account_tree_type;
108 }
109 
110 
111 /* Create a new account tree menu plugin. */
112 GncPlugin *
114 {
115  GncPluginAccountTree *plugin;
116 
117  /* Reference the account tree page plugin to ensure it exists
118  * in the gtk type system. */
119  GNC_TYPE_PLUGIN_PAGE_ACCOUNT_TREE;
120 
121  plugin = g_object_new (GNC_TYPE_PLUGIN_ACCOUNT_TREE,
122  NULL);
123 
124  return GNC_PLUGIN (plugin);
125 }
126 
127 
135 static void
136 gnc_plugin_account_tree_class_init (GncPluginAccountTreeClass *klass)
137 {
138  GObjectClass *object_class = G_OBJECT_CLASS (klass);
139  GncPluginClass *plugin_class = GNC_PLUGIN_CLASS (klass);
140 
141  parent_class = g_type_class_peek_parent (klass);
142 
143  object_class->finalize = gnc_plugin_account_tree_finalize;
144 
145  /* plugin info */
146  plugin_class->plugin_name = GNC_PLUGIN_ACCOUNT_TREE_NAME;
147 
148  /* widget addition/removal */
149  plugin_class->actions_name = PLUGIN_ACTIONS_NAME;
150  plugin_class->actions = gnc_plugin_actions;
151  plugin_class->n_actions = gnc_plugin_n_actions;
152  plugin_class->ui_filename = PLUGIN_UI_FILENAME;
153 
154  g_type_class_add_private(klass, sizeof(GncPluginAccountTreePrivate));
155 }
156 
157 
163 static void
164 gnc_plugin_account_tree_init (GncPluginAccountTree *plugin)
165 {
166 }
167 
168 
177 static void
178 gnc_plugin_account_tree_finalize (GObject *object)
179 {
180  g_return_if_fail (GNC_IS_PLUGIN_ACCOUNT_TREE (object));
181 
182  G_OBJECT_CLASS (parent_class)->finalize (object);
183 }
184 
185 /************************************************************
186  * Command Callbacks *
187  ************************************************************/
188 
189 static void
190 gnc_plugin_account_tree_cmd_new_account_tree (GtkAction *action,
192 {
193  GncPluginPage *page;
194 
195  g_return_if_fail (data != NULL);
196 
198  gnc_main_window_open_page (data->window, page);
199 }
200 
GncPluginPage * gnc_plugin_page_account_tree_new(void)
GType gnc_plugin_account_tree_get_type(void)
const gchar * ui_filename
Definition: gnc-plugin.h:137
void gnc_main_window_open_page(GncMainWindow *window, GncPluginPage *page)
GtkActionEntry * actions
Definition: gnc-plugin.h:122
const gchar * actions_name
Definition: gnc-plugin.h:119
struct GncPluginAccountTreePrivate GncPluginAccountTreePrivate
Functions providing a chart of account page.
const gchar * plugin_name
Definition: gnc-plugin.h:112
GncPlugin * gnc_plugin_account_tree_new(void)
Provide the menus to create a chart of account page.
#define PLUGIN_ACTIONS_NAME
#define PLUGIN_UI_FILENAME