|
GnuCash 2.4.99
|
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 { 00058 { 00059 "ViewAccountTreeAction", NULL, N_("New Accounts _Page"), NULL, 00060 N_("Open a new Account Tree page"), 00061 G_CALLBACK (gnc_plugin_account_tree_cmd_new_account_tree) 00062 }, 00063 }; 00065 static guint gnc_plugin_n_actions = G_N_ELEMENTS (gnc_plugin_actions); 00066 00067 00069 typedef struct GncPluginAccountTreePrivate 00070 { 00071 gpointer dummy; 00072 } GncPluginAccountTreePrivate; 00073 00074 #define GNC_PLUGIN_ACCOUNT_TREE_GET_PRIVATE(o) \ 00075 (G_TYPE_INSTANCE_GET_PRIVATE ((o), GNC_TYPE_PLUGIN_ACCOUNT_TREE, GncPluginAccountTreePrivate)) 00076 00078 static GObjectClass *parent_class = NULL; 00079 00080 00081 /* Get the type of the account tree menu plugin. */ 00082 GType 00083 gnc_plugin_account_tree_get_type (void) 00084 { 00085 static GType gnc_plugin_account_tree_type = 0; 00086 00087 if (gnc_plugin_account_tree_type == 0) 00088 { 00089 static const GTypeInfo our_info = 00090 { 00091 sizeof (GncPluginAccountTreeClass), 00092 NULL, /* base_init */ 00093 NULL, /* base_finalize */ 00094 (GClassInitFunc) gnc_plugin_account_tree_class_init, 00095 NULL, /* class_finalize */ 00096 NULL, /* class_data */ 00097 sizeof (GncPluginAccountTree), 00098 0, /* n_preallocs */ 00099 (GInstanceInitFunc) gnc_plugin_account_tree_init 00100 }; 00101 00102 gnc_plugin_account_tree_type = g_type_register_static (GNC_TYPE_PLUGIN, 00103 "GncPluginAccountTree", 00104 &our_info, 0); 00105 } 00106 00107 return gnc_plugin_account_tree_type; 00108 } 00109 00110 00111 /* Create a new account tree menu plugin. */ 00112 GncPlugin * 00113 gnc_plugin_account_tree_new (void) 00114 { 00115 GncPluginAccountTree *plugin; 00116 00117 /* Reference the account tree page plugin to ensure it exists 00118 * in the gtk type system. */ 00119 GNC_TYPE_PLUGIN_PAGE_ACCOUNT_TREE; 00120 00121 plugin = g_object_new (GNC_TYPE_PLUGIN_ACCOUNT_TREE, 00122 NULL); 00123 00124 return GNC_PLUGIN (plugin); 00125 } 00126 00127 00135 static void 00136 gnc_plugin_account_tree_class_init (GncPluginAccountTreeClass *klass) 00137 { 00138 GObjectClass *object_class = G_OBJECT_CLASS (klass); 00139 GncPluginClass *plugin_class = GNC_PLUGIN_CLASS (klass); 00140 00141 parent_class = g_type_class_peek_parent (klass); 00142 00143 object_class->finalize = gnc_plugin_account_tree_finalize; 00144 00145 /* plugin info */ 00146 plugin_class->plugin_name = GNC_PLUGIN_ACCOUNT_TREE_NAME; 00147 00148 /* widget addition/removal */ 00149 plugin_class->actions_name = PLUGIN_ACTIONS_NAME; 00150 plugin_class->actions = gnc_plugin_actions; 00151 plugin_class->n_actions = gnc_plugin_n_actions; 00152 plugin_class->ui_filename = PLUGIN_UI_FILENAME; 00153 00154 g_type_class_add_private(klass, sizeof(GncPluginAccountTreePrivate)); 00155 } 00156 00157 00163 static void 00164 gnc_plugin_account_tree_init (GncPluginAccountTree *plugin) 00165 { 00166 } 00167 00168 00177 static void 00178 gnc_plugin_account_tree_finalize (GObject *object) 00179 { 00180 GncPluginAccountTree *plugin; 00181 GncPluginAccountTreePrivate *priv; 00182 00183 g_return_if_fail (GNC_IS_PLUGIN_ACCOUNT_TREE (object)); 00184 00185 plugin = GNC_PLUGIN_ACCOUNT_TREE (object); 00186 priv = GNC_PLUGIN_ACCOUNT_TREE_GET_PRIVATE (object); 00187 00188 G_OBJECT_CLASS (parent_class)->finalize (object); 00189 } 00190 00191 /************************************************************ 00192 * Command Callbacks * 00193 ************************************************************/ 00194 00195 static void 00196 gnc_plugin_account_tree_cmd_new_account_tree (GtkAction *action, 00197 GncMainWindowActionData *data) 00198 { 00199 GncPluginPage *page; 00200 00201 g_return_if_fail (data != NULL); 00202 00203 page = gnc_plugin_page_account_tree_new (); 00204 gnc_main_window_open_page (data->window, page); 00205 } 00206
1.7.4