mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Add the 'log replay' menu item.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/branches/gnucash-gnome2-dev@9591 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
@@ -4,10 +4,12 @@ pkglib_LTLIBRARIES=libgncmod-log-replay.la
|
||||
|
||||
libgncmod_log_replay_la_SOURCES = \
|
||||
gnc-log-replay.c \
|
||||
gnc-plugin-log-replay.c \
|
||||
gncmod-log-replay.c
|
||||
|
||||
noinst_HEADERS = \
|
||||
gnc-log-replay.h
|
||||
gnc-log-replay.h \
|
||||
gnc-plugin-log-replay.h
|
||||
|
||||
libgncmod_log_replay_la_LDFLAGS = -module
|
||||
|
||||
@@ -15,13 +17,9 @@ libgncmod_log_replay_la_LIBADD = \
|
||||
${top_builddir}/src/gnc-module/libgncmodule.la \
|
||||
${top_builddir}/src/engine/libgncmod-engine.la \
|
||||
${top_builddir}/src/import-export/libgncmod-generic-import.la \
|
||||
${top_builddir}/lib/egg/libegg.la \
|
||||
${GLIB_LIBS}
|
||||
|
||||
gncscmdir = ${GNC_SCM_INSTALL_DIR}/log-replay
|
||||
|
||||
gncscm_DATA = \
|
||||
log-replay.scm
|
||||
|
||||
AM_CFLAGS = \
|
||||
-I${top_srcdir}/src \
|
||||
-I${top_srcdir}/src/engine \
|
||||
@@ -31,14 +29,18 @@ AM_CFLAGS = \
|
||||
-I${top_srcdir}/src/gnome \
|
||||
-I${top_srcdir}/src/gnome-utils \
|
||||
-I${top_srcdir}/src/import-export \
|
||||
-I${top_srcdir}/lib/egg \
|
||||
${GNOME_CFLAGS} \
|
||||
${GTKHTML_CFLAGS} \
|
||||
${GLADE_CFLAGS} \
|
||||
${GUILE_INCS} \
|
||||
${GLIB_CFLAGS}
|
||||
|
||||
EXTRA_DIST = \
|
||||
.cvsignore \
|
||||
${gncscm_DATA}
|
||||
uidir = $(GNC_UI_DIR)
|
||||
ui_DATA = \
|
||||
gnc-plugin-log-replay-ui.xml
|
||||
|
||||
CLEANFILES = g-wrapped .scm-links
|
||||
EXTRA_DIST = \
|
||||
.cvsignore
|
||||
|
||||
CLEANFILES = g-wrapped
|
||||
|
||||
@@ -102,12 +102,6 @@ typedef struct _split_record
|
||||
* Entry point
|
||||
\********************************************************************/
|
||||
|
||||
SCM scm_gnc_file_log_replay ()
|
||||
{
|
||||
gnc_file_log_replay();
|
||||
return SCM_EOL;
|
||||
}
|
||||
|
||||
static char *olds;
|
||||
/* This version of strtok will only match SINGLE occurence of delim,
|
||||
returning a 0 length valid string between two consecutive ocurence of delim.
|
||||
|
||||
@@ -30,5 +30,4 @@
|
||||
* is selected the the .log file is opened and read. It's contents
|
||||
* are then silently merged in the current log file. */
|
||||
void gnc_file_log_replay (void);
|
||||
SCM scm_gnc_file_log_replay (void);
|
||||
#endif
|
||||
|
||||
11
src/import-export/log-replay/gnc-plugin-log-replay-ui.xml
Normal file
11
src/import-export/log-replay/gnc-plugin-log-replay-ui.xml
Normal file
@@ -0,0 +1,11 @@
|
||||
<ui>
|
||||
<menubar>
|
||||
<menu name="File" action="FileAction">
|
||||
<menu name="FileImport" action="FileImportAction">
|
||||
<placeholder name="FileImportPlaceholder">
|
||||
<menuitem name="LogReplay" action="LogReplayAction"/>
|
||||
</placeholder>
|
||||
</menu>
|
||||
</menu>
|
||||
</menubar>
|
||||
</ui>
|
||||
181
src/import-export/log-replay/gnc-plugin-log-replay.c
Normal file
181
src/import-export/log-replay/gnc-plugin-log-replay.c
Normal file
@@ -0,0 +1,181 @@
|
||||
/*
|
||||
* gnc-plugin-log-replay.c --
|
||||
* Copyright (C) 2003 David Hampton <hampton@employees.org>
|
||||
* Author: Jan Arne Petersen <jpetersen@uni-bonn.de>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, contact:
|
||||
*
|
||||
* Free Software Foundation Voice: +1-617-542-5942
|
||||
* 59 Temple Place - Suite 330 Fax: +1-617-542-2652
|
||||
* Boston, MA 02111-1307, USA gnu@gnu.org
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gnc-log-replay.h"
|
||||
#include "gnc-plugin-log-replay.h"
|
||||
#include "gnc-plugin-manager.h"
|
||||
#include "messages.h"
|
||||
|
||||
static GList *active_plugins = NULL;
|
||||
|
||||
static void gnc_plugin_log_replay_class_init (GncPluginLogreplayClass *klass);
|
||||
static void gnc_plugin_log_replay_init (GncPluginLogreplay *plugin);
|
||||
static void gnc_plugin_log_replay_finalize (GObject *object);
|
||||
|
||||
/* Command callbacks */
|
||||
static void gnc_plugin_log_replay_cmd_new_log_replay (EggAction *action, GncMainWindowActionData *data);
|
||||
|
||||
|
||||
#define PLUGIN_ACTIONS_NAME "gnc-plugin-log-replay-actions"
|
||||
#define PLUGIN_UI_FILENAME "gnc-plugin-log-replay-ui.xml"
|
||||
|
||||
static EggActionEntry gnc_plugin_actions [] = {
|
||||
{ "LogReplayAction", N_("_Replay GnuCash .log file"), GTK_STOCK_CONVERT, NULL,
|
||||
N_("Replay a gnucash log file after a crash. This cannot be undone."),
|
||||
G_CALLBACK (gnc_plugin_log_replay_cmd_new_log_replay) },
|
||||
};
|
||||
static guint gnc_plugin_n_actions = G_N_ELEMENTS (gnc_plugin_actions);
|
||||
|
||||
struct GncPluginLogreplayPrivate
|
||||
{
|
||||
gpointer dummy;
|
||||
};
|
||||
|
||||
static GObjectClass *parent_class = NULL;
|
||||
|
||||
GType
|
||||
gnc_plugin_log_replay_get_type (void)
|
||||
{
|
||||
static GType gnc_plugin_log_replay_type = 0;
|
||||
|
||||
if (gnc_plugin_log_replay_type == 0) {
|
||||
static const GTypeInfo our_info = {
|
||||
sizeof (GncPluginLogreplayClass),
|
||||
NULL, /* base_init */
|
||||
NULL, /* base_finalize */
|
||||
(GClassInitFunc) gnc_plugin_log_replay_class_init,
|
||||
NULL, /* class_finalize */
|
||||
NULL, /* class_data */
|
||||
sizeof (GncPluginLogreplay),
|
||||
0, /* n_preallocs */
|
||||
(GInstanceInitFunc) gnc_plugin_log_replay_init,
|
||||
};
|
||||
|
||||
gnc_plugin_log_replay_type = g_type_register_static (GNC_TYPE_PLUGIN,
|
||||
"GncPluginLogreplay",
|
||||
&our_info, 0);
|
||||
}
|
||||
|
||||
return gnc_plugin_log_replay_type;
|
||||
}
|
||||
|
||||
GncPlugin *
|
||||
gnc_plugin_log_replay_new (void)
|
||||
{
|
||||
return GNC_PLUGIN (g_object_new (GNC_TYPE_PLUGIN_LOG_REPLAY, NULL));
|
||||
}
|
||||
|
||||
#if DEBUG_REFERENCE_COUNTING
|
||||
static void
|
||||
dump_model (GncPluginLogreplay *plugin, gpointer dummy)
|
||||
{
|
||||
g_warning("GncPluginLogreplay %p still exists.", plugin);
|
||||
}
|
||||
|
||||
static gint
|
||||
gnc_plugin_log_replay_report_references (void)
|
||||
{
|
||||
g_list_foreach(active_plugins, (GFunc)dump_model, NULL);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
gnc_plugin_log_replay_class_init (GncPluginLogreplayClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GncPluginClass *plugin_class = GNC_PLUGIN_CLASS (klass);
|
||||
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
|
||||
object_class->finalize = gnc_plugin_log_replay_finalize;
|
||||
|
||||
/* plugin info */
|
||||
plugin_class->plugin_name = GNC_PLUGIN_LOG_REPLAY_NAME;
|
||||
|
||||
/* widget addition/removal */
|
||||
plugin_class->actions_name = PLUGIN_ACTIONS_NAME;
|
||||
plugin_class->actions = gnc_plugin_actions;
|
||||
plugin_class->n_actions = gnc_plugin_n_actions;
|
||||
plugin_class->ui_filename = PLUGIN_UI_FILENAME;
|
||||
|
||||
#if DEBUG_REFERENCE_COUNTING
|
||||
gtk_quit_add (0,
|
||||
(GtkFunction)gnc_plugin_log_replay_report_references,
|
||||
NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_plugin_log_replay_init (GncPluginLogreplay *plugin)
|
||||
{
|
||||
plugin->priv = g_new0 (GncPluginLogreplayPrivate, 1);
|
||||
|
||||
active_plugins = g_list_append (active_plugins, plugin);
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_plugin_log_replay_finalize (GObject *object)
|
||||
{
|
||||
GncPluginLogreplay *plugin;
|
||||
|
||||
g_return_if_fail (GNC_IS_PLUGIN_LOG_REPLAY (object));
|
||||
|
||||
plugin = GNC_PLUGIN_LOG_REPLAY (object);
|
||||
active_plugins = g_list_remove (active_plugins, plugin);
|
||||
|
||||
g_return_if_fail (plugin->priv != NULL);
|
||||
|
||||
g_free (plugin->priv);
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
/************************************************************
|
||||
* Plugin Function Implementation *
|
||||
************************************************************/
|
||||
|
||||
/************************************************************
|
||||
* Command Callbacks *
|
||||
************************************************************/
|
||||
|
||||
static void
|
||||
gnc_plugin_log_replay_cmd_new_log_replay (EggAction *action,
|
||||
GncMainWindowActionData *data)
|
||||
{
|
||||
gnc_file_log_replay ();
|
||||
}
|
||||
|
||||
/************************************************************
|
||||
* Plugin Bootstrapping *
|
||||
************************************************************/
|
||||
|
||||
void
|
||||
gnc_plugin_log_replay_create_plugin (void)
|
||||
{
|
||||
GncPlugin *plugin = gnc_plugin_log_replay_new ();
|
||||
|
||||
gnc_plugin_manager_add_plugin (gnc_plugin_manager_get (), plugin);
|
||||
}
|
||||
63
src/import-export/log-replay/gnc-plugin-log-replay.h
Normal file
63
src/import-export/log-replay/gnc-plugin-log-replay.h
Normal file
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* gnc-plugin-log-replay.h --
|
||||
* Copyright (C) 2003 David Hampton <hampton@employees.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, contact:
|
||||
*
|
||||
* Free Software Foundation Voice: +1-617-542-5942
|
||||
* 59 Temple Place - Suite 330 Fax: +1-617-542-2652
|
||||
* Boston, MA 02111-1307, USA gnu@gnu.org
|
||||
*/
|
||||
|
||||
#ifndef __GNC_PLUGIN_LOG_REPLAY_H
|
||||
#define __GNC_PLUGIN_LOG_REPLAY_H
|
||||
|
||||
#include <gtk/gtkwindow.h>
|
||||
|
||||
#include "gnc-plugin.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/* type macros */
|
||||
#define GNC_TYPE_PLUGIN_LOG_REPLAY (gnc_plugin_log_replay_get_type ())
|
||||
#define GNC_PLUGIN_LOG_REPLAY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNC_TYPE_PLUGIN_LOG_REPLAY, GncPluginLogreplay))
|
||||
#define GNC_PLUGIN_LOG_REPLAY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GNC_TYPE_PLUGIN_LOG_REPLAY, GncPluginLogreplayClass))
|
||||
#define GNC_IS_PLUGIN_LOG_REPLAY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNC_TYPE_PLUGIN_LOG_REPLAY))
|
||||
#define GNC_IS_PLUGIN_LOG_REPLAY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GNC_TYPE_PLUGIN_LOG_REPLAY))
|
||||
#define GNC_PLUGIN_LOG_REPLAY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GNC_TYPE_PLUGIN_LOG_REPLAY, GncPluginLogreplayClass))
|
||||
|
||||
#define GNC_PLUGIN_LOG_REPLAY_NAME "gnc-plugin-log-replay"
|
||||
|
||||
/* typedefs & structures */
|
||||
typedef struct GncPluginLogreplayPrivate GncPluginLogreplayPrivate;
|
||||
|
||||
typedef struct {
|
||||
GncPlugin parent;
|
||||
GncPluginLogreplayPrivate *priv;
|
||||
} GncPluginLogreplay;
|
||||
|
||||
typedef struct {
|
||||
GncPluginClass parent;
|
||||
} GncPluginLogreplayClass;
|
||||
|
||||
/* function prototypes */
|
||||
GType gnc_plugin_log_replay_get_type (void);
|
||||
|
||||
GncPlugin *gnc_plugin_log_replay_new (void);
|
||||
|
||||
void gnc_plugin_log_replay_create_plugin (void);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GNC_PLUGIN_LOG_REPLAY_H */
|
||||
@@ -31,6 +31,7 @@
|
||||
#include "gnc-log-replay.h"
|
||||
#include "gnc-module.h"
|
||||
#include "gnc-module-api.h"
|
||||
#include "gnc-plugin-log-replay.h"
|
||||
|
||||
/* version of the gnc module system interface we require */
|
||||
int libgncmod_log_replay_LTX_gnc_module_system_interface = 0;
|
||||
@@ -79,8 +80,10 @@ libgncmod_log_replay_LTX_gnc_module_init(int refcount)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
scm_c_eval_string("(load-from-path \"log-replay/log-replay.scm\")");
|
||||
scm_c_define_gsubr("gnc:log-replay", 0, 0, 0, scm_gnc_file_log_replay);
|
||||
|
||||
/* Add menu items with C callbacks */
|
||||
gnc_plugin_log_replay_create_plugin();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
(define (add-log-replay-menu-item)
|
||||
(gnc:add-extension
|
||||
(gnc:make-menu-item(N_ "Replay GnuCash .log file")
|
||||
(N_ "Replay a gnucash log file after a crash. This cannot be undone.")
|
||||
(list gnc:window-name-main "File" "_Import" "")
|
||||
(lambda ()
|
||||
(gnc:log-replay)))))
|
||||
|
||||
(gnc:hook-add-dangler gnc:*ui-startup-hook* add-log-replay-menu-item)
|
||||
|
||||
Reference in New Issue
Block a user