GnuCash  4.11-11-ge9df8d41d2+
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 <jpetersen@uni-bonn.de>
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 gnu@gnu.org
23  */
24 
34 #include <config.h>
35 
36 #include <gtk/gtk.h>
37 #include <glib/gi18n.h>
38 #include <string.h>
39 
42 #include "dialog-find-account.h"
43 
44 static void gnc_plugin_account_tree_class_init (GncPluginAccountTreeClass *klass);
45 static void gnc_plugin_account_tree_init (GncPluginAccountTree *plugin);
46 static void gnc_plugin_account_tree_finalize (GObject *object);
47 
48 /* Command callbacks */
49 static void gnc_plugin_account_tree_cmd_new_account_tree (GtkAction *action, GncMainWindowActionData *data);
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 G_DEFINE_TYPE_WITH_PRIVATE(GncPluginAccountTree, gnc_plugin_account_tree, GNC_TYPE_PLUGIN)
75 
76 #define GNC_PLUGIN_ACCOUNT_TREE_GET_PRIVATE(o) \
77  ((GncPluginAccountTreePrivate*)g_type_instance_get_private((GTypeInstance*)o, GNC_TYPE_PLUGIN_ACCOUNT_TREE))
78 
80 static GObjectClass *parent_class = NULL;
81 
82 /* Create a new account tree menu plugin. */
83 GncPlugin *
85 {
86  GncPluginAccountTree *plugin;
87 
88  /* Reference the account tree page plugin to ensure it exists
89  * in the gtk type system. */
90  GNC_TYPE_PLUGIN_PAGE_ACCOUNT_TREE;
91 
92  plugin = g_object_new (GNC_TYPE_PLUGIN_ACCOUNT_TREE,
93  NULL);
94 
95  return GNC_PLUGIN (plugin);
96 }
97 
98 
106 static void
107 gnc_plugin_account_tree_class_init (GncPluginAccountTreeClass *klass)
108 {
109  GObjectClass *object_class = G_OBJECT_CLASS (klass);
110  GncPluginClass *plugin_class = GNC_PLUGIN_CLASS (klass);
111 
112  parent_class = g_type_class_peek_parent (klass);
113 
114  object_class->finalize = gnc_plugin_account_tree_finalize;
115 
116  /* plugin info */
117  plugin_class->plugin_name = GNC_PLUGIN_ACCOUNT_TREE_NAME;
118 
119  /* widget addition/removal */
120  plugin_class->actions_name = PLUGIN_ACTIONS_NAME;
121  plugin_class->actions = gnc_plugin_actions;
122  plugin_class->n_actions = gnc_plugin_n_actions;
123  plugin_class->ui_filename = PLUGIN_UI_FILENAME;
124 }
125 
126 
132 static void
133 gnc_plugin_account_tree_init (GncPluginAccountTree *plugin)
134 {
135 }
136 
137 
146 static void
147 gnc_plugin_account_tree_finalize (GObject *object)
148 {
149  g_return_if_fail (GNC_IS_PLUGIN_ACCOUNT_TREE (object));
150 
151  G_OBJECT_CLASS (parent_class)->finalize (object);
152 }
153 
154 /************************************************************
155  * Command Callbacks *
156  ************************************************************/
157 
158 static void
159 gnc_plugin_account_tree_cmd_new_account_tree (GtkAction *action,
161 {
162  GncPluginPage *page;
163 
164  g_return_if_fail (data != NULL);
165 
167  gnc_main_window_open_page (data->window, page);
168 }
169 
The class data structure for an account tree menu plugin.
guint n_actions
The number of actions in the actions array.
Definition: gnc-plugin.h:124
The instance data structure for a content plugin.
GncPluginPage * gnc_plugin_page_account_tree_new(void)
Create a new "account tree" plugin page.
The class data structure for a menu-only plugin.
Definition: gnc-plugin.h:107
const gchar * ui_filename
The relative name of the XML file describing the menu/toolbar action items.
Definition: gnc-plugin.h:137
void gnc_main_window_open_page(GncMainWindow *window, GncPluginPage *page)
Display a data plugin page in a window.
GtkActionEntry * actions
An array of actions that should automatically be added to any GnuCash "main" content window that is o...
Definition: gnc-plugin.h:122
const gchar * actions_name
A name for the set of actions that will be added by this plugin.
Definition: gnc-plugin.h:119
The instance private data structure for an account tree plugin.
Functions providing a chart of account page.
const gchar * plugin_name
The textual name of this plugin.
Definition: gnc-plugin.h:112
GncPlugin * gnc_plugin_account_tree_new(void)
Create a new account tree menu plugin.
The instance data structure for a menu-only plugin.
Definition: gnc-plugin.h:100
The instance data structure for an account tree menu plugin.
Provide the menus to create a chart of account page.
#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.