gnc-plugin-account-tree.c

Go to the documentation of this file.
00001 /* 
00002  * gnc-plugin-account-tree.c -- 
00003  *
00004  * Copyright (C) 2003 Jan Arne Petersen
00005  * Author: Jan Arne Petersen <jpetersen@uni-bonn.de>
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License as
00009  * published by the Free Software Foundation; either version 2 of
00010  * the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, contact:
00019  *
00020  * Free Software Foundation           Voice:  +1-617-542-5942
00021  * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
00022  * Boston, MA  02110-1301,  USA       gnu@gnu.org
00023  */
00024 
00034 #include "config.h"
00035 
00036 #include <gtk/gtk.h>
00037 #include <glib/gi18n.h>
00038 #include <string.h>
00039 
00040 #include "gnc-plugin-account-tree.h"
00041 #include "gnc-plugin-page-account-tree.h"
00042 
00043 static void gnc_plugin_account_tree_class_init (GncPluginAccountTreeClass *klass);
00044 static void gnc_plugin_account_tree_init (GncPluginAccountTree *plugin);
00045 static void gnc_plugin_account_tree_finalize (GObject *object);
00046 
00047 /* Command callbacks */
00048 static void gnc_plugin_account_tree_cmd_new_account_tree (GtkAction *action, GncMainWindowActionData *data);
00049 
00050 
00051 #define PLUGIN_ACTIONS_NAME "gnc-plugin-account-tree-actions"
00052 #define PLUGIN_UI_FILENAME  "gnc-plugin-account-tree-ui.xml"
00053 
00056 static GtkActionEntry gnc_plugin_actions [] = {
00057         { "FileNewAccountTreeAction", NULL, N_("New Accounts _Page"), NULL,
00058           N_("Open a new Account Tree page"),
00059           G_CALLBACK (gnc_plugin_account_tree_cmd_new_account_tree) },
00060 };
00062 static guint gnc_plugin_n_actions = G_N_ELEMENTS (gnc_plugin_actions);
00063 
00064 
00066 typedef struct GncPluginAccountTreePrivate
00067 {
00068         gpointer dummy;
00069 } GncPluginAccountTreePrivate;
00070 
00071 #define GNC_PLUGIN_ACCOUNT_TREE_GET_PRIVATE(o)  \
00072    (G_TYPE_INSTANCE_GET_PRIVATE ((o), GNC_TYPE_PLUGIN_ACCOUNT_TREE, GncPluginAccountTreePrivate))
00073 
00075 static GObjectClass *parent_class = NULL;
00076 
00077 
00078 /*  Get the type of the account tree menu plugin. */
00079 GType
00080 gnc_plugin_account_tree_get_type (void)
00081 {
00082         static GType gnc_plugin_account_tree_type = 0;
00083 
00084         if (gnc_plugin_account_tree_type == 0) {
00085                 static const GTypeInfo our_info = {
00086                         sizeof (GncPluginAccountTreeClass),
00087                         NULL,           /* base_init */
00088                         NULL,           /* base_finalize */
00089                         (GClassInitFunc) gnc_plugin_account_tree_class_init,
00090                         NULL,           /* class_finalize */
00091                         NULL,           /* class_data */
00092                         sizeof (GncPluginAccountTree),
00093                         0,              /* n_preallocs */
00094                         (GInstanceInitFunc) gnc_plugin_account_tree_init
00095                 };
00096                 
00097                 gnc_plugin_account_tree_type = g_type_register_static (GNC_TYPE_PLUGIN,
00098                                                                        "GncPluginAccountTree",
00099                                                                        &our_info, 0);
00100         }
00101 
00102         return gnc_plugin_account_tree_type;
00103 }
00104 
00105 
00106 /*  Create a new account tree menu plugin. */
00107 GncPlugin *
00108 gnc_plugin_account_tree_new (void)
00109 {
00110         GncPluginAccountTree *plugin;
00111 
00112         /* Reference the account tree page plugin to ensure it exists
00113          * in the gtk type system. */
00114         GNC_TYPE_PLUGIN_PAGE_ACCOUNT_TREE;
00115 
00116         plugin = g_object_new (GNC_TYPE_PLUGIN_ACCOUNT_TREE,
00117                               NULL);
00118 
00119         return GNC_PLUGIN (plugin);
00120 }
00121 
00122 
00130 static void
00131 gnc_plugin_account_tree_class_init (GncPluginAccountTreeClass *klass)
00132 {
00133         GObjectClass *object_class = G_OBJECT_CLASS (klass);
00134         GncPluginClass *plugin_class = GNC_PLUGIN_CLASS (klass);
00135 
00136         parent_class = g_type_class_peek_parent (klass);
00137 
00138         object_class->finalize = gnc_plugin_account_tree_finalize;
00139 
00140         /* plugin info */
00141         plugin_class->plugin_name  = GNC_PLUGIN_ACCOUNT_TREE_NAME;
00142 
00143         /* widget addition/removal */
00144         plugin_class->actions_name = PLUGIN_ACTIONS_NAME;
00145         plugin_class->actions      = gnc_plugin_actions;
00146         plugin_class->n_actions    = gnc_plugin_n_actions;
00147         plugin_class->ui_filename  = PLUGIN_UI_FILENAME;
00148 
00149         g_type_class_add_private(klass, sizeof(GncPluginAccountTreePrivate));
00150 }
00151 
00152 
00158 static void
00159 gnc_plugin_account_tree_init (GncPluginAccountTree *plugin)
00160 {
00161 }
00162 
00163 
00172 static void
00173 gnc_plugin_account_tree_finalize (GObject *object)
00174 {
00175         GncPluginAccountTree *plugin;
00176         GncPluginAccountTreePrivate *priv;
00177 
00178         g_return_if_fail (GNC_IS_PLUGIN_ACCOUNT_TREE (object));
00179 
00180         plugin = GNC_PLUGIN_ACCOUNT_TREE (object);
00181         priv = GNC_PLUGIN_ACCOUNT_TREE_GET_PRIVATE (object);
00182 
00183         G_OBJECT_CLASS (parent_class)->finalize (object);
00184 }
00185 
00186 /************************************************************
00187  *                    Command Callbacks                     *
00188  ************************************************************/
00189 
00190 static void
00191 gnc_plugin_account_tree_cmd_new_account_tree (GtkAction *action,
00192                                               GncMainWindowActionData *data)
00193 {
00194         GncPluginPage *page;
00195 
00196         g_return_if_fail (data != NULL);
00197 
00198         page = gnc_plugin_page_account_tree_new ();
00199         gnc_main_window_open_page (data->window, page);
00200 }
00201 

Generated on Tue Oct 14 05:04:43 2008 for GnuCash by  doxygen 1.5.2