mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Add plugin example to plugins
This is the former content of plugins-example.tgz, mentioned in the wiki documentation. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@23615 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
6efd839282
commit
1c0f4d61d1
@ -1 +1,9 @@
|
|||||||
SUBDIRS=customer_import bi_import
|
SUBDIRS=customer_import bi_import
|
||||||
|
EXTRA_DIST = \
|
||||||
|
example/Makefile.am \
|
||||||
|
example/gnc-plugin.example.c \
|
||||||
|
example/gnc-plugin.example.h \
|
||||||
|
example/gncmod-example.c \
|
||||||
|
example/glade/Makefile.am \
|
||||||
|
example/ui/Makefile.am \
|
||||||
|
example/ui/gnc-plugin-example-ui.xml
|
||||||
|
39
src/plugins/example/Makefile.am
Normal file
39
src/plugins/example/Makefile.am
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
SUBDIRS = ui glade .
|
||||||
|
|
||||||
|
pkglib_LTLIBRARIES = libgncmod-example.la
|
||||||
|
|
||||||
|
libgncmod_example_la_SOURCES = \
|
||||||
|
gnc-plugin-example.c \
|
||||||
|
gncmod-example.c
|
||||||
|
|
||||||
|
noinst_HEADERS = \
|
||||||
|
gnc-plugin-example.h
|
||||||
|
|
||||||
|
libgncmod_example_la_LDFLAGS = -avoid-version
|
||||||
|
|
||||||
|
libgncmod_example_la_LIBADD = \
|
||||||
|
${top_builddir}/src/gnc-module/libgnc-module.la \
|
||||||
|
${GNOME_LIBS} \
|
||||||
|
${GLADE_LIBS} \
|
||||||
|
${QOF_LIBS} \
|
||||||
|
${GLIB_LIBS} \
|
||||||
|
${AQBANKING_LIBS}
|
||||||
|
|
||||||
|
AM_CFLAGS = \
|
||||||
|
-I${top_srcdir}/src \
|
||||||
|
-I${top_srcdir}/src/gnome \
|
||||||
|
-I${top_srcdir}/src/register/ledger-core \
|
||||||
|
-I${top_srcdir}/src/register/register-gnome \
|
||||||
|
-I${top_srcdir}/src/register/register-core \
|
||||||
|
-I${top_srcdir}/src/gnome-utils \
|
||||||
|
-I${top_srcdir}/src/app-utils \
|
||||||
|
-I${top_srcdir}/src/engine \
|
||||||
|
-I${top_srcdir}/src/core-utils \
|
||||||
|
-I${top_srcdir}/src/gnc-module \
|
||||||
|
${GNOME_CFLAGS} \
|
||||||
|
${GLADE_CFLAGS} \
|
||||||
|
${QOF_CFLAGS} \
|
||||||
|
${GLIB_CFLAGS} \
|
||||||
|
${AQBANKING_CFLAGS}
|
||||||
|
|
||||||
|
INCLUDES = -DG_LOG_DOMAIN=\"gnc.plugin.example\"
|
4
src/plugins/example/glade/Makefile.am
Normal file
4
src/plugins/example/glade/Makefile.am
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
gladedir = $(GNC_GLADE_DIR)
|
||||||
|
glade_DATA =
|
||||||
|
|
||||||
|
EXTRA_DIST = ${glade_DATA}
|
107
src/plugins/example/gnc-plugin.example.c
Normal file
107
src/plugins/example/gnc-plugin.example.c
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
/*
|
||||||
|
* gnc-plugin-example.c --
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
|
||||||
|
* Boston, MA 02110-1301, USA gnu@gnu.org
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
* @file gnc-plugin-example.c
|
||||||
|
* @brief Plugin registration of the example plugin
|
||||||
|
* @author Copyright (C) 2009 ?enter your name here? <your-email@example.com>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <glib/gi18n.h>
|
||||||
|
|
||||||
|
#include "gnc-plugin-example.h"
|
||||||
|
|
||||||
|
/* This static indicates the debugging module that this .o belongs to. */
|
||||||
|
static QofLogModule log_module = G_LOG_DOMAIN;
|
||||||
|
|
||||||
|
static void gnc_plugin_example_class_init (GncPluginexampleClass *klass);
|
||||||
|
static void gnc_plugin_example_init (GncPluginexample *plugin);
|
||||||
|
static void gnc_plugin_example_finalize (GObject *object);
|
||||||
|
|
||||||
|
/* Command callbacks */
|
||||||
|
static void gnc_plugin_example_cmd_test (GtkAction *action, GncMainWindowActionData *data);
|
||||||
|
|
||||||
|
#define PLUGIN_ACTIONS_NAME "gnc-plugin-example-actions"
|
||||||
|
#define PLUGIN_UI_FILENAME "gnc-plugin-example-ui.xml"
|
||||||
|
|
||||||
|
static GtkActionEntry gnc_plugin_actions [] = {
|
||||||
|
/* Menu Items */
|
||||||
|
{ "exampleAction", NULL, N_("example description..."), NULL,
|
||||||
|
N_("example tooltip"),
|
||||||
|
G_CALLBACK(gnc_plugin_example_cmd_test) },
|
||||||
|
};
|
||||||
|
static guint gnc_plugin_n_actions = G_N_ELEMENTS(gnc_plugin_actions);
|
||||||
|
|
||||||
|
|
||||||
|
/************************************************************
|
||||||
|
* Object Implementation *
|
||||||
|
************************************************************/
|
||||||
|
|
||||||
|
G_DEFINE_TYPE(GncPluginexample, gnc_plugin_example, GNC_TYPE_PLUGIN)
|
||||||
|
|
||||||
|
GncPlugin *
|
||||||
|
gnc_plugin_example_new (void)
|
||||||
|
{
|
||||||
|
return GNC_PLUGIN (g_object_new (GNC_TYPE_PLUGIN_example, (gchar*) NULL));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gnc_plugin_example_class_init (GncPluginexampleClass *klass)
|
||||||
|
{
|
||||||
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
|
GncPluginClass *plugin_class = GNC_PLUGIN_CLASS(klass);
|
||||||
|
|
||||||
|
object_class->finalize = gnc_plugin_example_finalize;
|
||||||
|
|
||||||
|
/* plugin info */
|
||||||
|
plugin_class->plugin_name = GNC_PLUGIN_example_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;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gnc_plugin_example_init (GncPluginexample *plugin)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gnc_plugin_example_finalize (GObject *object)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/************************************************************
|
||||||
|
* Command Callbacks *
|
||||||
|
************************************************************/
|
||||||
|
|
||||||
|
static void
|
||||||
|
gnc_plugin_example_cmd_test (GtkAction *action, GncMainWindowActionData *data)
|
||||||
|
{
|
||||||
|
ENTER ("action %p, main window data %p", action, data);
|
||||||
|
g_message ("example");
|
||||||
|
LEAVE (" ");
|
||||||
|
}
|
78
src/plugins/example/gnc-plugin.example.h
Normal file
78
src/plugins/example/gnc-plugin.example.h
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
/*
|
||||||
|
* gnc-plugin-example.h --
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
|
||||||
|
* Boston, MA 02110-1301, USA gnu@gnu.org
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @addtogroup Tools
|
||||||
|
* @{
|
||||||
|
* @file gnc-plugin-example.h
|
||||||
|
* @brief Plugin registration of the example module
|
||||||
|
* @author Copyright (C) 2009 ?enter your name here? <your-email@example.com>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef GNC_PLUGIN_example_H
|
||||||
|
#define GNC_PLUGIN_example_H
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
|
||||||
|
#include "gnc-plugin.h"
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
/* type macros */
|
||||||
|
#define GNC_TYPE_PLUGIN_example (gnc_plugin_example_get_type())
|
||||||
|
#define GNC_PLUGIN_example(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GNC_TYPE_PLUGIN_example, GncPluginexample))
|
||||||
|
#define GNC_PLUGIN_example_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GNC_TYPE_PLUGIN_example, GncPluginexampleClass))
|
||||||
|
#define GNC_IS_PLUGIN_example(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GNC_TYPE_PLUGIN_example))
|
||||||
|
#define GNC_IS_PLUGIN_example_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GNC_TYPE_PLUGIN_example))
|
||||||
|
#define GNC_PLUGIN_example_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GNC_TYPE_PLUGIN_example, GncPluginexampleClass))
|
||||||
|
|
||||||
|
#define GNC_PLUGIN_example_NAME "gnc-plugin-example"
|
||||||
|
|
||||||
|
/* typedefs & structures */
|
||||||
|
typedef struct {
|
||||||
|
GncPlugin gnc_plugin;
|
||||||
|
} GncPluginexample;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
GncPluginClass gnc_plugin;
|
||||||
|
} GncPluginexampleClass;
|
||||||
|
|
||||||
|
/* function prototypes */
|
||||||
|
/**
|
||||||
|
* @return The glib runtime type of an example plugin page
|
||||||
|
**/
|
||||||
|
GType gnc_plugin_example_get_type (void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return A new GncPluginexample object
|
||||||
|
*/
|
||||||
|
GncPlugin* gnc_plugin_example_new (void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new GncPluginexample object and register it.
|
||||||
|
*/
|
||||||
|
void gnc_plugin_example_create_plugin (void);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
/** @} */
|
||||||
|
|
||||||
|
#endif /* GNC_PLUGIN_example_H */
|
97
src/plugins/example/gncmod-example.c
Normal file
97
src/plugins/example/gncmod-example.c
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
/*********************************************************************
|
||||||
|
* gncmod-example.c
|
||||||
|
* module definition/initialization for the example GNOME UI module
|
||||||
|
*
|
||||||
|
* Copyright (c) 2009 Sebastian Held <sebastian.held@gmx.de>
|
||||||
|
* Copyright (c) 2001 Derek Atkins <warlord@MIT.EDU>
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
|
||||||
|
* Boston, MA 02110-1301, USA gnu@gnu.org
|
||||||
|
*
|
||||||
|
*********************************************************************/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <gmodule.h>
|
||||||
|
#include <gtk/gtk.h>
|
||||||
|
#include <glib/gi18n.h>
|
||||||
|
#include <libguile.h>
|
||||||
|
|
||||||
|
#include "gnc-hooks.h"
|
||||||
|
#include "gnc-module.h"
|
||||||
|
#include "gnc-module-api.h"
|
||||||
|
|
||||||
|
#include "gnc-plugin-manager.h"
|
||||||
|
#include "gnc-plugin-example.h"
|
||||||
|
|
||||||
|
GNC_MODULE_API_DECL(libgncmod_example)
|
||||||
|
|
||||||
|
/* version of the gnc module system interface we require */
|
||||||
|
int libgncmod_example_gnc_module_system_interface = 0;
|
||||||
|
|
||||||
|
/* module versioning uses libtool semantics. */
|
||||||
|
int libgncmod_example_gnc_module_current = 0;
|
||||||
|
int libgncmod_example_gnc_module_revision = 0;
|
||||||
|
int libgncmod_example_gnc_module_age = 0;
|
||||||
|
|
||||||
|
|
||||||
|
char *
|
||||||
|
libgncmod_example_gnc_module_path (void)
|
||||||
|
{
|
||||||
|
return g_strdup("gnucash/plugins/example");
|
||||||
|
}
|
||||||
|
|
||||||
|
char *
|
||||||
|
libgncmod_example_gnc_module_description (void)
|
||||||
|
{
|
||||||
|
return g_strdup("The GnuCash example plugin");
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
libgncmod_example_gnc_module_init (int refcount)
|
||||||
|
{
|
||||||
|
if (!gnc_module_load ("gnucash/app-utils", 0)) {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
if (!gnc_module_load ("gnucash/gnome-utils", 0)) {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
if (!gnc_module_load ("gnucash/engine", 0)) {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (refcount == 0) {
|
||||||
|
/* this is the first time the module is loaded */
|
||||||
|
|
||||||
|
gnc_plugin_manager_add_plugin ( gnc_plugin_manager_get (),
|
||||||
|
gnc_plugin_example_new ());
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
libgncmod_example_gnc_module_end (int refcount)
|
||||||
|
{
|
||||||
|
if (refcount == 0) {
|
||||||
|
/* this is the last time the module is unloaded */
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
5
src/plugins/example/ui/Makefile.am
Normal file
5
src/plugins/example/ui/Makefile.am
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
uidir = $(GNC_UI_DIR)
|
||||||
|
ui_DATA = \
|
||||||
|
gnc-plugin-example-ui.xml
|
||||||
|
|
||||||
|
EXTRA_DIST = $(ui_DATA)
|
9
src/plugins/example/ui/gnc-plugin-example-ui.xml
Normal file
9
src/plugins/example/ui/gnc-plugin-example-ui.xml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<ui>
|
||||||
|
<menubar>
|
||||||
|
<menu name="Tools" action="ToolsAction">
|
||||||
|
<placeholder name="ToolsPlaceholder">
|
||||||
|
<menuitem name="example" action="exampleAction"/>
|
||||||
|
</placeholder>
|
||||||
|
</menu>
|
||||||
|
</menubar>
|
||||||
|
</ui>
|
Loading…
Reference in New Issue
Block a user