r20314 - gnucash/trunk/src/optional/gtkmm - Extend gtkmm/C++ plugin to include an actual gnc-plugin implementation.
Christian Stimming
cstim at code.gnucash.org
Fri Feb 18 06:35:45 EST 2011
Author: cstim
Date: 2011-02-18 06:35:45 -0500 (Fri, 18 Feb 2011)
New Revision: 20314
Trac: http://svn.gnucash.org/trac/changeset/20314
Added:
gnucash/trunk/src/optional/gtkmm/gnc-plugin-gtkmm-ui.xml
gnucash/trunk/src/optional/gtkmm/gnc-plugin-gtkmm.cpp
gnucash/trunk/src/optional/gtkmm/gnc-plugin-gtkmm.hpp
Modified:
gnucash/trunk/src/optional/gtkmm/Makefile.am
gnucash/trunk/src/optional/gtkmm/gncmod-gtkmm.cpp
Log:
Extend gtkmm/C++ plugin to include an actual gnc-plugin implementation.
Modified: gnucash/trunk/src/optional/gtkmm/Makefile.am
===================================================================
--- gnucash/trunk/src/optional/gtkmm/Makefile.am 2011-02-18 11:35:34 UTC (rev 20313)
+++ gnucash/trunk/src/optional/gtkmm/Makefile.am 2011-02-18 11:35:45 UTC (rev 20314)
@@ -3,9 +3,11 @@
pkglib_LTLIBRARIES = libgncmod-gtkmm.la
libgncmod_gtkmm_la_SOURCES = \
+ gnc-plugin-gtkmm.cpp \
gncmod-gtkmm.cpp
-noinst_HEADERS =
+noinst_HEADERS = \
+ gnc-plugin-gtkmm.hpp
libgncmod_gtkmm_la_LDFLAGS = -avoid-version
@@ -24,17 +26,18 @@
AM_CPPFLAGS = \
-I${top_srcdir}/src \
+ -I${top_srcdir}/src/libqof/qof \
${GTKMM_CFLAGS} \
${GNOME_CFLAGS} \
${GLADE_CFLAGS} \
${GLIB_CFLAGS}
uidir = $(GNC_UI_DIR)
-ui_DATA =
+ui_DATA = gnc-plugin-gtkmm-ui.xml
gladedir = $(GNC_GLADE_DIR)
glade_DATA =
EXTRA_DIST = ${ui_DATA} ${glade_DATA}
-INCLUDES = -DG_LOG_DOMAIN=\"gnc.gtkmm\"
+INCLUDES = -DG_LOG_DOMAIN=\"gnc.gui.gtkmm\"
Added: gnucash/trunk/src/optional/gtkmm/gnc-plugin-gtkmm-ui.xml
===================================================================
--- gnucash/trunk/src/optional/gtkmm/gnc-plugin-gtkmm-ui.xml (rev 0)
+++ gnucash/trunk/src/optional/gtkmm/gnc-plugin-gtkmm-ui.xml 2011-02-18 11:35:45 UTC (rev 20314)
@@ -0,0 +1,11 @@
+<ui>
+ <menubar>
+ <menu name="File" action="FileAction">
+ <menu name="FileImport" action="FileImportAction">
+ <placeholder name="FileImportPlaceholder">
+ <menuitem name="FileSomethingImport" action="GtkmmSomethingAction"/>
+ </placeholder>
+ </menu>
+ </menu>
+ </menubar>
+</ui>
Added: gnucash/trunk/src/optional/gtkmm/gnc-plugin-gtkmm.cpp
===================================================================
--- gnucash/trunk/src/optional/gtkmm/gnc-plugin-gtkmm.cpp (rev 0)
+++ gnucash/trunk/src/optional/gtkmm/gnc-plugin-gtkmm.cpp 2011-02-18 11:35:45 UTC (rev 20314)
@@ -0,0 +1,187 @@
+/*
+ * gnc-plugin-gtkmm.cpp --
+ *
+ * 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
+ * @brief Plugin registration of the Gtkmm module
+ * @author Copyright (C) 2011 Christian Stimming <christian at cstimming.de>
+ */
+
+#include "config.h"
+
+#include <gtk/gtk.h>
+#include <glib/gi18n.h>
+extern "C" {
+#include "gnome-utils/gnc-plugin-manager.h"
+#include "gnome-utils/gnc-main-window.h"
+#include "engine/Account.h"
+}
+
+#include "gnc-plugin-gtkmm.hpp"
+#include <gtkmm.h>
+
+namespace gncmm
+{
+
+// This static indicates the debugging module that this .o belongs to.
+static QofLogModule log_module = G_LOG_DOMAIN;
+
+static void gnc_plugin_gtkmm_class_init (GncPluginGtkmmClass *klass);
+static void gnc_plugin_gtkmm_init (GncPluginGtkmm *plugin);
+static void gnc_plugin_gtkmm_finalize (GObject *object);
+
+/* Command callbacks */
+static void gnc_plugin_gtkmm_cmd_something (GtkAction *action, GncMainWindowActionData *data);
+
+#define PLUGIN_ACTIONS_NAME "gnc-plugin-gtkmm-actions"
+#define PLUGIN_UI_FILENAME "gnc-plugin-gtkmm-ui.xml"
+
+static GtkActionEntry gnc_plugin_actions [] =
+{
+ {
+ // FIXME: I've intentionally remove the i18n markers so that
+ // translators don't have to deal with these example strings!
+ "GtkmmSomethingAction", NULL, "Do _Something in C++/gtkmm...", NULL,
+ "This demonstrates how to integrate C++/gtkmm in a plugin of gnucash",
+ G_CALLBACK (gnc_plugin_gtkmm_cmd_something)
+ },
+};
+static guint gnc_plugin_n_actions = G_N_ELEMENTS (gnc_plugin_actions);
+
+struct GncPluginGtkmmPrivate
+{
+ gpointer dummy;
+};
+
+#define GNC_PLUGIN_GTKMM_GET_PRIVATE(o) \
+ (G_TYPE_INSTANCE_GET_PRIVATE ((o), GNC_TYPE_PLUGIN_GTKMM, GncPluginGtkmmPrivate))
+
+static GObjectClass *parent_class = NULL;
+
+GType
+gnc_plugin_gtkmm_get_type (void)
+{
+ static GType gnc_plugin_gtkmm_type = 0;
+
+ if (gnc_plugin_gtkmm_type == 0)
+ {
+ static const GTypeInfo our_info =
+ {
+ sizeof (GncPluginGtkmmClass),
+ NULL, /* base_init */
+ NULL, /* base_finalize */
+ (GClassInitFunc) gnc_plugin_gtkmm_class_init,
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ sizeof (GncPluginGtkmm),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) gnc_plugin_gtkmm_init,
+ };
+
+ gnc_plugin_gtkmm_type = g_type_register_static (GNC_TYPE_PLUGIN,
+ "GncPluginGtkmm",
+ &our_info, GTypeFlags(0));
+ }
+
+ return gnc_plugin_gtkmm_type;
+}
+
+GncPlugin *
+gnc_plugin_gtkmm_new (void)
+{
+ return GNC_PLUGIN (g_object_new (GNC_TYPE_PLUGIN_GTKMM, NULL));
+}
+
+static void
+gnc_plugin_gtkmm_class_init (GncPluginGtkmmClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GncPluginClass *plugin_class = GNC_PLUGIN_CLASS (klass);
+
+ parent_class = reinterpret_cast<GObjectClass *>(g_type_class_peek_parent (klass));
+
+ object_class->finalize = gnc_plugin_gtkmm_finalize;
+
+ // plugin info
+ plugin_class->plugin_name = GNC_PLUGIN_GTKMM_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;
+
+ g_type_class_add_private(klass, sizeof(GncPluginGtkmmPrivate));
+}
+
+static void
+gnc_plugin_gtkmm_init (GncPluginGtkmm *plugin)
+{
+}
+
+static void
+gnc_plugin_gtkmm_finalize (GObject *object)
+{
+ g_return_if_fail (GNC_IS_PLUGIN_GTKMM (object));
+
+ GncPluginGtkmm *plugin = GNC_PLUGIN_GTKMM (object);
+ GncPluginGtkmmPrivate *priv = GNC_PLUGIN_GTKMM_GET_PRIVATE(plugin);
+
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+/************************************************************
+ * Plugin Function Implementation *
+ ************************************************************/
+
+/************************************************************
+ * Command Callbacks *
+ ************************************************************/
+
+static void
+gnc_plugin_gtkmm_cmd_something (GtkAction *action,
+ GncMainWindowActionData *data)
+{
+ // Now we're gonna do something.
+ ENTER("action %p, main window data %p", action, data);
+ g_return_if_fail(data);
+
+// ::Account *c_account = NULL;//main_window_to_account(data->window);
+// Glib::RefPtr<Glib::Object> account_ptr = Glib::wrap(c_account);
+
+ LEAVE("");
+}
+
+
+/************************************************************
+ * Plugin Bootstrapping *
+ ************************************************************/
+
+void
+gnc_plugin_gtkmm_create_plugin (void)
+{
+ GncPlugin *plugin = gnc_plugin_gtkmm_new ();
+
+ gnc_plugin_manager_add_plugin (gnc_plugin_manager_get (), plugin);
+}
+
+} // END namespace gncmm
Property changes on: gnucash/trunk/src/optional/gtkmm/gnc-plugin-gtkmm.cpp
___________________________________________________________________
Added: svn:eol-style
+ LF
Added: gnucash/trunk/src/optional/gtkmm/gnc-plugin-gtkmm.hpp
===================================================================
--- gnucash/trunk/src/optional/gtkmm/gnc-plugin-gtkmm.hpp (rev 0)
+++ gnucash/trunk/src/optional/gtkmm/gnc-plugin-gtkmm.hpp 2011-02-18 11:35:45 UTC (rev 20314)
@@ -0,0 +1,90 @@
+/*
+ * gnc-plugin-gtkmm.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 GUI
+ * @{
+ * @addtogroup Gtkmm
+ * @{
+ * @file
+ * @brief Plugin registration of the Gtkmm module
+ * @author Copyright (C) 2011 Christian Stimming <christian at cstimming.de>
+ */
+
+#ifndef GNC_PLUGIN_GTKMM_H
+#define GNC_PLUGIN_GTKMM_H
+
+#include <glib.h>
+extern "C" {
+#include "gnome-utils/gnc-plugin.h"
+}
+
+namespace gncmm
+{
+
+G_BEGIN_DECLS
+
+/* type macros */
+#define GNC_TYPE_PLUGIN_GTKMM (gnc_plugin_gtkmm_get_type())
+#define GNC_PLUGIN_GTKMM(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GNC_TYPE_PLUGIN_GTKMM, GncPluginGtkmm))
+#define GNC_PLUGIN_GTKMM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GNC_TYPE_PLUGIN_GTKMM, GncPluginGtkmmClass))
+#define GNC_IS_PLUGIN_GTKMM(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GNC_TYPE_PLUGIN_GTKMM))
+#define GNC_IS_PLUGIN_GTKMM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GNC_TYPE_PLUGIN_GTKMM))
+#define GNC_PLUGIN_GTKMM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GNC_TYPE_PLUGIN_GTKMM, GncPluginGtkmmClass))
+
+#define GNC_PLUGIN_GTKMM_NAME "gnc-plugin-gtkmm"
+
+/* typedefs & structures */
+struct GncPluginGtkmm
+{
+ GncPlugin gnc_plugin;
+};
+
+struct GncPluginGtkmmClass
+{
+ GncPluginClass gnc_plugin;
+};
+
+/* function prototypes */
+
+/**
+ * @return The glib runtime type of an gtkmm plugin page
+ **/
+GType gnc_plugin_gtkmm_get_type(void);
+
+/**
+ * @return A new GncPluginGtkmm object
+ */
+GncPlugin* gnc_plugin_gtkmm_new(void);
+
+/**
+ * Create a new GncPluginGtkmm object and register it.
+ */
+void gnc_plugin_gtkmm_create_plugin(void);
+
+G_END_DECLS
+
+} // END namespace gncmm
+
+/** @} */
+/** @} */
+
+#endif /* GNC_PLUGIN_GTKMM_H */
Property changes on: gnucash/trunk/src/optional/gtkmm/gnc-plugin-gtkmm.hpp
___________________________________________________________________
Added: svn:eol-style
+ LF
Modified: gnucash/trunk/src/optional/gtkmm/gncmod-gtkmm.cpp
===================================================================
--- gnucash/trunk/src/optional/gtkmm/gncmod-gtkmm.cpp 2011-02-18 11:35:34 UTC (rev 20313)
+++ gnucash/trunk/src/optional/gtkmm/gncmod-gtkmm.cpp 2011-02-18 11:35:45 UTC (rev 20314)
@@ -34,58 +34,62 @@
#include "gnc-module/gnc-module.h"
#include "gnc-module/gnc-module-api.h"
-GNC_MODULE_API_DECL(libgncmod_gtkmm)
+ GNC_MODULE_API_DECL(libgncmod_gtkmm)
-/* version of the gnc module system interface we require */
-gint libgncmod_gtkmm_gnc_module_system_interface = 0;
+ /* version of the gnc module system interface we require */
+ gint libgncmod_gtkmm_gnc_module_system_interface = 0;
-/* module versioning uses libtool semantics. */
-gint libgncmod_gtkmm_gnc_module_current = 0;
-gint libgncmod_gtkmm_gnc_module_revision = 0;
-gint libgncmod_gtkmm_gnc_module_age = 0;
+ /* module versioning uses libtool semantics. */
+ gint libgncmod_gtkmm_gnc_module_current = 0;
+ gint libgncmod_gtkmm_gnc_module_revision = 0;
+ gint libgncmod_gtkmm_gnc_module_age = 0;
} // END extern "C"
+// c++ includes
#include <gtkmm.h>
+// And our own plugin
+#include "gnc-plugin-gtkmm.hpp"
+
extern "C" {
-gchar *
-libgncmod_gtkmm_gnc_module_path(void)
-{
- return g_strdup("gnucash/gtkmm");
-}
+ gchar *
+ libgncmod_gtkmm_gnc_module_path(void)
+ {
+ return g_strdup("gnucash/gtkmm");
+ }
-gchar *
-libgncmod_gtkmm_gnc_module_description(void)
-{
- return g_strdup("Support for gtkmm gui");
-}
-
-gint
-libgncmod_gtkmm_gnc_module_init(gint refcount)
-{
- /* Load modules we depend on */
- if (!gnc_module_load("gnucash/engine", 0)
- || !gnc_module_load("gnucash/app-utils", 0)
- || !gnc_module_load("gnucash/gnome-utils", 0))
+ gchar *
+ libgncmod_gtkmm_gnc_module_description(void)
{
- return FALSE;
+ return g_strdup("Support for gtkmm gui");
}
- /* Initialize the gtkmm framework. Calling this static method is
- * sufficient; we don't actually need a Gtk::Main object. */
- Gtk::Main::init_gtkmm_internals();
+ gint
+ libgncmod_gtkmm_gnc_module_init(gint refcount)
+ {
+ // Load modules we depend on
+ if (!gnc_module_load("gnucash/engine", 0)
+ || !gnc_module_load("gnucash/app-utils", 0)
+ || !gnc_module_load("gnucash/gnome-utils", 0))
+ {
+ return FALSE;
+ }
- /* Add menu items with C callbacks */
- /*gnc_plugin_gtkmm_create_plugin();*/
+ // Initialize the gtkmm framework. Calling this static method
+ // is sufficient; we don't actually need a Gtk::Main object.
+ Gtk::Main::init_gtkmm_internals();
- return 1;
-}
+ // Register our plugin, adding menu items with callbacks
+ gncmm::gnc_plugin_gtkmm_create_plugin();
-gint
-libgncmod_gtkmm_gnc_module_end(gint refcount)
-{
- return 1;
-}
+ return 1;
+ }
+ gint
+ libgncmod_gtkmm_gnc_module_end(gint refcount)
+ {
+ return 1;
+ }
+
} // END extern "C"
More information about the gnucash-changes
mailing list