r23615 - gnucash/trunk/src/plugins - Add plugin example to plugins
John Ralls
jralls at code.gnucash.org
Wed Dec 25 01:12:56 EST 2013
Author: jralls
Date: 2013-12-25 01:12:56 -0500 (Wed, 25 Dec 2013)
New Revision: 23615
Trac: http://svn.gnucash.org/trac/changeset/23615
Added:
gnucash/trunk/src/plugins/example/
gnucash/trunk/src/plugins/example/Makefile.am
gnucash/trunk/src/plugins/example/glade/
gnucash/trunk/src/plugins/example/glade/Makefile.am
gnucash/trunk/src/plugins/example/gnc-plugin.example.c
gnucash/trunk/src/plugins/example/gnc-plugin.example.h
gnucash/trunk/src/plugins/example/gncmod-example.c
gnucash/trunk/src/plugins/example/ui/
gnucash/trunk/src/plugins/example/ui/Makefile.am
gnucash/trunk/src/plugins/example/ui/gnc-plugin-example-ui.xml
Modified:
gnucash/trunk/src/plugins/Makefile.am
Log:
Add plugin example to plugins
This is the former content of plugins-example.tgz, mentioned in the
wiki documentation.
Modified: gnucash/trunk/src/plugins/Makefile.am
===================================================================
--- gnucash/trunk/src/plugins/Makefile.am 2013-12-24 17:59:50 UTC (rev 23614)
+++ gnucash/trunk/src/plugins/Makefile.am 2013-12-25 06:12:56 UTC (rev 23615)
@@ -1 +1,9 @@
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
Added: gnucash/trunk/src/plugins/example/Makefile.am
===================================================================
--- gnucash/trunk/src/plugins/example/Makefile.am (rev 0)
+++ gnucash/trunk/src/plugins/example/Makefile.am 2013-12-25 06:12:56 UTC (rev 23615)
@@ -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\"
Added: gnucash/trunk/src/plugins/example/glade/Makefile.am
===================================================================
--- gnucash/trunk/src/plugins/example/glade/Makefile.am (rev 0)
+++ gnucash/trunk/src/plugins/example/glade/Makefile.am 2013-12-25 06:12:56 UTC (rev 23615)
@@ -0,0 +1,4 @@
+gladedir = $(GNC_GLADE_DIR)
+glade_DATA =
+
+EXTRA_DIST = ${glade_DATA}
Added: gnucash/trunk/src/plugins/example/gnc-plugin.example.c
===================================================================
--- gnucash/trunk/src/plugins/example/gnc-plugin.example.c (rev 0)
+++ gnucash/trunk/src/plugins/example/gnc-plugin.example.c 2013-12-25 06:12:56 UTC (rev 23615)
@@ -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 at 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 at 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 (" ");
+}
Added: gnucash/trunk/src/plugins/example/gnc-plugin.example.h
===================================================================
--- gnucash/trunk/src/plugins/example/gnc-plugin.example.h (rev 0)
+++ gnucash/trunk/src/plugins/example/gnc-plugin.example.h 2013-12-25 06:12:56 UTC (rev 23615)
@@ -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 at 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 at 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 */
Added: gnucash/trunk/src/plugins/example/gncmod-example.c
===================================================================
--- gnucash/trunk/src/plugins/example/gncmod-example.c (rev 0)
+++ gnucash/trunk/src/plugins/example/gncmod-example.c 2013-12-25 06:12:56 UTC (rev 23615)
@@ -0,0 +1,97 @@
+/*********************************************************************
+ * gncmod-example.c
+ * module definition/initialization for the example GNOME UI module
+ *
+ * Copyright (c) 2009 Sebastian Held <sebastian.held at gmx.de>
+ * Copyright (c) 2001 Derek Atkins <warlord at 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 at 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;
+}
Added: gnucash/trunk/src/plugins/example/ui/Makefile.am
===================================================================
--- gnucash/trunk/src/plugins/example/ui/Makefile.am (rev 0)
+++ gnucash/trunk/src/plugins/example/ui/Makefile.am 2013-12-25 06:12:56 UTC (rev 23615)
@@ -0,0 +1,5 @@
+uidir = $(GNC_UI_DIR)
+ui_DATA = \
+ gnc-plugin-example-ui.xml
+
+EXTRA_DIST = $(ui_DATA)
Added: gnucash/trunk/src/plugins/example/ui/gnc-plugin-example-ui.xml
===================================================================
--- gnucash/trunk/src/plugins/example/ui/gnc-plugin-example-ui.xml (rev 0)
+++ gnucash/trunk/src/plugins/example/ui/gnc-plugin-example-ui.xml 2013-12-25 06:12:56 UTC (rev 23615)
@@ -0,0 +1,9 @@
+<ui>
+ <menubar>
+ <menu name="Tools" action="ToolsAction">
+ <placeholder name="ToolsPlaceholder">
+ <menuitem name="example" action="exampleAction"/>
+ </placeholder>
+ </menu>
+ </menubar>
+</ui>
More information about the gnucash-changes
mailing list